/** * @param ignite Grid. */ private void deployTask(Ignite ignite) { ignite.compute().localDeployTask(GridLoadTestTask.class, GridLoadTestTask.class.getClassLoader()); }
/** {@inheritDoc} */ @SuppressWarnings("BusyWait") @Override public void run() { try { while (end - System.currentTimeMillis() > 0) { Class<? extends ComputeTask<?, ?>> cls = loadTaskClass(); // info("Deploying class: " + cls); ignite.compute().localDeployTask(cls, cls.getClassLoader()); Thread.sleep(1000); } } catch (Exception e) { error("Failed to deploy grid task.", e); fail(); } }
/** * Create events in grid. * * @param ignite Grid. */ private void generateEvents(Ignite ignite) { ignite.compute().localDeployTask(GridEventTestTask.class, GridEventTestTask.class.getClassLoader()); ignite.compute().execute(GridEventTestTask.class.getName(), null); }
/** {@inheritDoc} */ @Override public Long execute() { Long arg = argument(0); assert arg != null; assert arg > 0; if (arg == 1) return 1L; ignite.compute().localDeployTask(FactorialTask.class, FactorialTask.class.getClassLoader()); return ignite.compute().execute(FactorialTask.class, arg); } }
@Override public void test(Factory factory, Ignite ignite) throws Exception { final int[] i = {-1}; final IgniteCompute comp = ignite.compute(); comp.localDeployTask(TestTask.class, TestTask.class.getClassLoader()); List<Object> results = ignite.compute().execute( TestTask.class.getName(), new T2<>((Factory<ComputeJobAdapter>)factory, (Factory<Object>)new Factory<Object>() { @Override public Object create() { return value(i[0]++); } })); checkResultsClassCount(MAX_JOB_COUNT - 1, results, value(0).getClass()); assertCollectionsEquals("Results value mismatch", createGoldenResults(), results); comp.undeployTask(TestTask.class.getName()); } });
/** * @throws Exception if failed. */ @Test 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++) checkTask(i); }
/** {@inheritDoc} */ @Override public Serializable execute() { Integer i = this.<Integer>argument(0); assert i != null && i > 0; if (i == 1) return new GridLoadTestJobTarget().executeLoadTestJob(1); assert ignite != null; ignite.compute().localDeployTask(GridLoadTestTask.class, GridLoadTestTask.class.getClassLoader()); return (Integer) ignite.compute().execute(GridLoadTestTask.class.getName(), i); } }
/** * @throws Exception if failed. */ @Test public void testSetAttribute() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().localDeployTask(GridTaskSessionTestTask.class, GridTaskSessionTestTask.class.getClassLoader()); for (int i = 0; i < EXEC_COUNT; i++) checkTask(i); }
/** {@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); }
/** * @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); }
/** * @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); }
/** */ @Test public void testFailoverTask() { isFailoverCalled1 = false; Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().localDeployTask(GridTestFailoverTask.class, GridTestFailoverTask.class.getClassLoader()); try { ignite.compute().execute(GridTestFailoverTask.class.getName(), new ComputeExecutionRejectedException("Task should be failed over")); assert false; } catch (IgniteException e) { //No-op } assert isFailoverCalled1; }
/** */ @Test public void testNoneFailoverTask() { isFailoverCalled2 = false; Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().localDeployTask(GridTestFailoverTask.class, GridTestFailoverTask.class.getClassLoader()); try { ignite.compute().execute(GridTestFailoverTask.class.getName(), new IgniteException("Task should NOT be failed over")); assert false; } catch (IgniteException e) { //No-op } assert !isFailoverCalled2; }
/** * @throws Exception If failed. */ @Test public void testAsynchronousTimeout() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().localDeployTask(GridTaskTimeoutTestTask.class, GridTaskTimeoutTestTask.class.getClassLoader()); ComputeTaskFuture<?> fut = executeAsync(ignite.compute().withTimeout(TIMEOUT), GridTaskTimeoutTestTask.class.getName(), null); // Allow timed out events to be executed. Thread.sleep(TIMEOUT + 500); checkTimedOutEvents(fut.getTaskSession().getId()); }
/** * @throws Exception If failed. */ @Test public void testFailoverJobSession() throws Exception { try { Ignite ignite1 = startGrid(1); startGrid(2); ignite1.compute().localDeployTask(SessionTestTask.class, SessionTestTask.class.getClassLoader()); Object res = ignite1.compute().execute(SessionTestTask.class.getName(), "1"); assert (Integer)res == 1; } finally { stopGrid(1); stopGrid(2); } }
/** * @throws Exception If test failed. */ @Test public void testFailover() throws Exception { Ignite ignite = startGrid(); try { ignite.compute().localDeployTask(GridFailoverTestTask.class, GridFailoverTestTask.class.getClassLoader()); ComputeTaskFuture<?> fut = ignite.compute().execute(GridFailoverTestTask.class.getName(), null); assert fut != null; fut.get(); assert false : "Should never be reached due to exception thrown."; } catch (ClusterTopologyException e) { info("Received correct exception: " + e); } finally { stopGrid(); } }
/** * @throws Exception If failed. */ @Test public void testSynchronousTimeout() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().localDeployTask(GridTaskTimeoutTestTask.class, GridTaskTimeoutTestTask.class.getClassLoader()); ComputeTaskFuture<?> fut = executeAsync(ignite.compute().withTimeout(TIMEOUT), GridTaskTimeoutTestTask.class.getName(), null); try { fut.get(); assert false : "ComputeTaskTimeoutException was not thrown (synchronous apply)"; } catch (ComputeTaskTimeoutException e) { info("Received expected timeout exception (synchronous apply): " + e); } Thread.sleep(TIMEOUT + 500); checkTimedOutEvents(fut.getTaskSession().getId()); }
/** * @throws Exception If failed. */ @Test public void testResultFailed() throws Exception { Ignite ignite = G.ignite(getTestIgniteInstanceName()); ignite.compute().localDeployTask(GridTaskFailedTestTask.class, GridTaskFailedTestTask.class.getClassLoader()); ComputeTaskFuture<?> fut = executeAsync(ignite.compute(), GridTaskFailedTestTask.class.getName(), FailType.RESULT); try { fut.get(); assert false; } catch (IgniteException e) { info("Got expected grid exception: " + e); } IgniteUuid sesId = fut.getTaskSession().getId(); // Query for correct events. List<Event> evts = ignite.events().remoteQuery(new TaskFailedEventFilter(sesId), 0); assert evts.size() == 1; info("Task failed event: " + evts.get(0)); }
/** * @throws Exception If failed. */ @Test public void testJobSetAttribute() throws Exception { try { Ignite ignite1 = startGrid(1); Ignite ignite2 = startGrid(2); ignite1.compute().localDeployTask(SessionTestTask.class, SessionTestTask.class.getClassLoader()); ComputeTaskFuture<?> fut = executeAsync(ignite1.compute(), SessionTestTask.class.getName(), ignite2.cluster().localNode().id()); fut.get(); } finally { stopGrid(1); stopGrid(2); } }
/** * @throws Exception If failed. */ @Test public void testIgnoreDeploymentSpi() throws Exception { // If peer class loading is disabled and local deployment SPI // is configured, SPI should be ignored. p2pEnabled = false; Ignite ignite = startGrid(getTestIgniteInstanceName()); try { ignite.compute().localDeployTask(GridDeploymentTestTask.class, GridDeploymentTestTask.class.getClassLoader()); assert depSpi.getRegisterCount() == 0 : "Invalid deploy count: " + depSpi.getRegisterCount(); assert depSpi.getUnregisterCount() == 0 : "Invalid undeploy count: " + depSpi.getUnregisterCount(); ignite.compute().undeployTask(GridDeploymentTestTask.class.getName()); assert depSpi.getRegisterCount() == 0 : "Invalid deploy count: " + depSpi.getRegisterCount(); assert depSpi.getUnregisterCount() == 0 : "Invalid undeploy count: " + depSpi.getUnregisterCount(); } finally { stopGrid(ignite); } }