Search in sources :

Example 36 with GridStringLogger

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

the class IgniteDiagnosticMessagesTest method checkLongRunning.

/**
 * @param atomicityMode Cache atomicity mode.
 * @throws Exception If failed.
 */
public void checkLongRunning(CacheAtomicityMode atomicityMode) throws Exception {
    System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500");
    try {
        testSpi = true;
        startGrid(0);
        GridStringLogger strLog = this.strLog = new GridStringLogger();
        strLog.logLength(1024 * 100);
        startGrid(1);
        awaitPartitionMapExchange();
        CacheConfiguration ccfg = cacheConfiguration(atomicityMode);
        final Ignite node0 = ignite(0);
        node0.createCache(ccfg);
        final Ignite node1 = ignite(1);
        UUID id0 = node0.cluster().localNode().id();
        TestRecordingCommunicationSpi.spi(node0).blockMessages(GridNearSingleGetResponse.class, node1.name());
        IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Integer key = primaryKey(node0.cache(DEFAULT_CACHE_NAME));
                node1.cache(DEFAULT_CACHE_NAME).get(key);
                return null;
            }
        }, "get");
        U.sleep(10_000);
        assertFalse(fut.isDone());
        TestRecordingCommunicationSpi.spi(node0).stopBlock();
        fut.get();
        String log = strLog.toString();
        assertTrue(log.contains("GridPartitionedSingleGetFuture waiting for response [node=" + id0));
        assertTrue(log.contains("General node info [id=" + id0));
    } finally {
        System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 37 with GridStringLogger

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

the class IgniteUidAsConsistentIdMigrationTest method testOldStyleNodeWithUnexpectedPort.

/**
 * Test case If there are no matching folders,
 * but the directory contains old-style consistent IDs.
 * Ignite should print out a warning.
 *
 * @throws Exception if failed.
 */
@Test
public void testOldStyleNodeWithUnexpectedPort() throws Exception {
    // emulated old-style node with not appropriate consistent ID
    this.configuredConsistentId = "127.0.0.1:49999";
    final Ignite ignite = startActivateFillDataGrid(0);
    final IgniteCache<Object, Object> second = ignite.getOrCreateCache("second");
    final int entries = 100;
    for (int i = 0; i < entries; i++) second.put((int) (Math.random() * entries), getClass().getName());
    final String prevVerFolder = U.maskForFileName(ignite.cluster().localNode().consistentId().toString());
    final String path = new File(new File(U.defaultWorkDirectory(), "db"), prevVerFolder).getCanonicalPath();
    assertPdsDirsDefaultExist(prevVerFolder);
    stopAllGrids();
    this.configuredConsistentId = null;
    this.strLog = new GridStringLogger();
    startActivateGrid(0);
    // one 0 index folder is created
    assertNodeIndexesInFolder(0);
    final String wholeNodeLog = strLog.toString();
    stopAllGrids();
    String foundWarning = null;
    for (String line : wholeNodeLog.split("\n")) {
        if (line.contains("There is other non-empty storage folder under storage base directory")) {
            foundWarning = line;
            break;
        }
    }
    if (foundWarning != null)
        log.info("\nWARNING generated successfully [\n" + foundWarning + "\n]");
    assertTrue("Expected to warn user on existence of old style path", foundWarning != null);
    assertTrue("Expected to warn user on existence of old style path [" + path + "]", foundWarning.contains(path));
    assertTrue("Expected to print some size for [" + path + "]", Pattern.compile(" [0-9]* bytes").matcher(foundWarning).find());
    strLog = null;
    startActivateGrid(0);
    // one 0 index folder is created
    assertNodeIndexesInFolder(0);
    stopAllGrids();
}
Also used : GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite) File(java.io.File) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

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