/** * @return Loaded class. * @throws Exception Thrown if any exception occurs. */ private Class<? extends ComputeTask<int[], ?>> loadTaskClass() throws Exception { return (Class<? extends ComputeTask<int[], ?>>)new GridTestExternalClassLoader(new URL[]{ new URL(GridTestProperties.getProperty("p2p.uri.cls"))}).loadClass(TASK_NAME); } }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration c = super.getConfiguration(igniteInstanceName); c.setDeploymentMode(depMode); if (igniteInstanceName.endsWith("1")) c.setCacheConfiguration(); // Empty cache configuration. else { assert igniteInstanceName.endsWith("2") || igniteInstanceName.endsWith("3"); CacheConfiguration cc = defaultCacheConfiguration(); cc.setCacheMode(PARTITIONED); GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(URLS); cc.setAffinity((AffinityFunction)ldr.loadClass(EXT_AFFINITY_CLS_NAME).newInstance()); cc.setAffinityMapper((AffinityKeyMapper)ldr.loadClass(EXT_AFFINITY_MAPPER_CLS_NAME) .newInstance()); c.setCacheConfiguration(cc); c.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, igniteInstanceName.endsWith("2") ? 0 : 1)); } return c; }
/** * @param depMode deployment mode. * @throws Exception If failed. */ private void processFilterTest(DeploymentMode depMode) throws Exception { this.depMode = depMode; try { Ignite ignite = startGrid(1); startGrid(2); ignite.compute().execute(GridP2PTestTask.class, 777); // Create events. String path = GridTestProperties.getProperty("p2p.uri.cls"); GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(new URL[] {new URL(path)}); Class filter1 = ldr.loadClass("org.apache.ignite.tests.p2p.GridP2PEventFilterExternalPath1"); Class filter2 = ldr.loadClass("org.apache.ignite.tests.p2p.GridP2PEventFilterExternalPath2"); ldr.setTimeout(100); ignite.events().remoteQuery((IgnitePredicate<Event>) filter1.newInstance(), 0); ldr.setTimeout(2000); try { ignite.events().remoteQuery((IgnitePredicate<Event>) filter2.newInstance(), 0); assert false; // Timeout exception must be thrown. } catch (IgniteException ignored) { // Throwing exception is a correct behaviour. } } finally { stopAllGrids(); } }
/** * @param depMode deployment mode. * @throws Exception If failed. */ @SuppressWarnings("unchecked") private void processTest(DeploymentMode depMode) throws Exception { this.depMode = depMode; try { Ignite g1 = startGrid(1); Ignite g2 = startGrid(2); String path = GridTestProperties.getProperty("p2p.uri.cls"); GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(new URL[] {new URL(path)}); Class task1 = ldr.loadClass("org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1"); Class task2 = ldr.loadClass("org.apache.ignite.tests.p2p.P2PTestTaskExternalPath2"); ldr.setTimeout(100); g1.compute().execute(task1, g2.cluster().localNode().id()); ldr.setTimeout(2000); try { g1.compute().execute(task2, g2.cluster().localNode().id()); assert false; // Timeout exception must be thrown. } catch (IgniteException ignored) { // Throwing exception is a correct behaviour. } } finally { stopAllGrids(); } }
/** * @param depMode deployment mode. * @throws Exception If failed. */ @SuppressWarnings("unchecked") private void processSize0Test(DeploymentMode depMode) throws Exception { this.depMode = depMode; missedRsrcCacheSize = 0; try { Ignite ignite1 = startGrid(1); Ignite ignite2 = startGrid(2); String path = GridTestProperties.getProperty("p2p.uri.cls"); info("Using path: " + path); GridTestExternalClassLoader ldr = new GridTestExternalClassLoader(new URL[] { new URL(path) }); Class task = ldr.loadClass(TASK_NAME1); ignite1.compute().localDeployTask(task, task.getClassLoader()); ldr.setExcludeClassNames(TASK_NAME1); executeFail(ignite1, ignite2, task); ldr.setExcludeClassNames(); ignite1.compute().execute(task, ignite2.cluster().localNode().id()); } finally { stopGrid(1); stopGrid(2); } }