Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
import org.apache.ignite.internal.codegen.TcpInverseConnectionResponseMessageSerializer;
import org.apache.ignite.internal.codegen.TransactionAttributesAwareRequestSerializer;
import org.apache.ignite.internal.codegen.TxEntriesInfoSerializer;
import org.apache.ignite.internal.codegen.TxEntryValueHolderSerializer;
import org.apache.ignite.internal.codegen.TxInfoSerializer;
import org.apache.ignite.internal.codegen.TxLockListSerializer;
import org.apache.ignite.internal.codegen.TxLockSerializer;
Expand Down Expand Up @@ -433,7 +434,7 @@ public class GridIoMessageFactory implements MessageFactoryProvider {
factory.register((short)97, CacheEvictionEntry::new, new CacheEvictionEntrySerializer());
factory.register((short)98, CacheEntryPredicateAdapter::new, new CacheEntryPredicateAdapterSerializer());
factory.register((short)100, IgniteTxEntry::new);
factory.register((short)101, TxEntryValueHolder::new);
factory.register((short)101, TxEntryValueHolder::new, new TxEntryValueHolderSerializer());
factory.register((short)102, CacheVersionedValue::new, new CacheVersionedValueSerializer());
factory.register((short)103, GridCacheRawVersionedEntry::new);
factory.register((short)104, GridCacheVersionEx::new, new GridCacheVersionExSerializer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ public IgniteTxEntry cleanCopy(GridCacheContext<?, ?> ctx) {
cp.val = new TxEntryValueHolder();

cp.filters = filters;
cp.val.value(val.op(), val.value(), val.hasWriteValue(), val.hasReadValue());
cp.val.value(val.operation(), val.value(), val.hasWriteValue(), val.hasReadValue());
cp.entryProcessorsCol = entryProcessorsCol;
cp.ttl = ttl;
cp.conflictExpireTime = conflictExpireTime;
Expand Down Expand Up @@ -485,7 +485,7 @@ void setAndMarkValid(GridCacheOperation op, CacheObject val, boolean hasWriteVal
* to further peek operations.
*/
public void markValid() {
prevVal.value(val.op(), val.value(), val.hasWriteValue(), val.hasReadValue());
prevVal.value(val.operation(), val.value(), val.hasWriteValue(), val.hasReadValue());
}

/**
Expand Down Expand Up @@ -720,7 +720,7 @@ public boolean hasPreviousValue() {
* @return Previous operation to revert entry in case of filter failure.
*/
@Nullable public GridCacheOperation previousOperation() {
return prevVal.op();
return prevVal.operation();
}

/**
Expand Down Expand Up @@ -757,7 +757,7 @@ public void conflictExpireTime(long conflictExpireTime) {
* @param readVal Read value flag.
*/
public void value(@Nullable CacheObject val, boolean writeVal, boolean readVal) {
this.val.value(this.val.op(), val, writeVal, readVal);
this.val.value(this.val.operation(), val, writeVal, readVal);
}

/**
Expand All @@ -766,7 +766,7 @@ public void value(@Nullable CacheObject val, boolean writeVal, boolean readVal)
* @param val Read value to set.
*/
public void readValue(@Nullable CacheObject val) {
this.val.value(this.val.op(), val, false, true);
this.val.value(this.val.operation(), val, false, true);
}

/**
Expand All @@ -782,7 +782,7 @@ public void addEntryProcessor(EntryProcessor<Object, Object, Object> entryProces
// Must clear transform closure bytes since collection has changed.
transformClosBytes = null;

val.op(TRANSFORM);
val.operation(TRANSFORM);
}

/**
Expand Down Expand Up @@ -853,14 +853,14 @@ public void entryProcessors(
* @return Cache operation.
*/
public GridCacheOperation op() {
return val.op();
return val.operation();
}

/**
* @param op Cache operation.
*/
public void op(GridCacheOperation op) {
val.op(op);
val.operation(op);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@

package org.apache.ignite.internal.processors.cache.transactions;

import java.nio.ByteBuffer;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.GridDirectTransient;
import org.apache.ignite.internal.IgniteCodeGeneratingFail;
import org.apache.ignite.internal.Order;
import org.apache.ignite.internal.processors.cache.CacheObject;
import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
Expand All @@ -29,8 +27,6 @@
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.plugin.extensions.communication.Message;
import org.apache.ignite.plugin.extensions.communication.MessageReader;
import org.apache.ignite.plugin.extensions.communication.MessageWriter;
import org.jetbrains.annotations.Nullable;

import static org.apache.ignite.internal.processors.cache.GridCacheOperation.CREATE;
Expand All @@ -42,23 +38,24 @@
/**
* Auxiliary class to hold value, value-has-been-set flag, value update operation, value bytes.
*/
@IgniteCodeGeneratingFail // Need to handle 'hasWriteVal' flag during write.
public class TxEntryValueHolder implements Message {
/** */
/** Stored value. */
@Order(value = 0, method = "storedValue")
@GridToStringInclude(sensitive = true)
private CacheObject val;
private @Nullable CacheObject val;

/** */
/** Cache operation. */
@Order(value = 1, method = "operation")
@GridToStringInclude
private GridCacheOperation op = NOOP;

/** Flag indicating that value has been set for write. */
@Order(value = 2, method = "hasWriteValue")
@GridToStringExclude
private boolean hasWriteVal;

/** Flag indicating that value has been set for read. */
@GridToStringExclude
@GridDirectTransient
private boolean hasReadVal;

/**
Expand Down Expand Up @@ -102,51 +99,71 @@ public void value(@Nullable CacheObject val) {
}

/**
* Gets cache operation.
* Used only in serializer.
*
* @return Stored value or null.
*/
public @Nullable CacheObject storedValue() {
return hasWriteVal ? val : null;
}

/**
* Used only in serializer.
*
* @param val Stored value.
*/
public void storedValue(@Nullable CacheObject val) {
this.val = val;
}

/**
* @return Cache operation.
*/
public GridCacheOperation op() {
public GridCacheOperation operation() {
return op;
}

/**
* Sets cache operation.
*
* @param op Cache operation.
*/
public void op(GridCacheOperation op) {
public void operation(GridCacheOperation op) {
this.op = op;
}

/**
* @return {@code True} if write value was set.
* @return Flag indicating that value has been set for write.
*/
public boolean hasWriteValue() {
return hasWriteVal;
}

/**
* @return {@code True} if read value was set.
* @param hasWriteVal Flag indicating that value has been set for write.
*/
public void hasWriteValue(boolean hasWriteVal) {
this.hasWriteVal = hasWriteVal;
}

/**
* @return Flag indicating that value has been set for read.
*/
public boolean hasReadValue() {
return hasReadVal;
}

/**
* @param ctx Cache context.
* @throws org.apache.ignite.IgniteCheckedException If marshaling failed.
* @throws IgniteCheckedException If marshaling failed.
*/
public void marshal(GridCacheContext<?, ?> ctx)
throws IgniteCheckedException {
public void marshal(GridCacheContext<?, ?> ctx) throws IgniteCheckedException {
if (hasWriteVal && val != null)
val.prepareMarshal(ctx.cacheObjectContext());
}

/**
* @param ctx Cache context.
* @param ldr Class loader.
* @throws org.apache.ignite.IgniteCheckedException If unmarshalling failed.
* @throws IgniteCheckedException If unmarshalling failed.
*/
public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws IgniteCheckedException {
if (hasWriteVal && val != null)
Expand All @@ -158,79 +175,6 @@ public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws Ignit
return S.toString(TxEntryValueHolder.class, this);
}

/** {@inheritDoc} */
@Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
writer.setBuffer(buf);

if (!writer.isHeaderWritten()) {
if (!writer.writeHeader(directType()))
return false;

writer.onHeaderWritten();
}

switch (writer.state()) {
case 0:
if (!writer.writeBoolean(hasWriteVal))
return false;

writer.incrementState();

case 1:
if (!writer.writeByte(op != null ? (byte)op.ordinal() : -1))
return false;

writer.incrementState();

case 2:
if (!writer.writeCacheObject(hasWriteVal ? val : null))
return false;

writer.incrementState();

}

return true;
}

/** {@inheritDoc} */
@Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
reader.setBuffer(buf);

switch (reader.state()) {
case 0:
hasWriteVal = reader.readBoolean();

if (!reader.isLastRead())
return false;

reader.incrementState();

case 1:
byte opOrd;

opOrd = reader.readByte();

if (!reader.isLastRead())
return false;

op = GridCacheOperation.fromOrdinal(opOrd);

reader.incrementState();

case 2:
val = reader.readCacheObject();

if (!reader.isLastRead())
return false;

reader.incrementState();

}

return true;
}

/** {@inheritDoc} */
@Override public short directType() {
return 101;
Expand Down
Loading