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);
}
}
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;
}
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);
}
}
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);
}
}
}
}
}
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;
}
Aggregations