case "isolationGroup": if (member.getValue() instanceof String) { obj.setIsolationGroup((String)member.getValue());
@Override public void resolve(String identifier, DeploymentOptions deploymentOptions, ClassLoader classLoader, Future<String> resolution) { if (failInResolve) { resolution.fail(new IOException("whatever")); } else { identifierToResolve = identifier; deploymentOptionsToResolve = deploymentOptions; // Now we change the deployment options deploymentOptions.setConfig(new JsonObject().put("wibble", "quux")); deploymentOptions.setWorker(true); deploymentOptions.setIsolationGroup(isolationGroup); resolution.complete(resolvedIdentifier); } }
@Test public void testExtraClasspathLoaderAlreadyInParentLoader() throws Exception { String dir = createClassOutsideClasspath("MyVerticle"); URLClassLoader loader = new URLClassLoader(new URL[]{new File(dir).toURI().toURL()}, Thread.currentThread().getContextClassLoader()); List<String> extraClasspath = Arrays.asList(dir); ClassLoader currentCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(loader); try { vertx.deployVerticle("java:" + ExtraCPVerticleAlreadyInParentLoader.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup"). setExtraClasspath(extraClasspath), ar -> { assertTrue(ar.succeeded()); testComplete(); }); } finally { Thread.currentThread().setContextClassLoader(currentCL); } await(); }
@Test(expected = IllegalArgumentException.class) public void testDeployInstanceSetIsolationGroup() throws Exception { vertx.deployVerticle(new MyVerticle(), new DeploymentOptions().setIsolationGroup("foo")); }
@Test public void testNullIsolationGroup() throws Exception { vertx.deployVerticle("java:" + TestVerticle.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup(null), ar -> { assertTrue(ar.succeeded()); assertEquals(1, TestVerticle.instanceCount.get()); testComplete(); }); await(); }
@Test public void testIsolationGroup1() throws Exception { boolean expectedSuccess = Thread.currentThread().getContextClassLoader() instanceof URLClassLoader; List<String> isolatedClasses = Arrays.asList(TestVerticle.class.getCanonicalName()); try { vertx.deployVerticle("java:" + TestVerticle.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup").setIsolatedClasses(isolatedClasses), ar -> { assertTrue(ar.succeeded()); assertEquals(0, TestVerticle.instanceCount.get()); testComplete(); }); assertTrue(expectedSuccess); await(); } catch (IllegalStateException e) { assertFalse(expectedSuccess); } }
try { vertx.deployVerticle(verticleID, new DeploymentOptions(). setIsolationGroup(group1).setIsolatedClasses(isolatedClasses), ar -> { assertTrue(ar.succeeded()); deploymentID1.set(ar.result()); assertEquals(0, TestVerticle.instanceCount.get()); vertx.deployVerticle(verticleID, new DeploymentOptions().setIsolationGroup(group2).setIsolatedClasses(isolatedClasses), ar2 -> { assertTrue(ar2.succeeded()); deploymentID2.set(ar2.result());
@Test public void testExtraClasspathLoaderNotInParentLoader() throws Exception { boolean expectedSuccess = Thread.currentThread().getContextClassLoader() instanceof URLClassLoader; String dir = createClassOutsideClasspath("MyVerticle"); List<String> extraClasspath = Arrays.asList(dir); try { vertx.deployVerticle("java:" + ExtraCPVerticleNotInParentLoader.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup"). setExtraClasspath(extraClasspath), ar -> { assertTrue(ar.succeeded()); testComplete(); }); assertTrue(expectedSuccess); await(); } catch (IllegalStateException e) { assertFalse(expectedSuccess); } }
vertx.registerVerticleFactory(factResolve); JsonObject config = new JsonObject().put("foo", "bar"); DeploymentOptions original = new DeploymentOptions().setWorker(false).setConfig(config).setIsolationGroup("somegroup"); DeploymentOptions options = new DeploymentOptions(original); vertx.deployVerticle("resolve:someid", options, res -> {
options.setConfig(config); options.setWorker(worker); options.setIsolationGroup(isolationGroup); options.setHa(ha); options.setExtraClasspath(cp);
options.setConfig(config); options.setWorker(worker); options.setIsolationGroup(isolationGroup); options.setHa(ha); options.setExtraClasspath(cp);
assertNull(options.getIsolationGroup()); String rand = TestUtils.randomUnicodeString(1000); assertEquals(options, options.setIsolationGroup(rand)); assertEquals(rand, options.getIsolationGroup()); assertFalse(options.isHa());
@Override public void resolve(String identifier, DeploymentOptions deploymentOptions, ClassLoader classLoader, Future<String> resolution) { if (failInResolve) { resolution.fail(new IOException("whatever")); } else { identifierToResolve = identifier; deploymentOptionsToResolve = deploymentOptions; // Now we change the deployment options deploymentOptions.setConfig(new JsonObject().put("wibble", "quux")); deploymentOptions.setWorker(true); deploymentOptions.setIsolationGroup(isolationGroup); resolution.complete(resolvedIdentifier); } }
@Test public void testExtraClasspathLoaderAlreadyInParentLoader() throws Exception { String dir = createClassOutsideClasspath("MyVerticle"); URLClassLoader loader = new URLClassLoader(new URL[]{new File(dir).toURI().toURL()}, Thread.currentThread().getContextClassLoader()); List<String> extraClasspath = Arrays.asList(dir); ClassLoader currentCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(loader); try { vertx.deployVerticle("java:" + ExtraCPVerticleAlreadyInParentLoader.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup"). setExtraClasspath(extraClasspath), ar -> { assertTrue(ar.succeeded()); testComplete(); }); } finally { Thread.currentThread().setContextClassLoader(currentCL); } await(); }
@Test(expected = IllegalArgumentException.class) public void testDeployInstanceSetIsolationGroup() throws Exception { vertx.deployVerticle(new MyVerticle(), new DeploymentOptions().setIsolationGroup("foo")); }
@Test public void testNullIsolationGroup() throws Exception { vertx.deployVerticle("java:" + TestVerticle.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup(null), ar -> { assertTrue(ar.succeeded()); assertEquals(1, TestVerticle.instanceCount.get()); testComplete(); }); await(); }
@Test public void testIsolationGroup1() throws Exception { boolean expectedSuccess = Thread.currentThread().getContextClassLoader() instanceof URLClassLoader; List<String> isolatedClasses = Arrays.asList(TestVerticle.class.getCanonicalName()); try { vertx.deployVerticle("java:" + TestVerticle.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup").setIsolatedClasses(isolatedClasses), ar -> { assertTrue(ar.succeeded()); assertEquals(0, TestVerticle.instanceCount.get()); testComplete(); }); assertTrue(expectedSuccess); await(); } catch (IllegalStateException e) { assertFalse(expectedSuccess); } }
@Test public void testExtraClasspathLoaderNotInParentLoader() throws Exception { boolean expectedSuccess = Thread.currentThread().getContextClassLoader() instanceof URLClassLoader; String dir = createClassOutsideClasspath("MyVerticle"); List<String> extraClasspath = Arrays.asList(dir); try { vertx.deployVerticle("java:" + ExtraCPVerticleNotInParentLoader.class.getCanonicalName(), new DeploymentOptions().setIsolationGroup("somegroup"). setExtraClasspath(extraClasspath), ar -> { assertTrue(ar.succeeded()); testComplete(); }); assertTrue(expectedSuccess); await(); } catch (IllegalStateException e) { assertFalse(expectedSuccess); } }
try { vertx.deployVerticle(verticleID, new DeploymentOptions(). setIsolationGroup(group1).setIsolatedClasses(isolatedClasses), ar -> { assertTrue(ar.succeeded()); deploymentID1.set(ar.result()); assertEquals(0, TestVerticle.instanceCount.get()); vertx.deployVerticle(verticleID, new DeploymentOptions().setIsolationGroup(group2).setIsolatedClasses(isolatedClasses), ar2 -> { assertTrue(ar2.succeeded()); deploymentID2.set(ar2.result());
vertx.registerVerticleFactory(factResolve); JsonObject config = new JsonObject().put("foo", "bar"); DeploymentOptions original = new DeploymentOptions().setWorker(false).setConfig(config).setIsolationGroup("somegroup"); DeploymentOptions options = new DeploymentOptions(original); vertx.deployVerticle("resolve:someid", options, res -> {