use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class Frontend method startRpcService.
protected void startRpcService() throws Exception {
String hostName = InetAddress.getLocalHost().getHostAddress();
int threadCount = this.instanceConfig.getFrontendGrpcThreadCount();
LOG.info("rpc server thread count: " + threadCount);
NettyServerBuilder serverBuilder = NettyServerBuilder.forAddress(new InetSocketAddress(hostName, 0)).executor(CommonUtil.getGrpcExecutor(threadCount)).maxInboundMessageSize(Constants.MAXGRAPH_RPC_MAX_MESSAGE_SIZE);
Server rpcServer = serverBuilder.build().start();
this.endpoint = new Endpoint(hostName, rpcServer.getPort(), gremlinServerPort);
LOG.info("frontend host: {}, port: {}, gremlin server port:{}", endpoint.getIp(), endpoint.getPort(), gremlinServerPort);
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class RemoteGraph method refresh.
@Override
public void refresh() throws Exception {
InstanceStatus serverStatuses = clientManager.getServerDataApiClient().getServerStatuses();
List<RemoteProxy> proxys = new ArrayList<>(serverStatuses.server2WorkerInfo.size());
Set<WorkerInfo> workerInfoSet = new TreeSet<>(serverStatuses.getWorkInfo(RoleType.EXECUTOR));
for (WorkerInfo v : workerInfoSet) {
if (serverStatuses.assignments.containsKey(v.id)) {
ServerAssignment serverAssignment = serverStatuses.readServerAssignment(v.id);
serverAssignment.getPartitions().forEach(p -> partitionDistri.put(p, v.id));
proxys.add(new RemoteProxy(v.endpoint.getIp(), v.endpoint.getPort(), 120L, schemaFetcher, this));
}
}
List<Endpoint> endpointList = workerInfoSet.stream().map(workerInfo -> workerInfo.endpoint).collect(toList());
LOG.info("proxys: {}", JSON.toJson(endpointList));
List<RemoteProxy> prevProxyList = this.proxys;
this.proxys = proxys;
try {
for (RemoteProxy remoteProxy : prevProxyList) {
remoteProxy.close();
}
} finally {
LOG.info("Close all previous remote proxy");
}
// TODO : dynamic configuration of different Graph Partitioner;
this.partitioner = new DefaultGraphPartitioner(schemaFetcher.getPartitionNum());
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class ServerDataApiClient method doRefresh.
@Override
protected void doRefresh() throws Exception {
closeChannel();
Endpoint endpoint = namingProxy.getCoordinatorEndpoint();
if (endpoint == null) {
throw new RuntimeException("graphName: " + graphName + " with zk:" + this.zkUtils.getZkUrl() + " has no " + "valid endpoint");
}
channel.set(RpcUtils.createChannel(endpoint.getIp(), endpoint.getPort()));
serverStub.set(ServerDataApiGrpc.newBlockingStub(channel.get()));
LOG.info("graph: {}, init server data api client, endpoint: {}", graphName, endpoint);
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class InstanceInfo method updateExecutorRuntimeEnv.
public List<String> updateExecutorRuntimeEnv(int serverId, String ip, int port) {
// TODO : Avoid to use a mutex write lock to guard a concurrent hash map ???.
try (LockWrapper ignore = lock.openWriteLock()) {
if (server2WorkerInfo.containsKey(serverId)) {
server2WorkerInfo.get(serverId).endpoint.setRuntimePort(port);
server2WorkerInfo.get(serverId).endpoint.updateIp(ip);
} else {
Endpoint endpoint = new Endpoint(ip, -1);
endpoint.setRuntimePort(port);
server2WorkerInfo.put(serverId, new WorkerInfo(serverId, endpoint, RoleType.EXECUTOR, WorkerStatus.RUNNING, StringUtils.EMPTY, System.currentTimeMillis()));
}
}
return getRuntimeEnv();
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class ServerDataApiServer method resendRequest.
void resendRequest(ServerHBReq request) throws Exception {
StoreStatus status = request.getStatus();
if (status == StoreStatus.INITIALING) {
LOG.debug("ignore initialing node");
return;
}
long heartbeatTime = System.currentTimeMillis();
int serverID = request.getId();
int nodeId = serverID - 1;
EndpointProto endpoint = request.getEndpoint();
NodeInfo nodeInfo = NodeInfo.newBuilder().setNodeId(NodeID.newBuilder().setRole(RoleType.STORE_NODE).setId(nodeId)).setHost(endpoint.getHost()).setPort(endpoint.getPort()).build();
NodeStateProto.Builder nodeStateBuilder = NodeStateProto.newBuilder();
for (Integer partition : serverDataManager.partitionManager.getServerAssignment(serverID).getPartitions()) {
nodeStateBuilder.putNodeStateMap(partition, StateList.newBuilder().addStates(ShardState.ONLINING_VALUE).build());
}
NodeStateProto nodeState = nodeStateBuilder.build();
masterService.updateNodeState(nodeInfo, heartbeatTime, nodeState);
}
Aggregations