http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/IgniteObjectBuilderImpl.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/portable/builder/IgniteObjectBuilderImpl.java index 5a4a0a0,0000000..ccba7e6 mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/IgniteObjectBuilderImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/IgniteObjectBuilderImpl.java @@@ -1,540 -1,0 +1,550 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.portable.builder; + ++import org.apache.ignite.igniteobject.IgniteObject; ++import org.apache.ignite.igniteobject.IgniteObjectBuilder; ++import org.apache.ignite.igniteobject.IgniteObjectInvalidClassException; ++import org.apache.ignite.internal.portable.GridPortableMarshaller; ++import org.apache.ignite.internal.portable.IgniteObjectImpl; ++import org.apache.ignite.internal.portable.IgniteObjectWriterExImpl; ++import org.apache.ignite.internal.portable.PortableContext; ++import org.apache.ignite.internal.portable.PortableUtils; ++import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl; ++import org.apache.ignite.internal.util.GridArgumentCheck; ++import org.apache.ignite.internal.util.typedef.F; ++import org.apache.ignite.internal.util.typedef.internal.U; ++import org.apache.ignite.lang.IgniteBiTuple; ++import org.jetbrains.annotations.Nullable; ++ +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; - import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl; - import org.apache.ignite.internal.util.GridArgumentCheck; - import org.apache.ignite.internal.util.typedef.internal.U; - import org.apache.ignite.igniteobject.IgniteObjectBuilder; - import org.apache.ignite.igniteobject.IgniteObjectException; - import org.apache.ignite.igniteobject.IgniteObjectInvalidClassException; - import org.apache.ignite.igniteobject.IgniteObjectMetadata; - import org.apache.ignite.igniteobject.IgniteObject; - import org.jetbrains.annotations.Nullable; - import org.apache.ignite.internal.portable.*; + - import static org.apache.ignite.internal.portable.GridPortableMarshaller.CLS_NAME_POS; +import static org.apache.ignite.internal.portable.GridPortableMarshaller.DFLT_HDR_LEN; +import static org.apache.ignite.internal.portable.GridPortableMarshaller.HASH_CODE_POS; - import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER; +import static org.apache.ignite.internal.portable.GridPortableMarshaller.PROTO_VER_POS; - import static org.apache.ignite.internal.portable.GridPortableMarshaller.RAW_DATA_OFF_POS; - import static org.apache.ignite.internal.portable.GridPortableMarshaller.TOTAL_LEN_POS; +import static org.apache.ignite.internal.portable.GridPortableMarshaller.TYPE_ID_POS; +import static org.apache.ignite.internal.portable.GridPortableMarshaller.UNREGISTERED_TYPE_ID; + +/** + * + */ +public class IgniteObjectBuilderImpl implements IgniteObjectBuilder { + /** */ + private static final Object REMOVED_FIELD_MARKER = new Object(); + + /** */ + private final PortableContext ctx; + + /** */ + private final int typeId; + + /** May be null. */ + private String typeName; + + /** May be null. */ + private String clsNameToWrite; + + /** */ + private boolean registeredType = true; + + /** */ + private Map<String, Object> assignedVals; + + /** */ + private Map<Integer, Object> readCache; + + /** Position of object in source array, or -1 if object is not created from PortableObject. */ + private final int start; + + /** Total header length */ + private final int hdrLen; + + /** + * Context of PortableObject reading process. Or {@code null} if object is not created from PortableObject. + */ + private final PortableBuilderReader reader; + + /** */ + private int hashCode; + + /** + * @param clsName Class name. + * @param ctx Portable context. + */ + public IgniteObjectBuilderImpl(PortableContext ctx, String clsName) { + this(ctx, ctx.typeId(clsName), PortableContext.typeName(clsName)); + } + + /** + * @param typeId Type ID. + * @param ctx Portable context. + */ + public IgniteObjectBuilderImpl(PortableContext ctx, int typeId) { + this(ctx, typeId, null); + } + + /** + * @param typeName Type name. + * @param ctx Context. + * @param typeId Type id. + */ + public IgniteObjectBuilderImpl(PortableContext ctx, int typeId, String typeName) { + this.typeId = typeId; + this.typeName = typeName; + this.ctx = ctx; + + start = -1; + reader = null; + hdrLen = DFLT_HDR_LEN; + + readCache = Collections.emptyMap(); + } + + /** + * @param obj Object to wrap. + */ + public IgniteObjectBuilderImpl(IgniteObjectImpl obj) { + this(new PortableBuilderReader(obj), obj.start()); + + reader.registerObject(this); + } + + /** + * @param reader ctx + * @param start Start. + */ + IgniteObjectBuilderImpl(PortableBuilderReader reader, int start) { + this.reader = reader; + this.start = start; + + byte ver = reader.readByteAbsolute(start + PROTO_VER_POS); + + PortableUtils.checkProtocolVersion(ver); + - int typeId = reader.readIntAbsolute(start + TYPE_ID_POS); ++ int typeId = reader.readIntPositioned(start + TYPE_ID_POS); + ctx = reader.portableContext(); - hashCode = reader.readIntAbsolute(start + HASH_CODE_POS); ++ hashCode = reader.readIntPositioned(start + HASH_CODE_POS); + + if (typeId == UNREGISTERED_TYPE_ID) { + int mark = reader.position(); + - reader.position(start + CLS_NAME_POS); ++ reader.position(start + DFLT_HDR_LEN); + + clsNameToWrite = reader.readString(); + + Class cls; + + try { + // TODO: IGNITE-1272 - Is class loader needed here? + cls = U.forName(clsNameToWrite, null); + } + catch (ClassNotFoundException e) { + throw new IgniteObjectInvalidClassException("Failed to load the class: " + clsNameToWrite, e); + } + + this.typeId = ctx.descriptorForClass(cls).typeId(); + + registeredType = false; + + hdrLen = reader.position() - mark; + + reader.position(mark); + } + else { + this.typeId = typeId; + hdrLen = DFLT_HDR_LEN; + } + } + + /** {@inheritDoc} */ + @Override public IgniteObject build() { - try (IgniteObjectWriterExImpl writer = new IgniteObjectWriterExImpl(ctx, 0, typeId, false)) { ++ try (IgniteObjectWriterExImpl writer = new IgniteObjectWriterExImpl(ctx, typeId, false)) { + + PortableBuilderSerializer serializationCtx = new PortableBuilderSerializer(); + + serializationCtx.registerObjectWriting(this, 0); + + serializeTo(writer, serializationCtx); + + byte[] arr = writer.array(); + + return new IgniteObjectImpl(ctx, arr, 0); + } + } + + /** + * @param writer Writer. + * @param serializer Serializer. + */ + void serializeTo(IgniteObjectWriterExImpl writer, PortableBuilderSerializer serializer) { - writer.doWriteByte(GridPortableMarshaller.OBJ); - writer.doWriteByte(PROTO_VER); - writer.doWriteBoolean(true); - writer.doWriteInt(registeredType ? typeId : UNREGISTERED_TYPE_ID); - writer.doWriteInt(hashCode); - - // Length and raw offset. - writer.reserve(8); - - if (!registeredType) - writer.writeString(clsNameToWrite); ++ PortableUtils.writeHeader(writer, ++ true, ++ registeredType ? typeId : UNREGISTERED_TYPE_ID, ++ hashCode, ++ registeredType ? null : clsNameToWrite); + + Set<Integer> remainsFlds = null; + + if (reader != null) { + Map<Integer, Object> assignedFldsById; + + if (assignedVals != null) { + assignedFldsById = U.newHashMap(assignedVals.size()); + + for (Map.Entry<String, Object> entry : assignedVals.entrySet()) { + int fldId = ctx.fieldId(typeId, entry.getKey()); + + assignedFldsById.put(fldId, entry.getValue()); + } + + remainsFlds = assignedFldsById.keySet(); + } + else + assignedFldsById = Collections.emptyMap(); + - int rawOff = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS); ++ // Get footer details. ++ IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader, start); + - reader.position(start + hdrLen); ++ int footerPos = footer.get1(); ++ int footerEnd = footer.get2(); + - int cpStart = -1; ++ // Get raw position. ++ int rawPos = PortableUtils.rawOffsetAbsolute(reader, start); + - while (reader.position() < rawOff) { - int fldId = reader.readInt(); ++ // Position reader on data. ++ reader.position(start + hdrLen); + - int len = reader.readInt(); ++ while (reader.position() < rawPos) { ++ int fieldId = reader.readIntPositioned(footerPos); ++ int fieldLen = fieldPositionAndLength(footerPos, footerEnd, rawPos).get2(); + - if (assignedFldsById.containsKey(fldId)) { - if (cpStart >= 0) { - writer.write(reader.array(), cpStart, reader.position() - 4 - 4 - cpStart); ++ footerPos += 8; + - cpStart = -1; - } ++ if (assignedFldsById.containsKey(fieldId)) { ++ Object assignedVal = assignedFldsById.remove(fieldId); + - Object assignedVal = assignedFldsById.remove(fldId); - - reader.skip(len); ++ reader.skip(fieldLen); + + if (assignedVal != REMOVED_FIELD_MARKER) { - writer.writeInt(fldId); - - int lenPos = writer.reserveAndMark(4); ++ writer.writeFieldId(fieldId); + + serializer.writeValue(writer, assignedVal); - - writer.writeDelta(lenPos); + } + } + else { - int type = len != 0 ? reader.readByte(0) : 0; ++ int type = fieldLen != 0 ? reader.readByte(0) : 0; + - if (len != 0 && !PortableUtils.isPlainArrayType(type) && PortableUtils.isPlainType(type)) { - if (cpStart < 0) - cpStart = reader.position() - 4 - 4; ++ if (fieldLen != 0 && !PortableUtils.isPlainArrayType(type) && PortableUtils.isPlainType(type)) { ++ writer.writeFieldId(fieldId); ++ writer.write(reader.array(), reader.position(), fieldLen); + - reader.skip(len); ++ reader.skip(fieldLen); + } + else { - if (cpStart >= 0) { - writer.write(reader.array(), cpStart, reader.position() - 4 - cpStart); - - cpStart = -1; - } - else - writer.writeInt(fldId); ++ writer.writeFieldId(fieldId); + + Object val; + - if (len == 0) ++ if (fieldLen == 0) + val = null; + else if (readCache == null) { + int savedPos = reader.position(); + + val = reader.parseValue(); + - assert reader.position() == savedPos + len; ++ assert reader.position() == savedPos + fieldLen; + } + else { - val = readCache.get(fldId); ++ val = readCache.get(fieldId); + - reader.skip(len); ++ reader.skip(fieldLen); + } + - int lenPos = writer.reserveAndMark(4); - + serializer.writeValue(writer, val); - - writer.writeDelta(lenPos); + } + } + } - - if (cpStart >= 0) - writer.write(reader.array(), cpStart, reader.position() - cpStart); + } + + if (assignedVals != null && (remainsFlds == null || !remainsFlds.isEmpty())) { + boolean metadataEnabled = ctx.isMetaDataEnabled(typeId); + + IgniteObjectMetadata metadata = null; + + if (metadataEnabled) + metadata = ctx.metaData(typeId); + + Map<String, String> newFldsMetadata = null; + + for (Map.Entry<String, Object> entry : assignedVals.entrySet()) { + Object val = entry.getValue(); + + if (val == REMOVED_FIELD_MARKER) + continue; + + String name = entry.getKey(); + + int fldId = ctx.fieldId(typeId, name); + + if (remainsFlds != null && !remainsFlds.contains(fldId)) + continue; + - writer.writeInt(fldId); - - int lenPos = writer.reserveAndMark(4); ++ writer.writeFieldId(fldId); + + serializer.writeValue(writer, val); + - writer.writeDelta(lenPos); - + if (metadataEnabled) { + String oldFldTypeName = metadata == null ? null : metadata.fieldTypeName(name); + + String newFldTypeName; + + if (val instanceof PortableValueWithType) + newFldTypeName = ((PortableValueWithType)val).typeName(); + else { + byte type = PortableUtils.typeByClass(val.getClass()); + + newFldTypeName = CacheObjectPortableProcessorImpl.fieldTypeName(type); + } + + if (oldFldTypeName == null) { + // It's a new field, we have to add it to metadata. + + if (newFldsMetadata == null) + newFldsMetadata = new HashMap<>(); + + newFldsMetadata.put(name, newFldTypeName); + } + else { + if (!"Object".equals(oldFldTypeName) && !oldFldTypeName.equals(newFldTypeName)) { + throw new IgniteObjectException( + "Wrong value has been set [" + + "typeName=" + (typeName == null ? metadata.typeName() : typeName) + + ", fieldName=" + name + + ", fieldType=" + oldFldTypeName + + ", assignedValueType=" + newFldTypeName + + ", assignedValue=" + (((PortableValueWithType)val).value()) + ']' + ); + } + } + } + } + + if (newFldsMetadata != null) { + String typeName = this.typeName; + + if (typeName == null) + typeName = metadata.typeName(); + + ctx.updateMetaData(typeId, typeName, newFldsMetadata); + } + } + - writer.writeRawOffsetIfNeeded(); - + if (reader != null) { - int rawOff = reader.readIntAbsolute(start + RAW_DATA_OFF_POS); - int len = reader.readIntAbsolute(start + TOTAL_LEN_POS); ++ // Write raw data if any. ++ int rawOff = PortableUtils.rawOffsetAbsolute(reader, start); ++ int footerStart = PortableUtils.footerStartAbsolute(reader, start); ++ ++ if (rawOff < footerStart) { ++ writer.rawWriter(); ++ ++ writer.write(reader.array(), rawOff, footerStart - rawOff); ++ } + - if (rawOff < len) - writer.write(reader.array(), rawOff, len - rawOff); ++ // Shift reader to the end of the object. ++ reader.position(start + PortableUtils.length(reader, start)); + } + - writer.writeLength(); ++ writer.postWrite(true); + } + + /** {@inheritDoc} */ + @Override public IgniteObjectBuilderImpl hashCode(int hashCode) { + this.hashCode = hashCode; + + return this; + } + + /** ++ * Get field position and length. + * ++ * @param footerPos Field position inside the footer (absolute). ++ * @param footerEnd Footer end (absolute). ++ * @param rawPos Raw data position (absolute). ++ * @return Tuple with field position and length. ++ */ ++ private IgniteBiTuple<Integer, Integer> fieldPositionAndLength(int footerPos, int footerEnd, int rawPos) { ++ int fieldOffset = reader.readIntPositioned(footerPos + 4); ++ int fieldPos = start + fieldOffset; ++ ++ // Get field length. ++ int fieldLen; ++ ++ if (footerPos + 8 == footerEnd) ++ // This is the last field, compare to raw offset. ++ fieldLen = rawPos - fieldPos; ++ else { ++ // Field is somewhere in the middle, get difference with the next offset. ++ int nextFieldOffset = reader.readIntPositioned(footerPos + 8 + 4); ++ ++ fieldLen = nextFieldOffset - fieldOffset; ++ } ++ ++ return F.t(fieldPos, fieldLen); ++ } ++ ++ /** ++ * Initialize read cache if needed. + */ + private void ensureReadCacheInit() { + if (readCache == null) { + Map<Integer, Object> readCache = new HashMap<>(); + - int pos = start + hdrLen; - int end = start + reader.readIntAbsolute(start + RAW_DATA_OFF_POS); ++ IgniteBiTuple<Integer, Integer> footer = PortableUtils.footerAbsolute(reader, start); + - while (pos < end) { - int fieldId = reader.readIntAbsolute(pos); ++ int footerPos = footer.get1(); ++ int footerEnd = footer.get2(); + - pos += 4; ++ int rawPos = PortableUtils.rawOffsetAbsolute(reader, start); + - int len = reader.readIntAbsolute(pos); ++ while (footerPos < footerEnd) { ++ int fieldId = reader.readIntPositioned(footerPos); + - pos += 4; ++ IgniteBiTuple<Integer, Integer> posAndLen = fieldPositionAndLength(footerPos, footerEnd, rawPos); + - Object val = reader.getValueQuickly(pos, len); ++ Object val = reader.getValueQuickly(posAndLen.get1(), posAndLen.get2()); + + readCache.put(fieldId, val); + - pos += len; ++ // Shift current footer position. ++ footerPos += 8; + } + + this.readCache = readCache; + } + } + + /** {@inheritDoc} */ - @Override public <F> F getField(String name) { ++ @SuppressWarnings("unchecked") ++ @Override public <T> T getField(String name) { + Object val; + + if (assignedVals != null && assignedVals.containsKey(name)) { + val = assignedVals.get(name); + + if (val == REMOVED_FIELD_MARKER) + return null; + } + else { + ensureReadCacheInit(); + + int fldId = ctx.fieldId(typeId, name); + + val = readCache.get(fldId); + } + - return (F)PortableUtils.unwrapLazy(val); ++ return (T)PortableUtils.unwrapLazy(val); + } + + /** {@inheritDoc} */ + @Override public IgniteObjectBuilder setField(String name, Object val) { + GridArgumentCheck.notNull(val, name); + + if (assignedVals == null) + assignedVals = new LinkedHashMap<>(); + + Object oldVal = assignedVals.put(name, val); + + if (oldVal instanceof PortableValueWithType) { + ((PortableValueWithType)oldVal).value(val); + + assignedVals.put(name, oldVal); + } + + return this; + } + + /** {@inheritDoc} */ + @Override public <T> IgniteObjectBuilder setField(String name, @Nullable T val, Class<? super T> type) { + if (assignedVals == null) + assignedVals = new LinkedHashMap<>(); + + //int fldId = ctx.fieldId(typeId, fldName); + + assignedVals.put(name, new PortableValueWithType(PortableUtils.typeByClass(type), val)); + + return this; + } + + /** {@inheritDoc} */ + @Override public IgniteObjectBuilder setField(String name, @Nullable IgniteObjectBuilder builder) { + if (builder == null) + return setField(name, null, Object.class); + else + return setField(name, (Object)builder); + } + + /** + * Removes field from portable object. + * + * @param name Field name. + * @return {@code this} instance for chaining. + */ + @Override public IgniteObjectBuilderImpl removeField(String name) { + if (assignedVals == null) + assignedVals = new LinkedHashMap<>(); + + assignedVals.put(name, REMOVED_FIELD_MARKER); + + return this; + } + + /** + * Creates builder initialized by specified portable object. + * + * @param obj Portable object to initialize builder. + * @return New builder. + */ + public static IgniteObjectBuilderImpl wrap(IgniteObject obj) { + IgniteObjectImpl heapObj; + + if (obj instanceof IgniteObjectOffheapImpl) + heapObj = (IgniteObjectImpl)((IgniteObjectOffheapImpl)obj).heapCopy(); + else + heapObj = (IgniteObjectImpl)obj; + + return new IgniteObjectBuilderImpl(heapObj); + } + + /** + * @return Object start position in source array. + */ + int start() { + return start; + } + + /** + * @return Object type id. + */ + public int typeId() { + return typeId; + } +}
http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java index 6404a69,b999cde..cf8ad20 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderReader.java @@@ -23,12 -23,13 +23,13 @@@ import java.util.HashMap import java.util.Map; import org.apache.ignite.internal.portable.GridPortableMarshaller; import org.apache.ignite.internal.portable.PortableContext; -import org.apache.ignite.internal.portable.PortableObjectImpl; + import org.apache.ignite.internal.portable.PortablePositionReadable; +import org.apache.ignite.internal.portable.IgniteObjectImpl; import org.apache.ignite.internal.portable.PortablePrimitives; -import org.apache.ignite.internal.portable.PortableReaderExImpl; +import org.apache.ignite.internal.portable.IgniteObjectReaderExImpl; import org.apache.ignite.internal.portable.PortableUtils; -import org.apache.ignite.internal.portable.PortableWriterExImpl; -import org.apache.ignite.portable.PortableException; +import org.apache.ignite.internal.portable.IgniteObjectWriterExImpl; +import org.apache.ignite.igniteobject.IgniteObjectException; import static java.nio.charset.StandardCharsets.UTF_8; import static org.apache.ignite.internal.portable.GridPortableMarshaller.NULL; @@@ -357,12 -360,12 +360,12 @@@ public class PortableBuilderReader impl return null; case GridPortableMarshaller.HANDLE: { - int objStart = pos - readIntAbsolute(pos + 1); + int objStart = pos - readIntPositioned(pos + 1); - PortableBuilderImpl res = objMap.get(objStart); + IgniteObjectBuilderImpl res = objMap.get(objStart); if (res == null) { - res = new PortableBuilderImpl(this, objStart); + res = new IgniteObjectBuilderImpl(this, objStart); objMap.put(objStart, res); } @@@ -451,11 -454,11 +454,11 @@@ } case GridPortableMarshaller.PORTABLE_OBJ: { - int size = readIntAbsolute(pos + 1); + int size = readIntPositioned(pos + 1); - int start = readIntAbsolute(pos + 4 + size); + int start = readIntPositioned(pos + 4 + size); - PortableObjectImpl portableObj = new PortableObjectImpl(ctx, arr, pos + 4 + start); + IgniteObjectImpl portableObj = new IgniteObjectImpl(ctx, arr, pos + 4 + start); return new PortablePlainPortableObject(portableObj); } @@@ -747,9 -750,8 +750,8 @@@ return new PortablePlainPortableObject(portableObj); } - default: - throw new PortableException("Invalid flag value: " + type); + throw new IgniteObjectException("Invalid flag value: " + type); } PortableAbstractLazyValue res; http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableBuilderSerializer.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java index 098a70a,f29872e..02e116b --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyArrayList.java @@@ -131,9 -131,9 +131,9 @@@ class PortableLazyArrayList extends Abs } /** {@inheritDoc} */ - @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) { + @Override public void writeTo(IgniteObjectWriterExImpl writer, PortableBuilderSerializer ctx) { if (delegate == null) { - int size = reader.readIntAbsolute(off + 1); + int size = reader.readIntPositioned(off + 1); int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */; http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java index 998be43,4940311..65f7dbc --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyLinkedList.java @@@ -188,9 -188,9 +188,9 @@@ class PortableLazyLinkedList extends Ab } /** {@inheritDoc} */ - @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) { + @Override public void writeTo(IgniteObjectWriterExImpl writer, PortableBuilderSerializer ctx) { if (delegate == null) { - int size = reader.readIntAbsolute(off + 1); + int size = reader.readIntPositioned(off + 1); int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */; writer.write(reader.array(), off, hdrSize); http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java index c1c2c5a,74bd4c4..67fabde --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazyMap.java @@@ -85,9 -85,9 +85,9 @@@ class PortableLazyMap extends AbstractM } /** {@inheritDoc} */ - @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) { + @Override public void writeTo(IgniteObjectWriterExImpl writer, PortableBuilderSerializer ctx) { if (delegate == null) { - int size = reader.readIntAbsolute(off + 1); + int size = reader.readIntPositioned(off + 1); int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */; writer.write(reader.array(), off, hdrSize); http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java index 2f9a34b,c1099eb..9e37868 --- a/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/builder/PortableLazySet.java @@@ -47,9 -47,9 +47,9 @@@ class PortableLazySet extends PortableA } /** {@inheritDoc} */ - @Override public void writeTo(PortableWriterExImpl writer, PortableBuilderSerializer ctx) { + @Override public void writeTo(IgniteObjectWriterExImpl writer, PortableBuilderSerializer ctx) { if (val == null) { - int size = reader.readIntAbsolute(off + 1); + int size = reader.readIntPositioned(off + 1); int hdrSize = 1 /* flag */ + 4 /* size */ + 1 /* col type */; writer.write(reader.array(), off, hdrSize); http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/portable/streams/PortableAbstractInputStream.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java index 5b50818,44b91a5..a35b3e1 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheObjectContext.java @@@ -58,13 -57,15 +62,15 @@@ import org.apache.ignite.internal.util. public CacheObjectContext(GridKernalContext kernalCtx, AffinityKeyMapper dfltAffMapper, boolean cpyOnGet, - boolean storeVal) { + boolean storeVal, + boolean addDepInfo) { this.kernalCtx = kernalCtx; - this.p2pEnabled = kernalCtx.config().isPeerClassLoadingEnabled(); this.dfltAffMapper = dfltAffMapper; this.cpyOnGet = cpyOnGet; this.storeVal = storeVal; + this.addDepInfo = addDepInfo; + p2pEnabled = kernalCtx.config().isPeerClassLoadingEnabled(); proc = kernalCtx.cacheObjects(); } @@@ -164,70 -130,13 +177,70 @@@ } /** - * Unwraps collection. + * Unwraps array list. * - * @param col Collection to unwrap. - * @param keepPortable Keep portable flag. - * @return Unwrapped collection. + * @param col List to unwrap. + * @return Unwrapped list. */ - public Collection<Object> unwrapPortablesIfNeeded(Collection<Object> col, boolean keepPortable) { + private Collection<Object> unwrapPortables(ArrayList<Object> col, boolean keepPortable, boolean cpy) { + int size = col.size(); + + for (int i = 0; i < size; i++) { + Object o = col.get(i); + + Object unwrapped = unwrapPortable(o, keepPortable, cpy); + + if (o != unwrapped) + col.set(i, unwrapped); + } + return col; } + + /** + * Unwraps set with portables. + * + * @param set Set to unwrap. + * @return Unwrapped set. + */ + private Set<Object> unwrapPortables(Set<Object> set, boolean keepPortable, boolean cpy) { + Set<Object> set0 = PortableUtils.newSet(set); + + for (Object obj : set) + set0.add(unwrapPortable(obj, keepPortable, cpy)); + + return set0; + } + + /** + * @param o Object to unwrap. + * @return Unwrapped object. + */ + private Object unwrapPortable(Object o, boolean keepPortable, boolean cpy) { + if (o instanceof Map.Entry) { + Map.Entry entry = (Map.Entry)o; + + Object key = entry.getKey(); + + Object uKey = unwrapPortable(key, keepPortable, cpy); + + Object val = entry.getValue(); + + Object uVal = unwrapPortable(val, keepPortable, cpy); + + return (key != uKey || val != uVal) ? F.t(uKey, uVal) : o; + } + else if (o instanceof Collection) + return unwrapPortablesIfNeeded((Collection<Object>)o, keepPortable, cpy); + else if (o instanceof Map) + return unwrapPortablesIfNeeded((Map<Object, Object>)o, keepPortable, cpy); + else if (o instanceof CacheObject) { + CacheObject co = (CacheObject)o; + + if (!keepPortable || co.isPlatformType()) + return unwrapPortable(co.value(this, true), keepPortable, cpy); + } + + return o; + } - } + } http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedLockRequest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLockFuture.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicUpdateRequest.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java index 3b197bc,ae662c8..d06773f --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateFuture.java @@@ -1053,8 -1050,8 +1055,9 @@@ public class GridNearAtomicUpdateFutur subjId, taskNameHash, skipStore, + keepBinary, - cctx.kernalContext().clientNode()); + cctx.kernalContext().clientNode(), + cctx.deploymentEnabled()); pendingMappings.put(nodeId, mapped); } @@@ -1146,8 -1143,8 +1149,9 @@@ subjId, taskNameHash, skipStore, + keepBinary, - cctx.kernalContext().clientNode()); + cctx.kernalContext().clientNode(), + cctx.deploymentEnabled()); req.addUpdateEntry(cacheKey, val, http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java index d3b6afc,33fa4bd..b7100dd --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateRequest.java @@@ -199,8 -197,8 +200,9 @@@ public class GridNearAtomicUpdateReques @Nullable UUID subjId, int taskNameHash, boolean skipStore, + boolean keepBinary, - boolean clientReq + boolean clientReq, + boolean addDepInfo ) { assert futVer != null; @@@ -221,8 -219,8 +223,9 @@@ this.subjId = subjId; this.taskNameHash = taskNameHash; this.skipStore = skipStore; + this.keepBinary = keepBinary; this.clientReq = clientReq; + this.addDepInfo = addDepInfo; keys = new ArrayList<>(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicUpdateResponse.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtForceKeysFuture.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java index 3da08c7,ae1d43c..1f65e66 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java @@@ -533,11 -523,29 +523,18 @@@ public final class GridNearGetFuture<K } } - if (v != null && !reload) { - K key0 = (K)cctx.unwrapPortableIfNeeded(key, !deserializePortable); - V val0 = (V)cctx.unwrapPortableIfNeeded(v, !deserializePortable); + if (v != null) { + if (needVer) { + V val0 = (V)new T2<>(skipVals ? true : v, ver); - add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0))); + add(new GridFinishedFuture<>(Collections.singletonMap((K)key, val0))); + } + else { - if (keepCacheObjects) { - K key0 = (K)key; - V val0 = (V)(skipVals ? true : v); ++ K key0 = (K)cctx.unwrapPortableIfNeeded(key, !deserializePortable); ++ V val0 = (V)cctx.unwrapPortableIfNeeded(v, !deserializePortable); + - add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0))); - } - else { - K key0 = key.value(cctx.cacheObjectContext(), true); - V val0 = v.value(cctx.cacheObjectContext(), true); - - val0 = (V)cctx.unwrapPortableIfNeeded(val0, !deserializePortable); - key0 = (K)cctx.unwrapPortableIfNeeded(key0, !deserializePortable); - - add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0))); - } ++ add(new GridFinishedFuture<>(Collections.singletonMap(key0, val0))); + } } else { if (affNode == null) { http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableContext.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java index 85134bf,04c1e69..ab6ac25 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/portable/CacheObjectPortableProcessorImpl.java @@@ -430,10 -427,10 +430,10 @@@ public class CacheObjectPortableProcess /** * @param obj Object. * @return Bytes. - * @throws PortableException If failed. + * @throws org.apache.ignite.igniteobject.IgniteObjectException If failed. */ - public byte[] marshal(@Nullable Object obj) throws PortableException { + public byte[] marshal(@Nullable Object obj) throws IgniteObjectException { - byte[] arr = portableMarsh.marshal(obj, 0); + byte[] arr = portableMarsh.marshal(obj); assert arr.length > 0; http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java index cd9d09d,1c82636..fa19822 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java @@@ -1267,88 -1272,81 +1272,81 @@@ public abstract class IgniteTxAdapter e if (F.isEmpty(txEntry.entryProcessors())) return F.t(txEntry.op(), txEntry.value()); else { - try { - boolean recordEvt = cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ); - - CacheObject cacheVal = txEntry.hasValue() ? txEntry.value() : - txEntry.cached().innerGet(this, - /*swap*/false, - /*read through*/false, - /*fail fast*/true, - /*unmarshal*/true, - /*metrics*/metrics, - /*event*/recordEvt, - /*temporary*/true, - /*subjId*/subjId, - /**closure name */recordEvt ? F.first(txEntry.entryProcessors()).get1() : null, - resolveTaskName(), - null); + boolean recordEvt = cctx.gridEvents().isRecordable(EVT_CACHE_OBJECT_READ); - boolean modified = false; + CacheObject cacheVal = txEntry.hasValue() ? txEntry.value() : + txEntry.cached().innerGet(this, + /*swap*/false, + /*read through*/false, + /*fail fast*/true, + /*unmarshal*/true, + /*metrics*/metrics, + /*event*/recordEvt, + /*temporary*/true, + /*subjId*/subjId, + /**closure name */recordEvt ? F.first(txEntry.entryProcessors()).get1() : null, + resolveTaskName(), + null); - Object val = null; + boolean modified = false; - Object key = null; + Object val = null; - GridCacheVersion ver; + Object key = null; - try { - ver = txEntry.cached().version(); - } - catch (GridCacheEntryRemovedException e) { - assert optimistic() : txEntry; + GridCacheVersion ver; - if (log.isDebugEnabled()) - log.debug("Failed to get entry version: [msg=" + e.getMessage() + ']'); + try { + ver = txEntry.cached().version(); + } + catch (GridCacheEntryRemovedException e) { + assert optimistic() : txEntry; - ver = null; - } + if (log.isDebugEnabled()) + log.debug("Failed to get entry version: [msg=" + e.getMessage() + ']'); - for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : txEntry.entryProcessors()) { - CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(txEntry.context(), - txEntry.key(), key, cacheVal, val, ver, txEntry.keepBinary()); + ver = null; + } - try { - EntryProcessor<Object, Object, Object> processor = t.get1(); + for (T2<EntryProcessor<Object, Object, Object>, Object[]> t : txEntry.entryProcessors()) { + CacheInvokeEntry<Object, Object> invokeEntry = new CacheInvokeEntry(txEntry.context(), - txEntry.key(), key, cacheVal, val, ver); ++ txEntry.key(), key, cacheVal, val, ver, txEntry.keepBinary()); - processor.process(invokeEntry, t.get2()); + try { + EntryProcessor<Object, Object, Object> processor = t.get1(); - val = invokeEntry.getValue(); + processor.process(invokeEntry, t.get2()); - key = invokeEntry.key(); - } - catch (Exception ignore) { - // No-op. - } + val = invokeEntry.getValue(); - modified |= invokeEntry.modified(); + key = invokeEntry.key(); + } + catch (Exception ignore) { + // No-op. } - if (modified) - cacheVal = cacheCtx.toCacheObject(cacheCtx.unwrapTemporary(val)); + modified |= invokeEntry.modified(); + } - GridCacheOperation op = modified ? (val == null ? DELETE : UPDATE) : NOOP; + if (modified) + cacheVal = cacheCtx.toCacheObject(cacheCtx.unwrapTemporary(val)); - if (op == NOOP) { - ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry); + GridCacheOperation op = modified ? (val == null ? DELETE : UPDATE) : NOOP; - if (expiry != null) { - long ttl = CU.toTtl(expiry.getExpiryForAccess()); + if (op == NOOP) { + ExpiryPolicy expiry = cacheCtx.expiryForTxEntry(txEntry); - txEntry.ttl(ttl); + if (expiry != null) { + long ttl = CU.toTtl(expiry.getExpiryForAccess()); - if (ttl == CU.TTL_ZERO) - op = DELETE; - } - } + txEntry.ttl(ttl); - return F.t(op, cacheVal); + if (ttl == CU.TTL_ZERO) + op = DELETE; + } } - catch (GridCacheFilterFailedException e) { - assert false : "Empty filter failed for innerGet: " + e; - return null; - } + return F.t(op, cacheVal); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java index 930ed83,82e5f2a..fa2a53c --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java @@@ -2120,10 -2047,9 +2053,10 @@@ public abstract class IgniteTxLocalAdap @Nullable Map<KeyCacheObject, GridCacheDrInfo> drPutMap, @Nullable Map<KeyCacheObject, GridCacheVersion> drRmvMap, boolean skipStore, - final boolean singleRmv ++ final boolean singleRmv, + boolean keepBinary ) { - assert cached == null || keys.size() == 1; - assert cached == null || F.first(keys).equals(cached.key()); + assert retval || invokeMap == null; try { addActiveCache(cacheCtx); @@@ -2269,13 -2202,18 +2209,19 @@@ -1L, -1L, null, - skipStore); + skipStore, + keepBinary); txEntry.markValid(); + + if (needReadVer) { + assert readVer != null; + + txEntry.serializableReadVersion(singleRmv ? SER_READ_NOT_EMPTY_VER : readVer); + } } - if (readCommitted() || old == null) + if (readCommitted()) cacheCtx.evicts().touch(entry, topologyVersion()); break; // While. @@@ -2832,7 -2805,7 +2816,8 @@@ drMap, null, opCtx != null && opCtx.skipStore(), - false); ++ false, + opCtx != null && opCtx.isKeepPortable()); if (pessimistic()) { // Loose all skipped. @@@ -3062,7 -3032,7 +3044,8 @@@ null, drMap, opCtx != null && opCtx.skipStore(), - singleRmv ++ singleRmv, + opCtx != null && opCtx.isKeepPortable() ); if (log.isDebugEnabled()) http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java index f8ab6f5,0c2e564..b8a6c9b --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetCacheStore.java @@@ -351,12 -329,9 +329,9 @@@ public class PlatformDotNetCacheStore<K try (PlatformMemory mem = platformCtx.memory().allocate()) { PlatformOutputStream out = mem.output(); - PortableRawWriterEx writer = platformCtx.writer(out); + IgniteObjectRawWriterEx writer = platformCtx.writer(out); - writer.writeString(assemblyName); - writer.writeString(clsName); - writer.writeBoolean(convertPortable); - writer.writeMap(props); + write(writer, convertPortable); out.synchronize(); http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/dotnet/PlatformDotNetConfigurationClosure.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/events/PlatformEventFilterListenerImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java index a1d1cae,66c51e5..c847a61 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformUtils.java @@@ -780,8 -780,7 +780,7 @@@ public class PlatformUtils writeNullableCollection(writer, portableCfg.getTypesConfiguration(), new PlatformWriterClosure<PlatformDotNetPortableTypeConfiguration>() { - @Override public void write(PortableRawWriterEx writer, PlatformDotNetPortableTypeConfiguration typ) { + @Override public void write(IgniteObjectRawWriterEx writer, PlatformDotNetPortableTypeConfiguration typ) { - writer.writeString(typ.getAssemblyName()); writer.writeString(typ.getTypeName()); writer.writeString(typ.getNameMapper()); writer.writeString(typ.getIdMapper()); http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java index e44acfc,f9cf509..fa20e8d --- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java @@@ -298,7 -298,12 +298,12 @@@ public class PortableMarshaller extend return impl.deserialize(buf.toByteArray(), clsLdr); } catch (IOException e) { - throw new PortableException("Failed to unmarshal the object from InputStream", e); + throw new IgniteObjectException("Failed to unmarshal the object from InputStream", e); } } + + /** {@inheritDoc} */ + @Override public void onUndeploy(ClassLoader ldr) { + impl.context().onUndeploy(ldr); + } } http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java ---------------------------------------------------------------------- diff --cc modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java index d3d40bd,ec7110f..cd4f19a --- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java @@@ -741,9 -718,9 +718,9 @@@ public class GridPortableMarshallerSelf PortableMarshaller marsh = new PortableMarshaller(); marsh.setTypeConfigurations(Arrays.asList( - new IgniteObjectConfiguration(NoPublicConstructor.class.getName()), - new IgniteObjectConfiguration(NoPublicDefaultConstructor.class.getName()), - new IgniteObjectConfiguration(ProtectedConstructor.class.getName())) - new PortableTypeConfiguration(NoPublicConstructor.class.getName()), - new PortableTypeConfiguration(NoPublicDefaultConstructor.class.getName()), - new PortableTypeConfiguration(ProtectedConstructor.class.getName())) ++ new IgniteObjectConfiguration(NoPublicConstructor.class.getName()), ++ new IgniteObjectConfiguration(NoPublicDefaultConstructor.class.getName()), ++ new IgniteObjectConfiguration(ProtectedConstructor.class.getName())) ); initPortableContext(marsh); @@@ -846,11 -823,11 +823,11 @@@ CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str"); - IgniteObject po1 = marshal(obj1, marsh); - PortableObjectEx po1 = marshal(obj1, marsh); ++ IgniteObjectEx po1 = marshal(obj1, marsh); assertEquals(11111, po1.typeId()); - assertEquals(22222, intFromPortable(po1, 19)); - assertEquals(33333, intFromPortable(po1, 32)); + assertEquals(10, po1.field(22222)); + assertEquals("str", po1.field(33333)); assertEquals(10, po1.<CustomMappedObject1>deserialize().val1); assertEquals("str", po1.<CustomMappedObject1>deserialize().val2); @@@ -905,22 -882,22 +882,22 @@@ CustomMappedObject1 obj1 = new CustomMappedObject1(10, "str1"); - IgniteObject po1 = marshal(obj1, marsh); - PortableObjectEx po1 = marshal(obj1, marsh); ++ IgniteObjectEx po1 = marshal(obj1, marsh); assertEquals(11111, po1.typeId()); - assertEquals(22222, intFromPortable(po1, 19)); - assertEquals(33333, intFromPortable(po1, 32)); + assertEquals(10, po1.field(22222)); + assertEquals("str1", po1.field(33333)); assertEquals(10, po1.<CustomMappedObject1>deserialize().val1); assertEquals("str1", po1.<CustomMappedObject1>deserialize().val2); CustomMappedObject2 obj2 = new CustomMappedObject2(20, "str2"); - IgniteObject po2 = marshal(obj2, marsh); - PortableObjectEx po2 = marshal(obj2, marsh); ++ IgniteObjectEx po2 = marshal(obj2, marsh); assertEquals(44444, po2.typeId()); - assertEquals(55555, intFromPortable(po2, 19)); - assertEquals(66666, intFromPortable(po2, 32)); + assertEquals(20, po2.field(55555)); + assertEquals("str2", po2.field(66666)); assertEquals(20, po2.<CustomMappedObject2>deserialize().val1); assertEquals("str2", po2.<CustomMappedObject2>deserialize().val2); @@@ -1271,10 -1248,10 +1248,10 @@@ } }); - marsh.setTypeConfigurations(Arrays.asList(new PortableTypeConfiguration(Key.class.getName()), - new PortableTypeConfiguration("NonExistentClass2"), + marsh.setTypeConfigurations(Arrays.asList(new IgniteObjectConfiguration(Key.class.getName()), - new IgniteObjectConfiguration("NonExistentClass2"), - customType1, - customType2)); ++ new IgniteObjectConfiguration("NonExistentClass2"), + customType1, + customType2)); PortableContext ctx = initPortableContext(marsh); @@@ -2100,7 -2077,7 +2077,7 @@@ // Checking the writer directly. assertEquals(false, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired()); - try (IgniteObjectWriterExImpl writer = new IgniteObjectWriterExImpl(initPortableContext(new PortableMarshaller()), 0)) { - try (PortableWriterExImpl writer = new PortableWriterExImpl(initPortableContext(new PortableMarshaller()))) { ++ try (IgniteObjectWriterExImpl writer = new IgniteObjectWriterExImpl(initPortableContext(new PortableMarshaller()))) { assertEquals(true, THREAD_LOCAL_ALLOC.isThreadLocalArrayAcquired()); writer.writeString("Thread local test"); http://git-wip-us.apache.org/repos/asf/ignite/blob/b5c70a94/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java ---------------------------------------------------------------------- diff --cc modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java index db02f9d,abb2767..5bd4f9b --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java @@@ -455,11 -472,15 +472,16 @@@ public class GridCacheTestEntryEx exten long ttl, boolean evt, boolean metrics, + boolean keepPortable, AffinityTopologyVersion topVer, - CacheEntryPredicate[] filter, GridDrType drType, - long drExpireTime, @Nullable GridCacheVersion drVer, UUID subjId, String taskName) throws IgniteCheckedException, - GridCacheEntryRemovedException { + CacheEntryPredicate[] filter, + GridDrType drType, + long drExpireTime, + @Nullable GridCacheVersion drVer, + UUID subjId, + String taskName, + @Nullable GridCacheVersion dhtVer) + throws IgniteCheckedException, GridCacheEntryRemovedException { return new GridCacheUpdateTxResult(true, rawPut(val, ttl)); }
