Skip to content

Commit

Permalink
# ignite-283: Minor refactorings.
Browse files Browse the repository at this point in the history
  • Loading branch information
vozerov-gridgain committed Feb 18, 2015
1 parent e3d563b commit 81cce4c
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 116 deletions.
Expand Up @@ -43,15 +43,15 @@ public class GridCacheUpdateAtomicResult<K, V> {
private final long newTtl;

/** Explicit DR expire time (if any). */
private final long drExpireTime;
private final long conflictExpireTime;

/** Version for deferred delete. */
@GridToStringInclude
private final GridCacheVersion rmvVer;

/** DR resolution result. */
@GridToStringInclude
private final GridCacheVersionConflictContext<K, V> drRes;
private final GridCacheVersionConflictContext<K, V> conflictRes;

/** Whether update should be propagated to DHT node. */
private final boolean sndToDht;
Expand All @@ -67,28 +67,28 @@ public class GridCacheUpdateAtomicResult<K, V> {
* @param newVal New value.
* @param res Value computed by the {@link EntryProcessor}.
* @param newTtl New TTL.
* @param drExpireTime Explicit DR expire time (if any).
* @param conflictExpireTime Explicit DR expire time (if any).
* @param rmvVer Version for deferred delete.
* @param drRes DR resolution result.
* @param conflictRes DR resolution result.
* @param sndToDht Whether update should be propagated to DHT node.
*/
public GridCacheUpdateAtomicResult(boolean success,
@Nullable V oldVal,
@Nullable V newVal,
@Nullable EntryProcessorResult<?> res,
long newTtl,
long drExpireTime,
long conflictExpireTime,
@Nullable GridCacheVersion rmvVer,
@Nullable GridCacheVersionConflictContext<K, V> drRes,
@Nullable GridCacheVersionConflictContext<K, V> conflictRes,
boolean sndToDht) {
this.success = success;
this.oldVal = oldVal;
this.newVal = newVal;
this.res = res;
this.newTtl = newTtl;
this.drExpireTime = drExpireTime;
this.conflictExpireTime = conflictExpireTime;
this.rmvVer = rmvVer;
this.drRes = drRes;
this.conflictRes = conflictRes;
this.sndToDht = sndToDht;
}

Expand Down Expand Up @@ -121,17 +121,18 @@ public boolean success() {
}

/**
* @return {@code -1} if TTL did not change, otherwise new TTL.
* @return {@link GridCacheUtils#TTL_NOT_CHANGED} if TTL did not change, otherwise new TTL.
*/
public long newTtl() {
return newTtl;
}

/**
* @return Explicit DR expire time (if any).
* @return Explicit conflict expire time (if any). Set only if it is necessary to propagate concrete expire time
* value to DHT node. Otherwise set to {@link GridCacheUtils#EXPIRE_TIME_CALCULATE}.
*/
public long drExpireTime() {
return drExpireTime;
public long conflictExpireTime() {
return conflictExpireTime;
}

/**
Expand All @@ -144,8 +145,8 @@ public long drExpireTime() {
/**
* @return DR conflict resolution context.
*/
@Nullable public GridCacheVersionConflictContext<K, V> drResolveResult() {
return drRes;
@Nullable public GridCacheVersionConflictContext<K, V> conflictResolveResult() {
return conflictRes;
}

/**
Expand Down
Expand Up @@ -1699,7 +1699,7 @@ public static long toTtl(Duration duration) {

if (duration.getDurationAmount() == 0) {
if (duration.isEternal())
return 0;
return TTL_ETERNAL;

assert duration.isZero();

Expand Down
Expand Up @@ -346,8 +346,8 @@ private void doneRemote(IgniteTxEntry<K, V> txEntry, GridCacheVersion baseVer,
entry.groupLockEntry(e.groupLockEntry());

// DR stuff.
entry.drVersion(e.drVersion());
entry.drExpireTime(e.drExpireTime());
entry.conflictVersion(e.conflictVersion());
entry.conflictExpireTime(e.conflictExpireTime());
}

addExplicit(e);
Expand Down Expand Up @@ -504,7 +504,7 @@ private void commitIfLocked() throws IgniteCheckedException {
V val = res.get2();
byte[] valBytes = res.get3();

GridCacheVersion explicitVer = txEntry.drVersion();
GridCacheVersion explicitVer = txEntry.conflictVersion();

if (txEntry.ttl() == CU.TTL_ZERO)
op = DELETE;
Expand All @@ -515,7 +515,7 @@ private void commitIfLocked() throws IgniteCheckedException {
if (drNeedResolve) {
IgniteBiTuple<GridCacheOperation, GridCacheVersionConflictContext<K, V>>
drRes = conflictResolve(op, txEntry.key(), val, valBytes,
txEntry.ttl(), txEntry.drExpireTime(), explicitVer, cached);
txEntry.ttl(), txEntry.conflictExpireTime(), explicitVer, cached);

assert drRes != null;

Expand All @@ -527,9 +527,9 @@ else if (drCtx.isUseNew()) {
txEntry.ttl(drCtx.ttl());

if (drCtx.newEntry().dataCenterId() != cacheCtx.dataCenterId())
txEntry.drExpireTime(drCtx.expireTime());
txEntry.conflictExpireTime(drCtx.expireTime());
else
txEntry.drExpireTime(-1L);
txEntry.conflictExpireTime(-1L);
}
else if (drCtx.isMerge()) {
op = drRes.get1();
Expand All @@ -538,7 +538,7 @@ else if (drCtx.isMerge()) {
explicitVer = writeVersion();

txEntry.ttl(drCtx.ttl());
txEntry.drExpireTime(-1L);
txEntry.conflictExpireTime(-1L);
}
}
else
Expand All @@ -555,7 +555,7 @@ else if (drCtx.isMerge()) {
else {
cached.innerSet(this, eventNodeId(), nodeId, val, valBytes, false, false,
txEntry.ttl(), true, true, topVer, txEntry.filters(),
replicate ? DR_BACKUP : DR_NONE, txEntry.drExpireTime(),
replicate ? DR_BACKUP : DR_NONE, txEntry.conflictExpireTime(),
near() ? null : explicitVer, CU.subjectId(this, cctx),
resolveTaskName());

Expand Down
Expand Up @@ -452,8 +452,8 @@ private void addMapping0(
entry.ttl(e.ttl());
entry.filters(e.filters());
entry.expiry(e.expiry());
entry.drExpireTime(e.drExpireTime());
entry.drVersion(e.drVersion());
entry.conflictExpireTime(e.conflictExpireTime());
entry.conflictVersion(e.conflictVersion());
}
else {
entry = e;
Expand Down
Expand Up @@ -285,7 +285,7 @@ private void onEntriesLocked() {
expiry = cacheCtx.expiry();

try {
if (txEntry.op() == CREATE || txEntry.op() == UPDATE && txEntry.drExpireTime() == -1L) {
if (txEntry.op() == CREATE || txEntry.op() == UPDATE && txEntry.conflictExpireTime() == -1L) {
if (expiry != null) {
Duration duration = cached.hasValue() ?
expiry.getExpiryForUpdate() : expiry.getExpiryForCreation();
Expand Down

0 comments on commit 81cce4c

Please sign in to comment.