use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class InternalInstantiator method sendRegistrationMessage.
/**
* If we are connected to a distributed system, send a message to other members telling them about
* a newly-registered instantiator.
*/
private static void sendRegistrationMessage(Instantiator s) {
InternalDistributedSystem system = InternalDistributedSystem.getAnyInstance();
if (system != null) {
RegistrationMessage m = null;
if (s.getContext() == null) {
m = new RegistrationMessage(s);
} else {
m = new RegistrationContextMessage(s);
}
system.getDistributionManager().putOutgoing(m);
}
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class SerialAsyncEventQueueImpl method stop.
@Override
public void stop() {
if (logger.isDebugEnabled()) {
logger.debug("Stopping Gateway Sender : {}", this);
}
this.getLifeCycleLock().writeLock().lock();
try {
// Stop the dispatcher
AbstractGatewaySenderEventProcessor ev = this.eventProcessor;
if (ev != null && !ev.isStopped()) {
ev.stopProcessing();
}
// Stop the proxy (after the dispatcher, so the socket is still
// alive until after the dispatcher has stopped)
stompProxyDead();
// Close the listeners
for (AsyncEventListener listener : this.listeners) {
listener.close();
}
logger.info(LocalizedMessage.create(LocalizedStrings.GatewayImpl_STOPPED__0, this));
clearTempEventsAfterSenderStopped();
} finally {
this.getLifeCycleLock().writeLock().unlock();
}
if (this.isPrimary()) {
try {
DistributedLockService.destroy(getSenderAdvisor().getDLockServiceName());
} catch (IllegalArgumentException e) {
// service not found... ignore
}
}
if (getQueues() != null && !getQueues().isEmpty()) {
for (RegionQueue q : getQueues()) {
((SerialGatewaySenderQueue) q).cleanUp();
}
}
this.setIsPrimary(false);
try {
new UpdateAttributesProcessor(this).distribute(false);
} catch (CancelException e) {
}
Thread lockObtainingThread = getSenderAdvisor().getLockObtainingThread();
if (lockObtainingThread != null && lockObtainingThread.isAlive()) {
// wait a while for thread to terminate
try {
lockObtainingThread.join(3000);
} catch (InterruptedException ex) {
// we allowed our join to be canceled
// reset interrupt bit so this thread knows it has been interrupted
Thread.currentThread().interrupt();
}
if (lockObtainingThread.isAlive()) {
logger.info(LocalizedMessage.create(LocalizedStrings.GatewaySender_COULD_NOT_STOP_LOCK_OBTAINING_THREAD_DURING_GATEWAY_SENDER_STOP));
}
}
InternalDistributedSystem system = (InternalDistributedSystem) this.cache.getDistributedSystem();
system.handleResourceEvent(ResourceEvent.GATEWAYSENDER_STOP, this);
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class GMSMembershipManager method releaseQuorumChecker.
@Override
public void releaseQuorumChecker(QuorumChecker checker) {
checker.suspend();
InternalDistributedSystem system = InternalDistributedSystem.getAnyInstance();
if (system == null || !system.isConnected()) {
checker.close();
}
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class GMSHealthMonitor method doTCPCheckMember.
/**
* During final check, establish TCP connection between current member and suspect member. And
* exchange PING/PONG message to see if the suspect member is still alive.
*
* @param suspectMember member that does not respond to HeartbeatRequestMessage
* @return true if successfully exchanged PING/PONG with TCP connection, otherwise false.
*/
boolean doTCPCheckMember(InternalDistributedMember suspectMember, int port) {
Socket clientSocket = null;
InternalDistributedSystem internalDistributedSystem = InternalDistributedSystem.getConnectedInstance();
try {
logger.debug("Checking member {} with TCP socket connection {}:{}.", suspectMember, suspectMember.getInetAddress(), port);
clientSocket = SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).connect(suspectMember.getInetAddress(), port, (int) memberTimeout, new ConnectTimeoutTask(services.getTimer(), memberTimeout), false, -1, false);
clientSocket.setTcpNoDelay(true);
return doTCPCheckMember(suspectMember, clientSocket);
} catch (IOException e) {
// this is expected if it is a connection-timeout or other failure
// to connect
} catch (IllegalStateException e) {
if (!isStopping) {
logger.trace("Unexpected exception", e);
}
} finally {
try {
if (clientSocket != null) {
// abort the connection
clientSocket.setSoLinger(true, 0);
clientSocket.close();
}
} catch (IOException e) {
// expected
}
}
return false;
}
use of org.apache.geode.distributed.internal.InternalDistributedSystem in project geode by apache.
the class CreateRegionProcessor method getRecipients.
protected Set getRecipients() {
DistributionAdvisee parent = this.newRegion.getParentAdvisee();
Set recps = null;
if (parent == null) {
// root region, all recipients
InternalDistributedSystem system = this.newRegion.getSystem();
recps = system.getDistributionManager().getOtherDistributionManagerIds();
} else {
// get recipients that have the parent region defined as distributed.
recps = getAdvice();
}
return recps;
}
Aggregations