当前位置: 首页>>代码示例>>Java>>正文


Java Protos.Attribute方法代码示例

本文整理汇总了Java中org.apache.mesos.Protos.Attribute方法的典型用法代码示例。如果您正苦于以下问题:Java Protos.Attribute方法的具体用法?Java Protos.Attribute怎么用?Java Protos.Attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mesos.Protos的用法示例。


在下文中一共展示了Protos.Attribute方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matches

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public boolean matches(List<Protos.Attribute> attributes) {
    for (Protos.Attribute attribute : attributes) {
        if (!Objects.equals(attribute.getName(), this.getKey())) {
            continue;
        }
        switch (attribute.getType()) {
            case TEXT:
                return attribute.getText().getValue().matches(this.getValue());
            case SCALAR:
                return Pattern.compile(this.getValue()).matcher(Double.toString(attribute.getScalar().getValue())).matches();
            case SET:
                for (String string : attribute.getSet().getItemList()) {
                    if(string.matches(this.getValue())){
                        return true;
                    }
                }
            case RANGES:
                break;
            default:
        }
    }

    return false;
}
 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:26,代码来源:LikeConstraint.java

示例2: matches

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public boolean matches(List<Protos.Attribute> attributes) {
    for (Protos.Attribute attribute : attributes) {
        if (!Objects.equals(attribute.getName(), this.getKey())) {
            continue;
        }
        switch (attribute.getType()) {
            case TEXT:
                return !attribute.getText().getValue().matches(this.getValue());
            case SCALAR:
                return !Pattern.compile(this.getValue()).matcher(Double.toString(attribute.getScalar().getValue())).matches();
            case SET:
                for (String string : attribute.getSet().getItemList()) {
                    if(string.matches(this.getValue())){
                        return false;
                    }
                }
                return true;
            case RANGES:
                break;
            default:
        }
    }

    return false;
}
 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:27,代码来源:UnlikeConstraint.java

示例3: matches

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public boolean matches(List<Protos.Attribute> attributes) {
    for (Protos.Attribute attribute : attributes) {
        if (Objects.equals(attribute.getName(), this.getKey())) {
            switch (attribute.getType()) {
                case TEXT:
                    return attribute.getText().getValue().matches(this.getValue());
                case SCALAR:
                    return Objects.equals(Double.toString(attribute.getScalar().getValue()), this.getValue());
                case SET:
                    return attribute.getSet().getItemList().contains(this.getValue());
                case RANGES:
                    break;
                default:
            }

        }
    }

    return false;
}
 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:22,代码来源:EqualsConstraint.java

示例4: constraintsAllow

import org.apache.mesos.Protos; //导入方法依赖的package包/类
boolean constraintsAllow(Protos.Offer offer) {

        ArrayList<Constraint> constraints = this.getMatchConstraints();

        if (this.constraintsPairs.length > 0 && constraintsPairs.length != constraints.size()) {
            return false;
        }

        if (!constraints.isEmpty()) {
            List<Protos.Attribute> attributes = this.margeAttribute(offer);
            for (Constraint constraint : constraints) {
                boolean found = constraint.matches(attributes);

                if (!found) {
                    return false;
                }
            }
        }

        return true;
    }
 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:22,代码来源:ConstraintsChecker.java

示例5: getAttributes

import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
 * Converts protobuf attributes into thrift-generated attributes.
 *
 * @param offer Resource offer.
 * @return Equivalent thrift host attributes.
 */
public static IHostAttributes getAttributes(Offer offer) {
  // Group by attribute name.
  Multimap<String, Protos.Attribute> valuesByName =
      Multimaps.index(offer.getAttributesList(), ATTRIBUTE_NAME);

  return IHostAttributes.build(new HostAttributes(
      offer.getHostname(),
      FluentIterable.from(valuesByName.asMap().entrySet())
          .transform(ATTRIBUTE_CONVERTER)
          .toSet())
      .setSlaveId(offer.getSlaveId().getValue()));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:19,代码来源:Conversions.java

示例6: AttributeBuilder

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public AttributeBuilder(List<Protos.Attribute> attrs) {
    for (Protos.Attribute attr : attrs) {

        Attribute.Type t;
        Object o;
        if (attr.hasScalar()) {
            // converts to Double
            t = Attribute.Type.SCALAR;
            o = Double.valueOf(attr.getScalar().getValue());
        } else if (attr.hasRanges()) {
            // converts to List<Range>
            t = Attribute.Type.RANGES;
            List<Range> ranges = new ArrayList<>();
            for (Protos.Value.Range range : attr.getRanges().getRangeList()) {
                Range r = new Range(range.getBegin(), range.getEnd());
                ranges.add(r);
            }
            o = ranges;
        } else if (attr.hasSet()) {
            // converts to Set<String>
            t = Attribute.Type.SET;
            int count = attr.getSet().getItemCount();
            Set<String> items = new HashSet<>();
            for (int i = 0; i < count; i++) {
                items.add(attr.getSet().getItem(i));
            }
            o = items;
        } else if (attr.hasText()) {
            // converts to String
            t = Attribute.Type.TEXT;
            o = attr.getText().getValue();
        } else {
            throw new AssertionError("attribute has unknown type: " + attr.getType());
        }
        Attribute a = new Attribute(attr.getName(), t, o);
        list.add(a);
    }
}
 
开发者ID:retz,项目名称:retz,代码行数:39,代码来源:AttributeBuilder.java

示例7: contains

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private boolean contains(List<Protos.Attribute> attributes, String name) {
    for (Protos.Attribute attribute : attributes) {
        if (attribute.getName().equals(name)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:9,代码来源:ConstraintsChecker.java

示例8: Offer

import org.apache.mesos.Protos; //导入方法依赖的package包/类
public Offer(Protos.Offer offer) {
	this.offer = checkNotNull(offer);
	this.hostname = offer.getHostname();
	this.vmID = offer.getSlaveId().getValue();
	this.offeredTime = System.currentTimeMillis();

	List<Protos.Resource> resources = new ArrayList<>(offer.getResourcesList().size());
	Map<String, List<Protos.Resource>> resourceMap = new HashMap<>();
	for (Protos.Resource resource : offer.getResourcesList()) {
		switch (resource.getType()) {
			case SCALAR:
			case RANGES:
				resources.add(resource);
				resourceMap.computeIfAbsent(resource.getName(), k -> new ArrayList<>(2)).add(resource);
				break;
			default:
				logger.debug("Unknown resource type " + resource.getType() + " for resource " + resource.getName() +
					" in offer, hostname=" + hostname + ", offerId=" + offer.getId());
		}
	}
	this.resources = Collections.unmodifiableList(resources);

	this.cpuCores = aggregateScalarResource(resourceMap, "cpus");
	this.memoryMB = aggregateScalarResource(resourceMap, "mem");
	this.networkMbps = aggregateScalarResource(resourceMap, "network");
	this.diskMB = aggregateScalarResource(resourceMap, "disk");
	this.portRanges = Collections.unmodifiableList(aggregateRangesResource(resourceMap, "ports"));

	if (offer.getAttributesCount() > 0) {
		Map<String, Protos.Attribute> attributeMap = new HashMap<>();
		for (Protos.Attribute attribute: offer.getAttributesList()) {
			attributeMap.put(attribute.getName(), attribute);
		}
		this.attributeMap = Collections.unmodifiableMap(attributeMap);
	} else {
		this.attributeMap = Collections.emptyMap();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:39,代码来源:Offer.java

示例9: offer

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Protos.Offer offer(List<Protos.Resource> resources, List<Protos.Attribute> attributes) {
	return Protos.Offer.newBuilder()
		.setId(OFFER_ID)
		.setFrameworkId(FRAMEWORK_ID)
		.setHostname(HOSTNAME)
		.setSlaveId(AGENT_ID)
		.addAllAttributes(attributes)
		.addAllResources(resources)
		.build();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:11,代码来源:OfferTest.java

示例10: attr

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static Protos.Attribute attr(String name, double scalar) {
	return Protos.Attribute.newBuilder()
		.setName(name)
		.setType(Protos.Value.Type.SCALAR)
		.setScalar(Protos.Value.Scalar.newBuilder().setValue(scalar))
		.build();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:8,代码来源:OfferTest.java

示例11: getAttributeMap

import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public Map<String, Protos.Attribute> getAttributeMap() {
	return attributeMap;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:5,代码来源:Offer.java

示例12: attrs

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private static List<Protos.Attribute> attrs(Protos.Attribute... attributes) {
	return Arrays.asList(attributes);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:4,代码来源:OfferTest.java

示例13: margeAttribute

import org.apache.mesos.Protos; //导入方法依赖的package包/类
private List<Protos.Attribute> margeAttribute(Protos.Offer offer) {

        List<Protos.Attribute> mergeAttributes = new ArrayList<>();

        Protos.Value.Text hostnameText = Protos.Value.Text.newBuilder().setValue(offer.getHostname()).build();
        Protos.Attribute hostnameAttribute = Protos.Attribute.newBuilder().setName("hostname").setText(hostnameText).setType(Protos.Value.Type.TEXT).build();

        mergeAttributes.addAll(offer.getAttributesList());

        if (!contains(mergeAttributes, "hostname")) {
            mergeAttributes.add(hostnameAttribute);
        }

        return mergeAttributes;
    }
 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:16,代码来源:ConstraintsChecker.java

示例14: matches

import org.apache.mesos.Protos; //导入方法依赖的package包/类
abstract public boolean matches(List<Protos.Attribute> attributes); 
开发者ID:farmapromlab,项目名称:rundeck-mesos-plugin,代码行数:2,代码来源:Constraint.java


注:本文中的org.apache.mesos.Protos.Attribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。