use of com.alibaba.maxgraph.common.client.WorkerInfo 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.common.client.WorkerInfo in project GraphScope by alibaba.
the class InstanceInfo method toSimpleProto.
public InstanceInfoProto.Builder toSimpleProto() {
InstanceInfoProto.Builder builder = InstanceInfoProto.newBuilder();
PartitionProtos.Builder pBuilder = PartitionProtos.newBuilder();
for (Map.Entry<Integer, ServerAssignment> assignmentEntry : serverDataManager.partitionManager.assignments.entrySet()) {
pBuilder.clear();
pBuilder.addAllPartitionId(assignmentEntry.getValue().getPartitions());
builder.putAssignment(assignmentEntry.getKey(), pBuilder.build());
}
InstanceInfoProto.Status status = getInstanceServingStatus();
builder.setStatus(status);
try (LockWrapper ignore = lock.openReadLock()) {
WorkerInfoProtos.Builder wBuilder = WorkerInfoProtos.newBuilder();
for (Map.Entry<RoleType, Collection<WorkerInfo>> workerInfo : workerInfoMap.asMap().entrySet()) {
wBuilder.clear();
for (WorkerInfo info : workerInfo.getValue()) {
wBuilder.addInfos(info.toProto());
}
RoleType roleType = workerInfo.getKey();
builder.putWorkerInfos(roleType.getNumber(), wBuilder.build());
}
}
return builder;
}
use of com.alibaba.maxgraph.common.client.WorkerInfo in project GraphScope by alibaba.
the class ServerDataManager method startUpdateThread.
private void startUpdateThread() {
frontEndUpdateSchedule = new ScheduledThreadPoolExecutor(1, CommonUtil.createFactoryWithDefaultExceptionHandler("FrontEndUpdate_THREAD", LOG));
frontEndUpdateSchedule.scheduleWithFixedDelay(() -> {
Map<Integer, Endpoint> endpointMap = Maps.newHashMap();
for (WorkerInfo info : instanceInfo.getWorkerInfo(RoleType.FRONTEND)) {
endpointMap.put(info.id, info.endpoint);
}
if (!endpointMap.equals(this.endpointMap)) {
this.endpointMap = endpointMap;
StringBuilder sb = new StringBuilder();
for (Endpoint endpoint : this.endpointMap.values()) {
sb.append(endpoint.getIp()).append(":").append(endpoint.getGremlinServerPort()).append(" ");
}
String text = StringUtils.removeEnd(sb.toString(), " ");
try {
namingProxy.persistFrontEndEndpoints(vpcEndpoint, text);
} catch (Exception e) {
LOG.error("persist frontend ips error", e);
LOG.error("front ips info: {}", text);
}
}
}, 1, instanceConfig.getFrontendAmHbIntervalSeconds(), TimeUnit.SECONDS);
}
Aggregations