use of org.apache.geode.i18n.LogWriterI18n in project geode by apache.
the class ClientStatsManager method initializeStatistics.
/**
* This method initializes the client statistics to be queried.
*
* GuardedBy ClientStatsManager.class
*
* @return true if statistics correctly initialized
*/
private static boolean initializeStatistics(InternalCache currentCache) {
if (currentCache == null) {
return false;
}
LogWriterI18n logger = currentCache.getLoggerI18n();
InternalDistributedSystem ds = (InternalDistributedSystem) currentCache.getDistributedSystem();
if (currentCache.isClosed()) {
return false;
}
boolean restart = lastInitializedCache != currentCache;
lastInitializedCache = currentCache;
if (restart) {
if (logger.infoEnabled()) {
logger.info(LocalizedStrings.ClientStatsManager_CLIENTSTATSMANAGER_INTIALIZING_THE_STATISTICS);
}
cachePerfStats = null;
vmStats = null;
}
if (cachePerfStats == null) {
StatisticsType type = ds.findType("CachePerfStats");
if (type != null) {
Statistics[] statistics = ds.findStatisticsByType(type);
if (statistics != null && statistics.length > 0) {
cachePerfStats = statistics[0];
}
}
}
if (vmStats == null) {
StatisticsType type = ds.findType("VMStats");
if (type != null) {
Statistics[] statistics = ds.findStatisticsByType(type);
if (statistics != null && statistics.length > 0) {
vmStats = statistics[0];
}
}
}
// Validate that cache has changed before logging the warning, thus logging it once per cache
if (cachePerfStats == null && restart) {
logger.warning(LocalizedStrings.ClientStatsManager_CLIENTSTATSMANAGER_0_ARE_NOT_AVAILABLE, "CachePerfStats");
}
// Validate that cache has changed before logging the warning, thus logging it once per cache
if (vmStats == null && restart) {
logger.warning(LocalizedStrings.ClientStatsManager_CLIENTSTATSMANAGER_0_ARE_NOT_AVAILABLE, "VMStats");
}
return true;
}
use of org.apache.geode.i18n.LogWriterI18n in project geode by apache.
the class DistributedTransactionDUnitTest method testTransactionalPutOnPartitionedRegion.
@Test
public void testTransactionalPutOnPartitionedRegion() throws Exception {
Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM server2 = host.getVM(1);
VM server3 = host.getVM(2);
createPR(new VM[] { server1, server2, server3 });
execute(server1, new SerializableCallable() {
@Override
public Object call() throws Exception {
CacheTransactionManager mgr = getGemfireCache().getTxManager();
mgr.setDistributed(true);
LogWriterI18n logger = getGemfireCache().getLoggerI18n();
mgr.begin();
logger.fine("TEST:Commit-1");
mgr.commit();
mgr.begin();
Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER_PR);
CustId custId = new CustId(1);
Customer expectedCustomer = custRegion.get(custId);
assertNull(expectedCustomer);
// Perform a put
CustId custIdOne = new CustId(1);
Customer customerOne = new Customer("name1", "addr1");
logger.fine("TEST:Put-1");
custRegion.put(custIdOne, customerOne);
// Rollback the transaction
logger.fine("TEST:Rollback-1");
mgr.rollback();
mgr.begin();
// Verify that the entry is rolled back
expectedCustomer = custRegion.get(custId);
assertNull(expectedCustomer);
// Perform two more puts and a commit
CustId custIdTwo = new CustId(2);
Customer customerTwo = new Customer("name2", "addr2");
CustId custIdThree = new CustId(3);
Customer customerThree = new Customer("name3", "addr3");
logger.fine("TEST:Put-2");
custRegion.put(custIdTwo, customerTwo);
logger.fine("TEST:Put-3");
custRegion.put(custIdThree, customerThree);
logger.fine("TEST:Commit-2");
mgr.commit();
mgr.begin();
// Verify data
assertEquals(2, custRegion.size());
assertTrue(custRegion.containsKey(custIdTwo));
assertTrue(custRegion.containsKey(custIdThree));
assertEquals(customerTwo, custRegion.get(custIdTwo));
assertEquals(customerThree, custRegion.get(custIdThree));
// Perform one more put but don't commit
logger.fine("TEST:Put-4");
Customer customerOneMod = new Customer("name1", "addr11");
custRegion.put(custIdOne, customerOneMod);
// Verify data
assertEquals(3, custRegion.size());
assertTrue(custRegion.containsKey(custIdOne));
assertEquals(customerOneMod, custRegion.get(custIdOne));
logger.fine("TEST:Commit-3");
mgr.commit();
return null;
}
});
}
use of org.apache.geode.i18n.LogWriterI18n in project geode by apache.
the class MemberFunctionExecutionDUnitTest method registerExpectedExceptions.
public static void registerExpectedExceptions(boolean add) {
final String action = add ? "add" : "remove";
LogWriterI18n log = InternalDistributedSystem.getLoggerI18n();
if (log != null) {
log.convertToLogWriter().info("<ExpectedException action=" + action + ">ClassNotFoundException</ExpectedException>");
}
}
Aggregations