/** * @see com.gemstone.gemfire.cache.CacheEvent#getCallbackArgument() */ public final Object getCallbackArgument() { final Object result = this.callbackArg; if (result == null) { return null; } return getCallbackArgument(result); }
@Override public Object getValueInVM(EntryEventImpl event) throws EntryNotFoundException { final Object key = event.getKey(); if (this.dataStore == null) { throw new EntryNotFoundException(key.toString()); } final int bucketId = PartitionedRegionHelper.getHashKey(event, this, key, event.getCallbackArgument()); return this.dataStore.getLocalValueInVM(key, bucketId); }
public DistributedPutAllOperation setPutAllOperation(DistributedPutAllOperation nv) { DistributedPutAllOperation result = this.putAllOp; if (nv != null && nv.getBaseEvent() != null) { setCallbackArgument(nv.getBaseEvent().getCallbackArgument()); } this.putAllOp = nv; return result; } public DistributedRemoveAllOperation getRemoveAllOperation() {
public DistributedRemoveAllOperation setRemoveAllOperation(DistributedRemoveAllOperation nv) { DistributedRemoveAllOperation result = this.removeAllOp; if (nv != null && nv.getBaseEvent() != null) { setCallbackArgument(nv.getBaseEvent().getCallbackArgument()); } this.removeAllOp = nv; return result; }
final void putTXEntryCallbackArg(final TXEntryState txEntry) { final Object callbackArg = getRawCallbackArgument(); if (callbackArg != null) { txEntry.setCallbackArgument(getCallbackArgument(callbackArg)); } else { txEntry.setCallbackArgument(null); } }
public Object getValueInVM(EntryEventImpl event) throws EntryNotFoundException { return basicGetValueInVM(event.getKey(), event.getCallbackArgument(), event.getTXState(this)); }
/** * Runs hashCode() on given key/routing object producing a long value and then * finds absolute value of the modulus with bucketSize. For better key * distribution, possibly use MD5 or SHA or any unique ID generator for the * hash function. * * @param event * entry event created for this entry operation * @return the bucket id the key/routing object hashes to */ public static final int getHashKey(final EntryEventImpl event) { return getHashKey(event, (PartitionedRegion)event.getRegion(), null, event.getKey(), null, event.getCallbackArgument()); }
@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); }
public static void callEventCallbackOnEvent(final EntryEventImpl event, EventCallback ecb, Event.Type type) throws CacheWriterException { // Asif: I suppose the callback arg now will always be of type // GfxdCallbackArgument GfxdCallbackArgument callbackArg = (GfxdCallbackArgument)event .getCallbackArgument(); if (callbackArg != null && callbackArg.isSkipListeners()) { return; } EventImpl cbevent = new EventImpl(event, type); try { ecb.onEvent(cbevent); } catch (SQLException e) { throw GemFireXDRuntimeException.newRuntimeException( "GfxdCacheWriter#callEventCallbackOnEvent: unexpected exception", e); } }
public static void callEventCallbackOnEvent(final EntryEventImpl event, EventCallback ecb, Event.Type type) throws CacheWriterException { // Asif: I suppose the callback arg now will always be of type // GfxdCallbackArgument GfxdCallbackArgument callbackArg = (GfxdCallbackArgument)event .getCallbackArgument(); if (callbackArg != null && callbackArg.isSkipListeners()) { return; } EventImpl cbevent = new EventImpl(event, type); try { ecb.onEvent(cbevent); } catch (SQLException e) { throw GemFireXDRuntimeException.newRuntimeException( "GfxdCacheWriter#callEventCallbackOnEvent: unexpected exception", e); } }
public static void callEventCallbackOnEvent(final EntryEventImpl event, EventCallback ecb, Event.Type type) throws CacheWriterException { // Asif: I suppose the callback arg now will always be of type // GfxdCallbackArgument GfxdCallbackArgument callbackArg = (GfxdCallbackArgument)event .getCallbackArgument(); if (callbackArg != null && callbackArg.isSkipListeners()) { return; } EventImpl cbevent = new EventImpl(event, type); try { ecb.onEvent(cbevent); } catch (SQLException e) { throw GemFireXDRuntimeException.newRuntimeException( "GfxdCacheWriter#callEventCallbackOnEvent: unexpected exception", e); } }
public void destroyExistingEntry(EntryEventImpl event, boolean cacheWrite, Object expectedOldValue) { if(event.getOperation().isLocal()) { throw new UnsupportedOperationInTransactionException(); } Object result = proxy.destroy(event.getKey(), expectedOldValue, event.getOperation(), event, event.getCallbackArgument()); if (result instanceof EntryNotFoundException) { throw (EntryNotFoundException)result; } }
/** * @throws com.gemstone.gemfire.SerializationException if serialization fails */ public InvalidateOpImpl(LogWriterI18n lw, String region, EntryEventImpl event) { super(lw, MessageType.INVALIDATE, event.getCallbackArgument() != null ? 4 : 3); Object callbackArg = event.getCallbackArgument(); this.event = event; getMessage().addStringPart(region); getMessage().addStringOrObjPart(event.getKey()); getMessage().addBytesPart(event.getEventId().calcBytes()); if (callbackArg != null) { getMessage().addObjPart(callbackArg); } }
/** * @throws com.gemstone.gemfire.SerializationException if serialization fails */ public InvalidateOpImpl(String region, EntryEventImpl event) { super(MessageType.INVALIDATE, event.getCallbackArgument() != null ? 4 : 3); Object callbackArg = event.getCallbackArgument(); this.event = event; getMessage().addStringPart(region); getMessage().addStringOrObjPart(event.getKeyInfo().getKey()); getMessage().addBytesPart(event.getEventId().calcBytes()); if (callbackArg != null) { getMessage().addObjPart(callbackArg); } }
public static ProxyBucketRegion getProxyBucketRegion( final PartitionedRegion pr, final EntryEventImpl event) { int bucketId = event.getBucketId(); if (bucketId == KeyInfo.UNKNOWN_BUCKET) { bucketId = PartitionedRegionHelper.getHashKey(pr, event.getOperation(), event.getKey(), event.getValue(), event.getCallbackArgument()); event.setBucketId(bucketId); } final RegionAdvisor ra = pr.getRegionAdvisor(); return ra.getProxyBucketArray()[bucketId]; }
RemoteRemoveAllMessage(EntryEventImpl event, Set recipients, DirectReplyProcessor p, RemoveAllEntryData[] removeAllData, int removeAllDataCount, boolean useOriginRemote, int processorType, boolean possibleDuplicate) { super(recipients, event.getRegion().getFullPath(), p); this.resetRecipients(); if (recipients != null) { setRecipients(recipients); } this.processor = p; this.processorId = p==null? 0 : p.getProcessorId(); if (p != null && this.isSevereAlertCompatible()) { p.enableSevereAlertProcessing(); } this.removeAllData = removeAllData; this.removeAllDataCount = removeAllDataCount; this.posDup = possibleDuplicate; this.eventId = event.getEventId(); this.callbackArg = event.getCallbackArgument(); }
/** * Create RemoveAllPRMessage for notify only (to adjunct nodes) * * @param bucketId * create message to send to this bucket * @return RemoveAllPRMessage */ public RemoveAllPRMessage createPRMessagesNotifyOnly(int bucketId) { final EntryEventImpl event = getBaseEvent(); RemoveAllPRMessage prMsg = new RemoveAllPRMessage(bucketId, removeAllDataSize, true, event.isPossibleDuplicate(), !event.isGenerateCallbacks(), event.getCallbackArgument()); if (event.getContext() != null) { prMsg.setBridgeContext(event.getContext()); } // will not recover event id here for (int i=0; i<removeAllDataSize; i++) { prMsg.addEntry(removeAllData[i]); } return prMsg; }
/** * Create PutAllPRMessage for notify only (to adjunct nodes) * * @param bucketId * create message to send to this bucket * @return PutAllPRMessage */ public PutAllPRMessage createPRMessagesNotifyOnly(int bucketId) { final EntryEventImpl event = getBaseEvent(); PutAllPRMessage prMsg = new PutAllPRMessage(bucketId, putAllDataSize, true, event.isPossibleDuplicate(), !event.isGenerateCallbacks(), event.getCallbackArgument(), false, false /*isPutDML*/); if (event.getContext() != null) { prMsg.setBridgeContext(event.getContext()); } // will not recover event id here for (int i=0; i<putAllDataSize; i++) { prMsg.addEntry(putAllData[i]); } return prMsg; }
void putValueTXEntry(final TXEntryState tx) { Object v = basicGetNewValue(); if (v == null) { if (deltaBytes != null) { // since newValue is null, and we have deltaBytes // there must be a nearSidePendingValue processDeltaBytes(tx.getNearSidePendingValue()); v = basicGetNewValue(); } else if (this.delta != null) { v = this.delta; } else { v = isLocalInvalid() ? Token.LOCAL_INVALID : Token.INVALID; } } if (this.op != Operation.LOCAL_INVALIDATE && this.op != Operation.LOCAL_DESTROY) { // fix for bug 34387 tx.setPendingValue(OffHeapHelper.copyIfNeeded(v)); // TODO OFFHEAP optimize } tx.setCallbackArgument(getCallbackArgument()); }
RemotePutAllMessage(EntryEventImpl event, Set recipients, DirectReplyProcessor p, PutAllEntryData[] putAllData, int putAllDataCount, boolean useOriginRemote, int processorType, boolean possibleDuplicate, boolean skipCallbacks) { super(recipients, event.getRegion().getFullPath(), p); this.resetRecipients(); if (recipients != null) { setRecipients(recipients); } this.processor = p; this.processorId = p==null? 0 : p.getProcessorId(); if (p != null && this.isSevereAlertCompatible()) { p.enableSevereAlertProcessing(); } this.putAllData = putAllData; this.putAllDataCount = putAllDataCount; // this.useOriginRemote = useOriginRemote; // this.processorType = processorType; this.posDup = possibleDuplicate; this.eventId = event.getEventId(); this.skipCallbacks = skipCallbacks; this.callbackArg = event.getCallbackArgument(); this.isPutDML = event.isPutDML(); }