Search in sources :

Example 1 with RuntimeEnvList

use of com.alibaba.maxgraph.proto.RuntimeEnvList in project GraphScope by alibaba.

the class WorkerManagerApiServerTest method testReadRuntimeEnvsFromBinary.

@Test
public void testReadRuntimeEnvsFromBinary() throws InvalidProtocolBufferException {
    String logDir = "";
    InstanceInfo instanceInfo = new InstanceInfo();
    instanceInfo.setWorkerInfo(RoleType.EXECUTOR, 0, new Endpoint("127.0.0.1", 1, 2), logDir);
    instanceInfo.setWorkerInfo(RoleType.EXECUTOR, 1, new Endpoint("127.0.0.1", 1, 2), logDir);
    instanceInfo.setWorkerInfo(RoleType.EXECUTOR, 2, new Endpoint("127.0.0.1", 1, 2), logDir);
    instanceInfo.setWorkerInfo(RoleType.EXECUTOR, 3, new Endpoint("127.0.0.1", 1, 2), logDir);
    instanceInfo.updateExecutorRuntimeEnv(0, "127.0.0.1", 3);
    instanceInfo.updateExecutorRuntimeEnv(1, "127.0.0.1", 4);
    instanceInfo.updateExecutorRuntimeEnv(2, "127.0.0.1", 5);
    List<String> envs = instanceInfo.updateExecutorRuntimeEnv(3, "127.0.0.1", 6);
    RuntimeEnvList.Builder builder = RuntimeEnvList.newBuilder();
    envs.forEach(builder::addEnvs);
    byte[] binary = builder.build().toByteArray();
    RuntimeEnvList envList = RuntimeEnvList.parseFrom(binary);
    List<String> envs2 = Lists.newArrayList(envList.getEnvsList().iterator());
    Assert.assertEquals(envs2, Lists.newArrayList("127.0.0.1:3", "127.0.0.1:4", "127.0.0.1:5", "127.0.0.1:6"));
}
Also used : RuntimeEnvList(com.alibaba.maxgraph.proto.RuntimeEnvList) Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) InstanceInfo(com.alibaba.maxgraph.coordinator.manager.InstanceInfo) Test(org.junit.Test)

Aggregations

InstanceInfo (com.alibaba.maxgraph.coordinator.manager.InstanceInfo)1 RuntimeEnvList (com.alibaba.maxgraph.proto.RuntimeEnvList)1 Endpoint (com.alibaba.maxgraph.sdkcommon.client.Endpoint)1 Test (org.junit.Test)1