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

The following examples show how to use org.apache.ignite.internal.IgniteEx#cacheNames() . 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: IgniteDecimalSelfTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param tabName Table name.
 * @return QueryEntity of table.
 */
private QueryEntity findTableInfo(String tabName) {
    IgniteEx ignite = grid(0);

    Collection<String> cacheNames = ignite.cacheNames();
    for (String cacheName : cacheNames) {
        CacheConfiguration ccfg = ignite.cache(cacheName).getConfiguration(CacheConfiguration.class);

        Collection<QueryEntity> entities = ccfg.getQueryEntities();

        for (QueryEntity entity : entities)
            if (entity.getTableName().equalsIgnoreCase(tabName))
                return entity;
    }

    return null;
}
 
Example 2
Source File: IgniteLogicalRecoveryTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Checks that cache contexts have consistent parameters after recovery finished and nodes have joined to topology.
 */
private void checkCacheContextsConsistencyAfterRecovery() throws Exception {
    IgniteEx crd = grid(0);

    Collection<String> cacheNames = crd.cacheNames();

    for (String cacheName : cacheNames) {
        for (int nodeIdx = 1; nodeIdx < 3; nodeIdx++) {
            IgniteEx node = grid(nodeIdx);

            GridCacheContext one = cacheContext(crd, cacheName);
            GridCacheContext other = cacheContext(node, cacheName);

            checkCacheContextsConsistency(one, other);
        }
    }
}
 
Example 3
Source File: RebalanceCancellationTest.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Finds all existed rebalance future by all cache for Ignite's instance specified.
 *
 * @param ignite Ignite.
 * @return Array of rebelance futures.
 */
private IgniteInternalFuture<Boolean>[] getAllRebalanceFutures(IgniteEx ignite) {
    IgniteInternalFuture<Boolean>[] futs = new IgniteInternalFuture[ignite.cacheNames().size()];

    int i = 0;

    for (String cache : ignite.cacheNames()) {
        futs[i] = grid(1).context().cache()
            .cacheGroup(CU.cacheId(cache)).preloader().rebalanceFuture();

        assertFalse(futInfoString(futs[i]), futs[i].isDone());

        i++;
    }
    return futs;
}
 
Example 4
Source File: IgniteLogicalRecoveryTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @param ignite Ignite.
 */
public AggregateCacheLoader(IgniteEx ignite) {
    this.ignite = ignite;

    List<CacheLoader> cacheLoaders = new ArrayList<>();

    for (String cacheName : ignite.cacheNames())
        cacheLoaders.add(new CacheLoader(ignite, cacheName));

    this.cacheLoaders = cacheLoaders;
}
 
Example 5
Source File: CacheMetricsAddRemoveTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** */
private void destroyCache() throws InterruptedException {
    IgniteEx client = grid("client");

    for (String name : client.cacheNames())
        client.destroyCache(name);

    awaitPartitionMapExchange();
}
 
Example 6
Source File: EncryptedCacheDestroyTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** */
private void checkCacheDestroyed(IgniteEx grid, String encCacheName, String grpName, boolean keyShouldBeEmpty)
    throws Exception {
    awaitPartitionMapExchange();

    Collection<String> cacheNames = grid.cacheNames();

    for (String cacheName : cacheNames) {
        if (cacheName.equals(encCacheName))
            fail(encCacheName + " should be destroyed.");
    }

    int grpId = CU.cacheGroupId(encCacheName, grpName);

    KeystoreEncryptionKey encKey = (KeystoreEncryptionKey)grid.context().encryption().groupKey(grpId);
    MetaStorage metaStore = grid.context().cache().context().database().metaStorage();

    if (keyShouldBeEmpty) {
        assertNull(encKey);

        assertNull(metaStore.readRaw(ENCRYPTION_KEY_PREFIX + grpId));
    } else {
        assertNotNull(encKey);

        assertNotNull(metaStore.readRaw(ENCRYPTION_KEY_PREFIX + grpId));
    }
}
 
Example 7
Source File: BreakRebalanceChainTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Finds all existed rebalance future by all cache for Ignite's instance specified.
 *
 * @param ignite Ignite.
 * @return Array of rebelance futures.
 */
private IgniteInternalFuture<Boolean>[] getAllRebalanceFutures(IgniteEx ignite) {
    IgniteInternalFuture<Boolean>[] futs = new IgniteInternalFuture[ignite.cacheNames().size()];

    int i = 0;

    for (String cache : ignite.cacheNames()) {
        futs[i] = ignite.context().cache().cacheGroup(CU.cacheId(cache)).preloader().rebalanceFuture();

        i++;
    }
    return futs;
}
 
Example 8
Source File: NotOptimizedRebalanceTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Finds all existed rebalance future by all cache for Ignite's instance specified.
 *
 * @param ignite Ignite.
 * @return Array of rebelance futures.
 */
private Map<CacheGroupContext, IgniteInternalFuture<Boolean>> getAllRebalanceFuturesByGroup(IgniteEx ignite) {
    HashMap<CacheGroupContext, IgniteInternalFuture<Boolean>> futs = new HashMap<>(ignite.cacheNames().size());

    for (String cache : ignite.cacheNames()) {
        IgniteInternalFuture<Boolean> fut = ignite.context().cache().cacheGroup(CU.cacheId(cache)).preloader().rebalanceFuture();

        futs.put(ignite.context().cache().cacheGroup(CU.cacheId(cache)), fut);
    }
    return futs;
}
 
Example 9
Source File: AbstractEncryptionTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/** */
void checkEncryptedCaches(IgniteEx grid0, IgniteEx grid1) {
    Set<String> cacheNames = new HashSet<>(grid0.cacheNames());

    cacheNames.addAll(grid1.cacheNames());

    for (String cacheName : cacheNames) {
        CacheConfiguration ccfg = grid1.cache(cacheName).getConfiguration(CacheConfiguration.class);

        if (!ccfg.isEncryptionEnabled())
            continue;

        IgniteInternalCache<?, ?> encrypted0 = grid0.cachex(cacheName);

        int grpId = CU.cacheGroupId(cacheName, ccfg.getGroupName());

        assertNotNull(encrypted0);

        IgniteInternalCache<?, ?> encrypted1 = grid1.cachex(cacheName);

        assertNotNull(encrypted1);

        assertTrue(encrypted1.configuration().isEncryptionEnabled());

        KeystoreEncryptionKey encKey0 = (KeystoreEncryptionKey)grid0.context().encryption().groupKey(grpId);

        assertNotNull(encKey0);
        assertNotNull(encKey0.key());

        if (!grid1.configuration().isClientMode()) {
            KeystoreEncryptionKey encKey1 = (KeystoreEncryptionKey)grid1.context().encryption().groupKey(grpId);

            assertNotNull(encKey1);
            assertNotNull(encKey1.key());

            assertEquals(encKey0.key(), encKey1.key());
        }
        else
            assertNull(grid1.context().encryption().groupKey(grpId));
    }

    checkData(grid0);
}
 
Example 10
Source File: NotOptimizedRebalanceTest.java    From ignite with Apache License 2.0 2 votes vote down vote up
/**
 * Trigger rebalance when node left topology.
 *
 * @param persistence Persistent flag.
 * @throws Exception If failed.
 */
public void testRebalance(boolean persistence, boolean serverJoin) throws Exception {
    persistenceEnabled = persistence;

    IgniteEx ignite0 = startGrids(NODES_CNT);

    ignite0.cluster().active(true);

    ignite0.cluster().baselineAutoAdjustEnabled(false);

    IgniteEx newNode = serverJoin ? startGrid(NODES_CNT) : startClientGrid(NODES_CNT);

    grid(1).close();

    for (String cache : ignite0.cacheNames())
        loadData(ignite0, cache);

    awaitPartitionMapExchange();

    TestRecordingCommunicationSpi commSpi1 = startNodeWithBlockingRebalance(getTestIgniteInstanceName(1));

    commSpi1.waitForBlocked();

    Map<CacheGroupContext, IgniteInternalFuture<Boolean>> futs = getAllRebalanceFuturesByGroup(grid(1));

    checkAllFuturesProcessing(futs);

    for (int i = 0; i < 3; i++) {
        newNode.close();

        checkTopology(NODES_CNT);

        newNode = serverJoin ? startGrid(NODES_CNT) : startClientGrid(NODES_CNT);

        checkTopology(NODES_CNT + 1);
    }

    if (serverJoin)
        checkAllFuturesCancelled(futs);
    else
        checkAllFuturesProcessing(futs);

    commSpi1.stopBlock();

    awaitPartitionMapExchange();

    Map<CacheGroupContext, IgniteInternalFuture<Boolean>> newFuts = getAllRebalanceFuturesByGroup(grid(1));

    for (Map.Entry<CacheGroupContext, IgniteInternalFuture<Boolean>> grpFut : futs.entrySet()) {
        IgniteInternalFuture<Boolean> fut = grpFut.getValue();
        IgniteInternalFuture<Boolean> newFut = newFuts.get(grpFut.getKey());

        if (serverJoin)
            assertTrue(futureInfoString(fut), fut.isDone() && !fut.get());
        else
            assertSame(fut, newFut);

        assertTrue(futureInfoString(newFut), newFut.isDone() && newFut.get());
    }
}