Search in sources :

Example 6 with AgentID

use of org.apache.mesos.v1.Protos.AgentID in project Singularity by HubSpot.

the class SingularitySchedulerTestBase method createOffer.

protected Offer createOffer(double cpus, double memory, double disk, String slave, String host, Optional<String> rack, Map<String, String> attributes, String[] portRanges, Optional<String> role) {
    AgentID slaveId = AgentID.newBuilder().setValue(slave).build();
    FrameworkID frameworkId = FrameworkID.newBuilder().setValue("framework1").build();
    Random r = new Random();
    List<Attribute> attributesList = new ArrayList<>();
    for (Map.Entry<String, String> entry : attributes.entrySet()) {
        attributesList.add(Attribute.newBuilder().setType(Type.TEXT).setName(entry.getKey()).setText(Text.newBuilder().setValue(entry.getValue()).build()).build());
    }
    Resource.Builder cpusResource = Resource.newBuilder().setType(Type.SCALAR).setName(MesosUtils.CPUS).setScalar(Scalar.newBuilder().setValue(cpus));
    Resource.Builder memoryResources = Resource.newBuilder().setType(Type.SCALAR).setName(MesosUtils.MEMORY).setScalar(Scalar.newBuilder().setValue(memory));
    Resource.Builder diskResources = Resource.newBuilder().setType(Type.SCALAR).setName(MesosUtils.DISK).setScalar(Scalar.newBuilder().setValue(disk));
    if (role.isPresent()) {
        cpusResource = cpusResource.setRole(role.get());
        memoryResources = memoryResources.setRole(role.get());
        diskResources = diskResources.setRole(role.get());
    }
    return Offer.newBuilder().setId(OfferID.newBuilder().setValue("offer" + r.nextInt(1000)).build()).setFrameworkId(frameworkId).setAgentId(slaveId).setHostname(host).setUrl(URL.newBuilder().setScheme("scheme").setAddress(Address.newBuilder().setPort(8080))).addAttributes(Attribute.newBuilder().setType(Type.TEXT).setText(Text.newBuilder().setValue(rack.or(configuration.getMesosConfiguration().getDefaultRackId()))).setName(configuration.getMesosConfiguration().getRackIdAttributeKey())).addResources(cpusResource).addResources(memoryResources).addResources(diskResources).addResources(MesosUtilsTest.buildPortRanges(portRanges)).addAllAttributes(attributesList).build();
}
Also used : Random(java.util.Random) Attribute(org.apache.mesos.v1.Protos.Attribute) ArrayList(java.util.ArrayList) TaskResource(com.hubspot.singularity.resources.TaskResource) RequestResource(com.hubspot.singularity.resources.RequestResource) PriorityResource(com.hubspot.singularity.resources.PriorityResource) DeployResource(com.hubspot.singularity.resources.DeployResource) SlaveResource(com.hubspot.singularity.resources.SlaveResource) RackResource(com.hubspot.singularity.resources.RackResource) Resource(org.apache.mesos.v1.Protos.Resource) FrameworkID(org.apache.mesos.v1.Protos.FrameworkID) AgentID(org.apache.mesos.v1.Protos.AgentID) Map(java.util.Map)

Example 7 with AgentID

use of org.apache.mesos.v1.Protos.AgentID in project Singularity by HubSpot.

the class SingularityMesosSchedulerClient method shutdown.

public void shutdown(ExecutorID executorId, AgentID agentId) {
    Builder shutdown = build().setShutdown(Shutdown.newBuilder().setExecutorId(executorId).setAgentId(agentId));
    sendCall(shutdown, Type.SHUTDOWN);
}
Also used : MesosClientBuilder(com.mesosphere.mesos.rx.java.MesosClientBuilder) ProtobufMesosClientBuilder(com.mesosphere.mesos.rx.java.protobuf.ProtobufMesosClientBuilder) Builder(org.apache.mesos.v1.scheduler.Protos.Call.Builder)

Example 8 with AgentID

use of org.apache.mesos.v1.Protos.AgentID in project Singularity by HubSpot.

the class SingularityMesosSchedulerClient method kill.

public void kill(TaskID taskId, AgentID agentId) {
    Builder kill = build().setKill(Kill.newBuilder().setTaskId(taskId).setAgentId(agentId));
    sendCall(kill, Type.KILL);
}
Also used : MesosClientBuilder(com.mesosphere.mesos.rx.java.MesosClientBuilder) ProtobufMesosClientBuilder(com.mesosphere.mesos.rx.java.protobuf.ProtobufMesosClientBuilder) Builder(org.apache.mesos.v1.scheduler.Protos.Call.Builder)

Example 9 with AgentID

use of org.apache.mesos.v1.Protos.AgentID in project Singularity by HubSpot.

the class SingularityMesosSchedulerImpl method message.

@Override
public void message(Message message) {
    ExecutorID executorID = message.getExecutorId();
    AgentID slaveId = message.getAgentId();
    byte[] data = message.getData().toByteArray();
    LOG.info("Framework message from executor {} on slave {} with {} bytes of data", executorID, slaveId, data.length);
    messageHandler.handleMessage(executorID, slaveId, data);
}
Also used : ExecutorID(org.apache.mesos.v1.Protos.ExecutorID) AgentID(org.apache.mesos.v1.Protos.AgentID)

Aggregations

MesosClientBuilder (com.mesosphere.mesos.rx.java.MesosClientBuilder)6 ProtobufMesosClientBuilder (com.mesosphere.mesos.rx.java.protobuf.ProtobufMesosClientBuilder)6 Builder (org.apache.mesos.v1.scheduler.Protos.Call.Builder)6 AgentID (org.apache.mesos.v1.Protos.AgentID)4 ExecutorID (org.apache.mesos.v1.Protos.ExecutorID)3 FrameworkID (org.apache.mesos.v1.Protos.FrameworkID)2 Inject (com.google.inject.Inject)1 Named (com.google.inject.name.Named)1 ByteString (com.google.protobuf.ByteString)1 SingularityTask (com.hubspot.singularity.SingularityTask)1 SingularityTaskShellCommandRequest (com.hubspot.singularity.SingularityTaskShellCommandRequest)1 MesosConfiguration (com.hubspot.singularity.config.MesosConfiguration)1 SingularityConfiguration (com.hubspot.singularity.config.SingularityConfiguration)1 UIConfiguration (com.hubspot.singularity.config.UIConfiguration)1 DeployResource (com.hubspot.singularity.resources.DeployResource)1 PriorityResource (com.hubspot.singularity.resources.PriorityResource)1 RackResource (com.hubspot.singularity.resources.RackResource)1 RequestResource (com.hubspot.singularity.resources.RequestResource)1 SingularityServiceUIModule (com.hubspot.singularity.resources.SingularityServiceUIModule)1 SlaveResource (com.hubspot.singularity.resources.SlaveResource)1