use of com.alibaba.maxgraph.common.lock.LockWrapper 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.lock.LockWrapper 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;
}
Aggregations