Search in sources :

Example 76 with GatewaySender

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

the class GemFireCacheImpl method addGatewaySender.

@Override
public void addGatewaySender(GatewaySender sender) {
    if (isClient()) {
        throw new UnsupportedOperationException("operation is not supported on a client cache");
    }
    this.stopper.checkCancelInProgress(null);
    synchronized (this.allGatewaySendersLock) {
        if (!this.allGatewaySenders.contains(sender)) {
            new UpdateAttributesProcessor((DistributionAdvisee) sender).distribute(true);
            Set<GatewaySender> newSenders = new HashSet<>(this.allGatewaySenders.size() + 1);
            if (!this.allGatewaySenders.isEmpty()) {
                newSenders.addAll(this.allGatewaySenders);
            }
            newSenders.add(sender);
            this.allGatewaySenders = Collections.unmodifiableSet(newSenders);
        } else {
            throw new IllegalStateException(LocalizedStrings.GemFireCache_A_GATEWAYSENDER_WITH_ID_0_IS_ALREADY_DEFINED_IN_THIS_CACHE.toLocalizedString(sender.getId()));
        }
    }
    synchronized (this.rootRegions) {
        Set<LocalRegion> applicationRegions = getApplicationRegions();
        for (LocalRegion region : applicationRegions) {
            Set<String> senders = region.getAllGatewaySenderIds();
            if (senders.contains(sender.getId()) && !sender.isParallel()) {
                region.senderCreated();
            }
        }
    }
    if (!sender.isParallel()) {
        Region dynamicMetaRegion = getRegion(DynamicRegionFactory.dynamicRegionListName);
        if (dynamicMetaRegion == null) {
            if (logger.isDebugEnabled()) {
                logger.debug(" The dynamic region is null. ");
            }
        } else {
            dynamicMetaRegion.getAttributesMutator().addGatewaySenderId(sender.getId());
        }
    }
    if (!(sender.getRemoteDSId() < 0)) {
        this.system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_CREATE, sender);
    }
}
Also used : AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) GatewaySender(org.apache.geode.cache.wan.GatewaySender) DistributionAdvisee(org.apache.geode.distributed.internal.DistributionAdvisee) Region(org.apache.geode.cache.Region) HashSet(java.util.HashSet) ConcurrentHashSet(org.apache.geode.internal.concurrent.ConcurrentHashSet)

Example 77 with GatewaySender

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

the class GemFireCacheImpl method hasSerialSenders.

private boolean hasSerialSenders(PartitionedRegion region) {
    boolean hasSenders = false;
    Set<String> senders = region.getAllGatewaySenderIds();
    for (String sender : senders) {
        GatewaySender gatewaySender = this.getGatewaySender(sender);
        if (gatewaySender != null && !gatewaySender.isParallel()) {
            hasSenders = true;
            break;
        }
    }
    return hasSenders;
}
Also used : AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) GatewaySender(org.apache.geode.cache.wan.GatewaySender)

Example 78 with GatewaySender

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

the class PartitionedRegion method addGatewaySenderId.

public void addGatewaySenderId(String gatewaySenderId) {
    super.addGatewaySenderId(gatewaySenderId);
    new UpdateAttributesProcessor(this).distribute();
    ((PartitionedRegion) this).distributeUpdatedProfileOnSenderCreation();
    GatewaySender sender = getCache().getGatewaySender(gatewaySenderId);
    if (sender != null && sender.isParallel() && sender.isRunning()) {
        AbstractGatewaySender senderImpl = (AbstractGatewaySender) sender;
        ((ConcurrentParallelGatewaySenderQueue) senderImpl.getQueues().toArray(new RegionQueue[1])[0]).addShadowPartitionedRegionForUserPR(this);
    }
}
Also used : AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) GatewaySender(org.apache.geode.cache.wan.GatewaySender) ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender)

Example 79 with GatewaySender

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

the class PartitionedRegion method postCreateRegion.

@Override
protected void postCreateRegion() {
    super.postCreateRegion();
    CacheListener[] listeners = fetchCacheListenersField();
    if (listeners != null && listeners.length > 0) {
        Set others = getRegionAdvisor().adviseGeneric();
        for (int i = 0; i < listeners.length; i++) {
            if (listeners[i] instanceof RegionMembershipListener) {
                RegionMembershipListener rml = (RegionMembershipListener) listeners[i];
                try {
                    DistributedMember[] otherDms = new DistributedMember[others.size()];
                    others.toArray(otherDms);
                    rml.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);
                }
            }
        }
    }
    PartitionListener[] partitionListeners = this.getPartitionListeners();
    if (partitionListeners != null && partitionListeners.length != 0) {
        for (int i = 0; i < partitionListeners.length; i++) {
            PartitionListener listener = partitionListeners[i];
            if (listener != null) {
                listener.afterRegionCreate(this);
            }
        }
    }
    Set<String> allGatewaySenderIds = getAllGatewaySenderIds();
    if (!allGatewaySenderIds.isEmpty()) {
        for (GatewaySender sender : cache.getAllGatewaySenders()) {
            if (sender.isParallel() && allGatewaySenderIds.contains(sender.getId())) {
                /*
           * get the ParallelGatewaySender to create the colocated partitioned region for this
           * region.
           */
                if (sender.isRunning()) {
                    AbstractGatewaySender senderImpl = (AbstractGatewaySender) sender;
                    ((ConcurrentParallelGatewaySenderQueue) senderImpl.getQueues().toArray(new RegionQueue[1])[0]).addShadowPartitionedRegionForUserPR(this);
                }
            }
        }
    }
}
Also used : AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) GatewaySender(org.apache.geode.cache.wan.GatewaySender) HashSet(java.util.HashSet) Set(java.util.Set) ResultsSet(org.apache.geode.cache.query.internal.ResultsSet) RegionMembershipListener(org.apache.geode.cache.RegionMembershipListener) CacheListener(org.apache.geode.cache.CacheListener) PartitionListener(org.apache.geode.cache.partition.PartitionListener) ConcurrentParallelGatewaySenderQueue(org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender)

Example 80 with GatewaySender

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

the class MemberMBeanBridge method listConnectedGatewaySenders.

/**
   * @return Connected gateway senders
   */
public String[] listConnectedGatewaySenders() {
    if ((cache != null && cache.getGatewaySenders().size() > 0)) {
        Set<GatewaySender> senders = cache.getGatewaySenders();
        String[] arr = new String[senders.size()];
        int j = 0;
        for (GatewaySender sender : senders) {
            arr[j] = sender.getId();
            j++;
        }
        return arr;
    }
    return ManagementConstants.NO_DATA_STRING;
}
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