Ejemplo n.º 1
0
  @Override
  public final CacheEntry wrapEntryForReading(InvocationContext ctx, Object key)
      throws InterruptedException {
    CacheEntry cacheEntry = getFromContext(ctx, key);
    if (cacheEntry == null) {
      cacheEntry = getFromContainer(key);

      // do not bother wrapping though if this is not in a tx.  repeatable read etc are all
      // meaningless unless there is a tx.
      if (useRepeatableRead) {
        MVCCEntry mvccEntry =
            cacheEntry == null
                ? createWrappedEntry(key, null, null, false, false, -1)
                : createWrappedEntry(
                    key,
                    cacheEntry.getValue(),
                    cacheEntry.getVersion(),
                    false,
                    false,
                    cacheEntry.getLifespan());
        if (mvccEntry != null) ctx.putLookedUpEntry(key, mvccEntry);
        return mvccEntry;
      } else if (cacheEntry
          != null) { // if not in transaction and repeatable read, or simply read committed
                     // (regardless of whether in TX or not), do not wrap
        ctx.putLookedUpEntry(key, cacheEntry);
      }
      return cacheEntry;
    }
    return cacheEntry;
  }
Ejemplo n.º 2
0
 private MVCCEntry wrapMvccEntryForRemove(
     InvocationContext ctx, Object key, CacheEntry cacheEntry) {
   MVCCEntry mvccEntry =
       createWrappedEntry(
           key,
           cacheEntry.getValue(),
           cacheEntry.getVersion(),
           false,
           true,
           cacheEntry.getLifespan());
   ctx.putLookedUpEntry(key, mvccEntry);
   return mvccEntry;
 }
 @Override
 protected void commitContextEntry(
     CacheEntry entry, InvocationContext ctx, FlagAffectedCommand command) {
   if (ctx.isInTxScope() && !isFromStateTransfer(ctx)) {
     EntryVersion version =
         ((TxInvocationContext) ctx)
             .getCacheTransaction()
             .getUpdatedEntryVersions()
             .get(entry.getKey());
     cdl.commitEntry(entry, version, command, ctx);
   } else {
     // This could be a state transfer call!
     cdl.commitEntry(entry, entry.getVersion(), command, ctx);
   }
 }
  @Override
  protected void commitContextEntry(
      CacheEntry entry, InvocationContext ctx, boolean skipOwnershipCheck) {
    if (ctx.isInTxScope()) {
      ClusteredRepeatableReadEntry clusterMvccEntry = (ClusteredRepeatableReadEntry) entry;
      EntryVersion existingVersion = clusterMvccEntry.getVersion();

      EntryVersion newVersion;
      if (existingVersion == null) {
        newVersion = versionGenerator.generateNew();
      } else {
        newVersion = versionGenerator.increment((IncrementableEntryVersion) existingVersion);
      }
      commitEntry(entry, newVersion, skipOwnershipCheck);
    } else {
      // This could be a state transfer call!
      commitEntry(entry, entry.getVersion(), skipOwnershipCheck);
    }
  }
 @SuppressWarnings("UnusedParameters")
 protected EntryVersion getEntryVersion(InvocationContext ctx, Object key) {
   CacheEntry cacheEntry = dataContainer.get(key);
   return (cacheEntry != null) ? cacheEntry.getVersion() : null;
 }