Java Code Examples for org.apache.mesos.Protos.Offer#Builder
The following examples show how to use
org.apache.mesos.Protos.Offer#Builder .
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: AttributeRuleTest.java From dcos-commons with Apache License 2.0 | 6 votes |
@Test public void testExactMatchesString() { Offer.Builder o = getOfferWithResources() .addAttributes(ATTR_TEXT); assertTrue(AttributeRuleFactory.getInstance().require(ExactMatcher.create(AttributeStringUtils.toString(ATTR_TEXT))) .filter(o.build(), POD_INSTANCE, Collections.emptyList()).isPassing()); o = getOfferWithResources() .addAttributes(ATTR_SCALAR); assertTrue(AttributeRuleFactory.getInstance().require(ExactMatcher.create(AttributeStringUtils.toString(ATTR_SCALAR))) .filter(o.build(), POD_INSTANCE, Collections.emptyList()).isPassing()); o = getOfferWithResources() .addAttributes(ATTR_RANGES); assertTrue(AttributeRuleFactory.getInstance().require(ExactMatcher.create(AttributeStringUtils.toString(ATTR_RANGES))) .filter(o.build(), POD_INSTANCE, Collections.emptyList()).isPassing()); o = getOfferWithResources() .addAttributes(ATTR_SET); assertTrue(AttributeRuleFactory.getInstance().require(ExactMatcher.create(AttributeStringUtils.toString(ATTR_SET))) .filter(o.build(), POD_INSTANCE, Collections.emptyList()).isPassing()); }
Example 2
Source File: AttributeRuleTest.java From dcos-commons with Apache License 2.0 | 6 votes |
@Test public void testExactMatchesRegex() { Offer.Builder o = getOfferWithResources() .addAttributes(ATTR_TEXT); assertTrue(AttributeRuleFactory.getInstance().require(RegexMatcher.create(ATTR_TEXT_REGEX)) .filter(o.build(), POD_INSTANCE, Collections.emptyList()).isPassing()); o = getOfferWithResources() .addAttributes(ATTR_SCALAR); assertTrue(AttributeRuleFactory.getInstance().require(RegexMatcher.create(ATTR_SCALAR_REGEX)) .filter(o.build(), POD_INSTANCE, Collections.emptyList()).isPassing()); o = getOfferWithResources() .addAttributes(ATTR_RANGES); assertTrue(AttributeRuleFactory.getInstance().require(RegexMatcher.create(ATTR_RANGES_REGEX)) .filter(o.build(), POD_INSTANCE, Collections.emptyList()).isPassing()); o = getOfferWithResources() .addAttributes(ATTR_SET); assertTrue(AttributeRuleFactory.getInstance().require(RegexMatcher.create(ATTR_SET_REGEX)) .filter(o.build(), POD_INSTANCE, Collections.emptyList()).isPassing()); }
Example 3
Source File: SimulatedTitusAgent.java From titus-control-plane with Apache License 2.0 | 5 votes |
public SimulatedTitusAgent(String clusterName, ComputeResources computeResources, String hostName, Protos.SlaveID slaveId, Offer.Builder offerTemplate, AwsInstanceType instanceType, double cpus, double gpus, int memory, int disk, int totalNetworkMbs, int ipPerEni, ContainerPlayersManager containerPlayersManager, Scheduler scheduler) { this.computeResources = computeResources; this.containerPlayersManager = containerPlayersManager; this.worker = scheduler.createWorker(); this.clusterName = clusterName; this.hostName = hostName; this.slaveId = slaveId; this.offerTemplate = offerTemplate; this.instanceType = instanceType; this.totalCPUs = cpus; this.availableCPUs = cpus; this.totalGPUs = gpus; this.availableGPUs = gpus; this.totalMemory = memory; this.availableMemory = memory; this.totalDisk = disk; this.availableDisk = disk; this.totalNetworkMbs = totalNetworkMbs; this.availableNetworkMbs = totalNetworkMbs; this.networkResourceTracker = new NetworkResourceTracker(ipPerEni); this.zoneId = getZoneIdFromOfferTemplate(offerTemplate).orElse(""); logger.info("Creating a new agent {} with instance type {} and zone {} and resources {cpu={}, memory={}, disk={}, networkMbs={}}", slaveId.getValue(), instanceType, zoneId, cpus, memory, disk, totalNetworkMbs); emitAvailableOffers(0); }
Example 4
Source File: SimulatedTitusAgent.java From titus-control-plane with Apache License 2.0 | 5 votes |
private Optional<String> getZoneIdFromOfferTemplate(Offer.Builder offerTemplate) { for (Attribute attribute : offerTemplate.getAttributesList()) { if (attribute.getName().equals("zone")) { return Optional.of(attribute.getText().getValue()); } } return Optional.empty(); }
Example 5
Source File: OfferTestUtils.java From dcos-commons with Apache License 2.0 | 5 votes |
/** * Minimum to keep required field errors away. */ public static void addResource(Offer.Builder o, String name, String role) { Resource.Builder b = o.addResourcesBuilder().setType(Value.Type.RANGES).setName(name); if (role != null) { b.setRole(role); } }
Example 6
Source File: HostnameRuleTest.java From dcos-commons with Apache License 2.0 | 5 votes |
private static Offer offerWithHost(String host) { Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder().setHostname(host); OfferTestUtils.addResource(o, "a"); OfferTestUtils.addResource(o, "b"); OfferTestUtils.addResource(o, "c"); return o.build(); }
Example 7
Source File: NotRuleTest.java From dcos-commons with Apache License 2.0 | 5 votes |
private static Offer offerWith(Collection<Resource> resources) { Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder(); for (Resource r : resources) { o.addResources(r); } return o.build(); }
Example 8
Source File: AgentRuleTest.java From dcos-commons with Apache License 2.0 | 5 votes |
private static Offer offerWithAgent(String agentId) { Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder(); o.getSlaveIdBuilder().setValue(agentId); OfferTestUtils.addResource(o, "a"); OfferTestUtils.addResource(o, "b"); OfferTestUtils.addResource(o, "c"); return o.build(); }
Example 9
Source File: TaskTypeRuleTest.java From dcos-commons with Apache License 2.0 | 5 votes |
private static Offer getOffer(String agent) { Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder() .setSlaveId(SlaveID.newBuilder().setValue(agent)); OfferTestUtils.addResource(o, "a"); OfferTestUtils.addResource(o, "b"); return o.build(); }
Example 10
Source File: OrRuleTest.java From dcos-commons with Apache License 2.0 | 5 votes |
private static Offer offerWith(Collection<Resource> resources) { Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder(); for (Resource r : resources) { o.addResources(r); } return o.build(); }
Example 11
Source File: RoundRobinByAttributeRuleTest.java From dcos-commons with Apache License 2.0 | 5 votes |
private static Offer offerWithAttribute(String name, String value) { Protos.Resource resource = ResourceBuilder.fromUnreservedValue( "cpus", Protos.Value.newBuilder() .setType(Protos.Value.Type.SCALAR) .setScalar(Protos.Value.Scalar.newBuilder().setValue(1.0)) .build()) .build(); Offer.Builder offerBuilder = OfferTestUtils.getCompleteOffer(resource).toBuilder(); offerBuilder.addAttributesBuilder() .setName(name) .setType(Value.Type.TEXT) .getTextBuilder().setValue(value); return offerBuilder.build(); }
Example 12
Source File: AndRuleTest.java From dcos-commons with Apache License 2.0 | 5 votes |
private static Offer offerWith(Collection<Resource> resources) { Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder(); for (Resource r : resources) { o.addResources(r); } return o.build(); }
Example 13
Source File: OfferTestUtils.java From dcos-commons with Apache License 2.0 | 4 votes |
/** * Minimum to keep required field errors away. */ public static void addResource(Offer.Builder o, String name) { addResource(o, name, null); }
Example 14
Source File: AttributeRuleTest.java From dcos-commons with Apache License 2.0 | 4 votes |
private static Offer.Builder getOfferWithResources() { Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder(); OfferTestUtils.addResource(o, "a"); OfferTestUtils.addResource(o, "b"); return o; }
Example 15
Source File: MaxPerAttributeRuleTest.java From dcos-commons with Apache License 2.0 | 4 votes |
private static Offer getOfferWithResources() { Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder(); OfferTestUtils.addResource(o, "a"); OfferTestUtils.addResource(o, "b"); return o.build(); }