Search in sources :

Example 36 with LogWriterI18n

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;
}
Also used : StatisticsType(org.apache.geode.StatisticsType) LogWriterI18n(org.apache.geode.i18n.LogWriterI18n) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) Statistics(org.apache.geode.Statistics)

Example 37 with LogWriterI18n

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;
        }
    });
}
Also used : CustId(org.apache.geode.internal.cache.execute.data.CustId) Customer(org.apache.geode.internal.cache.execute.data.Customer) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) LocalRegion(org.apache.geode.internal.cache.LocalRegion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Host(org.apache.geode.test.dunit.Host) LogWriterI18n(org.apache.geode.i18n.LogWriterI18n) CommitConflictException(org.apache.geode.cache.CommitConflictException) CommitIncompleteException(org.apache.geode.cache.CommitIncompleteException) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 38 with LogWriterI18n

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>");
    }
}
Also used : LogWriterI18n(org.apache.geode.i18n.LogWriterI18n)

Aggregations

LogWriterI18n (org.apache.geode.i18n.LogWriterI18n)38 SystemException (javax.transaction.SystemException)11 DistributedSystemDisconnectedException (org.apache.geode.distributed.DistributedSystemDisconnectedException)8 HeuristicMixedException (javax.transaction.HeuristicMixedException)4 HeuristicRollbackException (javax.transaction.HeuristicRollbackException)4 InvalidTransactionException (javax.transaction.InvalidTransactionException)4 NotSupportedException (javax.transaction.NotSupportedException)4 RollbackException (javax.transaction.RollbackException)4 CancelException (org.apache.geode.CancelException)4 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)4 Transaction (javax.transaction.Transaction)3 Region (org.apache.geode.cache.Region)3 Test (org.junit.Test)3 Iterator (java.util.Iterator)2 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)2 CacheWriterException (org.apache.geode.cache.CacheWriterException)2 CommitConflictException (org.apache.geode.cache.CommitConflictException)2 CommitIncompleteException (org.apache.geode.cache.CommitIncompleteException)2 Struct (org.apache.geode.cache.query.Struct)2 ClientHealthStats (org.apache.geode.internal.admin.remote.ClientHealthStats)2