本文整理汇总了Java中org.apache.mesos.Protos.Value方法的典型用法代码示例。如果您正苦于以下问题:Java Protos.Value方法的具体用法?Java Protos.Value怎么用?Java Protos.Value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos
的用法示例。
在下文中一共展示了Protos.Value方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PortSpec
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@JsonCreator
public PortSpec(
@JsonProperty("value") Protos.Value value,
@JsonProperty("role") String role,
@JsonProperty("pre-reserved-role") String preReservedRole,
@JsonProperty("principal") String principal,
@JsonProperty("env-key") String envKey,
@JsonProperty("port-name") String portName,
@JsonProperty("visibility") DiscoveryInfo.Visibility visibility,
@JsonProperty("network-names") Collection<String> networkNames) {
super(Constants.PORTS_RESOURCE_TYPE, value, role, preReservedRole, principal);
this.envKey = envKey;
this.portName = portName;
this.visibility = visibility;
this.networkNames = networkNames;
}
示例2: NamedVIPSpec
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@JsonCreator
public NamedVIPSpec(
@JsonProperty("value") Protos.Value value,
@JsonProperty("role") String role,
@JsonProperty("pre-reserved-role") String preReservedRole,
@JsonProperty("principal") String principal,
@JsonProperty("env-key") String envKey,
@JsonProperty("port-name") String portName,
@JsonProperty("protocol") String protocol,
@JsonProperty("visibility") DiscoveryInfo.Visibility visibility,
@JsonProperty("vip-name") String vipName,
@JsonProperty("vip-port") Integer vipPort,
@JsonProperty("network-names") Collection<String> networkNames) {
super(value, role, preReservedRole, principal, envKey, portName, visibility, networkNames);
this.protocol = protocol;
this.vipName = vipName;
this.vipPort = vipPort;
ValidationUtils.validate(this);
}
示例3: getUnreservedResource
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@SuppressWarnings("deprecation") // for Resource.setRole()
private static Protos.Resource getUnreservedResource(String name, Protos.Value value, String role) {
Protos.Resource.Builder resBuilder = Protos.Resource.newBuilder()
.setName(name)
.setType(value.getType())
.setRole(role);
if (!role.equals(Constants.ANY_ROLE)) {
// Fill in the prereserved role info:
resBuilder.addReservationsBuilder()
.setRole(role)
.setPrincipal(TestConstants.PRINCIPAL);
}
switch (value.getType()) {
case SCALAR:
return resBuilder.setScalar(value.getScalar()).build();
case RANGES:
return resBuilder.setRanges(value.getRanges()).build();
case SET:
return resBuilder.setSet(value.getSet()).build();
default:
return null;
}
}
示例4: isValid
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public boolean isValid(Protos.Value value,
ConstraintValidatorContext context) {
return value != null // Not valid if null.
&& (value.hasRanges() // Ignore Ranges.
|| (value.hasScalar() && value.getScalar().getValue() > 0));
}
示例5: DefaultVolumeSpec
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@JsonCreator
private DefaultVolumeSpec(
@JsonProperty("type") Type type,
@JsonProperty("container-path") String containerPath,
@JsonProperty("name") String name,
@JsonProperty("value") Protos.Value value,
@JsonProperty("role") String role,
@JsonProperty("pre-reserved-role") String preReservedRole,
@JsonProperty("principal") String principal) {
super(name, value, role, preReservedRole, principal);
this.type = type;
this.containerPath = containerPath;
ValidationUtils.validate(this);
}
示例6: withValue
import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
* Returns a copy of the provided {@link PortSpec} which has been updated to have the provided {@code value}.
*/
@JsonIgnore
public static PortSpec withValue(PortSpec portSpec, Protos.Value value) {
return new PortSpec(
value,
portSpec.getRole(),
portSpec.getPreReservedRole(),
portSpec.getPrincipal(),
portSpec.getEnvKey(),
portSpec.getPortName(),
portSpec.getVisibility(),
portSpec.getNetworkNames());
}
示例7: DefaultResourceSpec
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@JsonCreator
public DefaultResourceSpec(
@JsonProperty("name") String name,
@JsonProperty("value") Protos.Value value,
@JsonProperty("role") String role,
@JsonProperty("pre-reserved-role") String preReservedRole,
@JsonProperty("principal") String principal) {
this.name = name;
this.value = value;
this.role = role;
this.preReservedRole = preReservedRole == null ? Constants.ANY_ROLE : preReservedRole;
this.principal = principal;
}
示例8: testConsumeUnreservedAtomicResource
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testConsumeUnreservedAtomicResource() {
Resource offerResource = ResourceTestUtils.getUnreservedMountVolume(1000);
Protos.Value resourceValue = ValueUtils.getValue(offerResource);
Offer offer = OfferTestUtils.getOffer(offerResource);
MesosResourcePool pool = new MesosResourcePool(offer, Optional.of(Constants.ANY_ROLE));
Assert.assertEquals(1, pool.getUnreservedAtomicPool().size());
MesosResource resourceToConsume = pool.consumeAtomic(offerResource.getName(), resourceValue).get();
Assert.assertEquals(offerResource, resourceToConsume.getResource());
Assert.assertEquals(0, pool.getUnreservedAtomicPool().size());
}
示例9: testConsumeReservedMergedResource
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testConsumeReservedMergedResource() {
Resource resource = ResourceTestUtils.getReservedCpus(1.0, TestConstants.RESOURCE_ID);
Protos.Value resourceValue = ValueUtils.getValue(resource);
String resourceId = ResourceTestUtils.getResourceId(resource);
Offer offer = OfferTestUtils.getOffer(resource);
MesosResourcePool pool = new MesosResourcePool(offer, Optional.of(Constants.ANY_ROLE));
Assert.assertEquals(1, pool.getDynamicallyReservedPoolByResourceId().size());
MesosResource resourceToConsume = pool.consumeReserved(resource.getName(), resourceValue, resourceId).get();
Assert.assertEquals(resource, resourceToConsume.getResource());
Assert.assertEquals(0, pool.getDynamicallyReservedPoolByResourceId().size());
}
示例10: testConsumeUnreservedMergedResource
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testConsumeUnreservedMergedResource() {
Resource resource = ResourceTestUtils.getUnreservedCpus(1.0);
Protos.Value resourceValue = ValueUtils.getValue(resource);
Offer offer = OfferTestUtils.getOffer(resource);
MesosResourcePool pool = new MesosResourcePool(offer, Optional.of(Constants.ANY_ROLE));
Assert.assertEquals(1, pool.getUnreservedMergedPool().size());
Assert.assertEquals(resource.getScalar().getValue(),
pool.getUnreservedMergedPool().get("cpus").getScalar().getValue(), 0.0);
MesosResource resourceToConsume = pool.consumeReservableMerged(resource.getName(), resourceValue, Constants.ANY_ROLE).get();
Assert.assertEquals(resource, resourceToConsume.getResource());
Assert.assertEquals(ValueUtils.getZero(Protos.Value.Type.SCALAR),
pool.getUnreservedMergedPool().get("cpus"));
}
示例11: testConsumeInsufficientUnreservedMergedResource
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testConsumeInsufficientUnreservedMergedResource() {
Resource desiredUnreservedResource = ResourceTestUtils.getUnreservedCpus(2.0);
Protos.Value resourceValue = ValueUtils.getValue(desiredUnreservedResource);
Resource offeredUnreservedResource = ResourceTestUtils.getUnreservedCpus(1.0);
Offer offer = OfferTestUtils.getOffer(offeredUnreservedResource);
MesosResourcePool pool = new MesosResourcePool(offer, Optional.of(Constants.ANY_ROLE));
Assert.assertFalse(
pool.consumeReservableMerged(desiredUnreservedResource.getName(), resourceValue, Constants.ANY_ROLE)
.isPresent());
}
示例12: testConsumeUnreservedWhenNoUnreservedResources
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void testConsumeUnreservedWhenNoUnreservedResources() {
Resource reservedCpu = ResourceTestUtils.getReservedCpus(1.0, UUID.randomUUID().toString());
Offer offer = OfferTestUtils.getOffer(reservedCpu);
MesosResourcePool pool = new MesosResourcePool(offer, Optional.of(Constants.ANY_ROLE));
Map<String, Protos.Value> map = pool.getUnreservedMergedPool();
Assert.assertTrue(map != null);
Assert.assertTrue(map.isEmpty());
}
示例13: getPort
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private Protos.Value getPort(int port) {
return Protos.Value.newBuilder()
.setType(Protos.Value.Type.RANGES)
.setRanges(Protos.Value.Ranges.newBuilder()
.addRange(Protos.Value.Range.newBuilder()
.setBegin(port)
.setEnd(port)))
.build();
}
示例14: scalarValue
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Protos.Value scalarValue(double value) {
Protos.Value.Builder builder = Protos.Value.newBuilder().setType(Protos.Value.Type.SCALAR);
builder.getScalarBuilder().setValue(value);
return builder.build();
}
示例15: getValue
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@JsonProperty("value")
Protos.Value getValue();