use of com.alibaba.maxgraph.common.client.WorkerInfo 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.common.client.WorkerInfo in project GraphScope by alibaba.
the class InstanceInfo method setServerStatus.
/**
* can't modify runtime port when update executor hb
*
* @param serverStatus
*/
public void setServerStatus(DataStatus serverStatus) {
try (LockWrapper ignore = lock.openWriteLock()) {
WorkerInfo newWorkerInfo = new WorkerInfo(serverStatus);
int serverId = serverStatus.serverId;
if (server2WorkerInfo.containsKey(serverId)) {
WorkerInfo originWorkerInfo = server2WorkerInfo.get(serverId);
workerInfoMap.remove(RoleType.EXECUTOR, originWorkerInfo);
newWorkerInfo.endpoint.setRuntimePort(originWorkerInfo.endpoint.getRuntimePort());
newWorkerInfo.endpoint.updateIp(serverStatus.endpoint.getIp());
if (originWorkerInfo.workerStatus == WorkerStatus.LOST || originWorkerInfo.workerStatus == WorkerStatus.RESTARTING) {
logSchedulerEvent(serverId, LogEvents.ScheduleEvent.WORKER_RESUME_RUNNING, "worker " + serverId + " running again at " + CommonUtil.getCurrentDate());
}
}
workerInfoMap.put(RoleType.EXECUTOR, newWorkerInfo);
server2WorkerInfo.put(serverStatus.serverId, newWorkerInfo);
}
}
use of com.alibaba.maxgraph.common.client.WorkerInfo in project GraphScope by alibaba.
the class InstanceInfo method setWorkerInfo.
public void setWorkerInfo(RoleType roleType, int workerId, Endpoint endpoint, String logDir) {
WorkerInfo workerInfo = new WorkerInfo(workerId, endpoint, roleType, WorkerStatus.RUNNING, logDir, System.currentTimeMillis());
try (LockWrapper ignore = lock.openWriteLock()) {
workerInfoMap.remove(roleType, workerInfo);
workerInfoMap.put(roleType, workerInfo);
if (server2WorkerInfo.containsKey(workerId)) {
WorkerInfo originWorkerInfo = server2WorkerInfo.get(workerId);
if (originWorkerInfo.workerStatus == WorkerStatus.LOST || originWorkerInfo.workerStatus == WorkerStatus.RESTARTING) {
logSchedulerEvent(workerId, LogEvents.ScheduleEvent.WORKER_RESUME_RUNNING, "worker " + workerId + " running again at " + CommonUtil.getCurrentDate());
}
}
server2WorkerInfo.put(workerId, workerInfo);
}
}
use of com.alibaba.maxgraph.common.client.WorkerInfo in project GraphScope by alibaba.
the class InstanceInfo method getCurrentRouting.
public List<Integer> getCurrentRouting() {
List<Integer> routingServerIds = new ArrayList<>();
Set<WorkerInfo> workerInfoSet = getWorkerInfo(RoleType.EXECUTOR);
Map<Integer, Set<WorkerInfo>> groupWorkerInfo = new HashMap<>();
for (WorkerInfo workerInfo : workerInfoSet) {
int serverId = workerInfo.dataStatus.serverId;
int groupId = getGroupId(serverId);
Set<WorkerInfo> workerInfos = groupWorkerInfo.computeIfAbsent(groupId, k -> new HashSet<>());
workerInfos.add(workerInfo);
}
for (int i = 0; i < replicaCount; i++) {
Set<WorkerInfo> workerInfos = groupWorkerInfo.get(i);
if (workerInfos == null || workerInfos.size() != executorCount / replicaCount) {
// bad group
LOG.error("Invalid group: " + i + ". expected " + executorCount / replicaCount + ", but workers are: " + workerInfos);
continue;
}
boolean badGroup = false;
for (WorkerInfo workerInfo : workerInfos) {
if (workerInfo.workerStatus != WorkerStatus.RUNNING) {
// bad group
LOG.error("Invalid group: " + i + ". WorkerInfo: " + workerInfo);
badGroup = true;
break;
}
}
if (badGroup) {
continue;
}
routingServerIds.add(i * nodesPerGroup + 1);
}
return routingServerIds;
}
use of com.alibaba.maxgraph.common.client.WorkerInfo in project GraphScope by alibaba.
the class InstanceInfo method updateWorkerStatus.
public void updateWorkerStatus(int workerId, WorkerStatus newStatus) {
try (LockWrapper ignore = lock.openWriteLock()) {
if (server2WorkerInfo.containsKey(workerId)) {
WorkerInfo originWorkerInfo = server2WorkerInfo.get(workerId);
WorkerInfo newWorkerInfo;
if (originWorkerInfo.roleType == RoleType.EXECUTOR && originWorkerInfo.dataStatus != null) {
newWorkerInfo = new WorkerInfo(originWorkerInfo.dataStatus, newStatus);
} else {
newWorkerInfo = new WorkerInfo(workerId, originWorkerInfo.endpoint, originWorkerInfo.roleType, newStatus, originWorkerInfo.logDir, originWorkerInfo.lastReportTime);
}
workerInfoMap.remove(originWorkerInfo.roleType, originWorkerInfo);
workerInfoMap.put(originWorkerInfo.roleType, newWorkerInfo);
server2WorkerInfo.put(workerId, newWorkerInfo);
}
}
}
Aggregations