public DistributedPutAllOperation setPutAllOperation(DistributedPutAllOperation nv) { DistributedPutAllOperation result = this.putAllOp; if (nv != null && nv.getBaseEvent() != null) { setCallbackArgument(nv.getBaseEvent().getCallbackArgument()); } this.putAllOp = nv; return result; }
@Override public void postPutAll(DistributedPutAllOperation putallOp, VersionedObjectList successfulPuts, InternalRegion reg) { super.postPutAll(putallOp, successfulPuts, reg); // TODO DISTTX: event is never released EntryEventImpl event = EntryEventImpl.createPutAllEvent(putallOp, reg, Operation.PUTALL_CREATE, putallOp.getBaseEvent().getKey(), putallOp.getBaseEvent().getValue()); event.setEventId(putallOp.getBaseEvent().getEventId()); DistTxEntryEvent dtop = new DistTxEntryEvent(event); dtop.setPutAllOperation(putallOp); this.primaryTransactionalOperations.add(dtop); }
@Test public void shouldBeMockable() throws Exception { DistributedPutAllOperation mockDistributedPutAllOperation = mock(DistributedPutAllOperation.class); EntryEventImpl mockEntryEventImpl = mock(EntryEventImpl.class); when(mockDistributedPutAllOperation.getBaseEvent()).thenReturn(mockEntryEventImpl); assertThat(mockDistributedPutAllOperation.getBaseEvent()).isSameAs(mockEntryEventImpl); } }
@Override protected CacheOperationMessage createMessage() { EntryEventImpl event = getBaseEvent(); PutAllMessage msg = new PutAllMessage(); msg.eventId = event.getEventId(); msg.context = event.getContext(); return msg; }
@Override public void postPutAll(DistributedPutAllOperation putallOp, VersionedObjectList successfulPuts, InternalRegion reg) { super.postPutAll(putallOp, successfulPuts, reg); // TODO DISTTX: event is never released EntryEventImpl event = EntryEventImpl.createPutAllEvent(putallOp, reg, Operation.PUTALL_CREATE, putallOp.getBaseEvent().getKey(), putallOp.getBaseEvent().getValue()); event.setEventId(putallOp.getBaseEvent().getEventId()); DistTxEntryEvent dtop = new DistTxEntryEvent(event); dtop.setPutAllOperation(putallOp); addPrimaryTransactionalOperations(dtop); }
@Test(expected = CacheClosedException.class) public void basicPutAllThrowsCacheClosedExceptionIfCacheIsClosing() { Map map = new HashMap(); map.put("key", "value"); DistributedPutAllOperation putAll = mock(DistributedPutAllOperation.class); when(putAll.getBaseEvent()).thenReturn(event); when(region.basicPutAll(map, putAll, null)).thenCallRealMethod(); when(region.getAtomicThresholdInfo()).thenReturn(mock(MemoryThresholdInfo.class)); when(serverRegionProxy.putAll(map, eventID, true, callbacks)).thenThrow(exception); region.basicPutAll(map, putAll, null); } }
}, putallOp.getBaseEvent().getEventId());
@Override public void run() { // final boolean requiresRegionContext = theRegion.keyRequiresRegionContext(); InternalDistributedMember myId = theRegion.getDistributionManager().getDistributionManagerId(); for (int i = 0; i < putallOp.putAllDataSize; ++i) { @Released EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(theRegion, myId, myId, i, putallOp.putAllData, false, putallOp.getBaseEvent().getContext(), false, !putallOp.getBaseEvent().isGenerateCallbacks()); try { ev.setPutAllOperation(putallOp); if (theRegion.basicPut(ev, false, false, null, false)) { successfulPuts.addKeyAndVersion(putallOp.putAllData[i].key, null); } } finally { ev.release(); } } } }, putallOp.getBaseEvent().getEventId());
@Override public void postPutAll(DistributedPutAllOperation putallOp, VersionedObjectList successfulPuts, InternalRegion region) { try { RemotePutAllMessage.PutAllResponse response = RemotePutAllMessage.send(state.getTarget(), putallOp.getBaseEvent(), putallOp.getPutAllEntryData(), putallOp.getPutAllEntryData().length, true, false); response.waitForRemoteResponse(); } catch (RegionDestroyedException rde) { throw new TransactionDataNotColocatedException( String.format("Region %s not colocated with other regions in transaction", rde.getRegionFullPath()), rde); } catch (RemoteOperationException roe) { throw new TransactionDataNodeHasDepartedException(roe); } }
}, putallOp.getBaseEvent().getEventId());
@Override public void putAll(Map map, Object aCallbackArgument) { long startPut = CachePerfStats.getStatTime(); final DistributedPutAllOperation putAllOp = newPutAllOperation(map, aCallbackArgument); if (putAllOp != null) { try { basicPutAll(map, putAllOp, null); } finally { putAllOp.getBaseEvent().release(); putAllOp.freeOffHeapResources(); } } getCachePerfStats().endPutAll(startPut); }
@Override public void postPutAllFireEvents(DistributedPutAllOperation putAllOp, VersionedObjectList successfulPuts) { if (!this.getDataPolicy().withStorage() && this.getConcurrencyChecksEnabled() && putAllOp.getBaseEvent().isBridgeEvent()) { // if there is no local storage we need to transfer version information // to the successfulPuts list for transmission back to the client successfulPuts.clear(); putAllOp.fillVersionedObjectList(successfulPuts); } Set successfulKeys = new HashSet(successfulPuts.size()); for (Object key : successfulPuts.getKeys()) { successfulKeys.add(key); } for (Iterator it = putAllOp.eventIterator(); it.hasNext();) { @Unretained EntryEventImpl event = (EntryEventImpl) it.next(); if (successfulKeys.contains(event.getKey())) { EnumListenerEvent op = event.getOperation().isCreate() ? EnumListenerEvent.AFTER_CREATE : EnumListenerEvent.AFTER_UPDATE; invokePutCallbacks(op, event, !event.callbacksInvoked() && !event.isPossibleDuplicate(), this.isUsedForPartitionedRegionBucket /* * If this is replicated region, use "false". We must notify gateways inside RegionEntry * lock, NOT here, to preserve the order of events sent by gateways for same key. If this is * bucket region, use "true", because the event order is guaranteed */); } } }
final EntryEventImpl event = getBaseEvent();
/** * Create PutAllPRMessage for notify only (to adjunct nodes) * * @param bucketId create message to send to this bucket */ public PutAllPRMessage createPRMessagesNotifyOnly(int bucketId) { final EntryEventImpl event = getBaseEvent(); PutAllPRMessage prMsg = new PutAllPRMessage(bucketId, putAllDataSize, 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 < putAllDataSize; i++) { prMsg.addEntry(putAllData[i]); } return prMsg; }
@Override public void postPutAll(DistributedPutAllOperation putallOp, VersionedObjectList successfulPuts, InternalRegion reg) { if (!reg.getDataPolicy().withStorage() && reg.getConcurrencyChecksEnabled() && putallOp.getBaseEvent().isBridgeEvent()) { // if there is no local storage we need to transfer version information // to the successfulPuts list for transmission back to the client successfulPuts.clear(); putallOp.fillVersionedObjectList(successfulPuts); } // BR & DR's putAll long token = -1; try { token = reg.postPutAllSend(putallOp, successfulPuts); reg.postPutAllFireEvents(putallOp, successfulPuts); } finally { if (token != -1 && reg instanceof DistributedRegion) { putallOp.endOperation(token); } } }
@Released EntryEventImpl ev = PutAllPRMessage.getEventFromEntry(theRegion, myId, myId, i, putallOp.putAllData, false, putallOp.getBaseEvent().getContext(), false, !putallOp.getBaseEvent().isGenerateCallbacks()); try {
final EntryEventImpl event = putAllOp.getBaseEvent(); EventID eventId = event.getEventId(); if (eventId == null && generateEventID()) { runtimeException = new RuntimeException(ex); } finally { putAllOp.getBaseEvent().release(); putAllOp.freeOffHeapResources();
event.setEventId(new EventID(putallOp.getBaseEvent().getEventId(), offset));
/** * Creates a PutAllEvent given the distributed operation, the region, and the entry data. * * @since GemFire 5.0 */ @Retained static EntryEventImpl createPutAllEvent(DistributedPutAllOperation putAllOp, InternalRegion region, Operation entryOp, Object entryKey, @Retained(ENTRY_EVENT_NEW_VALUE) Object entryNewValue) { @Retained EntryEventImpl e; if (putAllOp != null) { EntryEventImpl event = putAllOp.getBaseEvent(); if (event.isBridgeEvent()) { e = EntryEventImpl.create(region, entryOp, entryKey, entryNewValue, event.getRawCallbackArgument(), false, event.distributedMember, event.isGenerateCallbacks()); e.setContext(event.getContext()); } else { e = EntryEventImpl.create(region, entryOp, entryKey, entryNewValue, event.getCallbackArgument(), false, region.getMyId(), event.isGenerateCallbacks()); } } else { e = EntryEventImpl.create(region, entryOp, entryKey, entryNewValue, null, false, region.getMyId(), true); } e.putAllOp = putAllOp; return e; }
if (getBaseEvent().getContext() != null) { ev.setContext(getBaseEvent().getContext());