use of org.apache.ignite.Ignite in project ignite by apache.
the class GridSessionSetJobAttributeSelfTest method checkTask.
/**
* @param num Number.
* @throws IgniteCheckedException if failed.
*/
private void checkTask(int num) throws IgniteCheckedException {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
ComputeTaskFuture<?> fut = executeAsync(ignite.compute(), GridTaskSessionTestTask.class, num);
Object res = fut.get();
assert (Integer) res == SPLIT_COUNT - 1 : "Invalid result [num=" + num + ", fut=" + fut + ']';
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class GridSessionSetJobAttributeWaitListenerSelfTest method testSetAttribute.
/**
* @throws Exception If failed.
*/
public void testSetAttribute() throws Exception {
Ignite ignite = G.ignite(getTestIgniteInstanceName());
ignite.compute().localDeployTask(GridTaskSessionTestTask.class, GridTaskSessionTestTask.class.getClassLoader());
for (int i = 0; i < 5; i++) {
refreshInitialData();
ComputeTaskFuture<?> fut = ignite.compute().executeAsync(GridTaskSessionTestTask.class.getName(), null);
assert fut != null;
try {
// Wait until jobs begin execution.
boolean await = startSignal.await(WAIT_TIME, TimeUnit.MILLISECONDS);
assert await : "Jobs did not start.";
Object res = fut.get();
assert (Integer) res == SPLIT_COUNT : "Invalid result [i=" + i + ", fut=" + fut + ']';
} finally {
// We must wait for the jobs to be sure that they have completed
// their execution since they use static variable (shared for the tests).
fut.get();
}
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class LazyQuerySelfTest method checkSingleNode.
/**
* Check local query execution.
*
* @param parallelism Query parallelism.
* @throws Exception If failed.
*/
public void checkSingleNode(int parallelism) throws Exception {
Ignite srv = startGrid();
srv.createCache(cacheConfiguration(parallelism));
populateBaseQueryData(srv);
checkBaseOperations(srv);
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class GridMarshallerAbstractTest method testServices.
/**
* @throws Exception If failed.
*/
public void testServices() throws Exception {
IgniteConfiguration cfg = optimize(getConfiguration("g1"));
try (Ignite g1 = G.start(cfg)) {
IgniteServices services = grid().services(grid().cluster().forNode(g1.cluster().localNode()));
services.deployNodeSingleton("test", new DummyService());
GridMarshallerTestBean inBean = newTestBean(services);
byte[] buf = marshal(inBean);
GridMarshallerTestBean outBean = unmarshal(buf);
assert inBean.getObjectField() != null;
assert outBean.getObjectField() != null;
assert inBean.getObjectField().getClass().equals(IgniteServicesImpl.class);
assert outBean.getObjectField().getClass().equals(IgniteServicesImpl.class);
assert inBean != outBean;
assert inBean.equals(outBean);
ClusterGroup inPrj = services.clusterGroup();
ClusterGroup outPrj = ((IgniteServices) outBean.getObjectField()).clusterGroup();
assert inPrj.getClass().equals(outPrj.getClass());
assert F.eqNotOrdered(inPrj.nodes(), outPrj.nodes());
outBean.checkNullResources();
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class ComputeUtilsTest method testGetData.
/**
* Tests {@code getData()} method.
*/
public void testGetData() {
ClusterNode node = grid(1).cluster().localNode();
String upstreamCacheName = "CACHE_1_" + UUID.randomUUID();
String datasetCacheName = "CACHE_2_" + UUID.randomUUID();
CacheConfiguration<Integer, Integer> upstreamCacheConfiguration = new CacheConfiguration<>();
upstreamCacheConfiguration.setName(upstreamCacheName);
upstreamCacheConfiguration.setAffinity(new TestAffinityFunction(node));
IgniteCache<Integer, Integer> upstreamCache = ignite.createCache(upstreamCacheConfiguration);
CacheConfiguration<Integer, Integer> datasetCacheConfiguration = new CacheConfiguration<>();
datasetCacheConfiguration.setName(datasetCacheName);
datasetCacheConfiguration.setAffinity(new TestAffinityFunction(node));
IgniteCache<Integer, Integer> datasetCache = ignite.createCache(datasetCacheConfiguration);
upstreamCache.put(42, 42);
datasetCache.put(0, 0);
UUID datasetId = UUID.randomUUID();
IgniteAtomicLong cnt = ignite.atomicLong("CNT_" + datasetId, 0, true);
for (int i = 0; i < 10; i++) {
Collection<TestPartitionData> data = ComputeUtils.affinityCallWithRetries(ignite, Arrays.asList(datasetCacheName, upstreamCacheName), part -> ComputeUtils.<Integer, Integer, Serializable, TestPartitionData>getData(ignite, upstreamCacheName, datasetCacheName, datasetId, 0, (upstream, upstreamSize, ctx) -> {
cnt.incrementAndGet();
assertEquals(1, upstreamSize);
UpstreamEntry<Integer, Integer> e = upstream.next();
return new TestPartitionData(e.getKey() + e.getValue());
}), 0);
assertEquals(1, data.size());
TestPartitionData dataElement = data.iterator().next();
assertEquals(84, dataElement.val.intValue());
}
assertEquals(1, cnt.get());
}
Aggregations