Search in sources :

Example 6 with WorkerInfo

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();
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) WorkerInfo(com.alibaba.maxgraph.common.client.WorkerInfo) LockWrapper(com.alibaba.maxgraph.common.lock.LockWrapper)

Example 7 with WorkerInfo

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;
}
Also used : WorkerInfo(com.alibaba.maxgraph.common.client.WorkerInfo) LockWrapper(com.alibaba.maxgraph.common.lock.LockWrapper) ConcurrentMap(java.util.concurrent.ConcurrentMap) ServerAssignment(com.alibaba.maxgraph.common.ServerAssignment)

Example 8 with WorkerInfo

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);
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) WorkerInfo(com.alibaba.maxgraph.common.client.WorkerInfo)

Aggregations

WorkerInfo (com.alibaba.maxgraph.common.client.WorkerInfo)8 LockWrapper (com.alibaba.maxgraph.common.lock.LockWrapper)5 Endpoint (com.alibaba.maxgraph.sdkcommon.client.Endpoint)5 ServerAssignment (com.alibaba.maxgraph.common.ServerAssignment)2 InstanceStatus (com.alibaba.maxgraph.common.InstanceStatus)1 InstanceConfig (com.alibaba.maxgraph.common.cluster.InstanceConfig)1 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 SchemaFetcher (com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher)1 IteratorList (com.alibaba.maxgraph.iterator.IteratorList)1 RoleType (com.alibaba.maxgraph.proto.RoleType)1 CompositeId (com.alibaba.maxgraph.sdkcommon.graph.CompositeId)1 ElementId (com.alibaba.maxgraph.sdkcommon.graph.ElementId)1 JSON (com.alibaba.maxgraph.sdkcommon.util.JSON)1 DefaultGraphPartitioner (com.alibaba.maxgraph.structure.DefaultGraphPartitioner)1 Edge (com.alibaba.maxgraph.structure.Edge)1 GraphPartitioner (com.alibaba.maxgraph.structure.GraphPartitioner)1 IdManager (com.alibaba.maxgraph.structure.IdManager)1 Vertex (com.alibaba.maxgraph.structure.Vertex)1 MaxGraph (com.alibaba.maxgraph.structure.graph.MaxGraph)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1