use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.
the class ManagementAdapter method cleanUpMonitors.
private void cleanUpMonitors() {
MemberMBean bean = (MemberMBean) service.getMemberMXBean();
if (bean != null) {
bean.stopMonitor();
}
Set<GatewaySender> senders = internalCache.getGatewaySenders();
if (senders != null && senders.size() > 0) {
for (GatewaySender sender : senders) {
GatewaySenderMBean senderMBean = (GatewaySenderMBean) service.getLocalGatewaySenderMXBean(sender.getId());
if (senderMBean != null) {
senderMBean.stopMonitor();
}
}
}
GatewayReceiverMBean receiver = (GatewayReceiverMBean) service.getLocalGatewayReceiverMXBean();
if (receiver != null) {
receiver.stopMonitor();
}
}
use of org.apache.geode.cache.wan.GatewaySender 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.cache.wan.GatewaySender 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));
}
}
use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.
the class CommonParallelGatewaySenderDUnitTest method validateParallelSenderQueueAllBucketsDrained.
public static void validateParallelSenderQueueAllBucketsDrained(final String senderId) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
ConcurrentParallelGatewaySenderQueue regionQueue = (ConcurrentParallelGatewaySenderQueue) ((AbstractGatewaySender) sender).getQueues().toArray(new RegionQueue[1])[0];
Set<PartitionedRegion> shadowPRs = (Set<PartitionedRegion>) regionQueue.getRegions();
for (PartitionedRegion shadowPR : shadowPRs) {
Set<BucketRegion> buckets = shadowPR.getDataStore().getAllLocalBucketRegions();
for (final BucketRegion bucket : buckets) {
WaitCriterion wc = new WaitCriterion() {
public boolean done() {
if (bucket.keySet().size() == 0) {
LogWriterUtils.getLogWriter().info("Bucket " + bucket.getId() + " is empty");
return true;
}
return false;
}
public String description() {
return "Expected bucket entries for bucket: " + bucket.getId() + " is: 0 but actual entries: " + bucket.keySet().size() + " This bucket isPrimary: " + bucket.getBucketAdvisor().isPrimary() + " KEYSET: " + bucket.keySet();
}
};
Wait.waitForCriterion(wc, 180000, 50, true);
}
// for loop ends
}
}
use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.
the class WANTestBase method destroySender.
public static void destroySender(String senderId) {
Set<GatewaySender> senders = cache.getGatewaySenders();
GatewaySender sender = null;
for (GatewaySender s : senders) {
if (s.getId().equals(senderId)) {
sender = s;
break;
}
}
sender.destroy();
}
Aggregations