use of org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException in project geode by apache.
the class SerialGatewaySenderImpl method start.
@Override
public void start() {
if (logger.isDebugEnabled()) {
logger.debug("Starting gatewaySender : {}", this);
}
this.getLifeCycleLock().writeLock().lock();
try {
if (isRunning()) {
logger.warn(LocalizedMessage.create(LocalizedStrings.GatewaySender_SENDER_0_IS_ALREADY_RUNNING, this.getId()));
return;
}
if (this.remoteDSId != DEFAULT_DISTRIBUTED_SYSTEM_ID) {
String locators = this.cache.getInternalDistributedSystem().getConfig().getLocators();
if (locators.length() == 0) {
throw new GatewaySenderConfigurationException(LocalizedStrings.AbstractGatewaySender_LOCATOR_SHOULD_BE_CONFIGURED_BEFORE_STARTING_GATEWAY_SENDER.toLocalizedString());
}
}
getSenderAdvisor().initDLockService();
if (!isPrimary()) {
if (getSenderAdvisor().volunteerForPrimary()) {
getSenderAdvisor().makePrimary();
} else {
getSenderAdvisor().makeSecondary();
}
}
if (getDispatcherThreads() > 1) {
eventProcessor = new RemoteConcurrentSerialGatewaySenderEventProcessor(SerialGatewaySenderImpl.this);
} else {
eventProcessor = new RemoteSerialGatewaySenderEventProcessor(SerialGatewaySenderImpl.this, getId());
}
eventProcessor.start();
waitForRunningStatus();
this.startTime = System.currentTimeMillis();
// Only notify the type registry if this is a WAN gateway queue
if (!isAsyncEventQueue()) {
getCache().getPdxRegistry().gatewaySenderStarted(this);
}
new UpdateAttributesProcessor(this).distribute(false);
InternalDistributedSystem system = this.cache.getInternalDistributedSystem();
system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_START, this);
logger.info(LocalizedMessage.create(LocalizedStrings.SerialGatewaySenderImpl_STARTED__0, this));
enqueueTempEvents();
} finally {
this.getLifeCycleLock().writeLock().unlock();
}
}
use of org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException in project geode by apache.
the class SerialAsyncEventQueueImpl method start.
@Override
public void start() {
if (logger.isDebugEnabled()) {
logger.debug("Starting gatewaySender : {}", this);
}
this.getLifeCycleLock().writeLock().lock();
try {
if (isRunning()) {
logger.warn(LocalizedMessage.create(LocalizedStrings.GatewaySender_SENDER_0_IS_ALREADY_RUNNING, this.getId()));
return;
}
if (this.remoteDSId != DEFAULT_DISTRIBUTED_SYSTEM_ID) {
String locators = this.cache.getInternalDistributedSystem().getConfig().getLocators();
if (locators.length() == 0) {
throw new GatewaySenderConfigurationException(LocalizedStrings.AbstractGatewaySender_LOCATOR_SHOULD_BE_CONFIGURED_BEFORE_STARTING_GATEWAY_SENDER.toLocalizedString());
}
}
getSenderAdvisor().initDLockService();
if (!isPrimary()) {
if (getSenderAdvisor().volunteerForPrimary()) {
getSenderAdvisor().makePrimary();
} else {
getSenderAdvisor().makeSecondary();
}
}
if (getDispatcherThreads() > 1) {
eventProcessor = new ConcurrentSerialGatewaySenderEventProcessor(SerialAsyncEventQueueImpl.this);
} else {
eventProcessor = new SerialGatewaySenderEventProcessor(SerialAsyncEventQueueImpl.this, getId());
}
eventProcessor.start();
waitForRunningStatus();
this.startTime = System.currentTimeMillis();
// Only notify the type registry if this is a WAN gateway queue
if (!isAsyncEventQueue()) {
getCache().getPdxRegistry().gatewaySenderStarted(this);
}
new UpdateAttributesProcessor(this).distribute(false);
InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_START, this);
logger.info(LocalizedMessage.create(LocalizedStrings.SerialGatewaySenderImpl_STARTED__0, this));
enqueueTempEvents();
} finally {
this.getLifeCycleLock().writeLock().unlock();
}
}
use of org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException in project geode by apache.
the class PartitionedRegion method checkSameSenderIdsAvailableOnAllNodes.
public void checkSameSenderIdsAvailableOnAllNodes() {
List senderIds = this.getCacheDistributionAdvisor().adviseSameGatewaySenderIds(getGatewaySenderIds());
if (!senderIds.isEmpty()) {
throw new GatewaySenderConfigurationException(LocalizedStrings.Region_REGION_0_HAS_1_GATEWAY_SENDER_IDS_ANOTHER_CACHE_HAS_THE_SAME_REGION_WITH_2_GATEWAY_SENDER_IDS_FOR_REGION_ACROSS_ALL_MEMBERS_IN_DS_GATEWAY_SENDER_IDS_SHOULD_BE_SAME.toLocalizedString(new Object[] { this.getName(), senderIds.get(0), senderIds.get(1) }));
}
List asycnQueueIds = this.getCacheDistributionAdvisor().adviseSameAsyncEventQueueIds(getVisibleAsyncEventQueueIds());
if (!asycnQueueIds.isEmpty()) {
throw new GatewaySenderConfigurationException(LocalizedStrings.Region_REGION_0_HAS_1_ASYNC_EVENT_QUEUE_IDS_ANOTHER_CACHE_HAS_THE_SAME_REGION_WITH_2_ASYNC_EVENT_QUEUE_IDS_FOR_REGION_ACROSS_ALL_MEMBERS_IN_DS_ASYNC_EVENT_QUEUE_IDS_SHOULD_BE_SAME.toLocalizedString(new Object[] { this.getName(), asycnQueueIds.get(0), asycnQueueIds.get(1) }));
}
}
use of org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException 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() }));
}
}
}
}
}
use of org.apache.geode.internal.cache.wan.GatewaySenderConfigurationException in project geode by apache.
the class RemoteParallelGatewaySenderEventProcessor method shouldSendVersionEvents.
/**
* Returns if corresponding receiver WAN site of this GatewaySender has GemfireVersion > 7.0.1
*
* @param disp
* @return true if remote site Gemfire Version is >= 7.0.1
*/
private boolean shouldSendVersionEvents(GatewaySenderEventDispatcher disp) throws GatewaySenderException {
try {
GatewaySenderEventRemoteDispatcher remoteDispatcher = (GatewaySenderEventRemoteDispatcher) disp;
// This will create a new connection if no batch has been sent till
// now.
Connection conn = remoteDispatcher.getConnection(false);
if (conn != null) {
short remoteSiteVersion = conn.getWanSiteVersion();
if (Version.GFE_701.compareTo(remoteSiteVersion) <= 0) {
return true;
}
}
} catch (GatewaySenderException e) {
Throwable cause = e.getCause();
if (cause instanceof IOException || e instanceof GatewaySenderConfigurationException || cause instanceof ConnectionDestroyedException) {
try {
int sleepInterval = GatewaySender.CONNECTION_RETRY_INTERVAL;
if (logger.isDebugEnabled()) {
logger.debug("Sleeping for {} milliseconds", sleepInterval);
}
Thread.sleep(sleepInterval);
} catch (InterruptedException ie) {
// log the exception
if (logger.isDebugEnabled()) {
logger.debug(ie.getMessage(), ie);
}
}
}
throw e;
}
return false;
}
Aggregations