try { log.info("Attempting to bootstrap node:{} with layout:{}", server, layout); IClientRouter router = new NettyClientRouter(NodeLocator.parseString(server), corfuRuntimeParameters); router.addClient(new LayoutHandler())
@Test public void nettyServerClientPingable() throws Exception { runWithBaseServer( (port) -> { return new NettyServerData(ServerContextBuilder.defaultContext(port)); }, (port) -> { return new NettyClientRouter("localhost", port); }, (r, d) -> { assertThat(getBaseClient(r).pingSync()) .isTrue(); }); }
@Test public void nettyServerClientHandshakeMismatchId() throws Exception { runWithBaseServer( (port) -> { return new NettyServerData(ServerContextBuilder.defaultContext(port)); }, (port) -> { NodeLocator nl = NodeLocator.builder() .host("localhost") .port(port) .nodeId(UUID.nameUUIDFromBytes("test".getBytes())) .build(); return new NettyClientRouter(nl, CorfuRuntimeParameters.builder().build()); }, (r, d) -> { assertThat(getBaseClient(r).pingSync()) .isFalse(); }); }
@Test public void nettyServerClientPingableAfterFailure() throws Exception { runWithBaseServer( (port) -> { return new NettyServerData(ServerContextBuilder.defaultContext(port)); }, (port) -> { return new NettyClientRouter("localhost", port); }, (r, d) -> { assertThat(getBaseClient(r).pingSync()) .isTrue(); d.shutdownServer(); d.bootstrapServer(); getBaseClient(r).pingSync(); }); }
@Test public void nettyServerClientHandshakeDefaultId() throws Exception { runWithBaseServer( (port) -> { return new NettyServerData(ServerContextBuilder.defaultContext(port)); }, (port) -> { NodeLocator nl = NodeLocator.builder() .host("localhost") .port(port) .nodeId(UUID.fromString("00000000-0000-0000-0000-000000000000")) .build(); return new NettyClientRouter(nl, CorfuRuntimeParameters.builder().build()); }, (r, d) -> { assertThat(getBaseClient(r).pingSync()) .isTrue(); }); }
NettyClientRouter clientRouter = new NettyClientRouter( NodeLocator.builder().host("localhost").port(port).build(), CorfuRuntimeParameters.builder() Files.copy(serverTrustWithClient.toPath(), serverTrustFile.toPath(), StandardCopyOption.REPLACE_EXISTING); clientRouter = new NettyClientRouter( NodeLocator.builder().host("localhost").port(port).build(), CorfuRuntimeParameters.builder()
@Test public void nettyServerClientHandshakeMatchIds() throws Exception { runWithBaseServer( (port) -> { ServerContext sc = ServerContextBuilder .defaultContext(port); nodeId = sc.getNodeId(); return new NettyServerData(sc); }, (port) -> { NodeLocator nl = NodeLocator.builder() .host("localhost") .port(port) .nodeId(nodeId) .build(); return new NettyClientRouter(nl, CorfuRuntimeParameters.builder().build()); }, (r, d) -> { assertThat(getBaseClient(r).pingSync()) .isTrue(); }); }
/** * Setup a cluster of 1 node. Bootstrap the node with a wrong layout. * Bootstrap the cluster using the BootstrapUtil. It should assert that the node already * bootstrapped is with the wrong layout and then fail with the AlreadyBootstrappedException. */ @Test public void test1NodeBootstrapWithWrongBootstrappedLayoutServer() throws Exception { // Set up cluster of 1 node. final int PORT_0 = 9000; Process corfuServer_1 = runPersistentServer(corfuSingleNodeHost, PORT_0, false); final Layout layout = getLayout(1); final int retries = 3; IClientRouter router = new NettyClientRouter(NodeLocator .parseString(corfuSingleNodeHost + ":" + PORT_0), CorfuRuntime.CorfuRuntimeParameters.builder().build()); router.addClient(new LayoutHandler()).addClient(new BaseHandler()); Layout wrongLayout = new Layout(layout); wrongLayout.getLayoutServers().add("localhost:9005"); retryBootstrapOperation(() -> CFUtils.getUninterruptibly( new LayoutClient(router, layout.getEpoch()).bootstrapLayout(wrongLayout))); assertThatThrownBy(() -> BootstrapUtil.bootstrap(layout, retries, PARAMETERS.TIMEOUT_SHORT)) .hasCauseInstanceOf(AlreadyBootstrappedException.class); shutdownCorfuServer(corfuServer_1); }
/** * Setup a cluster of 1 node. Bootstrap the node with a wrong layout. * Bootstrap the cluster using the BootstrapUtil. It should assert that the node already * bootstrapped is with the wrong layout and then fail with the AlreadyBootstrappedException. */ @Test public void test1NodeBootstrapWithWrongBootstrappedManagementServer() throws Exception { // Set up cluster of 1 node. final int PORT_0 = 9000; Process corfuServer_1 = runPersistentServer(corfuSingleNodeHost, PORT_0, false); final Layout layout = getLayout(1); final int retries = 3; IClientRouter router = new NettyClientRouter(NodeLocator .parseString(corfuSingleNodeHost + ":" + PORT_0), CorfuRuntime.CorfuRuntimeParameters.builder().build()); router.addClient(new LayoutHandler()) .addClient(new ManagementHandler()) .addClient(new BaseHandler()); Layout wrongLayout = new Layout(layout); final ManagementClient managementClient = new ManagementClient(router, layout.getEpoch()); wrongLayout.getLayoutServers().add("localhost:9005"); retryBootstrapOperation(() -> CFUtils.getUninterruptibly( managementClient.bootstrapManagement(wrongLayout))); assertThatThrownBy(() -> BootstrapUtil.bootstrap(layout, retries, PARAMETERS.TIMEOUT_SHORT)) .hasCauseInstanceOf(AlreadyBootstrappedException.class); shutdownCorfuServer(corfuServer_1); }
/** * Setup a cluster of 1 node. Bootstrap the nodes. * Bootstrap the cluster using the BootstrapUtil. It should assert that the node already * bootstrapped is with the same layout and then bootstrap the cluster. */ @Test public void test1NodeBootstrapWithBootstrappedNode() throws Exception { // Set up cluster of 1 nodes. final int PORT_0 = 9000; Process corfuServer_1 = runPersistentServer(corfuSingleNodeHost, PORT_0, false); final Layout layout = getLayout(1); final int retries = 5; IClientRouter router = new NettyClientRouter(NodeLocator .parseString(corfuSingleNodeHost + ":" + PORT_0), CorfuRuntime.CorfuRuntimeParameters.builder().build()); router.addClient(new LayoutHandler()).addClient(new BaseHandler()); retryBootstrapOperation(() -> CFUtils.getUninterruptibly( new LayoutClient(router, layout.getEpoch()).bootstrapLayout(layout))); retryBootstrapOperation(() -> CFUtils.getUninterruptibly( new ManagementClient(router, layout.getEpoch()).bootstrapManagement(layout))); BootstrapUtil.bootstrap(layout, retries, PARAMETERS.TIMEOUT_SHORT); CorfuRuntime corfuRuntime = createDefaultRuntime(); assertThat(corfuRuntime.getLayoutView().getLayout().equals(layout)).isTrue(); shutdownCorfuServer(corfuServer_1); }
}, (port) -> { return new NettyClientRouter( NodeLocator.builder().host("localhost").port(port).build(), CorfuRuntimeParameters.builder()
}, (port) -> { return new NettyClientRouter( NodeLocator.builder().host("localhost").port(port).build(), CorfuRuntimeParameters.builder()
return d; }, (port) -> new NettyClientRouter( NodeLocator.builder().host("localhost").port(port).build(), CorfuRuntimeParameters.builder()
}, (port) -> { return new NettyClientRouter( NodeLocator.builder().host("localhost").port(port).build(), CorfuRuntimeParameters.builder()
}, (port) -> { return new NettyClientRouter( NodeLocator.builder().host("localhost").port(port).build(), CorfuRuntimeParameters.builder()