com.yahoo.component.Version.fromString()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(105)

本文整理了Java中com.yahoo.component.Version.fromString()方法的一些代码示例,展示了Version.fromString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.fromString()方法的具体详情如下:
包路径:com.yahoo.component.Version
类名称:Version
方法名:fromString

Version.fromString介绍

[英]Returns new Version(versionString), or Version.emptyVersion if the input string is null or ""
[中]返回新版本(versionString)或版本。如果输入字符串为null或“”

代码示例

代码示例来源:origin: com.yahoo.vespa/component

private ComponentId(SpecSplitter splitter) {
  this(splitter.name, Version.fromString(splitter.version), splitter.namespace);
}

代码示例来源:origin: com.yahoo.vespa/config-model

/**
 * Create id with a name and version
 * @param tagName Name of the id
 * @param tagVersion Version of the id
 * @return A ConfigModelId instance
 */
public static ConfigModelId fromNameAndVersion(String tagName, String tagVersion) {
  return new ConfigModelId(tagName, Version.fromString(tagVersion));
}

代码示例来源:origin: com.yahoo.vespa/node-repository

public static NodeOsVersionFilter from(String version, NodeFilter filter) {
  return new NodeOsVersionFilter(Version.fromString(version), filter);
}

代码示例来源:origin: com.yahoo.vespa/config-provisioning

/** Get Docker image tag as version */
public Version tagAsVersion() {
  String[] parts = asString().split(":");
  if (parts.length < 2) {
    throw new IllegalArgumentException("Could not parse tag from Docker image '" + asString() + "'");
  }
  return Version.fromString(parts[parts.length - 1]);
}

代码示例来源:origin: com.yahoo.vespa/config-model

private void checkVersion(Element spec) {
  String version = spec.getAttribute("version");
  if ( ! Version.fromString(version).equals(new Version(1))) {
    throw new RuntimeException("Expected container version to be 1.0, but got " + version);
  }
}

代码示例来源:origin: com.yahoo.vespa/node-repository

private Optional<Version> versionFromSlime(Inspector object) {
  if ( ! object.valid()) return Optional.empty();
  return Optional.of(Version.fromString(object.asString()));
}

代码示例来源:origin: com.yahoo.vespa/node-repository

public static Map<NodeType, Version> fromJson(byte[] data) {
  Map<NodeType, Version> versions = new TreeMap<>(); // Use TreeMap to sort by node type
  Inspector inspector = SlimeUtils.jsonToSlime(data).get();
  inspector.traverse((ObjectTraverser) (key, value) ->
      versions.put(NodeSerializer.nodeTypeFromString(key), Version.fromString(value.asString())));
  return versions;
}

代码示例来源:origin: com.yahoo.vespa/config-provisioning

private static ClusterMembership membershipFromSlime(Inspector object) {
  return ClusterMembership.from(object.field(hostSpecMembership).asString(),
                 com.yahoo.component.Version.fromString(object.field(hostSpecVespaVersion).asString()));
}

代码示例来源:origin: com.yahoo.vespa/node-repository

private MessageResponse setTargetVersions(HttpRequest request) {
  NodeType nodeType = NodeType.valueOf(lastElement(request.getUri().getPath()).toLowerCase());
  Inspector inspector = toSlime(request.getData()).get();
  List<String> messageParts = new ArrayList<>(3);
  boolean force = inspector.field("force").asBool();
  Inspector versionField = inspector.field("version");
  Inspector osVersionField = inspector.field("osVersion");
  if (versionField.valid()) {
    Version version = Version.fromString(versionField.asString());
    maintenance.infrastructureVersions().setTargetVersion(nodeType, version, force);
    messageParts.add("version to " + version.toFullString());
  }
  if (osVersionField.valid()) {
    String v = osVersionField.asString();
    if (v.isEmpty()) {
      nodeRepository.osVersions().removeTarget(nodeType);
      messageParts.add("osVersion to null");
    } else {
      Version osVersion = Version.fromString(v);
      nodeRepository.osVersions().setTarget(nodeType, osVersion, force);
      messageParts.add("osVersion to " + osVersion.toFullString());
    }
  }
  if (messageParts.isEmpty()) {
    throw new IllegalArgumentException("At least one of 'version' and 'osVersion' must be set");
  }
  return new MessageResponse("Set " + String.join(", ", messageParts) +
                " for nodes of type " + nodeType);
}

代码示例来源:origin: com.yahoo.vespa/node-repository

Status node10newStatus = node10.status();
node10newStatus = node10newStatus
    .withVespaVersion(Version.fromString("5.104.142"));
node10 = node10.with(node10newStatus);
nodes.add(node10);
ClusterSpec zoneCluster = ClusterSpec.request(ClusterSpec.Type.container,
                       ClusterSpec.Id.from("node-admin"),
                       Version.fromString("6.42"),
                       false,
                       Set.of(RotationName.from("us-cluster")));
ClusterSpec cluster1 = ClusterSpec.request(ClusterSpec.Type.container,
                      ClusterSpec.Id.from("id1"),
                      Version.fromString("6.42"),
                      false, Collections.emptySet());
provisioner.prepare(app1, cluster1, Capacity.fromNodeCount(2), 1, null);
ClusterSpec cluster2 = ClusterSpec.request(ClusterSpec.Type.content,
                      ClusterSpec.Id.from("id2"),
                      Version.fromString("6.42"),
                      false, Collections.emptySet());
activate(provisioner.prepare(app2, cluster2, Capacity.fromNodeCount(2), 1, null), app2, provisioner);
ClusterSpec cluster3 = ClusterSpec.request(ClusterSpec.Type.content,
                      ClusterSpec.Id.from("id3"),
                      Version.fromString("6.42"),
                      false, Collections.emptySet());
activate(provisioner.prepare(app3, cluster3, Capacity.fromNodeCount(2, Optional.of("docker"), false, true), 1, null), app3, provisioner);

代码示例来源:origin: com.yahoo.vespa/node-repository

case "vespaVersion" :
case "currentVespaVersion" :
  return node.with(node.status().withVespaVersion(Version.fromString(asString(value))));
case "currentOsVersion" :
  return node.with(node.status().withOsVersion(Version.fromString(asString(value))));
case "currentFirmwareCheck":
  return node.with(node.status().withFirmwareVerifiedAt(Instant.ofEpochMilli(asLong(value))));

相关文章