Пример #1
0
  public void testMainResponseXContent() throws IOException {
    final MainResponse mainResponse =
        new MainResponse(
            "node1", Version.CURRENT, new ClusterName("cluster1"), Build.CURRENT, false);
    final String expected =
        "{\"name\":\"node1\",\"cluster_name\":\"cluster1\",\"version\":{\"number\":\""
            + Version.CURRENT.toString()
            + "\",\"build_hash\":\""
            + Build.CURRENT.shortHash()
            + "\",\"build_date\":\""
            + Build.CURRENT.date()
            + "\","
            + "\"build_snapshot\":"
            + Build.CURRENT.isSnapshot()
            + ",\"lucene_version\":\""
            + Version.CURRENT.luceneVersion.toString()
            + "\"},\"tagline\":\"You Know, for Search\"}";

    XContentBuilder builder = XContentFactory.jsonBuilder();
    mainResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
    String xContent = builder.string();

    assertEquals(expected, xContent);
  }
Пример #2
0
 List<URL> urls() {
   List<URL> urls = new ArrayList<>();
   if (version != null) {
     // Elasticsearch new download service uses groupId org.elasticsearch.plugin from 2.0.0
     if (user == null) {
       if (!Strings.isNullOrEmpty(System.getProperty(PROPERTY_SUPPORT_STAGING_URLS))) {
         addUrl(
             urls,
             String.format(
                 Locale.ROOT,
                 "https://download.elastic.co/elasticsearch/staging/%s-%s/org/elasticsearch/plugin/%s/%s/%s-%s.zip",
                 version,
                 Build.CURRENT.hashShort(),
                 name,
                 version,
                 name,
                 version));
       }
       addUrl(
           urls,
           String.format(
               Locale.ROOT,
               "https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/%s/%s/%s-%s.zip",
               name,
               version,
               name,
               version));
     } else {
       // Elasticsearch old download service
       addUrl(
           urls,
           String.format(
               Locale.ROOT,
               "https://download.elastic.co/%1$s/%2$s/%2$s-%3$s.zip",
               user,
               name,
               version));
       // Maven central repository
       addUrl(
           urls,
           String.format(
               Locale.ROOT,
               "https://search.maven.org/remotecontent?filepath=%1$s/%2$s/%3$s/%2$s-%3$s.zip",
               user.replace('.', '/'),
               name,
               version));
       // Sonatype repository
       addUrl(
           urls,
           String.format(
               Locale.ROOT,
               "https://oss.sonatype.org/service/local/repositories/releases/content/%1$s/%2$s/%3$s/%2$s-%3$s.zip",
               user.replace('.', '/'),
               name,
               version));
       // Github repository
       addUrl(
           urls,
           String.format(
               Locale.ROOT,
               "https://github.com/%1$s/%2$s/archive/%3$s.zip",
               user,
               name,
               version));
     }
   }
   if (user != null) {
     // Github repository for master branch (assume site)
     addUrl(
         urls,
         String.format(
             Locale.ROOT, "https://github.com/%1$s/%2$s/archive/master.zip", user, name));
   }
   return urls;
 }
Пример #3
0
  public InternalNode(Settings preparedSettings, boolean loadConfigSettings)
      throws ElasticsearchException {
    final Settings pSettings =
        settingsBuilder()
            .put(preparedSettings)
            .put(Client.CLIENT_TYPE_SETTING, CLIENT_TYPE)
            .build();
    Tuple<Settings, Environment> tuple =
        InternalSettingsPreparer.prepareSettings(pSettings, loadConfigSettings);
    tuple = new Tuple<>(TribeService.processSettings(tuple.v1()), tuple.v2());

    // The only place we can actually fake the version a node is running on:
    Version version = pSettings.getAsVersion("tests.mock.version", Version.CURRENT);

    ESLogger logger = Loggers.getLogger(Node.class, tuple.v1().get("name"));
    logger.info(
        "version[{}], pid[{}], build[{}/{}]",
        version,
        JvmInfo.jvmInfo().pid(),
        Build.CURRENT.hashShort(),
        Build.CURRENT.timestamp());

    logger.info("initializing ...");

    if (logger.isDebugEnabled()) {
      Environment env = tuple.v2();
      logger.debug(
          "using home [{}], config [{}], data [{}], logs [{}], work [{}], plugins [{}]",
          env.homeFile(),
          env.configFile(),
          Arrays.toString(env.dataFiles()),
          env.logsFile(),
          env.workFile(),
          env.pluginsFile());
    }

    this.pluginsService = new PluginsService(tuple.v1(), tuple.v2());
    this.settings = pluginsService.updatedSettings();
    // create the environment based on the finalized (processed) view of the settings
    this.environment = new Environment(this.settings());

    CompressorFactory.configure(settings);
    final NodeEnvironment nodeEnvironment;
    try {
      nodeEnvironment = new NodeEnvironment(this.settings, this.environment);
    } catch (IOException ex) {
      throw new ElasticsearchIllegalStateException("Failed to created node environment", ex);
    }

    boolean success = false;
    try {
      ModulesBuilder modules = new ModulesBuilder();
      modules.add(new Version.Module(version));
      modules.add(new PageCacheRecyclerModule(settings));
      modules.add(new CircuitBreakerModule(settings));
      modules.add(new BigArraysModule(settings));
      modules.add(new PluginsModule(settings, pluginsService));
      modules.add(new SettingsModule(settings));
      modules.add(new NodeModule(this));
      modules.add(new NetworkModule());
      modules.add(new ScriptModule(settings));
      modules.add(new EnvironmentModule(environment));
      modules.add(new NodeEnvironmentModule(nodeEnvironment));
      modules.add(new ClusterNameModule(settings));
      modules.add(new ThreadPoolModule(settings));
      modules.add(new DiscoveryModule(settings));
      modules.add(new ClusterModule(settings));
      modules.add(new RestModule(settings));
      modules.add(new TransportModule(settings));
      if (settings.getAsBoolean(HTTP_ENABLED, true)) {
        modules.add(new HttpServerModule(settings));
      }
      modules.add(new RiversModule(settings));
      modules.add(new IndicesModule(settings));
      modules.add(new SearchModule());
      modules.add(new ActionModule(false));
      modules.add(new MonitorModule(settings));
      modules.add(new GatewayModule(settings));
      modules.add(new NodeClientModule());
      modules.add(new ShapeModule());
      modules.add(new PercolatorModule());
      modules.add(new ResourceWatcherModule());
      modules.add(new RepositoriesModule());
      modules.add(new TribeModule());
      modules.add(new BenchmarkModule(settings));

      injector = modules.createInjector();

      client = injector.getInstance(Client.class);
      success = true;
    } finally {
      if (!success) {
        nodeEnvironment.close();
      }
    }

    logger.info("initialized");
  }