/** * Create an async-event-queue with the given name. * For a partitioned region a parallel queue is created. * Otherwise a serial queue is created. */ private void createAsyncEventQueue(Cache cache, String queueName, boolean isPartitioned) { AsyncEventQueueFactory asyncEventQueueFactory = cache.createAsyncEventQueueFactory(); asyncEventQueueFactory.setParallel(isPartitioned); asyncEventQueueFactory.create(queueName, new JdbcAsyncWriter()); }
@Test public void executeCreatesSerialAsyncQueueForNonPartitionedRegion() throws Exception { when(attributes.getDataPolicy()).thenReturn(DataPolicy.REPLICATE); function.executeFunction(context); verify(asyncEventQueueFactory, times(1)).create(any(), any()); verify(asyncEventQueueFactory, times(1)).setParallel(false); }
@Test public void executeCreatesParallelAsyncQueueForPartitionedRegion() throws Exception { when(attributes.getDataPolicy()).thenReturn(DataPolicy.PARTITION); function.executeFunction(context); verify(asyncEventQueueFactory, times(1)).create(any(), any()); verify(asyncEventQueueFactory, times(1)).setParallel(true); }
private static AsyncEventQueueFactory getInitialAsyncEventQueueFactory(boolean isParallel, Integer maxMemory, Integer batchSize, boolean isPersistent, String diskStoreName) { AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory(); factory.setBatchSize(batchSize); factory.setPersistent(isPersistent); factory.setDiskStoreName(diskStoreName); factory.setMaximumQueueMemory(maxMemory); factory.setParallel(isParallel); return factory; }
public static String createAsyncEventQueueWithDiskStore(String asyncChannelId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isPersistent, String diskStoreName) { AsyncEventListener asyncEventListener = new MyAsyncEventListener(); File persistentDirectory = null; if (diskStoreName == null) { persistentDirectory = new File( asyncChannelId + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum()); } else { persistentDirectory = new File(diskStoreName); } LogWriterUtils.getLogWriter().info("The ds is : " + persistentDirectory.getName()); persistentDirectory.mkdir(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File[] dirs1 = new File[] {persistentDirectory}; AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory(); factory.setBatchSize(batchSize); factory.setParallel(isParallel); if (isPersistent) { factory.setPersistent(isPersistent); factory.setDiskStoreName(dsf.setDiskDirs(dirs1).create(asyncChannelId).getName()); } factory.setMaximumQueueMemory(maxMemory); // set dispatcher threads factory.setDispatcherThreads(numDispatcherThreadsForTheRun); AsyncEventQueue asyncChannel = factory.create(asyncChannelId, asyncEventListener); return persistentDirectory.getName(); }
cache.createAsyncEventQueueFactory().setParallel(config.isParallel()) .setBatchConflationEnabled(config.isEnableBatchConflation()) .setBatchSize(Integer.parseInt(config.getBatchSize()))
private void endAsyncEventQueue() { AsyncEventQueueCreation asyncEventChannelCreation = (AsyncEventQueueCreation) stack.peek(); AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory(); factory.setParallel(asyncEventChannelCreation.isParallel()); factory.setBatchSize(asyncEventChannelCreation.getBatchSize()); factory.setBatchTimeInterval(asyncEventChannelCreation.getBatchTimeInterval()); factory.setBatchConflationEnabled(asyncEventChannelCreation.isBatchConflationEnabled()); factory.setPersistent(asyncEventChannelCreation.isPersistent()); factory.setDiskStoreName(asyncEventChannelCreation.getDiskStoreName()); factory.setDiskSynchronous(asyncEventChannelCreation.isDiskSynchronous()); factory.setMaximumQueueMemory(asyncEventChannelCreation.getMaximumQueueMemory()); factory.setDispatcherThreads(asyncEventChannelCreation.getDispatcherThreads()); factory.setOrderPolicy(asyncEventChannelCreation.getOrderPolicy()); factory.setForwardExpirationDestroy(asyncEventChannelCreation.isForwardExpirationDestroy()); List<GatewayEventFilter> gatewayEventFilters = asyncEventChannelCreation.getGatewayEventFilters(); for (GatewayEventFilter gatewayEventFilter : gatewayEventFilters) { factory.addGatewayEventFilter(gatewayEventFilter); } factory.setGatewayEventSubstitutionListener( asyncEventChannelCreation.getGatewayEventSubstitutionFilter()); AsyncEventQueue asyncEventChannel = factory.create(asyncEventChannelCreation.getId(), asyncEventChannelCreation.getAsyncEventListener()); stack.pop(); }
@Override protected void doInit() { Assert.state(this.asyncEventListener != null, "AsyncEventListener must not be null"); AsyncEventQueueFactory asyncEventQueueFactory = this.factory != null ? (AsyncEventQueueFactory) this.factory : this.cache.createAsyncEventQueueFactory(); Optional.ofNullable(this.batchConflationEnabled).ifPresent(asyncEventQueueFactory::setBatchConflationEnabled); Optional.ofNullable(this.batchSize).ifPresent(asyncEventQueueFactory::setBatchSize); Optional.ofNullable(this.batchTimeInterval).ifPresent(asyncEventQueueFactory::setBatchTimeInterval); Optional.ofNullable(this.diskStoreReference).ifPresent(asyncEventQueueFactory::setDiskStoreName); Optional.ofNullable(this.diskSynchronous).ifPresent(asyncEventQueueFactory::setDiskSynchronous); Optional.ofNullable(this.dispatcherThreads).ifPresent(asyncEventQueueFactory::setDispatcherThreads); Optional.ofNullable(this.forwardExpirationDestroy).ifPresent(asyncEventQueueFactory::setForwardExpirationDestroy); Optional.ofNullable(this.gatewayEventSubstitutionFilter).ifPresent(asyncEventQueueFactory::setGatewayEventSubstitutionListener); Optional.ofNullable(this.maximumQueueMemory).ifPresent(asyncEventQueueFactory::setMaximumQueueMemory); Optional.ofNullable(this.persistent).ifPresent(asyncEventQueueFactory::setPersistent); asyncEventQueueFactory.setParallel(isParallelEventQueue()); nullSafeList(this.gatewayEventFilters).forEach(asyncEventQueueFactory::addGatewayEventFilter); if (this.orderPolicy != null) { Assert.state(isSerialEventQueue(), "OrderPolicy cannot be used with a Parallel AsyncEventQueue"); asyncEventQueueFactory.setOrderPolicy(this.orderPolicy); } setAsyncEventQueue(asyncEventQueueFactory.create(getName(), this.asyncEventListener)); }
@Override protected void doInit() { Assert.state(this.asyncEventListener != null, "AsyncEventListener must not be null"); AsyncEventQueueFactory asyncEventQueueFactory = this.factory != null ? (AsyncEventQueueFactory) this.factory : this.cache.createAsyncEventQueueFactory(); Optional.ofNullable(this.batchConflationEnabled).ifPresent(asyncEventQueueFactory::setBatchConflationEnabled); Optional.ofNullable(this.batchSize).ifPresent(asyncEventQueueFactory::setBatchSize); Optional.ofNullable(this.batchTimeInterval).ifPresent(asyncEventQueueFactory::setBatchTimeInterval); Optional.ofNullable(this.diskStoreReference).ifPresent(asyncEventQueueFactory::setDiskStoreName); Optional.ofNullable(this.diskSynchronous).ifPresent(asyncEventQueueFactory::setDiskSynchronous); Optional.ofNullable(this.dispatcherThreads).ifPresent(asyncEventQueueFactory::setDispatcherThreads); Optional.ofNullable(this.forwardExpirationDestroy).ifPresent(asyncEventQueueFactory::setForwardExpirationDestroy); Optional.ofNullable(this.gatewayEventSubstitutionFilter).ifPresent(asyncEventQueueFactory::setGatewayEventSubstitutionListener); Optional.ofNullable(this.maximumQueueMemory).ifPresent(asyncEventQueueFactory::setMaximumQueueMemory); Optional.ofNullable(this.persistent).ifPresent(asyncEventQueueFactory::setPersistent); asyncEventQueueFactory.setParallel(isParallelEventQueue()); nullSafeList(this.gatewayEventFilters).forEach(asyncEventQueueFactory::addGatewayEventFilter); if (this.orderPolicy != null) { Assert.state(isSerialEventQueue(), "OrderPolicy cannot be used with a Parallel AsyncEventQueue"); asyncEventQueueFactory.setOrderPolicy(this.orderPolicy); } setAsyncEventQueue(asyncEventQueueFactory.create(getName(), this.asyncEventListener)); }
.thenAnswer(newSetter(orderPolicy, mockAsyncEventQueueFactory)); when(mockAsyncEventQueueFactory.setParallel(anyBoolean())) .thenAnswer(newSetter(parallel, mockAsyncEventQueueFactory));