@Override public void afterRun() throws Exception { invalidateNearCache(invalidationKeys); super.afterRun(); }
private boolean canPublishWANEvent() { return mapContainer.isWanReplicationEnabled() && canThisOpGenerateWANEvent(); } }
/** * This method helps to add clearing Near Cache event only from one-partition which matches partitionId of the map name. */ protected final void invalidateAllKeysInNearCaches() { if (mapContainer.hasInvalidationListener()) { int partitionId = getPartitionId(); Invalidator invalidator = getNearCacheInvalidator(); if (partitionId == getNodeEngine().getPartitionService().getPartitionId(name)) { invalidator.invalidateAllKeys(name, getCallerUuid()); } invalidator.resetPartitionMetaData(name, getPartitionId()); } }
public final void invalidateNearCache(Data key) { if (!mapContainer.hasInvalidationListener() || key == null) { return; } Invalidator invalidator = getNearCacheInvalidator(); invalidator.invalidateKey(key, name, getCallerUuid()); }
@SuppressWarnings("checkstyle:executablestatementcount") private EntryOperator(MapOperation mapOperation, Object processor, Predicate predicate, boolean collectWanEvents) { this.backup = mapOperation instanceof BackupOperation; setProcessor(processor); this.mapOperation = mapOperation; this.predicate = predicate; this.recordStore = mapOperation.recordStore; this.readOnly = entryProcessor instanceof ReadOnly; this.mapContainer = recordStore.getMapContainer(); this.inMemoryFormat = mapContainer.getMapConfig().getInMemoryFormat(); this.mapName = mapContainer.getName(); this.wanReplicationEnabled = mapContainer.isWanReplicationEnabled(); this.shouldClone = mapContainer.shouldCloneOnEntryProcessing(mapOperation.getPartitionId()); this.mapServiceContext = mapContainer.getMapServiceContext(); LocalMapStatsProvider localMapStatsProvider = mapServiceContext.getLocalMapStatsProvider(); this.stats = localMapStatsProvider.getLocalMapStatsImpl(mapName); NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); this.ss = ((InternalSerializationService) nodeEngine.getSerializationService()); this.partitionService = nodeEngine.getPartitionService(); EventService eventService = nodeEngine.getEventService(); this.hasEventRegistration = eventService.hasEventRegistration(SERVICE_NAME, mapName); this.mapEventPublisher = mapServiceContext.getMapEventPublisher(); this.partitionId = recordStore.getPartitionId(); this.callerAddress = mapOperation.getCallerAddress(); }
public EntryOperator doPostOperateOps() { if (eventType == null) { // when event type is null, it means this is a read-only entry processor and not modified entry. return this; } switch (eventType) { case ADDED: case UPDATED: onAddedOrUpdated(); break; case REMOVED: onRemove(); break; default: throw new IllegalArgumentException("Unexpected event found:" + eventType); } if (wanReplicationEnabled) { publishWanReplicationEvent(); } if (!backup) { if (hasEventRegistration) { publishEntryEvent(); } mapOperation.invalidateNearCache(dataKey); } mapOperation.evict(dataKey); return this; }
protected final void publishWanRemove(Data dataKey) { if (!canPublishWANEvent()) { return; } mapEventPublisher.publishWanRemove(name, toHeapData(dataKey)); }
@Override public void beforeRun() throws Exception { super.beforeRun(); namespace = getServiceNamespace(); if (!mapServiceContext.getEventJournal().hasEventJournal(namespace)) { throw new UnsupportedOperationException( "Cannot subscribe to event journal because it is either not configured or disabled for map '" + name + '\''); } }
private RecordStore getRecordStoreOrNull() { int partitionId = getPartitionId(); if (partitionId == -1) { return null; } PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId); if (createRecordStoreOnDemand) { return partitionContainer.getRecordStore(name); } else { return partitionContainer.getExistingRecordStore(name); } }
public final void invalidateNearCache(Data key) { if (!mapContainer.hasInvalidationListener() || key == null) { return; } Invalidator invalidator = getNearCacheInvalidator(); invalidator.invalidateKey(key, name, getCallerUuid()); }
@SuppressWarnings("checkstyle:executablestatementcount") private EntryOperator(MapOperation mapOperation, Object processor, Predicate predicate, boolean collectWanEvents) { this.backup = mapOperation instanceof BackupOperation; setProcessor(processor); this.mapOperation = mapOperation; this.predicate = predicate; this.recordStore = mapOperation.recordStore; this.readOnly = entryProcessor instanceof ReadOnly; this.mapContainer = recordStore.getMapContainer(); this.inMemoryFormat = mapContainer.getMapConfig().getInMemoryFormat(); this.mapName = mapContainer.getName(); this.wanReplicationEnabled = mapContainer.isWanReplicationEnabled(); this.shouldClone = mapContainer.shouldCloneOnEntryProcessing(mapOperation.getPartitionId()); this.mapServiceContext = mapContainer.getMapServiceContext(); LocalMapStatsProvider localMapStatsProvider = mapServiceContext.getLocalMapStatsProvider(); this.stats = localMapStatsProvider.getLocalMapStatsImpl(mapName); NodeEngine nodeEngine = mapServiceContext.getNodeEngine(); this.ss = ((InternalSerializationService) nodeEngine.getSerializationService()); this.partitionService = nodeEngine.getPartitionService(); EventService eventService = nodeEngine.getEventService(); this.hasEventRegistration = eventService.hasEventRegistration(SERVICE_NAME, mapName); this.mapEventPublisher = mapServiceContext.getMapEventPublisher(); this.partitionId = recordStore.getPartitionId(); this.callerAddress = mapOperation.getCallerAddress(); }
public EntryOperator doPostOperateOps() { if (eventType == null) { // when event type is null, it means this is a read-only entry processor and not modified entry. return this; } switch (eventType) { case ADDED: case UPDATED: onAddedOrUpdated(); break; case REMOVED: onRemove(); break; default: throw new IllegalArgumentException("Unexpected event found:" + eventType); } if (wanReplicationEnabled) { publishWanReplicationEvent(); } if (!backup) { if (hasEventRegistration) { publishEntryEvent(); } mapOperation.invalidateNearCache(dataKey); } mapOperation.evict(dataKey); return this; }
protected final void publishWanRemove(Data dataKey) { if (!canPublishWANEvent()) { return; } mapEventPublisher.publishWanRemove(name, toHeapData(dataKey)); }
@Override public void beforeRun() throws Exception { super.beforeRun(); namespace = getServiceNamespace(); if (!mapServiceContext.getEventJournal().hasEventJournal(namespace)) { throw new UnsupportedOperationException( "Cannot subscribe to event journal because it is either not configured or disabled for map '" + name + '\''); } }
private RecordStore getRecordStoreOrNull() { int partitionId = getPartitionId(); if (partitionId == -1) { return null; } PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId); if (createRecordStoreOnDemand) { return partitionContainer.getRecordStore(name); } else { return partitionContainer.getExistingRecordStore(name); } }
/** * This method helps to add clearing Near Cache event only from one-partition which matches partitionId of the map name. */ protected final void invalidateAllKeysInNearCaches() { if (mapContainer.hasInvalidationListener()) { int partitionId = getPartitionId(); Invalidator invalidator = getNearCacheInvalidator(); if (partitionId == getNodeEngine().getPartitionService().getPartitionId(name)) { invalidator.invalidateAllKeys(name, getCallerUuid()); } invalidator.resetPartitionMetaData(name, getPartitionId()); } }
protected final void invalidateNearCache(List<Data> keys) { if (!mapContainer.hasInvalidationListener() || isEmpty(keys)) { return; } Invalidator invalidator = getNearCacheInvalidator(); for (Data key : keys) { invalidator.invalidateKey(key, name, getCallerUuid()); } }
@Override public void afterRun() throws Exception { super.afterRun(); invalidateNearCache(keys); }
private void publishWanUpdateInternal(Data dataKey, Object value, boolean hasLoadProvenance) { if (!canPublishWANEvent()) { return; } Record record = recordStore.getRecord(dataKey); if (record == null) { return; } Data dataValue = toHeapData(mapServiceContext.toData(value)); EntryView entryView = createSimpleEntryView(toHeapData(dataKey), dataValue, record); mapEventPublisher.publishWanUpdate(name, entryView, hasLoadProvenance); }
private boolean canPublishWANEvent() { return mapContainer.isWanReplicationEnabled() && canThisOpGenerateWANEvent(); } }