use of org.apache.geode.admin.GemFireHealthConfig in project geode by apache.
the class MemberHealthEvaluatorJUnitTest method testCheckVMProcessSize.
/**
* Tests that we are in {@link GemFireHealth#OKAY_HEALTH okay} health if the VM's process size is
* too big.
*
* @see MemberHealthEvaluator#checkVMProcessSize
*/
@Test
public void testCheckVMProcessSize() throws InterruptedException {
if (PureJavaMode.osStatsAreAvailable()) {
GemFireStatSampler sampler = system.getStatSampler();
assertNotNull(sampler);
// fix: remove infinite wait
sampler.waitForInitialization(10000);
ProcessStats stats = sampler.getProcessStats();
assertNotNull(stats);
List status = new ArrayList();
long threshold = stats.getProcessSize() * 2;
if (threshold <= 0) {
// The process size is zero on some Linux versions
return;
}
GemFireHealthConfig config = new GemFireHealthConfigImpl(null);
config.setMaxVMProcessSize(threshold);
MemberHealthEvaluator eval = new MemberHealthEvaluator(config, this.system.getDistributionManager());
eval.evaluate(status);
assertTrue(status.isEmpty());
status = new ArrayList();
long processSize = stats.getProcessSize();
threshold = processSize / 2;
assertTrue("Threshold (" + threshold + ") is > 0. " + "Process size is " + processSize, threshold > 0);
config = new GemFireHealthConfigImpl(null);
config.setMaxVMProcessSize(threshold);
eval = new MemberHealthEvaluator(config, this.system.getDistributionManager());
eval.evaluate(status);
assertEquals(1, status.size());
AbstractHealthEvaluator.HealthStatus ill = (AbstractHealthEvaluator.HealthStatus) status.get(0);
assertEquals(GemFireHealth.OKAY_HEALTH, ill.getHealthCode());
assertTrue(ill.getDiagnosis().indexOf("The size of this VM") != -1);
}
}
use of org.apache.geode.admin.GemFireHealthConfig in project geode by apache.
the class GemFireHealthJmxImpl method manageGemFireHealthConfig.
public ObjectName manageGemFireHealthConfig(String hostName) throws MalformedObjectNameException {
try {
GemFireHealthConfig config = getGemFireHealthConfig(hostName);
GemFireHealthConfigJmxImpl jmx = (GemFireHealthConfigJmxImpl) config;
return new ObjectName(jmx.getMBeanName());
}// catch (AdminException e) { logWriter.warning(e); throw e; }
catch (RuntimeException e) {
logger.warn(e.getMessage(), e);
throw e;
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
// now, so don't let this thread continue.
throw err;
} catch (Error e) {
// 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(e.getMessage(), e);
throw e;
}
}
Aggregations