org.elasticsearch.Version.toString()方法的使用及代码示例

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

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

Version.toString介绍

暂无

代码示例

代码示例来源:origin: thinkaurelius/titan

private void checkExpectedClientVersion() {
    /*
     * This is enclosed in a catch block to prevent an unchecked exception
     * from killing the startup thread.  This check is just advisory -- the
     * most it does is log a warning -- so there's no reason to allow it to
     * emit a exception and potentially block graph startup.
     */
    try {
      if (!Version.CURRENT.toString().equals(ElasticSearchConstants.ES_VERSION_EXPECTED)) {
        log.warn("ES client version ({}) does not match the version with which Titan was compiled ({}).  This might cause problems.",
            Version.CURRENT, ElasticSearchConstants.ES_VERSION_EXPECTED);
      } else {
        log.debug("Found ES client version matching Titan's compile-time version: {} (OK)", Version.CURRENT);
      }
    } catch (RuntimeException e) {
      log.warn("Unable to check expected ES client version", e);
    }
  }
}

代码示例来源:origin: floragunncom/search-guard

private static void issueWarnings(Client tc) {
    NodesInfoResponse nir = tc.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet();
    Version maxVersion = nir.getNodes().stream().max((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion();
    Version minVersion = nir.getNodes().stream().min((n1,n2) -> n1.getVersion().compareTo(n2.getVersion())).get().getVersion();
    
    if(!maxVersion.equals(minVersion)) {
      System.out.println("WARNING: Your cluster consists of different node versions. It is not recommended to run sgadmin against a mixed cluster. This may fail.");
      System.out.println("         Minimum node version is "+minVersion.toString());
      System.out.println("         Maximum node version is "+maxVersion.toString());
    } else {
      System.out.println("Elasticsearch Version: "+minVersion.toString());
    }
    
    if(nir.getNodes().size() > 0) {
      List<PluginInfo> pluginInfos = nir.getNodes().get(0).getPlugins().getPluginInfos();
      String sgVersion = pluginInfos.stream().filter(p->p.getClassname().equals("com.floragunn.searchguard.SearchGuardPlugin")).map(p->p.getVersion()).findFirst().orElse("<unknown>");
      System.out.println("Search Guard Version: "+sgVersion);
    }
  }
}

代码示例来源:origin: elastic/elasticsearch-hadoop

@Test
public void testVersionFromString() {
  for (int i = 0; i < SORTED_VERSIONS.size(); i++) {
    Version official = SORTED_VERSIONS.get(i);
    EsMajorVersion version = EsMajorVersion.parse(official.toString());
    assertThat(version.major,
        equalTo(official.major));
    assertTrue(version.onOrAfter(version));
    assertTrue(version.equals(version));
    for (int j = i + 1; j < SORTED_VERSIONS.size(); j++) {
      Version cmp_official = SORTED_VERSIONS.get(j);
      EsMajorVersion cmp_version = EsMajorVersion.parse(cmp_official.toString());
      assertThat(cmp_version.after(version), equalTo(cmp_official.major != official.major));
      assertTrue(cmp_version.onOrAfter(version));
      assertFalse(cmp_version.equals(version));
    }
    for (int j = i - 1; j >= 0; j--) {
      Version cmp_official = SORTED_VERSIONS.get(j);
      EsMajorVersion cmp_version = EsMajorVersion.parse(cmp_official.toString());
      assertThat(cmp_version.before(version), equalTo(cmp_official.major != official.major));
      assertTrue(cmp_version.onOrBefore(version));
      assertFalse(cmp_version.equals(version));
    }
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  return builder.value(toString());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Adds human readable version and creation date settings.
 * This method is used to display the settings in a human readable format in REST API
 */
public static Settings addHumanReadableSettings(Settings settings) {
  Settings.Builder builder = Settings.builder().put(settings);
  Version version = SETTING_INDEX_VERSION_CREATED.get(settings);
  if (version != Version.V_EMPTY) {
    builder.put(SETTING_VERSION_CREATED_STRING, version.toString());
  }
  Version versionUpgraded = settings.getAsVersion(SETTING_VERSION_UPGRADED, null);
  if (versionUpgraded != null) {
    builder.put(SETTING_VERSION_UPGRADED_STRING, versionUpgraded.toString());
  }
  Long creationDate = settings.getAsLong(SETTING_CREATION_DATE, null);
  if (creationDate != null) {
    ZonedDateTime creationDateTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(creationDate), ZoneOffset.UTC);
    builder.put(SETTING_CREATION_DATE_STRING, creationDateTime.toString());
  }
  return builder.build();
}

代码示例来源:origin: dadoonet/fscrawler

@Override
public ESVersion getVersion() throws IOException {
  Version version = client.info(RequestOptions.DEFAULT).getVersion();
  return ESVersion.fromString(version.toString());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * BWC serialization for nested {@link InnerHitBuilder}.
 * Should only be used to send nested inner hits to nodes pre 5.5.
 */
protected void writeToNestedBWC(StreamOutput out, QueryBuilder query, String nestedPath) throws IOException {
  assert out.getVersion().before(Version.V_5_5_0) :
    "invalid output version, must be < " + Version.V_5_5_0.toString();
  writeToBWC(out, query, nestedPath, null);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * BWC serialization for parent/child {@link InnerHitBuilder}.
 * Should only be used to send hasParent or hasChild inner hits to nodes pre 5.5.
 */
public void writeToParentChildBWC(StreamOutput out, QueryBuilder query, String parentChildPath) throws IOException {
  assert(out.getVersion().before(Version.V_5_5_0)) :
    "invalid output version, must be < " + Version.V_5_5_0.toString();
  writeToBWC(out, query, null, parentChildPath);
}

代码示例来源:origin: dadoonet/fscrawler

@Override
public ESVersion getVersion() throws IOException {
  Version version = client.info().getVersion();
  return ESVersion.fromString(version.toString());
}

代码示例来源:origin: dadoonet/fscrawler

@Override
public ESVersion getVersion() throws IOException {
  Version version = client.info(RequestOptions.DEFAULT).getVersion();
  return ESVersion.fromString(version.toString());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * BWC serialization for collapsing {@link InnerHitBuilder}.
 * Should only be used to send collapsing inner hits to nodes pre 5.5.
 */
public void writeToCollapseBWC(StreamOutput out) throws IOException {
  assert out.getVersion().before(Version.V_5_5_0) :
    "invalid output version, must be < " + Version.V_5_5_0.toString();
  writeToBWC(out, new MatchAllQueryBuilder(), null, null);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

builder.value(v.toString());

代码示例来源:origin: org.elasticsearch/elasticsearch

final boolean isRequest = TransportStatus.isRequest(status);
final String type = isRequest ? "request" : "response";
final String version = Version.fromId(streamInput.readInt()).toString();
sb.append(" [length: ").append(messageLengthWithHeader);
sb.append(", request id: ").append(requestId);

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
  builder.startObject();
  builder.field("name", nodeName);
  builder.field("cluster_name", clusterName.value());
  builder.field("cluster_uuid", clusterUuid);
  builder.startObject("version")
    .field("number", version.toString())
    .field("build_flavor", build.flavor().displayName())
    .field("build_type", build.type().displayName())
    .field("build_hash", build.shortHash())
    .field("build_date", build.date())
    .field("build_snapshot", build.isSnapshot())
    .field("lucene_version", version.luceneVersion.toString())
    .field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString())
    .field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString())
    .endObject();
  builder.field("tagline", "You Know, for Search");
  builder.endObject();
  return builder;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public void writeTo(StreamOutput out) throws IOException {
  if (out.getVersion().before(Version.V_5_5_0)) {
    throw new IOException("Invalid output version, must >= " + Version.V_5_5_0.toString());

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public void addAdditionalFields(XContentBuilder builder, ToXContent.Params params) throws IOException {
  builder.field("repository", snapshot.getRepository())
    .field("snapshot", snapshot.getSnapshotId().getName())
    .field("version", version.toString())
    .field("index", index)
    .field("restoreUUID", restoreUUID);
}

代码示例来源:origin: dadoonet/fscrawler

public void createIndices() throws Exception {
  String elasticsearchVersion;
  Path jobMappingDir = config.resolve(settings.getName()).resolve("_mappings");
  // Let's read the current version of elasticsearch cluster
  Version version = client.info(RequestOptions.DEFAULT).getVersion();
  logger.debug("FS crawler connected to an elasticsearch [{}] node.", version.toString());
  elasticsearchVersion = Byte.toString(version.major);
  // If needed, we create the new settings for this files index
  if (!settings.getFs().isAddAsInnerObject() || (!settings.getFs().isJsonSupport() && !settings.getFs().isXmlSupport())) {
    createIndex(jobMappingDir, elasticsearchVersion, INDEX_SETTINGS_FILE, settings.getElasticsearch().getIndex());
  } else {
    createIndex(settings.getElasticsearch().getIndex(), true, null);
  }
  // If needed, we create the new settings for this folder index
  if (settings.getFs().isIndexFolders()) {
    createIndex(jobMappingDir, elasticsearchVersion, INDEX_SETTINGS_FOLDER_FILE, settings.getElasticsearch().getIndexFolder());
  } else {
    createIndex(settings.getElasticsearch().getIndexFolder(), true, null);
  }
}

代码示例来源:origin: dadoonet/fscrawler

public void createIndices() throws Exception {
  String elasticsearchVersion;
  Path jobMappingDir = config.resolve(settings.getName()).resolve("_mappings");
  // Let's read the current version of elasticsearch cluster
  Version version = client.info().getVersion();
  logger.debug("FS crawler connected to an elasticsearch [{}] node.", version.toString());
  elasticsearchVersion = Byte.toString(version.major);
  // If needed, we create the new settings for this files index
  if (!settings.getFs().isAddAsInnerObject() || (!settings.getFs().isJsonSupport() && !settings.getFs().isXmlSupport())) {
    createIndex(jobMappingDir, elasticsearchVersion, INDEX_SETTINGS_FILE, settings.getElasticsearch().getIndex());
  } else {
    createIndex(settings.getElasticsearch().getIndex(), true, null);
  }
  // If needed, we create the new settings for this folder index
  if (settings.getFs().isIndexFolders()) {
    createIndex(jobMappingDir, elasticsearchVersion, INDEX_SETTINGS_FOLDER_FILE, settings.getElasticsearch().getIndexFolder());
  } else {
    createIndex(settings.getElasticsearch().getIndexFolder(), true, null);
  }
}

代码示例来源:origin: dadoonet/fscrawler

public void createIndices() throws Exception {
  String elasticsearchVersion;
  Path jobMappingDir = config.resolve(settings.getName()).resolve("_mappings");
  // Let's read the current version of elasticsearch cluster
  Version version = client.info(RequestOptions.DEFAULT).getVersion();
  logger.debug("FS crawler connected to an elasticsearch [{}] node.", version.toString());
  elasticsearchVersion = Byte.toString(version.major);
  // If needed, we create the new settings for this files index
  if (!settings.getFs().isAddAsInnerObject() || (!settings.getFs().isJsonSupport() && !settings.getFs().isXmlSupport())) {
    createIndex(jobMappingDir, elasticsearchVersion, INDEX_SETTINGS_FILE, settings.getElasticsearch().getIndex());
  } else {
    createIndex(settings.getElasticsearch().getIndex(), true, null);
  }
  // If needed, we create the new settings for this folder index
  if (settings.getFs().isIndexFolders()) {
    createIndex(jobMappingDir, elasticsearchVersion, INDEX_SETTINGS_FOLDER_FILE, settings.getElasticsearch().getIndexFolder());
  } else {
    createIndex(settings.getElasticsearch().getIndexFolder(), true, null);
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

private void buildRow(Table table, boolean fullId, boolean detailed, DiscoveryNodes discoveryNodes, TaskInfo taskInfo) {
  table.startRow();
  String nodeId = taskInfo.getTaskId().getNodeId();
  DiscoveryNode node = discoveryNodes.get(nodeId);
  table.addCell(taskInfo.getId());
  table.addCell(taskInfo.getAction());
  table.addCell(taskInfo.getTaskId().toString());
  if (taskInfo.getParentTaskId().isSet()) {
    table.addCell(taskInfo.getParentTaskId().toString());
  } else {
    table.addCell("-");
  }
  table.addCell(taskInfo.getType());
  table.addCell(taskInfo.getStartTime());
  table.addCell(FORMATTER.format(Instant.ofEpochMilli(taskInfo.getStartTime())));
  table.addCell(taskInfo.getRunningTimeNanos());
  table.addCell(TimeValue.timeValueNanos(taskInfo.getRunningTimeNanos()).toString());
  // Node information. Note that the node may be null because it has left the cluster between when we got this response and now.
  table.addCell(fullId ? nodeId : Strings.substring(nodeId, 0, 4));
  table.addCell(node == null ? "-" : node.getHostAddress());
  table.addCell(node.getAddress().address().getPort());
  table.addCell(node == null ? "-" : node.getName());
  table.addCell(node == null ? "-" : node.getVersion().toString());
  if (detailed) {
    table.addCell(taskInfo.getDescription());
  }
  table.endRow();
}

相关文章