Esempio n. 1
0
  @Override
  public Object perform(InvocationContext ctx) throws Throwable {
    MVCCEntry e = (MVCCEntry) ctx.lookupEntry(key);
    if (e != null) {
      if (ctx.isOriginLocal()) {
        // ISPN-514
        if (e.isNull() || e.getValue() == null) {
          // Revert assumption that new value is to be committed
          e.setChanged(false);
          return returnValue(null, false, ctx);
        }
      }

      if (oldValue == null || oldValue.equals(e.getValue()) || ignorePreviousValue) {
        e.setChanged(true);
        Object old = e.setValue(newValue);
        e.setLifespan(lifespanMillis);
        e.setMaxIdle(maxIdleTimeMillis);
        e.setLoaded(false);
        return returnValue(old, true, ctx);
      }
      // Revert assumption that new value is to be committed
      e.setChanged(false);
    }

    return returnValue(null, false, ctx);
  }
Esempio n. 2
0
  @Override
  public Object perform(InvocationContext ctx) throws Throwable {
    // It's not worth looking up the entry if we're never going to apply the change.
    if (valueMatcher == ValueMatcher.MATCH_NEVER) {
      successful = false;
      return null;
    }
    MVCCEntry e = (MVCCEntry) ctx.lookupEntry(key);
    if (e == null || e.isNull() || e.isRemoved()) {
      nonExistent = true;
      if (valueMatcher.matches(e, value, null, valueEquivalence)) {
        if (e != null) {
          e.setChanged(true);
          e.setRemoved(true);
        }
        return isConditional() ? true : null;
      } else {
        log.trace("Nothing to remove since the entry doesn't exist in the context or it is null");
        successful = false;
        return false;
      }
    }

    if (!valueMatcher.matches(e, value, null, valueEquivalence)) {
      successful = false;
      return false;
    }

    if (this instanceof EvictCommand) {
      e.setEvicted(true);
    }

    return performRemove(e, ctx);
  }