use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class RebalanceOperationDUnitTest method recoverRedundancyParallelAsyncEventQueue.
public void recoverRedundancyParallelAsyncEventQueue(final boolean simulate) {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
VM vm2 = host.getVM(2);
final DistributedMember member1 = createPRRegionWithAsyncQueue(vm0, 200);
// Create some buckets. Put enough data to cause the queue to overflow (more than 1 MB)
vm0.invoke(new SerializableRunnable("createSomeBuckets") {
public void run() {
Cache cache = getCache();
Region region = cache.getRegion("region1");
Region region2 = cache.getRegion("region2");
for (int i = 0; i < 12; i++) {
region.put(Integer.valueOf(i), "A", new byte[1024 * 512]);
}
// GEODE-244 - the async event queue uses asnychronous writes. Flush
// the default disk store to make sure all values have overflowed
cache.findDiskStore(null).flush();
}
});
// check to make sure our redundancy is impaired
SerializableRunnable checkLowRedundancy = new SerializableRunnable("checkLowRedundancy") {
public void run() {
Cache cache = getCache();
Region region = cache.getRegion("region1");
PartitionRegionInfo details = PartitionRegionHelper.getPartitionRegionInfo(region);
assertEquals(12, details.getCreatedBucketCount());
assertEquals(0, details.getActualRedundantCopies());
assertEquals(12, details.getLowRedundancyBucketCount());
// Get the async event queue region (It's a colocated region)
PartitionedRegion region2 = ColocationHelper.getColocatedChildRegions((PartitionedRegion) region).get(0);
details = PartitionRegionHelper.getPartitionRegionInfo(region2);
assertEquals(12, details.getCreatedBucketCount());
assertEquals(0, details.getActualRedundantCopies());
assertEquals(12, details.getLowRedundancyBucketCount());
AsyncEventQueue queue = cache.getAsyncEventQueue("parallelQueue");
assertEquals(12, queue.size());
}
};
vm0.invoke(checkLowRedundancy);
// Create the region on two more members, each with 1/2 of the memory
createPRRegionWithAsyncQueue(vm1, 100);
createPRRegionWithAsyncQueue(vm2, 100);
vm0.invoke(checkLowRedundancy);
// Now simulate a rebalance
vm0.invoke(new SerializableRunnable("rebalance") {
public void run() {
Cache cache = getCache();
ResourceManager manager = cache.getResourceManager();
RebalanceResults results = doRebalance(simulate, manager);
assertEquals(24, results.getTotalBucketCreatesCompleted());
assertEquals(12, results.getTotalPrimaryTransfersCompleted());
assertEquals(0, results.getTotalBucketTransferBytes());
assertEquals(0, results.getTotalBucketTransfersCompleted());
Set<PartitionRebalanceInfo> detailSet = results.getPartitionRebalanceDetails();
assertEquals(2, detailSet.size());
for (PartitionRebalanceInfo details : detailSet) {
assertEquals(12, details.getBucketCreatesCompleted());
assertEquals(6, details.getPrimaryTransfersCompleted());
assertEquals(0, details.getBucketTransferBytes());
assertEquals(0, details.getBucketTransfersCompleted());
Set<PartitionMemberInfo> afterDetails = details.getPartitionMemberDetailsAfter();
assertEquals(3, afterDetails.size());
for (PartitionMemberInfo memberDetails : afterDetails) {
if (memberDetails.getDistributedMember().equals(member1)) {
assertEquals(12, memberDetails.getBucketCount());
assertEquals(6, memberDetails.getPrimaryCount());
} else {
assertEquals(6, memberDetails.getBucketCount());
assertEquals(3, memberDetails.getPrimaryCount());
}
}
if (!simulate) {
verifyStats(manager, results);
}
}
}
});
if (!simulate) {
SerializableRunnable checkRedundancyFixed = new SerializableRunnable("checkLowRedundancy") {
public void run() {
Cache cache = getCache();
PartitionedRegion region1 = (PartitionedRegion) cache.getRegion("region1");
// Get the async event queue region (It's a colocated region)
PartitionedRegion region2 = ColocationHelper.getColocatedChildRegions(region1).get(0);
PartitionRegionInfo details = PartitionRegionHelper.getPartitionRegionInfo(cache.getRegion("region1"));
assertEquals(12, details.getCreatedBucketCount());
assertEquals(1, details.getActualRedundantCopies());
assertEquals(0, details.getLowRedundancyBucketCount());
details = PartitionRegionHelper.getPartitionRegionInfo(region2);
assertEquals(12, details.getCreatedBucketCount());
assertEquals(1, details.getActualRedundantCopies());
assertEquals(0, details.getLowRedundancyBucketCount());
assertEquals(region1.getLocalPrimaryBucketsListTestOnly(), region2.getLocalPrimaryBucketsListTestOnly());
assertEquals(region1.getLocalBucketsListTestOnly(), region2.getLocalBucketsListTestOnly());
}
};
vm0.invoke(checkRedundancyFixed);
vm1.invoke(checkRedundancyFixed);
vm2.invoke(checkRedundancyFixed);
}
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class AsyncEventQueueFactoryImpl method create.
public AsyncEventQueue create(String asyncQueueId, AsyncEventListener listener) {
if (listener == null) {
throw new IllegalArgumentException(LocalizedStrings.AsyncEventQueue_ASYNC_EVENT_LISTENER_CANNOT_BE_NULL.toLocalizedString());
}
AsyncEventQueue asyncEventQueue = null;
if (this.cache instanceof GemFireCacheImpl) {
if (logger.isDebugEnabled()) {
logger.debug("Creating GatewaySender that underlies the AsyncEventQueue");
}
addAsyncEventListener(listener);
GatewaySender sender = create(AsyncEventQueueImpl.getSenderIdFromAsyncEventQueueId(asyncQueueId));
AsyncEventQueueImpl queue = new AsyncEventQueueImpl(sender, listener);
asyncEventQueue = queue;
this.cache.addAsyncEventQueue(queue);
} else if (this.cache instanceof CacheCreation) {
asyncEventQueue = new AsyncEventQueueCreation(asyncQueueId, attrs, listener);
((CacheCreation) cache).addAsyncEventQueue(asyncEventQueue);
}
if (logger.isDebugEnabled()) {
logger.debug("Returning AsyncEventQueue" + asyncEventQueue);
}
return asyncEventQueue;
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class CacheCreation method create.
/**
* Fills in the contents of a {@link Cache} based on this creation object's state.
*/
void create(InternalCache cache) throws TimeoutException, CacheWriterException, GatewayException, RegionExistsException {
this.extensionPoint.beforeCreate(cache);
cache.setDeclarativeCacheConfig(this.cacheConfig);
if (cache.isClient()) {
throw new IllegalStateException("You must use client-cache in the cache.xml when ClientCacheFactory is used.");
}
if (this.hasLockLease()) {
cache.setLockLease(this.lockLease);
}
if (this.hasLockTimeout()) {
cache.setLockTimeout(this.lockTimeout);
}
if (this.hasSearchTimeout()) {
cache.setSearchTimeout(this.searchTimeout);
}
if (this.hasMessageSyncInterval()) {
cache.setMessageSyncInterval(this.getMessageSyncInterval());
}
if (this.gatewayConflictResolver != null) {
cache.setGatewayConflictResolver(this.gatewayConflictResolver);
}
// create connection pools
Map<String, Pool> pools = getPools();
if (!pools.isEmpty()) {
for (Pool pool : pools.values()) {
PoolFactoryImpl poolFactory = (PoolFactoryImpl) PoolManager.createFactory();
poolFactory.init(pool);
poolFactory.create(pool.getName());
}
}
if (hasResourceManager()) {
// moved this up to fix bug 42128
getResourceManager().configure(cache.getResourceManager());
}
DiskStoreAttributesCreation pdxRegDSC = initializePdxDiskStore(cache);
cache.initializePdxRegistry();
for (DiskStore diskStore : this.diskStores.values()) {
DiskStoreAttributesCreation creation = (DiskStoreAttributesCreation) diskStore;
if (creation != pdxRegDSC) {
createDiskStore(creation, cache);
}
}
if (this.hasDynamicRegionFactory()) {
DynamicRegionFactory.get().open(this.getDynamicRegionFactoryConfig());
}
if (this.hasServer()) {
cache.setIsServer(this.isServer);
}
if (this.hasCopyOnRead()) {
cache.setCopyOnRead(this.copyOnRead);
}
if (this.txMgrCreation != null && this.txMgrCreation.getListeners().length > 0 && cache.getCacheTransactionManager() != null) {
cache.getCacheTransactionManager().initListeners(this.txMgrCreation.getListeners());
}
if (this.txMgrCreation != null && cache.getCacheTransactionManager() != null) {
cache.getCacheTransactionManager().setWriter(this.txMgrCreation.getWriter());
}
for (GatewaySender senderCreation : this.getGatewaySenders()) {
GatewaySenderFactory factory = cache.createGatewaySenderFactory();
((InternalGatewaySenderFactory) factory).configureGatewaySender(senderCreation);
GatewaySender gatewaySender = factory.create(senderCreation.getId(), senderCreation.getRemoteDSId());
// Start the sender if it is not set to manually start
if (gatewaySender.isManualStart()) {
cache.getLoggerI18n().info(LocalizedStrings.CacheCreation_0_IS_NOT_BEING_STARTED_SINCE_IT_IS_CONFIGURED_FOR_MANUAL_START, gatewaySender);
}
}
for (AsyncEventQueue asyncEventQueueCreation : this.getAsyncEventQueues()) {
AsyncEventQueueFactoryImpl asyncQueueFactory = (AsyncEventQueueFactoryImpl) cache.createAsyncEventQueueFactory();
asyncQueueFactory.configureAsyncEventQueue(asyncEventQueueCreation);
AsyncEventQueue asyncEventQueue = cache.getAsyncEventQueue(asyncEventQueueCreation.getId());
if (asyncEventQueue == null) {
asyncQueueFactory.create(asyncEventQueueCreation.getId(), asyncEventQueueCreation.getAsyncEventListener());
}
}
cache.initializePdxRegistry();
for (String id : this.regionAttributesNames) {
RegionAttributesCreation creation = (RegionAttributesCreation) getRegionAttributes(id);
creation.inheritAttributes(cache, false);
// Don't let the RegionAttributesCreation escape to the user
AttributesFactory<?, ?> factory = new AttributesFactory<>(creation);
RegionAttributes<?, ?> attrs = factory.create();
cache.setRegionAttributes(id, attrs);
}
initializeRegions(this.roots, cache);
cache.readyDynamicRegionFactory();
// Create and start the BridgeServers. This code was moved from
// before region initialization to after it to fix bug 33587.
// Create and start the CacheServers after the gateways have been initialized
// to fix bug 39736.
Integer serverPort = CacheServerLauncher.getServerPort();
String serverBindAdd = CacheServerLauncher.getServerBindAddress();
Boolean disableDefaultServer = CacheServerLauncher.getDisableDefaultServer();
startCacheServers(getCacheServers(), cache, serverPort, serverBindAdd, disableDefaultServer);
for (GatewayReceiver receiverCreation : this.getGatewayReceivers()) {
GatewayReceiverFactory factory = cache.createGatewayReceiverFactory();
factory.setBindAddress(receiverCreation.getBindAddress());
factory.setMaximumTimeBetweenPings(receiverCreation.getMaximumTimeBetweenPings());
factory.setStartPort(receiverCreation.getStartPort());
factory.setEndPort(receiverCreation.getEndPort());
factory.setSocketBufferSize(receiverCreation.getSocketBufferSize());
factory.setManualStart(receiverCreation.isManualStart());
for (GatewayTransportFilter filter : receiverCreation.getGatewayTransportFilters()) {
factory.addGatewayTransportFilter(filter);
}
factory.setHostnameForSenders(receiverCreation.getHost());
GatewayReceiver receiver = factory.create();
if (receiver.isManualStart()) {
cache.getLoggerI18n().info(LocalizedStrings.CacheCreation_0_IS_NOT_BEING_STARTED_SINCE_IT_IS_CONFIGURED_FOR_MANUAL_START, receiver);
}
}
cache.setBackupFiles(this.backups);
cache.addDeclarableProperties(this.declarablePropertiesMap);
runInitializer();
cache.setInitializer(getInitializer(), getInitializerProps());
// Create all extensions
this.extensionPoint.fireCreate(cache);
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class CacheXmlGenerator method generateAsyncEventQueue.
private void generateAsyncEventQueue(Cache cache) throws SAXException {
Set<AsyncEventQueue> asyncEventQueues = cache.getAsyncEventQueues();
for (AsyncEventQueue asyncEventQueue : asyncEventQueues) {
AttributesImpl atts = new AttributesImpl();
// id
atts.addAttribute("", "", ID, "", asyncEventQueue.getId());
// parallel
if (generateDefaults() || asyncEventQueue.isParallel() != GatewaySender.DEFAULT_IS_PARALLEL)
atts.addAttribute("", "", PARALLEL, "", String.valueOf(asyncEventQueue.isParallel()));
// batch-size
if (generateDefaults() || asyncEventQueue.getBatchSize() != GatewaySender.DEFAULT_BATCH_SIZE)
atts.addAttribute("", "", BATCH_SIZE, "", String.valueOf(asyncEventQueue.getBatchSize()));
// batch-time-interval
if (generateDefaults() || asyncEventQueue.getBatchTimeInterval() != GatewaySender.DEFAULT_BATCH_TIME_INTERVAL)
atts.addAttribute("", "", BATCH_TIME_INTERVAL, "", String.valueOf(asyncEventQueue.getBatchTimeInterval()));
// enable-batch-conflation
if (generateDefaults() || asyncEventQueue.isBatchConflationEnabled() != GatewaySender.DEFAULT_BATCH_CONFLATION)
atts.addAttribute("", "", ENABLE_BATCH_CONFLATION, "", String.valueOf(asyncEventQueue.isBatchConflationEnabled()));
// maximum-queue-memory
if (generateDefaults() || asyncEventQueue.getMaximumQueueMemory() != GatewaySender.DEFAULT_MAXIMUM_QUEUE_MEMORY)
atts.addAttribute("", "", MAXIMUM_QUEUE_MEMORY, "", String.valueOf(asyncEventQueue.getMaximumQueueMemory()));
// enable-persistence
if (generateDefaults() || asyncEventQueue.isPersistent() != GatewaySender.DEFAULT_PERSISTENCE_ENABLED)
atts.addAttribute("", "", PERSISTENT, "", String.valueOf(asyncEventQueue.isPersistent()));
if (asyncEventQueue.isPersistent()) {
// disk-store-name
if (generateDefaults() || (asyncEventQueue.getDiskStoreName() != null && !asyncEventQueue.getDiskStoreName().equals("")))
atts.addAttribute("", "", DISK_STORE_NAME, "", String.valueOf(asyncEventQueue.getDiskStoreName()));
}
// dispatcher-threads
if (generateDefaults() || asyncEventQueue.getDispatcherThreads() != GatewaySender.DEFAULT_DISPATCHER_THREADS)
atts.addAttribute("", "", DISPATCHER_THREADS, "", String.valueOf(asyncEventQueue.getDispatcherThreads()));
// order-policy
if (asyncEventQueue.getOrderPolicy() != null) {
if (generateDefaults() || !asyncEventQueue.getOrderPolicy().equals(GatewaySender.DEFAULT_ORDER_POLICY))
atts.addAttribute("", "", ORDER_POLICY, "", String.valueOf(asyncEventQueue.getOrderPolicy()));
}
// eviction and expiration events
if (this.version.compareTo(CacheXmlVersion.GEODE_1_0) >= 0) {
if (generateDefaults() || asyncEventQueue.isForwardExpirationDestroy() != (GatewaySender.DEFAULT_FORWARD_EXPIRATION_DESTROY))
atts.addAttribute("", "", FORWARD_EXPIRATION_DESTROY, "", String.valueOf(asyncEventQueue.isForwardExpirationDestroy()));
}
// disk-synchronous
if (generateDefaults() || asyncEventQueue.isDiskSynchronous() != GatewaySender.DEFAULT_DISK_SYNCHRONOUS)
atts.addAttribute("", "", DISK_SYNCHRONOUS, "", String.valueOf(asyncEventQueue.isDiskSynchronous()));
// AsyncEventQueue element start
handler.startElement("", ASYNC_EVENT_QUEUE, ASYNC_EVENT_QUEUE, atts);
List<GatewayEventFilter> eventFilters = asyncEventQueue.getGatewayEventFilters();
if (eventFilters != null) {
for (GatewayEventFilter eventFilter : eventFilters) {
generateGatewayEventFilter(eventFilter);
}
}
if (this.version.compareTo(CacheXmlVersion.GEMFIRE_8_0) >= 0) {
if (asyncEventQueue.getGatewayEventSubstitutionFilter() != null) {
generateGatewayEventSubstitutionFilter(asyncEventQueue.getGatewayEventSubstitutionFilter());
}
}
AsyncEventListener asyncListener = asyncEventQueue.getAsyncEventListener();
if (asyncListener != null) {
generate(ASYNC_EVENT_LISTENER, asyncListener);
}
handler.endElement("", ASYNC_EVENT_QUEUE, ASYNC_EVENT_QUEUE);
}
}
use of org.apache.geode.cache.asyncqueue.AsyncEventQueue in project geode by apache.
the class QueueCommandsDUnitTest method testAsyncEventQueue.
// GEODE-1429
@Category(FlakyTest.class)
@Test
public void testAsyncEventQueue() throws IOException {
final String queue1Name = "testAsyncEventQueue1";
final String queue2Name = "testAsyncEventQueue2";
final String diskStoreName = "testAsyncEventQueueDiskStore";
Properties localProps = new Properties();
localProps.setProperty(GROUPS, "Group0");
setUpJmxManagerOnVm0ThenConnect(localProps);
CommandResult cmdResult = executeCommand(CliStrings.LIST_ASYNC_EVENT_QUEUES);
assertEquals(Result.Status.OK, cmdResult.getStatus());
assertTrue(commandResultToString(cmdResult).contains("No Async Event Queues Found"));
final VM vm1 = Host.getHost(0).getVM(1);
final String vm1Name = "VM" + vm1.getPid();
final File diskStoreDir = new File(new File(".").getAbsolutePath(), diskStoreName);
this.filesToBeDeleted.add(diskStoreDir.getAbsolutePath());
vm1.invoke(new SerializableRunnable() {
public void run() {
diskStoreDir.mkdirs();
Properties localProps = new Properties();
localProps.setProperty(NAME, vm1Name);
localProps.setProperty(GROUPS, "Group1");
getSystem(localProps);
getCache();
}
});
final VM vm2 = Host.getHost(0).getVM(2);
final String vm2Name = "VM" + vm2.getPid();
vm2.invoke(new SerializableRunnable() {
public void run() {
Properties localProps = new Properties();
localProps.setProperty(NAME, vm2Name);
localProps.setProperty(GROUPS, "Group2");
getSystem(localProps);
getCache();
}
});
// Deploy a JAR file with an
// AsyncEventListener/GatewayEventFilter/GatewayEventSubstitutionFilter
// that can be instantiated on each server
final File jarFile = new File(new File(".").getAbsolutePath(), "QueueCommandsDUnit.jar");
QueueCommandsDUnitTest.this.filesToBeDeleted.add(jarFile.getAbsolutePath());
ClassBuilder classBuilder = new ClassBuilder();
byte[] jarBytes = classBuilder.createJarFromClassContent("com/qcdunit/QueueCommandsDUnitTestHelper", "package com.qcdunit;" + "import java.util.List; import java.util.Properties;" + "import org.apache.geode.internal.cache.xmlcache.Declarable2; import org.apache.geode.cache.asyncqueue.AsyncEvent;" + "import org.apache.geode.cache.wan.GatewayEventFilter; import org.apache.geode.cache.wan.GatewayEventSubstitutionFilter;" + "import org.apache.geode.cache.asyncqueue.AsyncEventListener; import org.apache.geode.cache.wan.GatewayQueueEvent;" + "import org.apache.geode.cache.EntryEvent;" + "public class QueueCommandsDUnitTestHelper implements Declarable2, GatewayEventFilter, GatewayEventSubstitutionFilter, AsyncEventListener {" + "Properties props;" + "public boolean processEvents(List<AsyncEvent> events) { return true; }" + "public void afterAcknowledgement(GatewayQueueEvent event) {}" + "public boolean beforeEnqueue(GatewayQueueEvent event) { return true; }" + "public boolean beforeTransmit(GatewayQueueEvent event) { return true; }" + "public Object getSubstituteValue(EntryEvent event) { return null; }" + "public void close() {}" + "public void init(final Properties props) {this.props = props;}" + "public Properties getConfig() {return this.props;}}");
writeJarBytesToFile(jarFile, jarBytes);
cmdResult = executeCommand("deploy --jar=QueueCommandsDUnit.jar");
assertEquals(Result.Status.OK, cmdResult.getStatus());
CommandStringBuilder commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_DISK_STORE);
commandStringBuilder.addOption(CliStrings.CREATE_DISK_STORE__NAME, diskStoreName);
commandStringBuilder.addOption(CliStrings.CREATE_DISK_STORE__GROUP, "Group1");
commandStringBuilder.addOption(CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE, diskStoreDir.getAbsolutePath());
cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.OK, cmdResult.getStatus());
String stringResult = commandResultToString(cmdResult);
assertEquals(3, countLinesInString(stringResult, false));
assertEquals(false, stringResult.contains("ERROR"));
assertTrue(stringContainsLine(stringResult, vm1Name + ".*Success"));
commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE);
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, queue1Name);
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__GROUP, "Group1");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCH_SIZE, "514");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT, "true");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISK_STORE, diskStoreName);
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__MAXIMUM_QUEUE_MEMORY, "213");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__BATCHTIMEINTERVAL, "946");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PARALLEL, "true");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ENABLEBATCHCONFLATION, "true");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISPATCHERTHREADS, "2");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ORDERPOLICY, "PARTITION");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__GATEWAYEVENTFILTER, "com.qcdunit.QueueCommandsDUnitTestHelper");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__SUBSTITUTION_FILTER, "com.qcdunit.QueueCommandsDUnitTestHelper");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__DISKSYNCHRONOUS, "false");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__FORWARD_EXPIRATION_DESTROY, "true");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER, "com.qcdunit.QueueCommandsDUnitTestHelper");
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER_PARAM_AND_VALUE, "param1,param2#value2");
cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.OK, cmdResult.getStatus());
stringResult = commandResultToString(cmdResult);
assertEquals(3, countLinesInString(stringResult, false));
assertEquals(false, stringResult.contains("ERROR"));
assertTrue(stringContainsLine(stringResult, vm1Name + ".*Success"));
// Verify that the queue was created on the correct member
cmdResult = executeCommand(CliStrings.LIST_ASYNC_EVENT_QUEUES);
assertEquals(Result.Status.OK, cmdResult.getStatus());
stringResult = commandResultToString(cmdResult);
assertEquals(3, countLinesInString(stringResult, false));
assertTrue(stringContainsLine(stringResult, vm1Name + " .*" + queue1Name + " .*514 .*true .*" + diskStoreName + " .*213 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper" + ".*"));
assertTrue(stringContainsLine(stringResult, vm1Name + ".*param2=value2.*"));
assertTrue(stringContainsLine(stringResult, vm1Name + ".*param1=[^\\w].*"));
assertFalse(stringContainsLine(stringResult, vm2Name + ".*" + queue1Name + ".*"));
vm1.invoke(new SerializableRunnable() {
public void run() {
Cache cache = getCache();
AsyncEventQueue queue = cache.getAsyncEventQueue(queue1Name);
assertEquals(queue.getBatchSize(), 514);
assertEquals(queue.isPersistent(), true);
assertEquals(queue.getDiskStoreName(), diskStoreName);
assertEquals(queue.getMaximumQueueMemory(), 213);
assertEquals(queue.getBatchTimeInterval(), 946);
assertEquals(queue.isParallel(), true);
assertEquals(queue.isBatchConflationEnabled(), true);
assertEquals(queue.getDispatcherThreads(), 2);
assertEquals(queue.getOrderPolicy().toString(), "PARTITION");
assertEquals(queue.getGatewayEventFilters().size(), 1);
assertEquals(queue.getGatewayEventFilters().get(0).getClass().getName(), "com.qcdunit.QueueCommandsDUnitTestHelper");
assertEquals(queue.getGatewayEventSubstitutionFilter().getClass().getName(), "com.qcdunit.QueueCommandsDUnitTestHelper");
assertEquals(queue.isDiskSynchronous(), false);
assertEquals(queue.isForwardExpirationDestroy(), true);
assertEquals(queue.getAsyncEventListener().getClass().getName(), "com.qcdunit.QueueCommandsDUnitTestHelper");
}
});
commandStringBuilder = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE);
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, queue2Name);
commandStringBuilder.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__LISTENER, "com.qcdunit.QueueCommandsDUnitTestHelper");
cmdResult = executeCommand(commandStringBuilder.toString());
assertEquals(Result.Status.OK, cmdResult.getStatus());
stringResult = commandResultToString(cmdResult);
assertEquals(5, countLinesInString(stringResult, false));
assertTrue(stringContainsLine(stringResult, "Manager.*Success"));
assertTrue(stringContainsLine(stringResult, vm2Name + ".*Success"));
assertTrue(stringContainsLine(stringResult, vm1Name + ".*Success"));
// Verify that the queue was created on the correct members
cmdResult = executeCommand(CliStrings.LIST_ASYNC_EVENT_QUEUES);
assertEquals(Result.Status.OK, cmdResult.getStatus());
stringResult = commandResultToString(cmdResult);
assertEquals(6, countLinesInString(stringResult, false));
assertTrue(stringContainsLine(stringResult, "Manager .*" + queue2Name + " .*100 .*false .*null .*100 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper"));
assertTrue(stringContainsLine(stringResult, vm1Name + " .*" + queue1Name + " .*514 .*true .*" + diskStoreName + " .*213 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper" + ".*"));
assertTrue(stringContainsLine(stringResult, vm1Name + " .*" + queue2Name + " .*100 .*false .*null .*100 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper"));
assertTrue(stringContainsLine(stringResult, vm2Name + " .*" + queue2Name + " .*100 .*false .*null .*100 .*" + " .*com.qcdunit.QueueCommandsDUnitTestHelper"));
}
Aggregations