Search in sources :

Example 1 with ExecutorInfo

use of org.apache.mesos.Protos.ExecutorInfo in project incubator-myriad by apache.

the class ByteBufferSupportTest method testExecutorInfoToFromByteBuffer.

public void testExecutorInfoToFromByteBuffer() throws Exception {
    ExecutorInfo info = getExecutorInfo();
    ByteBuffer bb = ByteBufferSupport.toByteBuffer(task);
    ExecutorInfo bInfo = ByteBufferSupport.toExecutorInfo(bb);
    assertEquals(info.getClass().getName(), bInfo.getClass().getName());
}
Also used : ExecutorInfo(org.apache.mesos.Protos.ExecutorInfo) ByteBuffer(java.nio.ByteBuffer)

Example 2 with ExecutorInfo

use of org.apache.mesos.Protos.ExecutorInfo in project dcos-commons by mesosphere.

the class TaskPackingUtils method unpack.

/**
 * This method reverses the work done in {@link TaskPackingUtils#pack(TaskInfo)} such that the original TaskInfo is
 * regenerated. If the provided {@link TaskInfo} doesn't appear to have packed data then this operation does
 * nothing.
 *
 * @see #pack(TaskInfo)
 */
public static TaskInfo unpack(TaskInfo taskInfo) {
    if (!taskInfo.hasData() || !taskInfo.hasExecutor()) {
        return taskInfo;
    } else {
        TaskInfo.Builder taskBuilder = TaskInfo.newBuilder(taskInfo);
        ExecutorInfo pkgExecutorInfo;
        try {
            pkgExecutorInfo = ExecutorInfo.parseFrom(taskInfo.getData());
        } catch (InvalidProtocolBufferException e) {
            // ExecutorInfo. Let's assume this means that the TaskInfo isn't packed and return it as-is.
            return taskInfo;
        }
        if (pkgExecutorInfo.hasCommand()) {
            taskBuilder.setCommand(pkgExecutorInfo.getCommand());
        }
        if (pkgExecutorInfo.hasData()) {
            taskBuilder.setData(pkgExecutorInfo.getData());
        } else {
            taskBuilder.clearData();
        }
        return taskBuilder.build();
    }
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) ExecutorInfo(org.apache.mesos.Protos.ExecutorInfo) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 3 with ExecutorInfo

use of org.apache.mesos.Protos.ExecutorInfo in project elastic-job by dangdangdotcom.

the class TaskExecutorTest method assertRegisteredWithoutData.

@Test
public void assertRegisteredWithoutData() {
    // CHECKSTYLE:OFF
    HashMap<String, String> data = new HashMap<>(4, 1);
    // CHECKSTYLE:ON
    data.put("event_trace_rdb_driver", "org.h2.Driver");
    data.put("event_trace_rdb_url", "jdbc:h2:mem:test_executor");
    data.put("event_trace_rdb_username", "sa");
    data.put("event_trace_rdb_password", "");
    ExecutorInfo executorInfo = ExecutorInfo.newBuilder().setExecutorId(Protos.ExecutorID.newBuilder().setValue("test_executor")).setCommand(Protos.CommandInfo.getDefaultInstance()).setData(ByteString.copyFrom(SerializationUtils.serialize(data))).build();
    taskExecutor.registered(executorDriver, executorInfo, frameworkInfo, slaveInfo);
}
Also used : ExecutorInfo(org.apache.mesos.Protos.ExecutorInfo) HashMap(java.util.HashMap) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Aggregations

ExecutorInfo (org.apache.mesos.Protos.ExecutorInfo)3 ByteString (com.google.protobuf.ByteString)1 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 ByteBuffer (java.nio.ByteBuffer)1 HashMap (java.util.HashMap)1 TaskInfo (org.apache.mesos.Protos.TaskInfo)1 Test (org.junit.Test)1