use of org.apache.geode.internal.cache.wan.GatewaySenderException in project geode by apache.
the class WANConfigurationJUnitTest method test_GatewaySender_Serial_ZERO_DispatcherThread.
@Test
public void test_GatewaySender_Serial_ZERO_DispatcherThread() {
cache = new CacheFactory().set(MCAST_PORT, "0").create();
GatewaySenderFactory fact = cache.createGatewaySenderFactory();
fact.setManualStart(true);
fact.setDispatcherThreads(0);
try {
GatewaySender sender1 = fact.create("NYSender", 2);
fail("Expected GatewaySenderException but not thrown");
} catch (GatewaySenderException e) {
if (e.getMessage().contains("can not be created with dispatcher threads less than 1")) {
} else {
fail("Expected IllegalStateException but received :" + e);
}
}
}
use of org.apache.geode.internal.cache.wan.GatewaySenderException in project geode by apache.
the class WANConfigurationJUnitTest method test_GatewaySender_Parallel_MultipleDispatcherThread.
@Test
public void test_GatewaySender_Parallel_MultipleDispatcherThread() {
cache = new CacheFactory().set(MCAST_PORT, "0").create();
GatewaySenderFactory fact = cache.createGatewaySenderFactory();
fact.setParallel(true);
fact.setManualStart(true);
fact.setDispatcherThreads(4);
try {
GatewaySender sender1 = fact.create("NYSender", 2);
} catch (GatewaySenderException e) {
fail("UnExpected Exception " + e);
}
}
use of org.apache.geode.internal.cache.wan.GatewaySenderException in project geode by apache.
the class ParallelGatewaySenderQueue method addShadowPartitionedRegionForUserPR.
public void addShadowPartitionedRegionForUserPR(PartitionedRegion userPR) {
if (logger.isDebugEnabled()) {
logger.debug("{} addShadowPartitionedRegionForUserPR: Attempting to create queue region: {}", this, userPR.getDisplayName());
}
this.sender.getLifeCycleLock().writeLock().lock();
PartitionedRegion prQ = null;
try {
String regionName = userPR.getFullPath();
// Find if there is any parent region for this userPR
// if there is then no need to add another q for the same
String leaderRegionName = ColocationHelper.getLeaderRegion(userPR).getFullPath();
if (!regionName.equals(leaderRegionName)) {
// colocation chain
if (!this.userRegionNameToshadowPRMap.containsKey(leaderRegionName)) {
addShadowPartitionedRegionForUserPR(ColocationHelper.getLeaderRegion(userPR));
}
return;
}
if (this.userRegionNameToshadowPRMap.containsKey(regionName))
return;
if (userPR.getDataPolicy().withPersistence() && !sender.isPersistenceEnabled()) {
throw new GatewaySenderException(LocalizedStrings.ParallelGatewaySenderQueue_NON_PERSISTENT_GATEWAY_SENDER_0_CAN_NOT_BE_ATTACHED_TO_PERSISTENT_REGION_1.toLocalizedString(new Object[] { this.sender.getId(), userPR.getFullPath() }));
}
InternalCache cache = sender.getCache();
boolean isAccessor = (userPR.getLocalMaxMemory() == 0);
final String prQName = sender.getId() + QSTRING + convertPathToName(userPR.getFullPath());
prQ = (PartitionedRegion) cache.getRegion(prQName);
if (prQ == null) {
// TODO:REF:Avoid deprecated apis
AttributesFactory fact = new AttributesFactory();
fact.setConcurrencyChecksEnabled(false);
PartitionAttributesFactory pfact = new PartitionAttributesFactory();
pfact.setTotalNumBuckets(userPR.getTotalNumberOfBuckets());
pfact.setRedundantCopies(userPR.getRedundantCopies());
pfact.setColocatedWith(regionName);
// EITHER set localMaxMemory to 0 for accessor node
// OR override shadowPRs default local max memory with the sender's max
// queue memory (Fix for bug#44254)
int localMaxMemory = isAccessor ? 0 : sender.getMaximumQueueMemory();
pfact.setLocalMaxMemory(localMaxMemory);
pfact.setStartupRecoveryDelay(userPR.getPartitionAttributes().getStartupRecoveryDelay());
pfact.setRecoveryDelay(userPR.getPartitionAttributes().getRecoveryDelay());
if (sender.isPersistenceEnabled() && !isAccessor) {
fact.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
}
fact.setDiskStoreName(sender.getDiskStoreName());
// else set it to false
if (sender.isPersistenceEnabled())
fact.setDiskSynchronous(sender.isDiskSynchronous());
else {
fact.setDiskSynchronous(false);
}
// allow for no overflow directory
EvictionAttributes ea = EvictionAttributes.createLIFOMemoryAttributes(sender.getMaximumQueueMemory(), EvictionAction.OVERFLOW_TO_DISK);
fact.setEvictionAttributes(ea);
fact.setPartitionAttributes(pfact.create());
final RegionAttributes ra = fact.create();
if (logger.isDebugEnabled()) {
logger.debug("{}: Attempting to create queue region: {}", this, prQName);
}
ParallelGatewaySenderQueueMetaRegion meta = metaRegionFactory.newMetataRegion(cache, prQName, ra, sender);
try {
prQ = (PartitionedRegion) cache.createVMRegion(prQName, ra, new InternalRegionArguments().setInternalMetaRegion(meta).setDestroyLockFlag(true).setInternalRegion(true).setSnapshotInputStream(null).setImageTarget(null));
// at this point we should be able to assert prQ == meta;
// TODO This should not be set on the PR but on the GatewaySender
prQ.enableConflation(sender.isBatchConflationEnabled());
if (isAccessor)
// return from here if accessor node
return;
// Wait for buckets to be recovered.
prQ.shadowPRWaitForBucketRecovery();
} catch (IOException | ClassNotFoundException veryUnLikely) {
logger.fatal(LocalizedMessage.create(LocalizedStrings.SingleWriteSingleReadRegionQueue_UNEXPECTED_EXCEPTION_DURING_INIT_OF_0, this.getClass()), veryUnLikely);
}
if (logger.isDebugEnabled()) {
logger.debug("{}: Created queue region: {}", this, prQ);
}
} else {
if (isAccessor)
// return from here if accessor node
return;
// started from stop operation)
if (// HItesh:for first parallelGatewaySenderQueue only
this.index == 0)
handleShadowPRExistsScenario(cache, prQ);
}
} finally {
if (prQ != null) {
this.userRegionNameToshadowPRMap.put(userPR.getFullPath(), prQ);
}
/*
* Here, enqueueTempEvents need to be invoked when a sender is already running and userPR is
* created later. When the flow comes here through start() method of sender i.e. userPR
* already exists and sender is started later, the enqueueTempEvents is done in the start()
* method of ParallelGatewaySender
*/
if ((this.index == this.nDispatcher - 1) && this.sender.isRunning()) {
((AbstractGatewaySender) sender).enqueueTempEvents();
}
afterRegionAdd(userPR);
this.sender.getLifeCycleLock().writeLock().unlock();
}
}
use of org.apache.geode.internal.cache.wan.GatewaySenderException in project geode by apache.
the class GatewaySenderDestroyFunction method execute.
@Override
public void execute(FunctionContext context) {
ResultSender<Object> resultSender = context.getResultSender();
Cache cache = CacheFactory.getAnyInstance();
String memberNameOrId = CliUtil.getMemberNameOrId(cache.getDistributedSystem().getDistributedMember());
GatewaySenderDestroyFunctionArgs gatewaySenderDestroyFunctionArgs = (GatewaySenderDestroyFunctionArgs) context.getArguments();
try {
GatewaySender gatewaySender = cache.getGatewaySender(gatewaySenderDestroyFunctionArgs.getId());
if (gatewaySender != null) {
gatewaySender.stop();
gatewaySender.destroy();
} else {
throw new GatewaySenderException("GateWaySender with Id " + gatewaySenderDestroyFunctionArgs.getId() + " not found");
}
resultSender.lastResult(new CliFunctionResult(memberNameOrId, true, CliStrings.format(CliStrings.DESTROY_GATEWAYSENDER__MSG__GATEWAYSENDER_0_DESTROYED_ON_1, new Object[] { gatewaySenderDestroyFunctionArgs.getId(), memberNameOrId })));
} catch (GatewaySenderException gse) {
resultSender.lastResult(handleException(memberNameOrId, gse.getMessage(), gse));
} catch (Exception e) {
String exceptionMsg = e.getMessage();
if (exceptionMsg == null) {
exceptionMsg = CliUtil.stackTraceAsString(e);
}
resultSender.lastResult(handleException(memberNameOrId, exceptionMsg, e));
}
}
use of org.apache.geode.internal.cache.wan.GatewaySenderException in project geode by apache.
the class GatewaySenderCreateFunction method execute.
@Override
public void execute(FunctionContext context) {
ResultSender<Object> resultSender = context.getResultSender();
Cache cache = CacheFactory.getAnyInstance();
String memberNameOrId = CliUtil.getMemberNameOrId(cache.getDistributedSystem().getDistributedMember());
GatewaySenderFunctionArgs gatewaySenderCreateArgs = (GatewaySenderFunctionArgs) context.getArguments();
try {
GatewaySender createdGatewaySender = createGatewaySender(cache, gatewaySenderCreateArgs);
XmlEntity xmlEntity = new XmlEntity(CacheXml.GATEWAY_SENDER, "id", gatewaySenderCreateArgs.getId());
resultSender.lastResult(new CliFunctionResult(memberNameOrId, xmlEntity, CliStrings.format(CliStrings.CREATE_GATEWAYSENDER__MSG__GATEWAYSENDER_0_CREATED_ON_1, new Object[] { createdGatewaySender.getId(), memberNameOrId })));
} catch (GatewaySenderException e) {
resultSender.lastResult(handleException(memberNameOrId, e.getMessage(), e));
} catch (Exception e) {
String exceptionMsg = e.getMessage();
if (exceptionMsg == null) {
exceptionMsg = CliUtil.stackTraceAsString(e);
}
resultSender.lastResult(handleException(memberNameOrId, exceptionMsg, e));
}
}
Aggregations