Mesos Custom Framework: Our goal is to initiate the docker container. This docker container should have custom executor running which is possible if the container has an access to the jar file that is passed as part of URI. This is the edited code excerpts as part of standalone main class which acts as a starting point of framework.
String path = "http://localhost/example/example-1.0-SNAPSHOT-jar-with-dependencies.jar";
Protos.CommandInfo.URI uri = Protos.CommandInfo.URI.newBuilder().setValue(path).setExtract(false).build();
String command = "java -cp example-1.0-SNAPSHOT-jar-with-dependencies.jar com.example.ExampleExecutor";
Protos.CommandInfo commandInfo = Protos.CommandInfo.newBuilder().setValue(command).addUris(uri).build();
Protos.ContainerInfo.DockerInfo.Builder dockerInfo = Protos.ContainerInfo.DockerInfo.newBuilder();
dockerInfo.setImage(imageName);
dockerInfo.setNetwork(Protos.ContainerInfo.DockerInfo.Network.BRIDGE);
Protos.ContainerInfo.Builder containerInfo = Protos.ContainerInfo.newBuilder();
containerInfo.setType(Protos.ContainerInfo.Type.DOCKER);
containerInfo.setDocker(dockerInfo.build());
Protos.ExecutorInfo exampleExecutor = Protos.ExecutorInfo.newBuilder()
.setExecutorId(Protos.ExecutorID.newBuilder().setValue("ExampleExecutor"))
.setCommand(commandInfo)
.setName("Example Executor")
.setContainer(containerInfo)
.setSource("java")
.build();
Mesos Custom Scheduler: Below is the code excerpts which is used to launch the docker tasks. We want to run docker as an executor and not as a task.
Protos.TaskInfo task = Protos.TaskInfo.newBuilder()
.setName("task " + taskId).setTaskId(taskId)
.setSlaveId(offer.getSlaveId())
.addResources(buildResource("cpus", job.getCpu()))
.addResources(buildResource("mem", 128)) .setData(ByteString.copyFromUtf8(ExampleModelObject.toJSON()))
.setExecutor(Protos.ExecutorInfo.newBuilder(exampleExecutor))
.build();
I am not sure what exactly it is doing. Our containers were launched by mesos but the jar file was not available inside the container so the command to run the executor class inside the container failed with reason as not able to load main class. Also, i am not sure if the docker containers are ran as tasks or executors. Didn't find any related issue on the internet.