Java Code Examples for org.apache.ignite.Ignite

The following examples show how to use org.apache.ignite.Ignite. These examples are extracted from open source projects. 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 Project: ignite   Source File: EventsExample.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Listen to events that happen only on local node.
 *
 * @throws IgniteException If failed.
 */
private static void localListen() throws IgniteException {
    System.out.println();
    System.out.println(">>> Local event listener example.");

    Ignite ignite = Ignition.ignite();

    IgnitePredicate<TaskEvent> lsnr = evt -> {
        System.out.println("Received task event [evt=" + evt.name() + ", taskName=" + evt.taskName() + ']');

        return true; // Return true to continue listening.
    };

    // Register event listener for all local task execution events.
    ignite.events().localListen(lsnr, EVTS_TASK_EXECUTION);

    // Generate task events.
    ignite.compute().withName("example-event-task").run(() -> System.out.println("Executing sample job."));

    // Unsubscribe local task event listener.
    ignite.events().stopLocalListen(lsnr);
}
 
Example 2
Source Project: ignite   Source File: IgniteWalReaderTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates and fills cache with data.
 *
 * @param ig Ignite instance.
 * @param mode Cache Atomicity Mode.
 */
private void createCache2(Ignite ig, CacheAtomicityMode mode) {
    if (log.isInfoEnabled())
        log.info("Populating the cache...");

    final CacheConfiguration<Integer, Organization> cfg = new CacheConfiguration<>("Org" + "11");
    cfg.setAtomicityMode(mode);
    final IgniteCache<Integer, Organization> cache = ig.getOrCreateCache(cfg).withKeepBinary()
        .withAllowAtomicOpsInTx();

    try (Transaction tx = ig.transactions().txStart()) {
        for (int i = 0; i < 10; i++) {

            cache.put(i, new Organization(i, "Organization-" + i));

            if (i % 2 == 0)
                cache.put(i, new Organization(i, "Organization-updated-" + i));

            if (i % 5 == 0)
                cache.remove(i);
        }
        tx.commit();
    }

}
 
Example 3
Source Project: ignite   Source File: GridCacheClearLocallySelfTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Startup routine.
 *
 * @throws Exception If failed.
 */
private void startUp() throws Exception {
    cachesLoc = (IgniteCache<Integer, Integer>[])Array.newInstance(IgniteCache.class, GRID_CNT);
    cachesPartitioned = (IgniteCache<Integer, Integer>[])Array.newInstance(IgniteCache.class, GRID_CNT);
    cachesColocated = (IgniteCache<Integer, Integer>[])Array.newInstance(IgniteCache.class, GRID_CNT);
    cachesReplicated = (IgniteCache<Integer, Integer>[])Array.newInstance(IgniteCache.class, GRID_CNT);

    for (int i = 0; i < GRID_CNT; i++) {
        Ignite ignite = startGrid(i);

        if (i == 1) {
            NearCacheConfiguration nearCfg = new NearCacheConfiguration();

            ignite.createNearCache(CACHE_PARTITIONED, nearCfg);
        }

        if (i == 2)
            ignite.cache(CACHE_PARTITIONED);

        cachesLoc[i] = ignite.cache(CACHE_LOCAL);
        cachesPartitioned[i] = ignite.cache(CACHE_PARTITIONED);
        cachesColocated[i] = ignite.cache(CACHE_COLOCATED);
        cachesReplicated[i] = ignite.cache(CACHE_REPLICATED);
    }
}
 
Example 4
/** */
@Test
public void testDestroyCacheWithSystemPermissions() throws Exception {
    SecurityPermissionSet secPermSet = builder()
        .appendSystemPermissions(CACHE_DESTROY)
        .build();

    grid(SRV).createCache(CACHE_NAME);

    try (Ignite node = startGrid(TEST_NODE, secPermSet, clientMode)) {
        assertThrowsWithCause(() -> forbidden(clientMode).destroyCache(CACHE_NAME), SecurityException.class);

        node.destroyCache(CACHE_NAME);

        assertNull(grid(SRV).cache(CACHE_NAME));
    }
}
 
Example 5
Source Project: ignite   Source File: ClosureServiceClientsNodesTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testClientClosure() throws Exception {
    for (int i = 0; i < NODES_CNT; i++) {
        log.info("Iteration: " + i);

        Ignite ignite = grid(i);

        Collection<String> res = ignite.compute(ignite.cluster().forClients()).
            broadcast(new IgniteCallable<String>() {
                @IgniteInstanceResource
                Ignite ignite;

                @Override public String call() throws Exception {
                    assertTrue(ignite.configuration().isClientMode());

                    return ignite.name();
                }
            });

        assertEquals(1, res.size());

        assertEquals(getTestIgniteInstanceName(CLIENT_IDX), F.first(res));
    }
}
 
Example 6
Source Project: ignite   Source File: CacheMvccTransactionsTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception if failed.
 */
@Test
public void testEmptyTx() throws Exception {
    Ignite node = startGrids(2);

    IgniteCache cache = node.createCache(cacheConfiguration(PARTITIONED, FULL_SYNC, 1, DFLT_PARTITION_COUNT));

    cache.putAll(Collections.emptyMap());

    IgniteTransactions txs = node.transactions();
    try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
        tx.commit();
    }
    finally {
        stopAllGrids();
    }
}
 
Example 7
/**
 * @param ignite Node.
 * @throws Exception If failed.
 * @return {@code True} if closed at least one session.
 */
static boolean closeSessions(Ignite ignite) throws Exception {
    TcpCommunicationSpi commSpi = (TcpCommunicationSpi)ignite.configuration().getCommunicationSpi();

    Map<UUID, GridCommunicationClient[]> clients = U.field(commSpi, "clients");

    boolean closed = false;

    for (GridCommunicationClient[] clients0 : clients.values()) {
        for (GridCommunicationClient client : clients0) {
            if (client != null) {
                GridTcpNioCommunicationClient client0 = (GridTcpNioCommunicationClient)client;

                GridNioSession ses = client0.session();

                ses.close();

                closed = true;
            }
        }
    }

    return closed;
}
 
Example 8
Source Project: ignite   Source File: IgnitePersistentStoreTest.java    License: Apache License 2.0 6 votes vote down vote up
/** */
@Test
public void pojoStrategyTransactionTest() {
    CassandraHelper.dropTestKeyspaces();

    Ignition.stopAll(true);

    try (Ignite ignite = Ignition.start("org/apache/ignite/tests/persistence/pojo/ignite-config.xml")) {
        pojoStrategyTransactionTest(ignite, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.READ_COMMITTED);
        pojoStrategyTransactionTest(ignite, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.REPEATABLE_READ);
        pojoStrategyTransactionTest(ignite, TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
        pojoStrategyTransactionTest(ignite, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.READ_COMMITTED);
        pojoStrategyTransactionTest(ignite, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.REPEATABLE_READ);
        pojoStrategyTransactionTest(ignite, TransactionConcurrency.PESSIMISTIC, TransactionIsolation.SERIALIZABLE);
    }
}
 
Example 9
/**
 * @param jobCls Job class.
 * @throws Exception If test failed.
 */
public void testContinuousJobAnnotation(Class<?> jobCls) throws Exception {
    try {
        Ignite ignite = startGrid(0);
        startGrid(1);

        fail.set(true);

        ignite.compute().execute(TestTask.class, jobCls);

        Exception e = err.get();

        if (e != null)
            throw e;
    }
    finally {
        stopGrid(0);
        stopGrid(1);
    }

    assertEquals(2, afterSendCnt.getAndSet(0));
    assertEquals(1, beforeFailoverCnt.getAndSet(0));
}
 
Example 10
public static void main(String[] args) {
    // Start Ignite cluster
    Ignite ignite = Ignition.start("default-config.xml");

    // get or create cache
    IgniteCache<Integer, Person> cache =  ignite.getOrCreateCache("testCache");
    Person p1 = new Person(37, "Shamim");
    Person p2 = new Person(2, "Mishel");
    Person p3 = new Person(55, "scott");
    Person p4 = new Person(5, "Tiger");

    cache.put(1, p1);
    cache.put(2, p2);
    cache.put(3, p3);
    cache.put(4, p4);

    System.out.println("Enter crtl-x to quite the application!!!");

}
 
Example 11
Source Project: ignite   Source File: TcpDiscoveryWithWrongServerTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Some simple sanity check with the Server and Client
 * It is expected that both client and server could successfully perform Discovery Procedure when there is
 * unknown (test) server in the ipFinder list.
 */
private void simpleTest() {
    try {
        Ignite srv = startGrid("server");
        Ignite client = startClientGrid("client");

        awaitPartitionMapExchange();

        assertEquals(2, srv.cluster().nodes().size());
        assertEquals(2, client.cluster().nodes().size());
        assertTrue(connCnt.get() >= 2);

        srv.getOrCreateCache(DEFAULT_CACHE_NAME).put(1, 1);

        assertEquals(1, client.getOrCreateCache(DEFAULT_CACHE_NAME).get(1));
    }
    catch (Exception e) {
        fail("Failed with unexpected exception: " + e.getMessage());
    }
}
 
Example 12
Source Project: ignite   Source File: AttributeNodeFilterSelfTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @throws Exception If failed.
 */
@Test
public void testClusterGroup() throws Exception {
    Ignite group1 = startGridsMultiThreaded(3);

    attrs = F.asMap("group", "data");

    Ignite group2 = startGridsMultiThreaded(3, 2);

    assertEquals(2, group1.cluster().forPredicate(new AttributeNodeFilter("group", "data")).nodes().size());
    assertEquals(2, group2.cluster().forPredicate(new AttributeNodeFilter("group", "data")).nodes().size());

    assertEquals(3, group1.cluster().forPredicate(new AttributeNodeFilter("group", null)).nodes().size());
    assertEquals(3, group2.cluster().forPredicate(new AttributeNodeFilter("group", null)).nodes().size());

    assertEquals(0, group1.cluster().forPredicate(new AttributeNodeFilter("group", "wrong")).nodes().size());
    assertEquals(0, group2.cluster().forPredicate(new AttributeNodeFilter("group", "wrong")).nodes().size());
}
 
Example 13
/**
 * @param nodes Nodes number.
 */
private void checkNoTemplateCaches(int nodes) {
    for (int i = 0; i < nodes; i++) {
        final Ignite ignite = grid(i);

        GridTestUtils.assertThrows(log, new Callable<Void>() {
            @Override public Void call() throws Exception {
                ignite.cache(GridCacheUtils.UTILITY_CACHE_NAME);

                return null;
            }
        }, IllegalStateException.class, null);

        assertNull(ignite.cache(TEMPLATE1));
        assertNull(ignite.cache(TEMPLATE2));
        assertNull(ignite.cache(TEMPLATE3));
    }
}
 
Example 14
public static void main(String[] args) throws IOException {

        try (Ignite ignite = Ignition.start(CLIENT_CONFIG)) {
            IgniteCompute compute = ignite.compute();
            CacheConfiguration cacheConfiguration = new CacheConfiguration("checkpoints");
            // explicitly uses of checkpoint
            CacheCheckpointSpi cacheCheckpointSpi = new CacheCheckpointSpi();
            cacheCheckpointSpi.setCacheName("checkpointCache");
            //cacheConfiguration.setC
            ignite.configuration().setCheckpointSpi(cacheCheckpointSpi)
                                  .setFailoverSpi(new AlwaysFailoverSpi());
            // create or get cache
            ignite.getOrCreateCache(cacheConfiguration);

            ValidateMessage[] validateMessages = TestDataGenerator.getValidateMessages();

            Boolean result = compute.execute(new ForkJoinWithCheckpointComputation(), validateMessages);
            System.out.println("final result=" + result);
        }
    }
 
Example 15
/**
 * @throws Exception If failed.
 */
@Test
public void testGetOrCreateCache() throws Exception {
    final Ignite ignite = grid(0);

    final String key = "key";
    final String val = "val";

    IgniteCache<String, String> cache = ignite.cache(DEFAULT_CACHE_NAME).withAllowAtomicOpsInTx();

    try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
        cache.put(key, val);

        GridTestUtils.assertThrows(log, new Callable<Object>() {
            @Override public Object call() throws Exception {
                ignite.getOrCreateCache("NEW_CACHE");

                return null;
            }
        }, IgniteException.class, EXPECTED_MSG);

        tx.commit();
    }
}
 
Example 16
Source Project: ignite   Source File: GridFactorySelfTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Tests named grid
 */
@Test
public void testNamedGridGetOrStart() throws Exception {
    IgniteConfiguration cfg = getConfiguration("test");
    try (Ignite ignite = Ignition.getOrStart(cfg)) {
        try {
            Ignition.start(cfg);

            fail("Expected exception after grid started");
        }
        catch (IgniteException ignored) {
            // No-op.
        }

        Ignite ignite2 = Ignition.getOrStart(cfg);

        assertEquals("Must return same instance", ignite, ignite2);
    }

    assertTrue(G.allGrids().isEmpty());
}
 
Example 17
Source Project: ignite   Source File: SecuritySubjectPermissionsTest.java    License: Apache License 2.0 6 votes vote down vote up
/** */
@Test
public void test() throws Exception {
    Ignite srv = startGrid("srv", ALLOW_ALL, false);

    Permissions perms = new Permissions();
    // Permission that Ignite and subject do have.
    perms.add(new TestPermission("common"));
    // Permission that Ignite does not have.
    perms.add(new TestPermission("only_subject"));

    Ignite clnt = startGrid("clnt", ALLOW_ALL, perms, true);

    srv.cluster().active(true);

    clnt.compute().broadcast(() -> securityManager().checkPermission(new TestPermission("common")));

    assertThrowsWithCause(() -> clnt.compute().broadcast(
        () -> {
            securityManager().checkPermission(new TestPermission("only_subject"));

            fail();
        }),
        AccessControlException.class);
}
 
Example 18
/**
 * @throws Exception If failed.
 */
@Test
public void testEvict() throws Exception {
    Ignite ignite1 = startGrid(1);

    IgniteCache<Object, Object> cache = ignite1.cache(DEFAULT_CACHE_NAME).withExpiryPolicy(new CreatedExpiryPolicy(
        new Duration(TimeUnit.MILLISECONDS, 100L)));

    // Putting entry.
    for (int i = 0; i < KEYS; i++)
        cache.put(i, i);

    // Wait when entry
    U.sleep(200);

    // Check that entry is evicted from cache, but local store does contain it.
    for (int i = 0; i < KEYS; i++) {
        cache.localEvict(Arrays.asList(i));

        assertNull(cache.localPeek(i));

        assertEquals(i, (int)LOCAL_STORE_1.load(i).get1());

        assertEquals(i, cache.get(i));
    }
}
 
Example 19
Source Project: ignite   Source File: GridCacheReloadSelfTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Actual test logic.
 *
 * @throws Exception If error occurs.
 */
private void doTest() throws Exception {
    Ignite ignite = startGrid();

    try {
        IgniteCache<Integer, Integer> cache = ignite.cache(CACHE_NAME);

        for (int i = 0; i < N_ENTRIES; i++)
            load(cache, i, true);

        assertEquals(MAX_CACHE_ENTRIES, cache.size(CachePeekMode.ONHEAP));
    }
    finally {
        stopGrid();
    }
}
 
Example 20
Source Project: ignite   Source File: CacheExchangeMergeTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param crd Exchange coordinator.
 * @param topVer Exchange topology version.
 */
private void blockExchangeFinish(Ignite crd, long topVer) {
    final AffinityTopologyVersion topVer0 = new AffinityTopologyVersion(topVer);

    TestRecordingCommunicationSpi.spi(crd).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
        @Override public boolean apply(ClusterNode node, Message msg) {
            if (msg instanceof GridDhtPartitionsFullMessage) {
                GridDhtPartitionsFullMessage msg0 = (GridDhtPartitionsFullMessage)msg;

                return msg0.exchangeId() != null && msg0.exchangeId().topologyVersion().equals(topVer0);
            }

            return false;
        }
    });
}
 
Example 21
/**
 * @throws Exception If failed.
 */
@Test
public void testMultiCacheAffinityRunAsync() throws Exception {
    runTest(runnableFactories, new ComputeTest() {
        @Override public void test(Factory factory, Ignite ignite) throws Exception {
            ignite.getOrCreateCache("test0");
            ignite.getOrCreateCache("test1");

            final IgniteCompute comp = ignite.compute();

            for (int i = 0; i < MAX_JOB_COUNT; ++i) {
                IgniteRunnable job = (IgniteRunnable)factory.create();

                IgniteFuture<Void> fut = comp.affinityRunAsync(Arrays.asList("test0", "test1"), key(0), job);

                fut.get();
            }
        }
    });
}
 
Example 22
Source Project: ignite   Source File: CacheMvccStreamingInsertTest.java    License: Apache License 2.0 6 votes vote down vote up
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
    super.beforeTest();

    Ignite ignite = startGrid(0);
    sqlNexus = ignite.getOrCreateCache(new CacheConfiguration<>("sqlNexus").setSqlSchema("PUBLIC"));
    sqlNexus.query(q("" +
        "create table person(" +
        "  id int not null primary key," +
        "  name varchar not null" +
        ") with \"atomicity=transactional_snapshot\""
    ));

    Properties props = new Properties();
    props.setProperty(IgniteJdbcDriver.PROP_STREAMING, "true");
    conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1", props);
}
 
Example 23
/**
 * @param ig Ignite instance.
 * @param stopFlag Stop flag.
 * @param start Load key start index.
 * @return Completion future.
 */
private IgniteInternalFuture<?> loadAsync(Ignite ig, AtomicBoolean stopFlag, int start) {
    AtomicInteger generator = new AtomicInteger(start);

    return GridTestUtils.runMultiThreadedAsync(new GridPlainRunnable() {
        @Override public void run() {
            IgniteCache<Integer, TestValue> cache = ig.cache(CACHE_NAME);

            while (!stopFlag.get()) {
                int idx = generator.getAndAdd(100);

                Map<Integer, TestValue> putMap = new HashMap<>(100, 1.f);

                for (int i = 0; i < 100; i++)
                    putMap.put(idx + i, new TestValue(idx + i));

                cache.putAll(putMap);
            }
        }
    }, Runtime.getRuntime().availableProcessors(), "load-runner");
}
 
Example 24
Source Project: ignite   Source File: SqlStatisticsAbstractTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Start the cache with a test table and test data.
 */
protected IgniteCache createCacheFrom(Ignite node) {
    CacheConfiguration<Integer, String> ccfg = new CacheConfiguration<Integer, String>(DEFAULT_CACHE_NAME)
        .setSqlFunctionClasses(SuspendQuerySqlFunctions.class)
        .setQueryEntities(Collections.singleton(
            new QueryEntity(Integer.class.getName(), String.class.getName())
                .setTableName("TAB")
                .addQueryField("id", Integer.class.getName(), null)
                .addQueryField("name", String.class.getName(), null)
                .setKeyFieldName("id")
                .setValueFieldName("name")
        ));

    IgniteCache<Integer, String> cache = node.createCache(ccfg);

    try (IgniteDataStreamer<Object, Object> ds = node.dataStreamer(DEFAULT_CACHE_NAME)) {
        for (int i = 0; i < TABLE_SIZE; i++)
            ds.addData(i, UUID.randomUUID().toString());
    }

    return cache;
}
 
Example 25
/**
 * @throws Exception If failed.
 */
@SuppressWarnings("ThrowableNotThrown")
@Test
public void testMvccModeMismatchForGroup2() throws Exception {
    final Ignite node = startGrid(0);

    node.createCache(
        new CacheConfiguration("cache1").setGroupName("grp1").setAtomicityMode(TRANSACTIONAL_SNAPSHOT));

    GridTestUtils.assertThrows(log, new Callable<Void>() {
        @Override public Void call() {
            node.createCache(new CacheConfiguration("cache2").setGroupName("grp1").setAtomicityMode(ATOMIC));

            return null;
        }
    }, CacheException.class, null);

    node.createCache(
        new CacheConfiguration("cache2").setGroupName("grp1").setAtomicityMode(TRANSACTIONAL_SNAPSHOT));
}
 
Example 26
Source Project: ignite   Source File: ClientStopNodeTask.java    License: Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override public Object execute() {
    log.info(">>> Stop node [nodeId=" + ignite.cluster().localNode().id() + ", name='" + ignite.name() + "']");

    String prefix = ClientStartNodeTask.getConfig(gridType).getIgniteInstanceName() + " (";

    if (!ignite.name().startsWith(prefix)) {
        int stoppedCnt = 0;

        for (Ignite g : G.allGrids())
            if (g.name().startsWith(prefix)) {
                try {
                    log.info(">>> Grid stopping [nodeId=" + g.cluster().localNode().id() +
                        ", name='" + g.name() + "']");

                    G.stop(g.name(), true);

                    stoppedCnt++;
                }
                catch (IllegalStateException e) {
                    log.warning("Failed to stop grid.", e);
                }
            }

        return stoppedCnt;
    }

    return 0;
}
 
Example 27
/**
 * Blocks tx recovery between all nodes.
 */
protected void blockRecovery() {
    for (Ignite grid : G.allGrids()) {
        if (grid.configuration().isClientMode())
            continue;

        TestRecordingCommunicationSpi.spi(grid).blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
            @Override public boolean apply(ClusterNode clusterNode, Message msg) {
                return msg instanceof GridCacheTxRecoveryRequest;
            }
        });
    }
}
 
Example 28
/** {@inheritDoc} */
@Override public Void process(MutableEntry<Integer, Integer> entry, Object... args) {
    Ignite ignite = entry.unwrap(Ignite.class);

    System.out.println(Thread.currentThread().getName() + " process [node=" + ignite.name() +
        ", commit=" + commit + ", skipFirst=" + skipFirst + ']');

    boolean skip = false;

    if (commit && ignite.name().equals(skipFirst)) {
        skipFirst = null;

        skip = true;
    }

    if (!skip && commit && nodeNames.contains(ignite.name())) {
        try {
            System.out.println(Thread.currentThread().getName() + " start process invoke.");

            assertTrue(commitStartedLatch != null && commitStartedLatch.getCount() > 0);

            commitStartedLatch.countDown();

            assertTrue(commitFinishLatch.await(10, SECONDS));

            System.out.println(Thread.currentThread().getName() + " end process invoke.");
        }
        catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
    else
        System.out.println(Thread.currentThread().getName() + " invoke set value.");

    entry.setValue(1);

    return null;
}
 
Example 29
Source Project: ignite   Source File: CacheGetRemoveSkipStoreTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @throws Exception if failed.
 */
private void checkNoNullReads(Ignite client, CacheConfiguration<Integer, Integer> ccfg) throws Exception {
    client.getOrCreateCache(ccfg);

    try {
        checkNoNullReads(client.cache(ccfg.getName()), 0);
        checkNoNullReads(grid(0).cache(ccfg.getName()), primaryKey(grid(0).cache(ccfg.getName())));

        if (ccfg.getBackups() > 0)
            checkNoNullReads(grid(0).cache(ccfg.getName()), backupKey(grid(0).cache(ccfg.getName())));
    }
    finally {
        client.destroyCache(ccfg.getName());
    }
}
 
Example 30
Source Project: ignite   Source File: GridCommonAbstractTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get or create instance of cache specified by K,V types;
 * new instance of cache is created
 *
 * @param ig Ignite.
 * @param ccfg Cache configuration.
 * @param name Cache name.
 * @return cache instance
 */
@SuppressWarnings("unchecked")
protected <K, V> IgniteCache<K, V> jcache(Ignite ig,
    CacheConfiguration ccfg,
    @NotNull String name) {
    CacheConfiguration<K, V> cc = new CacheConfiguration<>(ccfg);
    cc.setName(name);

    return ig.getOrCreateCache(cc);
}