/** * @param key * @return the wrapped {@link KeyInfo} */ public KeyInfo getKeyInfo(Object key) { return new KeyInfo(key, null, null); }
protected final InternalDistributedMember getOrCreateNodeForBucketRead( final KeyInfo keyInfo, final boolean noCreateNode) { final Object key = keyInfo.getKey(); int bucketId = keyInfo.getBucketId(); if (bucketId == KeyInfo.UNKNOWN_BUCKET) { bucketId = PartitionedRegionHelper.getHashKey(this, Operation.GET_ENTRY, key, keyInfo.getValue(), keyInfo.getCallbackArg()); keyInfo.setBucketId(bucketId); } if (noCreateNode) { return getNodeForBucketRead(bucketId); } return getOrCreateNodeForBucketRead(bucketId); }
@Override public Object next() { this.key.setKey(super.next()); this.key.setBucketId(this.currentBucketId); Object entry = view.getEntryForIterator(this.key, PartitionedRegion.this, allowTombstones); return entry != null ? entry : new DestroyedEntry(key.getKey().toString()); } }
public void setCallbackArgument(Object newCallbackArgument) { if (this.keyInfo.getCallbackArg() instanceof WrappedCallbackArgument) { ((WrappedCallbackArgument)this.keyInfo.getCallbackArg()) .setOriginalCallbackArgument(newCallbackArgument); } else { this.keyInfo.setCallbackArg(newCallbackArgument); } }
public Object findObject(KeyInfo keyInfo, boolean isCreate, boolean generateCallbacks, Object value, boolean preferCD, ClientProxyMembershipID requestingClient, EntryEventImpl event, boolean allowReadFromHDFS) { return proxy.get(keyInfo.getKey(), keyInfo.getCallbackArg(), event); }
public Object getEntryForIterator(KeyInfo curr, LocalRegion currRgn, boolean rememberReads, boolean allowTombstones) { if (currRgn instanceof PartitionedRegion) { PartitionedRegion pr = (PartitionedRegion)currRgn; if (!pr.getBucketPrimary(curr.getBucketId()).equals(pr.cache.getMyId())) { // to fix bug 47893 suspend the tx before calling nonTXGetEntry final TXManagerImpl txmgr = pr.getGemFireCache().getTXMgr(); TransactionId tid = txmgr.suspend(); try { return pr.nonTXGetEntry(curr, false, allowTombstones); } finally { txmgr.resume(tid); } } } if (! readEntryAndCheckIfDestroyed(curr, currRgn, rememberReads)) { // need to create KeyInfo since higher level iterator may reuse KeyInfo return new TXEntry(currRgn, new KeyInfo(curr.getKey(), curr.getCallbackArg(), curr.getBucketId()), proxy, rememberReads); } else { return null; } }
public Object findObject(KeyInfo keyInfo, boolean isCreate, boolean generateCallbacks, Object value, boolean peferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent, boolean allowReadFromHDFS) { Object retVal = null; final Object key = keyInfo.getKey(); final Object callbackArgument = keyInfo.getCallbackArg(); PartitionedRegion pr = (PartitionedRegion)region; try { retVal = pr.getRemotely((InternalDistributedMember)state.getTarget(), keyInfo.getBucketId(), key, callbackArgument, peferCD, requestingClient, clientEvent, false, allowReadFromHDFS); } catch (TransactionException e) { RuntimeException re = getTransactionException(keyInfo, e); re.initCause(e.getCause()); throw re; } catch (PrimaryBucketException e) { RuntimeException re = getTransactionException(keyInfo, e); re.initCause(e); throw re; } catch (ForceReattemptException e) { if (isBucketNotFoundException(e)) { return null; } waitToRetry(); RuntimeException re = getTransactionException(keyInfo, e); re.initCause(e); throw re; } trackBucketForTx(keyInfo); return retVal; }
/** * Return a value from the bucket region, always serialized * * @param keyInfo * TODO * @param clientEvent a "client" event that will hold version information about the entry * @param returnTombstones TODO * @throws ForceReattemptException * if bucket region is null * @return value from the bucket region * @throws PrimaryBucketException * if the locally managed bucket is not primary * @see #getLocally(int, Object, Object, boolean, boolean, * ClientProxyMembershipID, TXStateInterface, TXStateInterface, * EntryEventImpl, boolean, boolean) */ public RawValue getSerializedLocally(KeyInfo keyInfo, boolean doNotLockEntry, final TXStateInterface lockState, EntryEventImpl clientEvent, boolean returnTombstones, boolean allowReadFromHDFS) throws PrimaryBucketException, ForceReattemptException { return getSerializedLocally(keyInfo.getKey(), null /* do not require callbackArg since keyInfo non-null */, keyInfo.getBucketId(), keyInfo, doNotLockEntry, lockState, clientEvent, returnTombstones, allowReadFromHDFS); }
@Override public Object getKeyForIterator(KeyInfo curr, LocalRegion currRgn, boolean allowTombstones) { // do not perform a value check here, it will send out an // extra message. Also BucketRegion will check to see if // the value for this key is a removed token return curr.getKey(); }
private void trackBucketForTx(KeyInfo keyInfo) { GemFireCacheImpl cache = (GemFireCacheImpl) txMgr.getCache(); if (keyInfo.getBucketId() >= 0) { if (logger.isDebugEnabled()) { logger.debug("adding bucket:{} for tx:{}", keyInfo.getBucketId(), getTransactionId()); } } if (keyInfo.getBucketId() >= 0) { buckets.put(keyInfo.getBucketId(), Boolean.TRUE); } }
/** * * @param keyInfo * @param access * true if caller wants last accessed time updated * @param allowTombstones - whether a tombstone can be returned * @return TODO */ @Override protected Region.Entry<?, ?> nonTXGetEntry(KeyInfo keyInfo, boolean access, boolean allowTombstones) { final long startTime = PartitionedRegionStats.startTime(); final Object key = keyInfo.getKey(); try { int bucketId = keyInfo.getBucketId(); if (bucketId == KeyInfo.UNKNOWN_BUCKET) { bucketId = PartitionedRegionHelper.getHashKey(this, Operation.GET_ENTRY, key, null, null); keyInfo.setBucketId(bucketId); } InternalDistributedMember targetNode = getOrCreateNodeForBucketRead(bucketId); return getEntryInBucket(targetNode, bucketId, key, access, allowTombstones); } finally { this.prStats.endGetEntry(startTime); } }
distributedMember = other.distributedMember; this.filterInfo = other.filterInfo; this.keyInfo = other.keyInfo.isDistKeyInfo() ? new DistTxKeyInfo( (DistTxKeyInfo) other.keyInfo) : new KeyInfo(other.keyInfo); if (other.getRawCallbackArgument() instanceof GatewaySenderEventCallbackArgument) { this.keyInfo .setCallbackArg((new GatewaySenderEventCallbackArgument( (GatewaySenderEventCallbackArgument) other .getRawCallbackArgument())));
@Override public boolean hasNext() { if (nextValue != null) { return true; } while (nextValue == null) { if (!super.hasNext()) { return false; } this.key.setKey(super.next()); this.key.setBucketId(this.currentBucketId); Region.Entry re = (Region.Entry) view.getEntryForIterator(key, PartitionedRegion.this, rememberReads, allowTombstones); if (re != null) { nextValue = re.getValue(); } } return true; }
Object key = DataSerializer.readObject(in); Object value = DataSerializer.readObject(in); this.keyInfo = new KeyInfo(key, value, null); this.op = Operation.fromOrdinal(in.readByte()); this.eventFlags = in.readShort(); this.keyInfo.setCallbackArg(DataSerializer.readObject(in)); this.txId = (TXId)DataSerializer.readObject(in);
/** * Returns the value of the EntryEventImpl field. * This is for internal use only. Customers should always call * {@link #getCallbackArgument} * @since 5.5 */ public Object getRawCallbackArgument() { return this.keyInfo.getCallbackArg(); }
@Override void updateKeyInfo(final KeyInfo keyInfo, final Object key, final Object newValue) { final int bucketId; if (key == null) { // key is null for putAll bucketId = KeyInfo.UNKNOWN_BUCKET; } else { if (keyInfo instanceof EntryEventImpl) { final EntryEventImpl event = (EntryEventImpl)keyInfo; bucketId = PartitionedRegionHelper.getHashKey(event, this, key, event.getCallbackArgument()); } else { bucketId = PartitionedRegionHelper.getHashKey(this, null, key, newValue, keyInfo.callbackArg); } } keyInfo.setBucketId(bucketId); }
final Object result; this.keyInfo.setKey(currKey); if (this.additionalKeysFromView != null) { if (currKey instanceof AbstractRegionEntry) {
DataSerializer.writeObject(this.keyInfo.getValue(), out); out.writeByte(this.op.ordinal); out.writeShort(this.eventFlags & EventFlags.FLAG_TRANSIENT_MASK);
/** * Search for the value in a server (if one exists), * then try a loader. * * If we find a value, we put it in the cache. * @param preferCD return the CacheDeserializable, if that's what the value is. * @param requestingClient the client making the request, if any * @param clientEvent the client's event, if any. If not null, we set the version tag * @param returnTombstones TODO * @return the deserialized value * @see DistributedRegion#findObjectInSystem(KeyInfo, boolean, * TXStateInterface, boolean, Object, boolean, boolean, * ClientProxyMembershipID, EntryEventImpl, boolean, boolean) */ protected Object findObjectInSystem(KeyInfo keyInfo, boolean isCreate, final TXStateInterface lockState, boolean generateCallbacks, Object localValue, boolean disableCopyOnRead, boolean preferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent, boolean returnTombstones, boolean allowReadFromHDFS) throws CacheLoaderException, TimeoutException { return findObjectInLocalSystem(keyInfo.getKey(), keyInfo.getCallbackArg(), isCreate, lockState, generateCallbacks, localValue, clientEvent); }