Tabnine Logo
Protos$Offer.getResourcesList
Code IndexAdd Tabnine to your IDE (free)

How to use
getResourcesList
method
in
org.apache.mesos.v1.Protos$Offer

Best Java code snippets using org.apache.mesos.v1.Protos$Offer.getResourcesList (Showing top 20 results out of 315)

origin: HubSpot/Singularity

public SingularityOfferHolder(List<Protos.Offer> offers, int taskSizeHint, String rackId, String slaveId, String hostname, Map<String, String> textAttributes, Map<String, String> reservedSlaveAttributes) {
 this.rackId = rackId;
 this.slaveId = slaveId;
 this.hostname = hostname;
 this.offers = offers;
 this.roles = MesosUtils.getRoles(offers.get(0));
 this.acceptedTasks = Lists.newArrayListWithExpectedSize(taskSizeHint);
 this.currentResources = offers.size()  > 1 ? MesosUtils.combineResources(offers.stream().map(Protos.Offer::getResourcesList).collect(Collectors.toList())) : offers.get(0).getResourcesList();
 this.sanitizedHost = JavaUtils.getReplaceHyphensWithUnderscores(hostname);
 this.sanitizedRackId = JavaUtils.getReplaceHyphensWithUnderscores(rackId);
 this.textAttributes = textAttributes;
 this.reservedSlaveAttributes = reservedSlaveAttributes;
}
origin: HubSpot/Singularity

public static Set<String> getRoles(Offer offer) {
 Set<String> roles = Sets.newHashSet();
 for (Resource r : offer.getResourcesList()) {
  roles.add(r.getRole());
 }
 return roles;
}
origin: HubSpot/Singularity

public static double getMemory(Offer offer) {
 return getMemory(offer.getResourcesList(), Optional.<String>absent());
}
origin: com.hubspot/SingularityService

List<Long> ports = MesosUtils.getAllPorts(offer.getResourcesList());
boolean offerCanBeReclaimedFromUnusedResources = offer.getResourcesList().stream()
   offer.getId().getValue(), offer.getHostname(), MesosUtils.getNumCpus(offer), MesosUtils.getMemory(offer), MesosUtils.getDisk(offer)
 );
 currentResources = MesosUtils.subtractResources(currentResources, offer.getResourcesList());
origin: com.hubspot/SingularityService

@Test
public void testLiteralHostPortSelection() {
 String[] rangesNotOverlappingRequestedPorts = {"23:24", "25:25", "31:32", "50:51"};
 int numPorts = 1;
 List<Long> requestedPorts = Arrays.asList(50L, 51L);
 Resource resource = MesosUtils.getPortsResource(numPorts, buildOffer(rangesNotOverlappingRequestedPorts).getResourcesList(), requestedPorts);
 Assert.assertTrue(MesosUtils.getAllPorts(Collections.singletonList(resource)).containsAll(requestedPorts));
 Assert.assertEquals(numPorts + requestedPorts.size(), MesosUtils.getNumPorts(Collections.singletonList(resource)));
 String[] rangesOverlappingRequestPorts = {"23:28"};
 numPorts = 4;
 requestedPorts = Arrays.asList(25L, 27L);
 resource = MesosUtils.getPortsResource(numPorts, buildOffer(rangesOverlappingRequestPorts).getResourcesList(), requestedPorts);
 Assert.assertTrue(MesosUtils.getAllPorts(Collections.singletonList(resource)).containsAll(requestedPorts));
 Assert.assertEquals(numPorts + requestedPorts.size(), MesosUtils.getNumPorts(Collections.singletonList(resource)));
}
origin: com.hubspot/SingularityService

public static double getMemory(Offer offer) {
 return getMemory(offer.getResourcesList(), Optional.<String>absent());
}
origin: com.hubspot/SingularityService

public static double getNumCpus(Offer offer) {
 return getNumCpus(offer.getResourcesList(), Optional.<String>absent());
}
origin: com.hubspot/SingularityService

public static int getNumPorts(Offer offer) {
 return getNumPorts(offer.getResourcesList());
}
origin: com.hubspot/SingularityService

public static double getDisk(Offer offer) {
 return getDisk(offer.getResourcesList(), Optional.<String>absent());
}
origin: com.hubspot/SingularityService

public static Resource getPortsResource(int numPorts, Offer offer) {
 return getPortsResource(numPorts, offer.getResourcesList(), Collections.<Long>emptyList());
}
origin: com.hubspot/SingularityService

public SingularityOfferHolder(List<Protos.Offer> offers, int taskSizeHint, String rackId, String slaveId, String hostname, Map<String, String> textAttributes, Map<String, String> reservedSlaveAttributes) {
 this.rackId = rackId;
 this.slaveId = slaveId;
 this.hostname = hostname;
 this.offers = offers;
 this.roles = MesosUtils.getRoles(offers.get(0));
 this.acceptedTasks = Lists.newArrayListWithExpectedSize(taskSizeHint);
 this.currentResources = offers.size()  > 1 ? MesosUtils.combineResources(offers.stream().map(Protos.Offer::getResourcesList).collect(Collectors.toList())) : offers.get(0).getResourcesList();
 this.sanitizedHost = JavaUtils.getReplaceHyphensWithUnderscores(hostname);
 this.sanitizedRackId = JavaUtils.getReplaceHyphensWithUnderscores(rackId);
 this.textAttributes = textAttributes;
 this.reservedSlaveAttributes = reservedSlaveAttributes;
}
origin: com.hubspot/SingularityService

public static Set<String> getRoles(Offer offer) {
 Set<String> roles = Sets.newHashSet();
 for (Resource r : offer.getResourcesList()) {
  roles.add(r.getRole());
 }
 return roles;
}
origin: com.hubspot/SingularityService

@Test
public void testGetZeroPortsFromResource() {
 String[] rangesOverlappingRequestPorts = {"23:28"};
 int numPorts = 0;
 List<Long> requestedPorts = Arrays.asList(25L, 27L);
 Resource resource = MesosUtils.getPortsResource(numPorts, buildOffer(rangesOverlappingRequestPorts).getResourcesList(), requestedPorts);
 Assert.assertEquals(0, MesosUtils.getPorts(resource, numPorts).length);
}
origin: HubSpot/Singularity

List<Long> ports = MesosUtils.getAllPorts(offer.getResourcesList());
boolean offerCanBeReclaimedFromUnusedResources = offer.getResourcesList().stream()
   offer.getId().getValue(), offer.getHostname(), MesosUtils.getNumCpus(offer), MesosUtils.getMemory(offer), MesosUtils.getDisk(offer)
 );
 currentResources = MesosUtils.subtractResources(currentResources, offer.getResourcesList());
origin: HubSpot/Singularity

@Test
public void testLiteralHostPortSelection() {
 String[] rangesNotOverlappingRequestedPorts = {"23:24", "25:25", "31:32", "50:51"};
 int numPorts = 1;
 List<Long> requestedPorts = Arrays.asList(50L, 51L);
 Resource resource = MesosUtils.getPortsResource(numPorts, buildOffer(rangesNotOverlappingRequestedPorts).getResourcesList(), requestedPorts);
 Assert.assertTrue(MesosUtils.getAllPorts(Collections.singletonList(resource)).containsAll(requestedPorts));
 Assert.assertEquals(numPorts + requestedPorts.size(), MesosUtils.getNumPorts(Collections.singletonList(resource)));
 String[] rangesOverlappingRequestPorts = {"23:28"};
 numPorts = 4;
 requestedPorts = Arrays.asList(25L, 27L);
 resource = MesosUtils.getPortsResource(numPorts, buildOffer(rangesOverlappingRequestPorts).getResourcesList(), requestedPorts);
 Assert.assertTrue(MesosUtils.getAllPorts(Collections.singletonList(resource)).containsAll(requestedPorts));
 Assert.assertEquals(numPorts + requestedPorts.size(), MesosUtils.getNumPorts(Collections.singletonList(resource)));
}
origin: HubSpot/Singularity

public static double getNumCpus(Offer offer) {
 return getNumCpus(offer.getResourcesList(), Optional.<String>absent());
}
origin: HubSpot/Singularity

public static Resource getPortsResource(int numPorts, Offer offer) {
 return getPortsResource(numPorts, offer.getResourcesList(), Collections.<Long>emptyList());
}
origin: HubSpot/Singularity

public static int getNumPorts(Offer offer) {
 return getNumPorts(offer.getResourcesList());
}
origin: HubSpot/Singularity

public static double getDisk(Offer offer) {
 return getDisk(offer.getResourcesList(), Optional.<String>absent());
}
origin: HubSpot/Singularity

@Test
public void testGetZeroPortsFromResource() {
 String[] rangesOverlappingRequestPorts = {"23:28"};
 int numPorts = 0;
 List<Long> requestedPorts = Arrays.asList(25L, 27L);
 Resource resource = MesosUtils.getPortsResource(numPorts, buildOffer(rangesOverlappingRequestPorts).getResourcesList(), requestedPorts);
 Assert.assertEquals(0, MesosUtils.getPorts(resource, numPorts).length);
}
org.apache.mesos.v1Protos$OffergetResourcesList

Popular methods of Protos$Offer

  • getAgentId
  • getId
  • getHostname
  • newBuilder
  • getAttributesList
  • getDefaultInstance
  • isInitialized

Popular in Java

  • Making http post requests using okhttp
  • findViewById (Activity)
  • runOnUiThread (Activity)
  • getExternalFilesDir (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JButton (javax.swing)
  • JList (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now