@Test public void executeFunctionGivenARegionWithNonJdbcAsyncEventQueueDoesNotRemoveTheQueueName() { when(regionAttributes.getAsyncEventQueueIds()) .thenReturn(Collections.singleton("nonJdbcQueue")); when(service.getMappingForRegion(eq(regionName))).thenReturn(mapping); function.executeFunction(context); verify(regionMutator, never()).removeAsyncEventQueueId(any()); }
@Test public void updateWithGatewaySenders() { regionAttributes.setGatewaySenderIds("2,3"); when(region.getGatewaySenderIds()).thenReturn(new HashSet<>(Arrays.asList("1", "2"))); function.alterRegion(cache, config); verify(mutator).removeGatewaySenderId("1"); verify(mutator, times(0)).removeGatewaySenderId("2"); verify(mutator).addGatewaySenderId("3"); // asyncEventQueue is left intact verify(mutator, times(0)).addAsyncEventQueueId(any()); verify(mutator, times(0)).removeAsyncEventQueueId(any()); }
@Test public void executeFunctionGivenARegionWithJdbcAsyncEventQueueRemovesTheQueueName() { String queueName = CreateMappingCommand.createAsyncEventQueueName(regionName); when(regionAttributes.getAsyncEventQueueIds()).thenReturn(Collections.singleton(queueName)); when(service.getMappingForRegion(eq(regionName))).thenReturn(mapping); function.executeFunction(context); verify(regionMutator, times(1)).removeAsyncEventQueueId(queueName); }
private void destroyAsyncEventQueue(boolean initiator) { String aeqId = LuceneServiceImpl.getUniqueIndexName(indexName, regionPath); // Get the AsyncEventQueue AsyncEventQueueImpl aeq = (AsyncEventQueueImpl) cache.getAsyncEventQueue(aeqId); // Stop the AsyncEventQueue (this stops the AsyncEventQueue's underlying GatewaySender) // The AsyncEventQueue can be null in an accessor member if (aeq != null) { aeq.stop(); } // Remove the id from the dataRegion's AsyncEventQueue ids // Note: The region may already have been destroyed by a remote member Region region = getDataRegion(); if (!region.isDestroyed()) { region.getAttributesMutator().removeAsyncEventQueueId(aeqId); } // Destroy the aeq (this also removes it from the GemFireCacheImpl) // The AsyncEventQueue can be null in an accessor member if (aeq != null) { aeq.destroy(initiator); } if (logger.isDebugEnabled()) { logger.debug("Destroyed aeqId=" + aeqId); } } }
for (String asyncEventQueueId : oldAsyncEventQueueIds) { if (!newAsyncEventQueueIds.contains(asyncEventQueueId)) { mutator.removeAsyncEventQueueId(asyncEventQueueId);
private void cleanupRegionAndQueue(Cache cache, String regionName) { String queueName = CreateMappingCommand.createAsyncEventQueueName(regionName); Region<?, ?> region = cache.getRegion(regionName); if (region != null) { CacheLoader<?, ?> loader = region.getAttributes().getCacheLoader(); if (loader instanceof JdbcLoader) { region.getAttributesMutator().setCacheLoader(null); } CacheWriter<?, ?> writer = region.getAttributes().getCacheWriter(); if (writer instanceof JdbcWriter) { region.getAttributesMutator().setCacheWriter(null); } Set<String> queueIds = region.getAttributes().getAsyncEventQueueIds(); if (queueIds.contains(queueName)) { region.getAttributesMutator().removeAsyncEventQueueId(queueName); } } InternalAsyncEventQueue queue = (InternalAsyncEventQueue) cache.getAsyncEventQueue(queueName); if (queue != null) { queue.stop(); queue.destroy(); } } }
.when(mockAttributesMutator).removeAsyncEventQueueId(anyString());