org.apache.mesos.Protos.Value.Scalar Java Examples

The following examples show how to use org.apache.mesos.Protos.Value.Scalar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimulatedTitusAgent.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
private Offer createOfferForAvailableResources() {
    Protos.OfferID offerId = Protos.OfferID.newBuilder().setValue(slaveId.getValue() + "_O_" + offerIdx++).build();
    String enis = "ResourceSet-ENIs-7-" + networkResourceTracker.getIpsPerEni();
    return offerTemplate.clone()
            .setId(offerId)
            .setSlaveId(slaveId)
            .addAllResources(asList(
                    Resource.newBuilder().setName("cpus").setType(Type.SCALAR).setScalar(Scalar.newBuilder().setValue(availableCPUs)).build(),
                    Resource.newBuilder().setName("gpu").setType(Type.SCALAR).setScalar(Scalar.newBuilder().setValue(availableGPUs)).build(),
                    Resource.newBuilder().setName("mem").setType(Type.SCALAR).setScalar(Scalar.newBuilder().setValue(availableMemory)).build(),
                    Resource.newBuilder().setName("disk").setType(Type.SCALAR).setScalar(Scalar.newBuilder().setValue(availableDisk)).build(),
                    Resource.newBuilder().setName("ports").setType(Type.RANGES).setRanges(
                            Ranges.newBuilder().addRange(Protos.Value.Range.newBuilder().setBegin(1024).setEnd(65535).build()).build()
                    ).build(),
                    Resource.newBuilder().setName("network").setType(Type.SCALAR).setScalar(Scalar.newBuilder().setValue(availableNetworkMbs)).build()
            ))
            .addAllAttributes(asList(
                    Attribute.newBuilder().setName("cluster").setType(Type.TEXT).setText(Text.newBuilder().setValue(clusterName)).build(),
                    Attribute.newBuilder().setName("asg").setType(Type.TEXT).setText(Text.newBuilder().setValue(clusterName)).build(),
                    Attribute.newBuilder().setName("id").setType(Type.TEXT).setText(Text.newBuilder().setValue(hostName)).build(),
                    Attribute.newBuilder().setName("itype").setType(Type.TEXT).setText(Text.newBuilder().setValue(instanceType.getDescriptor().getId())).build(),
                    Attribute.newBuilder().setName("SLAVE_ID").setType(Type.TEXT).setText(Text.newBuilder().setValue(clusterName)).build(),
                    Attribute.newBuilder().setName("res").setType(Type.TEXT).setText(Text.newBuilder().setValue(enis)).build()
            ))
            .build();
}
 
Example #2
Source File: MesosNimbus.java    From storm with Apache License 2.0 6 votes vote down vote up
private List<Resource> createMesosScalarResourceList(ResourceType resourceType, List<ResourceEntry> scalarResourceEntryList) {
  List<Resource> retVal = new ArrayList<>();
  ScalarResourceEntry scalarResourceEntry = null;

  for (ResourceEntry resourceEntry : scalarResourceEntryList) {
    scalarResourceEntry = (ScalarResourceEntry) resourceEntry;
    Resource.Builder resourceBuilder = Resource.newBuilder()
                                               .setName(resourceType.toString())
                                               .setType(Protos.Value.Type.SCALAR)
                                               .setScalar(Scalar.newBuilder().setValue(scalarResourceEntry.getValue()));
    if (resourceEntry.getReservationType() != null && resourceEntry.getReservationType().equals(ReservationType.STATIC)) {
      resourceBuilder.setRole(MesosCommon.getRole(mesosStormConf));
    }
    retVal.add(resourceBuilder.build());
  }
  return retVal;
}
 
Example #3
Source File: OfferUtilsTest.java    From incubator-myriad with Apache License 2.0 5 votes vote down vote up
private List<Resource> generateResources() {
  Resource rOne = Protos.Resource.newBuilder().setName("cpus").setType(Value.Type.SCALAR).setScalar(Scalar.newBuilder().setValue(0.5)).build();
  Resource rTwo = Protos.Resource.newBuilder().setName("mem").setType(Value.Type.SCALAR).setScalar(Scalar.newBuilder().setValue(1.0)).build();
  Resource rThree = Protos.Resource.newBuilder().setName("cpus").setType(Value.Type.SCALAR).setScalar(Scalar.newBuilder().setValue(1.0)).build();
  Resource rFour = Protos.Resource.newBuilder().setName("mem").setType(Value.Type.SCALAR).setScalar(Scalar.newBuilder().setValue(2.0)).build();
  
  return Lists.newArrayList(rOne, rTwo, rThree, rFour);
}
 
Example #4
Source File: MesosNimbus.java    From storm with Apache License 2.0 5 votes vote down vote up
private Resource createMesosScalarResource(ResourceType resourceType, ScalarResourceEntry scalarResourceEntry) {
  return Resource.newBuilder()
                 .setName(resourceType.toString())
                 .setType(Protos.Value.Type.SCALAR)
                 .setScalar(Scalar.newBuilder().setValue(scalarResourceEntry.getValue()))
                 .build();
}