コード例 #1
0
ファイル: GridNearTxLocal.java プロジェクト: WinnieRzz/ignite
  /** {@inheritDoc} */
  @Override
  protected GridCacheEntryEx entryEx(GridCacheContext cacheCtx, IgniteTxKey key) {
    if (cacheCtx.isColocated()) {
      IgniteTxEntry txEntry = entry(key);

      if (txEntry == null) return cacheCtx.colocated().entryExx(key.key(), topologyVersion(), true);

      GridCacheEntryEx cached = txEntry.cached();

      assert cached != null;

      if (cached.detached()) return cached;

      if (cached.obsoleteVersion() != null) {
        cached = cacheCtx.colocated().entryExx(key.key(), topologyVersion(), true);

        txEntry.cached(cached);
      }

      return cached;
    } else return cacheCtx.cache().entryEx(key.key());
  }
コード例 #2
0
ファイル: GridNearTxLocal.java プロジェクト: WinnieRzz/ignite
  /** {@inheritDoc} */
  @Override
  public IgniteInternalFuture<Void> loadMissing(
      final GridCacheContext cacheCtx,
      boolean readThrough,
      boolean async,
      final Collection<KeyCacheObject> keys,
      final boolean skipVals,
      final boolean needVer,
      boolean keepBinary,
      final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c) {
    if (cacheCtx.isNear()) {
      return cacheCtx
          .nearTx()
          .txLoadAsync(
              this,
              keys,
              readThrough,
              /*deserializeBinary*/ false,
              accessPolicy(cacheCtx, keys),
              skipVals,
              needVer)
          .chain(
              new C1<IgniteInternalFuture<Map<Object, Object>>, Void>() {
                @Override
                public Void apply(IgniteInternalFuture<Map<Object, Object>> f) {
                  try {
                    Map<Object, Object> map = f.get();

                    processLoaded(map, keys, needVer, c);

                    return null;
                  } catch (Exception e) {
                    setRollbackOnly();

                    throw new GridClosureException(e);
                  }
                }
              });
    } else if (cacheCtx.isColocated()) {
      if (keys.size() == 1) {
        final KeyCacheObject key = F.first(keys);

        return cacheCtx
            .colocated()
            .loadAsync(
                key,
                readThrough,
                /*force primary*/ needVer,
                topologyVersion(),
                CU.subjectId(this, cctx),
                resolveTaskName(),
                /*deserializeBinary*/ false,
                accessPolicy(cacheCtx, keys),
                skipVals,
                /*can remap*/ true,
                needVer,
                /*keepCacheObject*/ true)
            .chain(
                new C1<IgniteInternalFuture<Object>, Void>() {
                  @Override
                  public Void apply(IgniteInternalFuture<Object> f) {
                    try {
                      Object val = f.get();

                      processLoaded(key, val, needVer, skipVals, c);

                      return null;
                    } catch (Exception e) {
                      setRollbackOnly();

                      throw new GridClosureException(e);
                    }
                  }
                });
      } else {
        return cacheCtx
            .colocated()
            .loadAsync(
                keys,
                readThrough,
                /*force primary*/ needVer,
                topologyVersion(),
                CU.subjectId(this, cctx),
                resolveTaskName(),
                /*deserializeBinary*/ false,
                accessPolicy(cacheCtx, keys),
                skipVals,
                /*can remap*/ true,
                needVer,
                /*keepCacheObject*/ true)
            .chain(
                new C1<IgniteInternalFuture<Map<Object, Object>>, Void>() {
                  @Override
                  public Void apply(IgniteInternalFuture<Map<Object, Object>> f) {
                    try {
                      Map<Object, Object> map = f.get();

                      processLoaded(map, keys, needVer, c);

                      return null;
                    } catch (Exception e) {
                      setRollbackOnly();

                      throw new GridClosureException(e);
                    }
                  }
                });
      }
    } else {
      assert cacheCtx.isLocal();

      return super.loadMissing(
          cacheCtx, readThrough, async, keys, skipVals, keepBinary, needVer, c);
    }
  }