Java Code Examples for org.apache.ignite.internal.IgniteEx#name()

The following examples show how to use org.apache.ignite.internal.IgniteEx#name() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlQueriesTopologyMappingTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/** */
private void checkQueryWithNodeFilter(CacheMode cacheMode) throws Exception {
    IgniteEx ign0 = startGrid(0);
    String name0 = ign0.name();

    IgniteCache<Object, Object> cache = ign0.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME)
        .setCacheMode(cacheMode)
        .setNodeFilter(node -> name0.equals(node.attribute(ATTR_IGNITE_INSTANCE_NAME)))
        .setIndexedTypes(Integer.class, Integer.class));

    cache.put(1, 2);

    startGrid(1);
    startClientGrid(10);

    for (Ignite ign : G.allGrids()) {
        List<List<?>> res = ign.cache(DEFAULT_CACHE_NAME)
            .query(new SqlFieldsQuery("select * from Integer")).getAll();

        assertEquals(1, res.size());
        assertEqualsCollections(Arrays.asList(1, 2), res.get(0));
    }
}
 
Example 2
Source File: SystemWorkersTerminationTest.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testSyntheticWorkerTermination() throws Exception {
    IgniteEx ignite = grid(0);

    WorkersRegistry registry = ignite.context().workersRegistry();

    long fdTimeout = ignite.configuration().getFailureDetectionTimeout();

    GridWorker worker = new GridWorker(ignite.name(), "test-worker", log, registry) {
        @Override protected void body() throws InterruptedException {
            Thread.sleep(fdTimeout / 2);
        }
    };

    IgniteThread thread = new IgniteThread(worker);

    failureHndThreadName = null;

    thread.start();

    thread.join();

    assertTrue(GridTestUtils.waitForCondition(() -> thread.getName().equals(failureHndThreadName), fdTimeout * 2));
}
 
Example 3
Source File: RebuildIndexLogMessageTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/** */
@Test
public void testRebuildIndexLogMessage() throws Exception {
    IgniteEx ignite = startGrids(1);

    String gridName = ignite.name();

    ignite.cluster().active(true);

    IgniteCache<Integer, Person> cacheA = ignite.getOrCreateCache(CACHE_NAME_A);
    IgniteCache<Integer, Person> cacheB = ignite.getOrCreateCache(CACHE_NAME_B);

    IgniteInternalCache<Integer, Person> cacheAEx = ignite.cachex(CACHE_NAME_A);
    IgniteInternalCache<Integer, Person> cacheBEx = ignite.cachex(CACHE_NAME_B);

    for (int i = 0; i < 100; i++)
        cacheA.put(i, new Person(i, i));

    for (int i = 0; i < 100; i++)
        cacheB.put(i, new Person(i, i));

    forceCheckpoint();

    File cacheAWorkDir = ((FilePageStoreManager)cacheAEx.context().shared().pageStore())
        .cacheWorkDir(cacheAEx.configuration());
    File cacheBWorkDir = ((FilePageStoreManager)cacheBEx.context().shared().pageStore())
        .cacheWorkDir(cacheBEx.configuration());

    File idxPathA = cacheAWorkDir.toPath().resolve("index.bin").toFile();
    File idxPathB = cacheBWorkDir.toPath().resolve("index.bin").toFile();

    stopAllGrids();

    assertTrue(U.delete(idxPathA));
    assertTrue(U.delete(idxPathB));

    ignite = startGrid(getConfiguration(gridName));

    ignite.cluster().active(true);

    cacheA = ignite.getOrCreateCache(CACHE_NAME_A);
    cacheB = ignite.getOrCreateCache(CACHE_NAME_B);

    cacheA.put(1000, new Person(1000, 1));
    cacheB.put(1000, new Person(1000, 1));

    checkLatch.await(60, TimeUnit.SECONDS);

    if (checkLatch.getCount() > 0)
        throw new TimeoutException("Test timed out: cannot detect log message about completion of indexes rebuilding");

    assertTrue(logLsnr.check());
}