Search in sources :

Example 81 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.

the class ManagementListener method handleEvent.

/**
   * Handles various GFE resource life-cycle methods vis-a-vis Management and Monitoring
   * 
   * It checks for race conditions cases by calling shouldProceed();
   *
   * @param event Management event for which invocation has happened
   * @param resource the GFE resource type
   */
public void handleEvent(ResourceEvent event, Object resource) {
    if (!shouldProceed(event)) {
        return;
    }
    switch(event) {
        case CACHE_CREATE:
            InternalCache createdCache = (InternalCache) resource;
            adapter.handleCacheCreation(createdCache);
            break;
        case CACHE_REMOVE:
            InternalCache removedCache = (InternalCache) resource;
            adapter.handleCacheRemoval(removedCache);
            break;
        case REGION_CREATE:
            Region createdRegion = (Region) resource;
            adapter.handleRegionCreation(createdRegion);
            break;
        case REGION_REMOVE:
            Region removedRegion = (Region) resource;
            adapter.handleRegionRemoval(removedRegion);
            break;
        case DISKSTORE_CREATE:
            DiskStore createdDisk = (DiskStore) resource;
            adapter.handleDiskCreation(createdDisk);
            break;
        case DISKSTORE_REMOVE:
            DiskStore removedDisk = (DiskStore) resource;
            adapter.handleDiskRemoval(removedDisk);
            break;
        case GATEWAYRECEIVER_CREATE:
            GatewayReceiver createdRecv = (GatewayReceiver) resource;
            adapter.handleGatewayReceiverCreate(createdRecv);
            break;
        case GATEWAYRECEIVER_START:
            GatewayReceiver startedRecv = (GatewayReceiver) resource;
            adapter.handleGatewayReceiverStart(startedRecv);
            break;
        case GATEWAYRECEIVER_STOP:
            GatewayReceiver stoppededRecv = (GatewayReceiver) resource;
            adapter.handleGatewayReceiverStop(stoppededRecv);
            break;
        case GATEWAYSENDER_CREATE:
            GatewaySender sender = (GatewaySender) resource;
            adapter.handleGatewaySenderCreation(sender);
            break;
        case GATEWAYSENDER_START:
            GatewaySender startedSender = (GatewaySender) resource;
            adapter.handleGatewaySenderStart(startedSender);
            break;
        case GATEWAYSENDER_STOP:
            GatewaySender stoppedSender = (GatewaySender) resource;
            adapter.handleGatewaySenderStop(stoppedSender);
            break;
        case GATEWAYSENDER_PAUSE:
            GatewaySender pausedSender = (GatewaySender) resource;
            adapter.handleGatewaySenderPaused(pausedSender);
            break;
        case GATEWAYSENDER_RESUME:
            GatewaySender resumedSender = (GatewaySender) resource;
            adapter.handleGatewaySenderResumed(resumedSender);
            break;
        case LOCKSERVICE_CREATE:
            DLockService createdLockService = (DLockService) resource;
            adapter.handleLockServiceCreation(createdLockService);
            break;
        case LOCKSERVICE_REMOVE:
            DLockService removedLockService = (DLockService) resource;
            adapter.handleLockServiceRemoval(removedLockService);
            break;
        case MANAGER_CREATE:
            adapter.handleManagerCreation();
            break;
        case MANAGER_START:
            adapter.handleManagerStart();
            break;
        case MANAGER_STOP:
            adapter.handleManagerStop();
            break;
        case ASYNCEVENTQUEUE_CREATE:
            AsyncEventQueue queue = (AsyncEventQueue) resource;
            adapter.handleAsyncEventQueueCreation(queue);
            break;
        case ASYNCEVENTQUEUE_REMOVE:
            AsyncEventQueue removedQueue = (AsyncEventQueue) resource;
            adapter.handleAsyncEventQueueRemoval(removedQueue);
            break;
        case SYSTEM_ALERT:
            AlertDetails details = (AlertDetails) resource;
            adapter.handleSystemNotification(details);
            break;
        case CACHE_SERVER_START:
            CacheServer startedServer = (CacheServer) resource;
            adapter.handleCacheServerStart(startedServer);
            break;
        case CACHE_SERVER_STOP:
            CacheServer stoppedServer = (CacheServer) resource;
            adapter.handleCacheServerStop(stoppedServer);
            break;
        case LOCATOR_START:
            Locator loc = (Locator) resource;
            adapter.handleLocatorStart(loc);
            break;
        case CACHE_SERVICE_CREATE:
            CacheService service = (CacheService) resource;
            adapter.handleCacheServiceCreation(service);
            break;
        default:
            break;
    }
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) GatewaySender(org.apache.geode.cache.wan.GatewaySender) Locator(org.apache.geode.distributed.Locator) AlertDetails(org.apache.geode.management.internal.AlertDetails) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) DLockService(org.apache.geode.distributed.internal.locks.DLockService) InternalCache(org.apache.geode.internal.cache.InternalCache) Region(org.apache.geode.cache.Region) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) CacheServer(org.apache.geode.cache.server.CacheServer) CacheService(org.apache.geode.internal.cache.CacheService)

Example 82 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.

the class DistributedRegion method postCreateRegion.

/**
   * In addition to inherited code this method also invokes RegionMembershipListeners
   */
@Override
protected void postCreateRegion() {
    super.postCreateRegion();
    // should we sync on this.distAdvisor first to prevent bug 44369?
    synchronized (this.advisorListener) {
        Set others = this.advisorListener.getInitialMembers();
        CacheListener[] listeners = fetchCacheListenersField();
        if (listeners != null) {
            for (CacheListener listener : listeners) {
                if (listener instanceof RegionMembershipListener) {
                    RegionMembershipListener regionMembershipListener = (RegionMembershipListener) listener;
                    try {
                        DistributedMember[] otherDms = new DistributedMember[others.size()];
                        others.toArray(otherDms);
                        regionMembershipListener.initialMembers(this, otherDms);
                    } catch (VirtualMachineError err) {
                        SystemFailure.initiateFailure(err);
                        // now, so don't let this thread continue.
                        throw err;
                    } catch (Throwable t) {
                        // Whenever you catch Error or Throwable, you must also
                        // catch VirtualMachineError (see above). However, there is
                        // _still_ a possibility that you are dealing with a cascading
                        // error condition, so you also need to check to see if the JVM
                        // is still usable:
                        SystemFailure.checkFailure();
                        logger.error(LocalizedMessage.create(LocalizedStrings.DistributedRegion_EXCEPTION_OCCURRED_IN_REGIONMEMBERSHIPLISTENER), t);
                    }
                }
            }
        }
        Set<String> allGatewaySenderIds = getAllGatewaySenderIds();
        if (!allGatewaySenderIds.isEmpty()) {
            for (GatewaySender sender : this.cache.getAllGatewaySenders()) {
                if (sender.isParallel() && allGatewaySenderIds.contains(sender.getId())) {
                    // addShadowPartitionedRegionForUserRR
                    if (sender.getId().contains(AsyncEventQueueImpl.ASYNC_EVENT_QUEUE_PREFIX)) {
                        throw new AsyncEventQueueConfigurationException(LocalizedStrings.ParallelAsyncEventQueue_0_CAN_NOT_BE_USED_WITH_REPLICATED_REGION_1.toLocalizedString(new Object[] { AsyncEventQueueImpl.getAsyncEventQueueIdFromSenderId(sender.getId()), this.getFullPath() }));
                    }
                    throw new GatewaySenderConfigurationException(LocalizedStrings.ParallelGatewaySender_0_CAN_NOT_BE_USED_WITH_REPLICATED_REGION_1.toLocalizedString(new Object[] { sender.getId(), this.getFullPath() }));
                }
            }
        }
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) HashSet(java.util.HashSet) GatewaySenderConfigurationException(org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException) RegionMembershipListener(org.apache.geode.cache.RegionMembershipListener) CacheListener(org.apache.geode.cache.CacheListener) AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember)

Example 83 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.

the class MyDistributedSystemListener method addedDistributedSystem.

/**
   * Please note that dynamic addition of the sender id to region is not yet available.
   */
public void addedDistributedSystem(int remoteDsId) {
    cache = CacheFactory.getAnyInstance();
    // remoteDsId = 2
    if (remoteDsId == 2) {
        if (cache != null) {
            GatewaySender serialSender = cache.createGatewaySenderFactory().setManualStart(true).setPersistenceEnabled(false).setDiskStoreName("LN_" + remoteDsId).create("LN_" + remoteDsId, remoteDsId);
            System.out.println("Sender Created : " + serialSender.getId());
            Region region = cache.createRegionFactory().create("MyRegion");
            System.out.println("Created Region : " + region.getName());
            try {
                serialSender.start();
                System.out.println("Sender Started: " + serialSender.getId());
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            throw new CacheClosedException("Cache is not initialized here");
        }
    } else {
        // gatewayReceiver with
        if (cache != null) {
            Region region = cache.createRegionFactory().create("MyRegion");
            System.out.println("Created Region :" + region.getName());
            GatewayReceiver receiver = cache.createGatewayReceiverFactory().setStartPort(12345).setManualStart(true).create();
            System.out.println("Created GatewayReceiver : " + receiver);
            try {
                receiver.start();
                System.out.println("GatewayReceiver Started.");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) Region(org.apache.geode.cache.Region) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) CacheClosedException(org.apache.geode.cache.CacheClosedException) IOException(java.io.IOException) CacheClosedException(org.apache.geode.cache.CacheClosedException) IOException(java.io.IOException)

Example 84 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.

the class DescribeDiskStoreFunction method setGatewayDetails.

protected void setGatewayDetails(final InternalCache cache, final DiskStore diskStore, final DiskStoreDetails diskStoreDetails) {
    for (GatewaySender gatewaySender : cache.getGatewaySenders()) {
        if (isUsingDiskStore(gatewaySender, diskStore)) {
            DiskStoreDetails.GatewayDetails gatewayDetails = new DiskStoreDetails.GatewayDetails(gatewaySender.getId());
            gatewayDetails.setPersistent(isPersistent(gatewaySender));
            diskStoreDetails.add(gatewayDetails);
        }
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) DiskStoreDetails(org.apache.geode.management.internal.cli.domain.DiskStoreDetails)

Example 85 with GatewaySender

use of org.apache.geode.cache.wan.GatewaySender in project geode by apache.

the class AsyncEventQueueFactoryImpl method create.

private GatewaySender create(String id) {
    this.attrs.id = id;
    GatewaySender sender = null;
    if (this.attrs.getDispatcherThreads() <= 0) {
        throw new AsyncEventQueueConfigurationException(LocalizedStrings.AsyncEventQueue_0_CANNOT_HAVE_DISPATCHER_THREADS_LESS_THAN_1.toLocalizedString(id));
    }
    if (this.attrs.isParallel()) {
        if ((this.attrs.getOrderPolicy() != null) && this.attrs.getOrderPolicy().equals(OrderPolicy.THREAD)) {
            throw new AsyncEventQueueConfigurationException(LocalizedStrings.AsyncEventQueue_0_CANNOT_BE_CREATED_WITH_ORDER_POLICY_1.toLocalizedString(id, this.attrs.getOrderPolicy()));
        }
        if (this.cache instanceof GemFireCacheImpl) {
            sender = new ParallelAsyncEventQueueImpl(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
            if (!this.attrs.isManualStart()) {
                sender.start();
            }
        } else if (this.cache instanceof CacheCreation) {
            sender = new ParallelAsyncEventQueueCreation(this.cache, this.attrs);
            ((CacheCreation) this.cache).addGatewaySender(sender);
        }
    } else {
        if (this.attrs.getOrderPolicy() == null && this.attrs.getDispatcherThreads() > 1) {
            this.attrs.policy = GatewaySender.DEFAULT_ORDER_POLICY;
        }
        if (this.cache instanceof GemFireCacheImpl) {
            sender = new SerialAsyncEventQueueImpl(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
            if (!this.attrs.isManualStart()) {
                sender.start();
            }
        } else if (this.cache instanceof CacheCreation) {
            sender = new SerialAsyncEventQueueCreation(this.cache, this.attrs);
            ((CacheCreation) this.cache).addGatewaySender(sender);
        }
    }
    return sender;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AsyncEventQueueConfigurationException(org.apache.geode.internal.cache.wan.AsyncEventQueueConfigurationException) ParallelAsyncEventQueueCreation(org.apache.geode.internal.cache.xmlcache.ParallelAsyncEventQueueCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) SerialAsyncEventQueueCreation(org.apache.geode.internal.cache.xmlcache.SerialAsyncEventQueueCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation)

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