Search in sources :

Example 26 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class ClientAbstractMultiNodeSelfTest method testProjectionRun.

/**
     * @throws Exception If failed.
     */
public void testProjectionRun() throws Exception {
    GridClientCompute dflt = client.compute();
    Collection<? extends GridClientNode> nodes = dflt.nodes();
    assertEquals(NODES_CNT, nodes.size());
    for (int i = 0; i < NODES_CNT; i++) {
        Ignite g = grid(i);
        assert g != null;
        GridClientNode clientNode = dflt.node(g.cluster().localNode().id());
        assertNotNull("Client node for " + g.cluster().localNode().id() + " was not found", clientNode);
        GridClientCompute prj = dflt.projection(clientNode);
        String res = prj.execute(TestTask.class.getName(), null);
        assertNotNull(res);
        assertEquals(g.cluster().localNode().id().toString(), res);
    }
}
Also used : GridClientCompute(org.apache.ignite.internal.client.GridClientCompute) GridClientNode(org.apache.ignite.internal.client.GridClientNode) Ignite(org.apache.ignite.Ignite)

Example 27 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class IgnitePersistentStoreTest method blobStrategyTest.

/** */
@Test
public void blobStrategyTest() {
    Ignition.stopAll(true);
    Map<Long, Long> longMap = TestsHelper.generateLongsMap();
    Map<Long, Person> personMap = TestsHelper.generateLongsPersonsMap();
    LOGGER.info("Running BLOB strategy write tests");
    try (Ignite ignite = Ignition.start("org/apache/ignite/tests/persistence/blob/ignite-config.xml")) {
        IgniteCache<Long, Long> longCache = ignite.getOrCreateCache(new CacheConfiguration<Long, Long>("cache1"));
        IgniteCache<Long, Person> personCache = ignite.getOrCreateCache(new CacheConfiguration<Long, Person>("cache2"));
        LOGGER.info("Running single operation write tests");
        longCache.put(1L, 1L);
        personCache.put(1L, TestsHelper.generateRandomPerson(1L));
        LOGGER.info("Single operation write tests passed");
        LOGGER.info("Running bulk operation write tests");
        longCache.putAll(longMap);
        personCache.putAll(personMap);
        LOGGER.info("Bulk operation write tests passed");
    }
    LOGGER.info("BLOB strategy write tests passed");
    Ignition.stopAll(true);
    try (Ignite ignite = Ignition.start("org/apache/ignite/tests/persistence/blob/ignite-config.xml")) {
        LOGGER.info("Running BLOB strategy read tests");
        IgniteCache<Long, Long> longCache = ignite.getOrCreateCache(new CacheConfiguration<Long, Long>("cache1"));
        IgniteCache<Long, Person> personCache = ignite.getOrCreateCache(new CacheConfiguration<Long, Person>("cache2"));
        LOGGER.info("Running single operation read tests");
        Long longVal = longCache.get(1L);
        if (!longVal.equals(longMap.get(1L)))
            throw new RuntimeException("Long value was incorrectly deserialized from Cassandra");
        Person person = personCache.get(1L);
        if (!person.equals(personMap.get(1L)))
            throw new RuntimeException("Person value was incorrectly deserialized from Cassandra");
        LOGGER.info("Single operation read tests passed");
        LOGGER.info("Running bulk operation read tests");
        Map<Long, Long> longMap1 = longCache.getAll(longMap.keySet());
        if (!TestsHelper.checkMapsEqual(longMap, longMap1))
            throw new RuntimeException("Long values batch was incorrectly deserialized from Cassandra");
        Map<Long, Person> personMap1 = personCache.getAll(personMap.keySet());
        if (!TestsHelper.checkPersonMapsEqual(personMap, personMap1, false))
            throw new RuntimeException("Person values batch was incorrectly deserialized from Cassandra");
        LOGGER.info("Bulk operation read tests passed");
        LOGGER.info("BLOB strategy read tests passed");
        LOGGER.info("Running BLOB strategy delete tests");
        longCache.remove(1L);
        longCache.removeAll(longMap.keySet());
        personCache.remove(1L);
        personCache.removeAll(personMap.keySet());
        LOGGER.info("BLOB strategy delete tests passed");
    }
}
Also used : Ignite(org.apache.ignite.Ignite) Person(org.apache.ignite.tests.pojos.Person) Test(org.junit.Test)

Example 28 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class IgnitePersistentStoreTest method pojoStrategyTransactionTest.

/** */
@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);
    }
}
Also used : Ignite(org.apache.ignite.Ignite) Test(org.junit.Test)

Example 29 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class LoadTestDriver method createWorker.

/** */
@SuppressWarnings("unchecked")
private Worker createWorker(Class clazz, Object cfg, long startPosition, long endPosition) {
    try {
        Class cfgCls = cfg instanceof Ignite ? Ignite.class : CacheStore.class;
        Constructor ctor = clazz.getConstructor(cfgCls, long.class, long.class);
        return (Worker) ctor.newInstance(cfg, startPosition, endPosition);
    } catch (Throwable e) {
        logger().error("Failed to instantiate worker of class '" + clazz.getName() + "'", e);
        throw new RuntimeException("Failed to instantiate worker of class '" + clazz.getName() + "'", e);
    }
}
Also used : Constructor(java.lang.reflect.Constructor) Ignite(org.apache.ignite.Ignite)

Example 30 with Ignite

use of org.apache.ignite.Ignite in project ignite by apache.

the class ClientStartNodeTask method executeJob.

/** {@inheritDoc} */
@Override
protected Object executeJob(int gridSize, String type) {
    log.info(">>> Starting new grid node [currGridSize=" + gridSize + ", arg=" + type + "]");
    if (type == null)
        throw new IllegalArgumentException("Node type to start should be specified.");
    IgniteConfiguration cfg = getConfig(type);
    // Generate unique for this VM Ignite instance name.
    String igniteInstanceName = cfg.getIgniteInstanceName() + " (" + UUID.randomUUID() + ")";
    // Update Ignite instance name (required to be unique).
    cfg.setIgniteInstanceName(igniteInstanceName);
    // Start new node in current VM.
    Ignite g = G.start(cfg);
    log.info(">>> Grid started [nodeId=" + g.cluster().localNode().id() + ", name='" + g.name() + "']");
    return true;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Ignite(org.apache.ignite.Ignite)

Aggregations

Ignite (org.apache.ignite.Ignite)1560 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)275 CountDownLatch (java.util.concurrent.CountDownLatch)188 IgniteException (org.apache.ignite.IgniteException)187 Transaction (org.apache.ignite.transactions.Transaction)166 IgniteCache (org.apache.ignite.IgniteCache)161 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)161 ArrayList (java.util.ArrayList)135 ClusterNode (org.apache.ignite.cluster.ClusterNode)121 UUID (java.util.UUID)104 Event (org.apache.ignite.events.Event)104 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)98 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)97 CacheException (javax.cache.CacheException)94 HashMap (java.util.HashMap)78 IgniteKernal (org.apache.ignite.internal.IgniteKernal)71 Map (java.util.Map)61 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)61 Callable (java.util.concurrent.Callable)60 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)60