Search in sources :

Example 46 with GatewaySender

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();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender)

Example 47 with GatewaySender

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));
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) GatewaySenderException(org.apache.geode.internal.cache.wan.GatewaySenderException) GatewaySenderException(org.apache.geode.internal.cache.wan.GatewaySenderException) Cache(org.apache.geode.cache.Cache)

Example 48 with GatewaySender

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));
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) XmlEntity(org.apache.geode.management.internal.configuration.domain.XmlEntity) GatewaySenderException(org.apache.geode.internal.cache.wan.GatewaySenderException) GatewaySenderException(org.apache.geode.internal.cache.wan.GatewaySenderException) Cache(org.apache.geode.cache.Cache)

Example 49 with GatewaySender

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
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) Set(java.util.Set) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion)

Example 50 with GatewaySender

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();
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender)

Aggregations

GatewaySender (org.apache.geode.cache.wan.GatewaySender)116 RegionQueue (org.apache.geode.internal.cache.RegionQueue)28 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)28 Test (org.junit.Test)17 IgnoredException (org.apache.geode.test.dunit.IgnoredException)16 Region (org.apache.geode.cache.Region)10 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)10 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)9 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)9 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)9 DiskStore (org.apache.geode.cache.DiskStore)8 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)8 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)8 Expectations (org.jmock.Expectations)8 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)7 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)7 UnitTest (org.apache.geode.test.junit.categories.UnitTest)7 AttributesFactory (org.apache.geode.cache.AttributesFactory)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5