use of com.alibaba.graphscope.groot.discovery.LocalNodeProvider in project GraphScope by alibaba.
the class Frontend method buildServiceServer.
private RpcServer buildServiceServer(Configs configs, BindableService... services) {
int port = FrontendConfig.FRONTEND_SERVICE_PORT.get(configs);
int threadCount = FrontendConfig.FRONTEND_SERVICE_THREAD_COUNT.get(configs);
int maxBytes = CommonConfig.RPC_MAX_BYTES_MB.get(configs) * 1024 * 1024;
NettyServerBuilder builder = NettyServerBuilder.forPort(port);
builder.executor(RpcUtils.createGrpcExecutor(threadCount)).maxInboundMessageSize(maxBytes);
String username = FrontendConfig.AUTH_USERNAME.get(configs);
String password = FrontendConfig.AUTH_PASSWORD.get(configs);
if (!username.isEmpty()) {
AuthorizationServerInterceptor interceptor = new AuthorizationServerInterceptor(Collections.singletonMap(username, password));
builder.intercept(interceptor);
}
LocalNodeProvider lnp = new LocalNodeProvider(RoleType.FRONTEND_SERVICE, configs);
return new RpcServer(builder, lnp, services);
}
use of com.alibaba.graphscope.groot.discovery.LocalNodeProvider in project GraphScope by alibaba.
the class LocalNodeProviderTest method testProvider.
@Test
void testProvider() {
RoleType role = RoleType.STORE;
int idx = 2;
int port = 1111;
Configs configs = Configs.newBuilder().put("role.name", role.getName()).put("node.idx", String.valueOf(idx)).put("discovery.mode", "zookeeper").build();
LocalNodeProvider localNodeProvider = new LocalNodeProvider(configs);
MaxGraphNode node = localNodeProvider.apply(port);
Assertions.assertAll(() -> assertEquals(node.getRoleName(), role.getName()), () -> assertEquals(node.getIdx(), idx), () -> assertEquals(node.getPort(), port));
assertThrows(MaxGraphException.class, () -> localNodeProvider.apply(port));
}
use of com.alibaba.graphscope.groot.discovery.LocalNodeProvider in project GraphScope by alibaba.
the class RpcServerTest method testRpcServer.
@Test
void testRpcServer() throws IOException {
int port = 1111;
Configs configs = Configs.newBuilder().put(CommonConfig.RPC_PORT.getKey(), String.valueOf(port)).put(CommonConfig.ROLE_NAME.getKey(), RoleType.STORE.getName()).put(CommonConfig.NODE_IDX.getKey(), "0").build();
LocalNodeProvider localNodeProvider = new LocalNodeProvider(configs);
RpcServer rpcServer = new RpcServer(configs, localNodeProvider);
rpcServer.start();
MaxGraphNode localNode = localNodeProvider.get();
assertEquals(port, localNode.getPort());
assertEquals(port, rpcServer.getPort());
rpcServer.stop();
}
use of com.alibaba.graphscope.groot.discovery.LocalNodeProvider in project GraphScope by alibaba.
the class ExecutorDiscoveryManagerTest method testExecutorServerStart.
@Test
void testExecutorServerStart() throws Exception {
try (TestingServer testingServer = new TestingServer(-1)) {
int zkPort = testingServer.getPort();
Configs configs = Configs.newBuilder().put(ZkConfig.ZK_CONNECT_STRING.getKey(), "localhost:" + zkPort).put(ZkConfig.ZK_BASE_PATH.getKey(), "test_discovery").build();
CuratorFramework curator = CuratorUtils.makeCurator(configs);
curator.start();
LocalNodeProvider engineServerProvider = new LocalNodeProvider(RoleType.EXECUTOR_ENGINE, configs);
NodeDiscovery engineServerDiscovery = new ZkDiscovery(configs, engineServerProvider, curator);
LocalNodeProvider storeQueryProvider = new LocalNodeProvider(RoleType.EXECUTOR_GRAPH, configs);
NodeDiscovery storeQueryDiscovery = new ZkDiscovery(configs, storeQueryProvider, curator);
LocalNodeProvider queryExecuteProvider = new LocalNodeProvider(RoleType.EXECUTOR_QUERY, configs);
NodeDiscovery queryExecuteDiscovery = new ZkDiscovery(configs, queryExecuteProvider, curator);
LocalNodeProvider queryManageProvider = new LocalNodeProvider(RoleType.EXECUTOR_MANAGE, configs);
NodeDiscovery queryManageDiscovery = new ZkDiscovery(configs, queryManageProvider, curator);
ExecutorDiscoveryManager executorDiscoveryManager = new ExecutorDiscoveryManager(engineServerProvider, engineServerDiscovery, storeQueryProvider, storeQueryDiscovery, queryExecuteProvider, queryExecuteDiscovery, queryManageProvider, queryManageDiscovery);
executorDiscoveryManager.getEngineServerProvider().apply(123);
executorDiscoveryManager.getEngineServerDiscovery().start();
executorDiscoveryManager.getQueryExecuteProvider().apply(1234);
executorDiscoveryManager.getQueryExecuteDiscovery().start();
}
}
use of com.alibaba.graphscope.groot.discovery.LocalNodeProvider in project GraphScope by alibaba.
the class ZkDiscoveryTest method createNodeDiscovery.
private NodeDiscovery createNodeDiscovery(RoleType role, int idx, int port, Configs zkConfigs, CuratorFramework curator) {
Configs nodeConfigs = Configs.newBuilder().put(CommonConfig.ROLE_NAME.getKey(), role.getName()).put(CommonConfig.NODE_IDX.getKey(), String.valueOf(idx)).build();
LocalNodeProvider localNodeProvider = new LocalNodeProvider(nodeConfigs);
localNodeProvider.apply(port);
return new ZkDiscovery(zkConfigs, localNodeProvider, curator);
}
Aggregations