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();
}
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);
}
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);
}
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);
}
Aggregations