本文整理汇总了Java中org.apache.mesos.Protos.Offer.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java Offer.Builder方法的具体用法?Java Offer.Builder怎么用?Java Offer.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos.Offer
的用法示例。
在下文中一共展示了Offer.Builder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExactMatchesString
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
@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());
}
示例2: testExactMatchesRegex
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
@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());
}
示例3: buildOffer
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
private Offer buildOffer(String... ranges) {
Offer.Builder offer = Offer.newBuilder()
.setId(OfferID.newBuilder().setValue("offerid").build())
.setFrameworkId(FrameworkID.newBuilder().setValue("frameworkid").build())
.setHostname("hostname")
.setSlaveId(SlaveID.newBuilder().setValue("slaveid").build());
offer.addResources(buildPortRanges(ranges));
return offer.build();
}
示例4: addResource
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
/**
* 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);
}
}
示例5: offerWithHost
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
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();
}
示例6: offerWith
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
private static Offer offerWith(Collection<Resource> resources) {
Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder();
for (Resource r : resources) {
o.addResources(r);
}
return o.build();
}
示例7: offerWithAgent
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
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();
}
示例8: getOffer
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
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();
}
示例9: offerWithAttribute
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
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();
}
示例10: getOfferWithResources
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
private static Offer.Builder getOfferWithResources() {
Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder();
OfferTestUtils.addResource(o, "a");
OfferTestUtils.addResource(o, "b");
return o;
}
示例11: getOfferWithResources
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
private static Offer getOfferWithResources() {
Offer.Builder o = OfferTestUtils.getEmptyOfferBuilder();
OfferTestUtils.addResource(o, "a");
OfferTestUtils.addResource(o, "b");
return o.build();
}
示例12: getSizeOptimizedTask
import org.apache.mesos.Protos.Offer; //导入方法依赖的package包/类
public SingularityTask getSizeOptimizedTask(SingularityTask task) {
if (configuration.isStoreAllMesosTaskInfoForDebugging()) {
return task;
}
TaskInfo.Builder mesosTask = task.getMesosTask().toBuilder();
mesosTask.clearData();
Offer.Builder offer = task.getOffer().toBuilder();
offer.clearExecutorIds();
offer.clearResources();
SingularityTaskRequest taskRequest = task.getTaskRequest();
if (task.getTaskRequest().getDeploy().getExecutorData().isPresent()) {
SingularityDeployBuilder deploy = task.getTaskRequest().getDeploy().toBuilder();
deploy.setExecutorData(Optional.<ExecutorData> absent());
taskRequest = new SingularityTaskRequest(task.getTaskRequest().getRequest(),
deploy.build(), task.getTaskRequest().getPendingTask());
}
return new SingularityTask(taskRequest, task.getTaskId(), offer.build(), mesosTask.build(), task.getRackId());
}