Search in sources :

Example 21 with GridStringLogger

use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.

the class IgniteDiagnosticMessagesTest method testLongRunningTx.

/**
 * @throws Exception If failed.
 */
public void testLongRunningTx() throws Exception {
    System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500");
    try {
        startGrid(0);
        GridStringLogger strLog = this.strLog = new GridStringLogger();
        startGrid(1);
        awaitPartitionMapExchange();
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
        ccfg.setWriteSynchronizationMode(FULL_SYNC);
        ccfg.setCacheMode(PARTITIONED);
        ccfg.setAtomicityMode(TRANSACTIONAL);
        final Ignite node0 = ignite(0);
        final Ignite node1 = ignite(1);
        node0.createCache(ccfg);
        UUID id0 = node0.cluster().localNode().id();
        final CountDownLatch l1 = new CountDownLatch(1);
        final CountDownLatch l2 = new CountDownLatch(1);
        final AtomicReference<Integer> key = new AtomicReference<>();
        GridCompoundFuture<Void, Void> fut = new GridCompoundFuture<>();
        fut.add(GridTestUtils.runAsync(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                IgniteCache<Object, Object> cache = node0.cache(DEFAULT_CACHE_NAME);
                try (Transaction tx = node0.transactions().txStart()) {
                    key.set(primaryKey(cache));
                    cache.putIfAbsent(key.get(), "dummy val");
                    l1.countDown();
                    l2.await();
                    tx.commit();
                }
                return null;
            }
        }, "tx-1"));
        fut.add(GridTestUtils.runAsync(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                IgniteCache<Object, Object> cache = node1.cache(DEFAULT_CACHE_NAME);
                try (Transaction tx = node1.transactions().txStart()) {
                    l1.await();
                    cache.replace(key.get(), "dummy val2");
                    tx.commit();
                }
                return null;
            }
        }, "tx-2"));
        fut.markInitialized();
        U.sleep(10_000);
        assertFalse(fut.isDone());
        l2.countDown();
        fut.get();
        String log = strLog.toString();
        assertTrue(log.contains("Cache entries [cacheId=" + CU.cacheId(DEFAULT_CACHE_NAME) + ", cacheName=" + DEFAULT_CACHE_NAME + "]:"));
        assertTrue(log.contains("General node info [id=" + id0));
    } finally {
        System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
    }
}
Also used : GridStringLogger(org.apache.ignite.testframework.GridStringLogger) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) Callable(java.util.concurrent.Callable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Transaction(org.apache.ignite.transactions.Transaction) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 22 with GridStringLogger

use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.

the class ContinuousQueryRemoteFilterMissingInClassPathSelfTest method testWarningMessageOnClientNode.

/**
 * @throws Exception If fail.
 */
public void testWarningMessageOnClientNode() throws Exception {
    ldr = new URLClassLoader(URLS, getClass().getClassLoader());
    clientMode = false;
    setExternalLoader = true;
    final Ignite ignite0 = startGrid(1);
    executeContiniouseQuery(ignite0.cache("simple"));
    log = new GridStringLogger();
    clientMode = true;
    setExternalLoader = false;
    startGrid(2);
    assertTrue(log.toString().contains("Failed to unmarshal continuous query remote filter on client node. " + "Can be ignored."));
}
Also used : URLClassLoader(java.net.URLClassLoader) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite)

Example 23 with GridStringLogger

use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.

the class ContinuousQueryRemoteFilterMissingInClassPathSelfTest method testNoExceptionOnServerNode.

/**
 * @throws Exception If fail.
 */
public void testNoExceptionOnServerNode() throws Exception {
    ldr = new URLClassLoader(URLS, getClass().getClassLoader());
    clientMode = false;
    setExternalLoader = true;
    final Ignite ignite0 = startGrid(1);
    executeContiniouseQuery(ignite0.cache("simple"));
    log = new GridStringLogger();
    startGrid(2);
    assertTrue(!log.toString().contains("class org.apache.ignite.IgniteCheckedException: " + "Failed to find class with given class loader for unmarshalling"));
}
Also used : URLClassLoader(java.net.URLClassLoader) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite)

Example 24 with GridStringLogger

use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.

the class JdbcThinTransactionsSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings({ "deprecation", "unchecked" })
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setCacheConfiguration(cacheConfiguration(DEFAULT_CACHE_NAME).setNearConfiguration(null));
    cfg.setMarshaller(new BinaryMarshaller());
    cfg.setGridLogger(log = new GridStringLogger());
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) GridStringLogger(org.apache.ignite.testframework.GridStringLogger)

Example 25 with GridStringLogger

use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.

the class BinaryTypeMismatchLoggingTest method startGridWithLogCapture.

/**
 */
private IgniteEx startGridWithLogCapture() throws Exception {
    IgniteEx ignite = startGrid(0);
    this.capture = new GridStringLogger(false, this.log);
    GridTestUtils.setFieldValue(ignite.context().query(), GridProcessorAdapter.class, "log", capture);
    return ignite;
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) GridStringLogger(org.apache.ignite.testframework.GridStringLogger)

Aggregations

GridStringLogger (org.apache.ignite.testframework.GridStringLogger)37 Ignite (org.apache.ignite.Ignite)22 Test (org.junit.Test)16 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)14 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)9 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)9 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)9 UUID (java.util.UUID)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Transaction (org.apache.ignite.transactions.Transaction)5 URLClassLoader (java.net.URLClassLoader)4 IgniteCache (org.apache.ignite.IgniteCache)4 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)2 IgniteClusterEx (org.apache.ignite.internal.cluster.IgniteClusterEx)2 GridTestLog4jLogger (org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger)2 File (java.io.File)1 Callable (java.util.concurrent.Callable)1