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);
}
}
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");
}
}
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);
}
}
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);
}
}
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;
}
Aggregations