/** * Roulette Wheel selection * * @param map Map of keys/fitness scores * @return List of primary Keys for respective chromosomes that will breed */ private List<Long> selectByRouletteWheel(LinkedHashMap map) { List<Long> populationKeys = this.ignite.compute().execute(new RouletteWheelSelectionTask(this.cfg), map); return populationKeys; }
/** * @param prj Projection. * @return {@link org.apache.ignite.IgniteCompute} for given projection. */ protected IgniteCompute compute(ClusterGroup prj) { return prj.ignite().compute(prj); }
/** * @param ignite Grid. * @param taskName Task name. * @return {@code True} if task is not deployed. */ private boolean checkUndeployed(Ignite ignite, String taskName) { return ignite.compute().localTasks().get(taskName) == null; }
/** * @throws Exception If test failed. */ @Test public void testMany() throws Exception { ignite1.compute().execute(GridCacheLoadPopulationTask.class, null); } }
@Override public void test(Factory factory, Ignite ignite) throws Exception { Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT); for (int i = 0; i < MAX_JOB_COUNT; ++i) { // value(i - 1): use negative argument of the value method to generate nullong value. results.add(ignite.compute().apply((IgniteClosure<Object, Object>)factory.create(), value(i - 1))); } checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); } });
/** * Called to remove object from cache without regard to transaction. * * @param ignite Grid. * @param cache Cache. * @param key Key. */ public static void evict(Ignite ignite, HibernateCacheProxy cache, Object key) { key = cache.keyTransformer().transform(key); ignite.compute(ignite.cluster()).call(new ClearKeyCallable(key, cache.name())); }
@Override public void test(Factory factory, Ignite ignite) throws Exception { Collection<EchoCallable> jobs = new ArrayList<>(MAX_JOB_COUNT); for (int i = 0; i < MAX_JOB_COUNT; ++i) { EchoCallable job = (EchoCallable)factory.create(); job.setArg(value(i - 1)); jobs.add(job); } Collection<Object> results = ignite.compute().call(jobs); checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); } });
@Override public void test(Factory factory, Ignite ignite) throws Exception { Collection<Object> results = new ArrayList<>(MAX_JOB_COUNT); for (int i = 0; i < MAX_JOB_COUNT; ++i) { EchoCallable job = (EchoCallable)factory.create(); job.setArg(value(i - 1)); results.add(ignite.compute().call(job)); } checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); } });
/** * @param num Number. */ private void checkTask(int num) { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ComputeTaskFuture<?> fut = ignite.compute().executeAsync(GridTaskSessionTestTask.class.getName(), num); Object res = fut.get(); assert (Integer)res == SPLIT_COUNT : "Invalid result [num=" + num + ", fut=" + fut + ']'; }
@Override public void test(Factory factory, Ignite ignite) throws Exception { Collection<EchoCallable> jobs = new ArrayList<>(MAX_JOB_COUNT); for (int i = 0; i < MAX_JOB_COUNT; ++i) { EchoCallable job = (EchoCallable)factory.create(); job.setArg(value(i - 1)); jobs.add(job); } IgniteFuture<Collection<Object>> fut = ignite.compute().callAsync(jobs); checkResultsClassCount(MAX_JOB_COUNT - 1, fut.get(), value(0).getClass()); assertCollectionsEquals("Results value mismatch", createGoldenResults(), fut.get()); } });
/** * @throws Exception If failed. */ @Test public void testTaskMap() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); info("Executing sync mapped task."); ignite.compute().execute(SyncMappedTask.class, null); info("Executing async mapped task."); ignite.compute().execute(AsyncMappedTask.class, null); }
@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"), 0, job); fut.get(); } } });
/** * @param ignite Grid. * @param taskName Task name. * @return {@code true} if task has been deployed on passed grid. */ private boolean checkDeployed(Ignite ignite, String taskName) { Map<String, Class<? extends ComputeTask<?, ?>>> locTasks = ignite.compute().localTasks(); if (log().isInfoEnabled()) log().info("Local tasks found: " + locTasks); return locTasks.get(taskName) != null; }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { ignite = G.ignite(getTestIgniteInstanceName()); long tstamp = startTimestamp(); ignite.compute().localDeployTask(GridAllEventsTestTask.class, GridAllEventsTestTask.class.getClassLoader()); List<Event> evts = pullEvents(tstamp, 1); assertEvent(evts.get(0).type(), EVT_TASK_DEPLOYED, evts); }
/** */ private void checkExecuteException(IgniteException resE) throws Exception { try (Ignite ignite = startGrid()) { IgniteCompute compute = ignite.compute(); try { compute.execute(new ResultExceptionTask(resE), null); } catch (IgniteException e) { assertSame(resE, e); } } }
/** * @throws Exception if failed. */ @Test public void testSetAttribute() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().localDeployTask(GridTaskSessionTestTask.class, GridTaskSessionTestTask.class.getClassLoader()); refreshInitialData(); for (int i = 0; i < EXEC_COUNT; i++) checkTask(i); }
@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(); } } });
/** * Starts computation job. * * @param idx Grid index on which computation job should start. * @param restartIdx The index of the node to be restarted. * @param workersCntr The current number of computation threads. */ private void startComputation(int idx, AtomicInteger restartIdx, AtomicInteger workersCntr) { Ignite ignite = grid(idx); ClusterGroup cg = ignite.cluster().forLocal(); ignite.compute(cg).callAsync(new BinaryObjectAdder(startLatch, idx, updatesQueue, restartIdx, workersCntr)); }
/** * @throws Exception If failed. */ @Test public void testNoCacheResultMethodUsage() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().withNoResultCache() .execute(GridResultNoCacheResultMethodTestTask.class, "Grid Result No Cache Method Test Argument"); }
@Override public void run() { doSleep(1000); //spi1.failSend = false; cnt.getAndAdd(c1.compute(c1.cluster().forNodeId(c2.cluster().localNode().id())).call(new TestClosure())); } }, 1, "hang-thread");