use of org.apache.geode.CancelException in project geode by apache.
the class MemberHealthEvaluator method checkCacheRequiredRolesMeet.
/**
* The function keeps updating the health of the cache based on roles required by the regions and
* their reliability policies.
*/
private void checkCacheRequiredRolesMeet(List status) {
try {
InternalCache cache = (InternalCache) CacheFactory.getAnyInstance();
CachePerfStats cPStats = cache.getCachePerfStats();
if (cPStats.getReliableRegionsMissingFullAccess() > 0) {
// health is okay.
int numRegions = cPStats.getReliableRegionsMissingFullAccess();
status.add(okayHealth(LocalizedStrings.MemberHealthEvaluator_THERE_ARE_0_REGIONS_MISSING_REQUIRED_ROLES_BUT_ARE_CONFIGURED_FOR_FULL_ACCESS.toLocalizedString(numRegions)));
} else if (cPStats.getReliableRegionsMissingLimitedAccess() > 0) {
// health is poor
int numRegions = cPStats.getReliableRegionsMissingLimitedAccess();
status.add(poorHealth(LocalizedStrings.MemberHealthEvaluator_THERE_ARE_0_REGIONS_MISSING_REQUIRED_ROLES_AND_CONFIGURED_WITH_LIMITED_ACCESS.toLocalizedString(numRegions)));
} else if (cPStats.getReliableRegionsMissingNoAccess() > 0) {
// health is poor
int numRegions = cPStats.getReliableRegionsMissingNoAccess();
status.add(poorHealth(LocalizedStrings.MemberHealthEvaluator_THERE_ARE_0_REGIONS_MISSING_REQUIRED_ROLES_AND_CONFIGURED_WITHOUT_ACCESS.toLocalizedString(numRegions)));
}
} catch (CancelException ignore) {
}
}
use of org.apache.geode.CancelException in project geode by apache.
the class DistributionManager method sendShutdownMessage.
/**
* Sends the shutdown message. Not all DistributionManagers need to do this.
*/
protected void sendShutdownMessage() {
if (getDMType() == ADMIN_ONLY_DM_TYPE && Locator.getLocators().size() == 0) {
// If two locators are simultaneously shut down this may not occur.
return;
}
ShutdownMessage m = new ShutdownMessage();
InternalDistributedMember theId = this.getDistributionManagerId();
m.setDistributionManagerId(theId);
Set allOthers = new HashSet(getViewMembers());
allOthers.remove(getDistributionManagerId());
// ReplyProcessor21 rp = new ReplyProcessor21(this, allOthers);
// m.setProcessorId(rp.getProcessorId());
// m.setMulticast(system.getConfig().getMcastPort() != 0);
m.setRecipients(allOthers);
// Address recipient = (Address) m.getRecipient();
if (logger.isTraceEnabled()) {
logger.trace("{} Sending {} to {}", this.getDistributionManagerId(), m, m.getRecipientsDescription());
}
try {
// m.resetTimestamp(); // nanotimers across systems don't match
long startTime = DistributionStats.getStatTime();
channel.send(m.getRecipients(), m, this, stats);
this.stats.incSentMessages(1L);
if (DistributionStats.enableClockStats) {
stats.incSentMessagesTime(DistributionStats.getStatTime() - startTime);
}
} catch (CancelException e) {
logger.debug("CancelException caught sending shutdown: {}", e.getMessage(), e);
} catch (Exception ex2) {
logger.fatal(LocalizedMessage.create(LocalizedStrings.DistributionManager_WHILE_SENDING_SHUTDOWN_MESSAGE), ex2);
} finally {
// Even if the message wasn't sent, *lie* about it, so that
// everyone believes that message distribution is done.
this.shutdownMsgSent = true;
}
}
use of org.apache.geode.CancelException in project geode by apache.
the class ConnectionFactoryImpl method createClientToServerConnection.
public Connection createClientToServerConnection(Set excludedServers) throws GemFireSecurityException {
final Set origExcludedServers = excludedServers;
excludedServers = new HashSet(excludedServers);
Set blackListedServers = blackList.getBadServers();
excludedServers.addAll(blackListedServers);
Connection conn = null;
// long startTime = System.currentTimeMillis();
RuntimeException fatalException = null;
boolean tryBlackList = true;
do {
ServerLocation server = source.findServer(excludedServers);
if (server == null) {
if (tryBlackList) {
// Nothing worked! Let's try without the blacklist.
tryBlackList = false;
int size = excludedServers.size();
excludedServers.removeAll(blackListedServers);
// make sure we didn't remove any of the ones that the caller set not to use
excludedServers.addAll(origExcludedServers);
if (excludedServers.size() < size) {
// We are able to remove some exclusions, so lets give this another whirl.
continue;
}
}
if (logger.isDebugEnabled()) {
logger.debug("Source was unable to locate any servers");
}
if (fatalException != null) {
throw fatalException;
}
return null;
}
try {
conn = createClientToServerConnection(server, false);
} catch (CancelException e) {
// propagate this up immediately
throw e;
} catch (GemFireSecurityException e) {
// propagate this up immediately
throw e;
} catch (GatewayConfigurationException e) {
// propagate this up immediately
throw e;
} catch (ServerRefusedConnectionException srce) {
fatalException = srce;
if (logger.isDebugEnabled()) {
logger.debug("ServerRefusedConnectionException attempting to connect to {}", server, srce);
}
} catch (Exception e) {
logger.warn(LocalizedMessage.create(LocalizedStrings.ConnectException_COULD_NOT_CONNECT_TO_0, server), e);
}
excludedServers.add(server);
} while (conn == null);
// }
return conn;
}
use of org.apache.geode.CancelException in project geode by apache.
the class ConnectionFactoryImpl method createClientToServerConnection.
public Connection createClientToServerConnection(ServerLocation location, boolean forQueue) throws GemFireSecurityException {
ConnectionImpl connection = new ConnectionImpl(this.ds, this.cancelCriterion);
FailureTracker failureTracker = blackList.getFailureTracker(location);
boolean initialized = false;
try {
HandShake connHandShake = new HandShake(handshake);
connection.connect(endpointManager, location, connHandShake, socketBufferSize, handShakeTimeout, readTimeout, getCommMode(forQueue), this.gatewaySender, this.socketCreator);
failureTracker.reset();
connection.setHandShake(connHandShake);
authenticateIfRequired(connection);
initialized = true;
} catch (GemFireConfigException e) {
throw e;
} catch (CancelException e) {
// propagate this up, don't retry
throw e;
} catch (GemFireSecurityException e) {
// propagate this up, don't retry
throw e;
} catch (GatewayConfigurationException e) {
// propagate this up, don't retry
throw e;
} catch (ServerRefusedConnectionException src) {
// propagate this up, don't retry
logger.warn(LocalizedMessage.create(LocalizedStrings.AutoConnectionSourceImpl_COULD_NOT_CREATE_A_NEW_CONNECTION_TO_SERVER_0, src.getMessage()));
testFailedConnectionToServer = true;
throw src;
} catch (Exception e) {
if (e.getMessage() != null && (e.getMessage().equals("Connection refused") || e.getMessage().equals("Connection reset"))) {
// print an exception
if (logger.isDebugEnabled()) {
logger.debug("Unable to connect to {}: connection refused", location);
}
} else {
// print a warning with the exception stack trace
logger.warn(LocalizedMessage.create(LocalizedStrings.ConnectException_COULD_NOT_CONNECT_TO_0, location), e);
}
testFailedConnectionToServer = true;
} finally {
if (!initialized) {
connection.destroy();
failureTracker.addFailure();
connection = null;
}
}
return connection;
}
use of org.apache.geode.CancelException in project geode by apache.
the class HostStatSampler method run.
/**
* This service's main loop
*/
@Override
public void run() {
final boolean isDebugEnabled_STATISTICS = logger.isTraceEnabled(LogMarker.STATISTICS);
if (isDebugEnabled_STATISTICS) {
logger.trace(LogMarker.STATISTICS, "HostStatSampler started");
}
boolean latchCountedDown = false;
try {
initSpecialStats();
this.sampleCollector = new SampleCollector(this);
this.sampleCollector.initialize(this, timer.getTime(), new MainWithChildrenRollingFileHandler());
this.statSamplerInitializedLatch.countDown();
latchCountedDown = true;
timer.reset();
// subtract getNanoRate from lastTS to force a quick initial sample
long nanosLastTimeStamp = timer.getLastResetTime() - getNanoRate();
while (!stopRequested()) {
SystemFailure.checkFailure();
if (Thread.currentThread().isInterrupted()) {
break;
}
final long nanosBeforeSleep = timer.getLastResetTime();
final long nanosToDelay = nanosLastTimeStamp + getNanoRate();
delay(nanosToDelay);
nanosLastTimeStamp = timer.getLastResetTime();
if (!stopRequested() && isSamplingEnabled()) {
final long nanosTimeStamp = timer.getLastResetTime();
final long nanosElapsedSleeping = nanosTimeStamp - nanosBeforeSleep;
checkElapsedSleepTime(nanosElapsedSleeping);
if (stopRequested())
break;
sampleSpecialStats(false);
if (stopRequested())
break;
checkListeners();
if (stopRequested())
break;
this.sampleCollector.sample(nanosTimeStamp);
final long nanosSpentWorking = timer.reset();
accountForTimeSpentWorking(nanosSpentWorking, nanosElapsedSleeping);
} else if (!stopRequested() && !isSamplingEnabled()) {
// fixes bug 42527
sampleSpecialStats(true);
}
}
} catch (InterruptedException ex) {
// Silently exit
} catch (CancelException ex) {
// Silently exit
} catch (RuntimeException ex) {
logger.fatal(LogMarker.STATISTICS, ex.getMessage(), ex);
throw ex;
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
// now, so don't let this thread continue.
throw err;
} catch (Error ex) {
// 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.fatal(LogMarker.STATISTICS, ex.getMessage(), ex);
throw ex;
} finally {
try {
closeSpecialStats();
if (this.sampleCollector != null) {
this.sampleCollector.close();
}
} finally {
if (!latchCountedDown) {
// Make sure the latch gets counted down since
// other threads wait for this to indicate that
// the sampler is initialized.
this.statSamplerInitializedLatch.countDown();
}
}
if (isDebugEnabled_STATISTICS) {
logger.trace(LogMarker.STATISTICS, "HostStatSampler stopped");
}
}
}
Aggregations