/** {@inheritDoc} */ @Override public int partition() { assert key != null; return key.partition(); }
/** {@inheritDoc} */ @Override public int partition() { assert key != null; return key.partition(); }
/** {@inheritDoc} */ @Override public int partition() { int p = key.partition(); assert p >= 0; return p; }
/** {@inheritDoc} */ @Override public int partition() { return keys != null && !keys.isEmpty() ? keys.get(0).partition() : -1; }
/** {@inheritDoc} */ @Override public int partition() { return keys != null && !keys.isEmpty() ? keys.get(0).partition() : -1; }
/** {@inheritDoc} */ @Override public int partition() { return keys != null && !keys.isEmpty() ? keys.get(0).partition() : -1; }
/** * @param key Cache key. * @param val Cache value. * @param ver Version. * @param expireTime Expired time. * @param cacheId Cache id. * @return Made data row. */ @NotNull private DataRow makeDataRow(KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, int cacheId) { if (key.partition() == -1) key.partition(partId); return new DataRow(key, val, ver, partId, expireTime, cacheId); }
/** {@inheritDoc} */ @Override public int partition() { assert !F.isEmpty(keys); return keys.get(0).partition(); }
/** * @param cacheName Cache name (needed only if {@code aff} is not provided. * @param key Key. * @param aff Affinity information. * @return Key partition. * @throws IgniteCheckedException If failed. */ public int partition(String cacheName, Object key, @Nullable AffinityInfo aff) throws IgniteCheckedException { assert cacheName != null; if (key instanceof KeyCacheObject) { int part = ((KeyCacheObject)key).partition(); if (part >= 0) return part; } return partition0(cacheName, key, aff); }
/** * @param key Key to add. * @param val Value, {@code null} if should be removed. * @param entryProcessor Entry processor. * @param ttl TTL. * @param expireTime Expire time. */ @Override public void addNearWriteValue(KeyCacheObject key, @Nullable CacheObject val, EntryProcessor<Object, Object, Object> entryProcessor, long ttl, long expireTime) { assert entryProcessor == null; assert ttl <= 0 : ttl; assert key.partition() >= 0 : key; if (this.key != null) { setFlag(true, DHT_ATOMIC_OBSOLETE_NEAR_KEY_FLAG_MASK); return; } near(true); this.key = key; this.val = val; }
/** * @param grp Cache group (used to initialize row). * @param hash Hash code. * @param link Link. * @param part Partition. * @param rowData Required row data. * @param skipVer Whether version read should be skipped. */ protected DataRow(CacheGroupContext grp, int hash, long link, int part, RowData rowData, boolean skipVer) { super(link); this.hash = hash; this.part = part; try { // We can not init data row lazily outside of entry lock because underlying buffer can be concurrently cleared. if (rowData != RowData.LINK_ONLY) initFromLink(grp, rowData, skipVer); } catch (IgniteCheckedException e) { throw new IgniteException(e); } if (key != null) key.partition(part); }
/** {@inheritDoc} */ @Override public void insertDataRow(CacheDataRow row, IoStatisticsHolder statHolder) throws IgniteCheckedException { super.insertDataRow(row, statHolder); assert row.key().partition() == PageIdUtils.partId(row.link()) : "Constructed a link with invalid partition ID [partId=" + row.key().partition() + ", link=" + U.hexLong(row.link()) + ']'; }
/** * @param cctx Cache context. * @param key Key. * @param topVer Topology version. * @param create Create flag. * @return Local partition. */ @Nullable private GridDhtLocalPartition localPartition( GridCacheContext cctx, KeyCacheObject key, AffinityTopologyVersion topVer, boolean create ) { int p = key.partition(); if (p == -1) p = cctx.affinity().partition(key); return grp.topology().localPartition(p, topVer, create); }
/** */ private boolean isLocalBackup(EnlistOperation op, KeyCacheObject key) { if (!cctx.affinityNode() || op == EnlistOperation.LOCK) return false; else if (cctx.isReplicated()) return true; return cctx.topology().nodes(key.partition(), tx.topologyVersion()).indexOf(cctx.localNode()) > 0; }
/** */ private boolean isLocalBackup(EnlistOperation op, KeyCacheObject key) { if (!cctx.affinityNode() || op == EnlistOperation.LOCK) return false; else if (cctx.isReplicated()) return true; return cctx.topology().nodes(key.partition(), tx.topologyVersion()).contains(cctx.localNode()); }
/** {@inheritDoc} */ @Override public KeyCacheObject key() { try { if (key == null) { GridCacheContext cacheCtx = cctx.cacheContext(cacheId); if (cacheCtx == null) throw new IgniteException("Failed to find cache context for the given cache ID: " + cacheId); IgniteCacheObjectProcessor co = cctx.kernalContext().cacheObjects(); key = co.toKeyCacheObject(cacheCtx.cacheObjectContext(), keyType, keyBytes); if (key.partition() == -1) key.partition(partId); } return key; } catch (IgniteCheckedException e) { throw new IgniteException(e); } }
/** {@inheritDoc} */ @Override public KeyCacheObject key() { try { if (key == null) { GridCacheContext cacheCtx = cctx.cacheContext(cacheId); if (cacheCtx == null) throw new IgniteException("Failed to find cache context for the given cache ID: " + cacheId); IgniteCacheObjectProcessor co = cctx.kernalContext().cacheObjects(); key = co.toKeyCacheObject(cacheCtx.cacheObjectContext(), keyType, keyBytes); if (key.partition() == -1) key.partition(partId); } return key; } catch (IgniteCheckedException e) { throw new IgniteException(e); } }
/** * NOTE: Use this method always when you need to calculate partition id for * a key provided by user. It's required since we should apply affinity mapper * logic in order to find a key that will eventually be passed to affinity function. * * @param key Key. * @param useKeyPart If {@code true} can use pre-calculated partition stored in KeyCacheObject. * @return Partition. */ public int partition(Object key, boolean useKeyPart) { GridAffinityAssignmentCache aff0 = aff; if (aff0 == null) throw new IgniteException(FAILED_TO_FIND_CACHE_ERR_MSG + cctx.name()); if (useKeyPart && (key instanceof KeyCacheObject)) { int part = ((KeyCacheObject)key).partition(); if (part != -1) return part; } return affFunction.partition(affinityKey(key)); }