use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class ZkNamingProxy method persistEndpointToZK.
private void persistEndpointToZK(String zkPath, String hostName, int port) throws Exception {
Endpoint endpoint = new Endpoint(hostName, port);
String serverInfo = JSON.toJson(endpoint);
zkUtils.createOrUpdatePath(zkPath, serverInfo, CreateMode.EPHEMERAL);
LOG.info("update coordinator endpoint in zk success:{}", endpoint);
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class DataStatus method fromProto.
public static DataStatus fromProto(ServerHBReq serverHBReq) {
int serverId = serverHBReq.getId();
Endpoint endpoint = Endpoint.fromProto(serverHBReq.getEndpoint());
RuntimeHBReq runtimeHBReq = serverHBReq.getRuntimeReq();
StoreStatus storeStatus = serverHBReq.getStatus();
return new DataStatus(serverId, endpoint, storeStatus, runtimeHBReq);
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class ClientManager method startCoordinatorNodeCache.
private void startCoordinatorNodeCache() throws Exception {
ExecutorService pool = Executors.newFixedThreadPool(1);
final NodeCache nodeCache = new NodeCache(this.serverDataApiClient.getZkNamingProxy().getZkClient(), ZKPaths.getCoordinatorPath(instanceConfig.getGraphName()), false);
nodeCache.start(true);
nodeCache.getListenable().addListener(() -> {
if (nodeCache.getCurrentData() == null || StringUtils.isEmpty(Arrays.toString(nodeCache.getCurrentData().getData()))) {
LOG.info("coordinator node not exist in zk");
} else {
try {
Endpoint newEndpoint = JSON.fromJson(new String(nodeCache.getCurrentData().getData()), Endpoint.class);
LOG.info("current coordinator endpoint:{}", newEndpoint);
startCoordinatorRelatedClient(newEndpoint);
} catch (Exception e) {
LOG.warn("{}", e);
}
}
}, pool);
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class ClientManager method updateGroupExecutors.
public void updateGroupExecutors() {
int replicaCount = this.instanceConfig.getReplicaCount();
List<List<Endpoint>> endpointGroups = new ArrayList<>(replicaCount);
int executorCnt = this.instanceConfig.getResourceExecutorCount() / replicaCount;
for (int r = 0; r < replicaCount; r++) {
List<Endpoint> endpoints = new ArrayList<>();
for (int i = 0; i < executorCnt; i++) {
endpoints.add(executorEndpointMap.get(r * executorCnt + i + 1));
}
endpointGroups.add(endpoints);
}
this.endpointGroupsRef.set(endpointGroups);
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class ExecutorAddressFetcher method getAddressList.
@Override
public List<RpcAddress> getAddressList() {
List<RpcAddress> rpcAddressList = Lists.newArrayList();
for (int i = 1; i <= clientManager.getExecutorCount(); i++) {
Endpoint endpoint = clientManager.getExecutor(i);
rpcAddressList.add(new RpcAddress(endpoint.getIp(), endpoint.getPort()));
}
return rpcAddressList;
}
Aggregations