Search in sources :

Example 66 with Environment

use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.

the class MetadataIndexTemplateServiceTests method putTemplate.

private static List<Throwable> putTemplate(NamedXContentRegistry xContentRegistry, PutRequest request) {
    MetadataCreateIndexService createIndexService = new MetadataCreateIndexService(Settings.EMPTY, null, null, null, null, createTestShardLimitService(randomIntBetween(1, 1000)), new Environment(builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(), null), IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, null, xContentRegistry, new SystemIndices(Collections.emptyMap()), true);
    MetadataIndexTemplateService service = new MetadataIndexTemplateService(null, createIndexService, new AliasValidator(), null, new IndexScopedSettings(Settings.EMPTY, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS), xContentRegistry);
    final List<Throwable> throwables = new ArrayList<>();
    service.putTemplate(request, new MetadataIndexTemplateService.PutListener() {

        @Override
        public void onResponse(MetadataIndexTemplateService.PutResponse response) {
        }

        @Override
        public void onFailure(Exception e) {
            throwables.add(e);
        }
    });
    return throwables;
}
Also used : IndexScopedSettings(org.opensearch.common.settings.IndexScopedSettings) ArrayList(java.util.ArrayList) IndexTemplateMissingException(org.opensearch.indices.IndexTemplateMissingException) MapperParsingException(org.opensearch.index.mapper.MapperParsingException) IOException(java.io.IOException) InvalidIndexTemplateException(org.opensearch.indices.InvalidIndexTemplateException) Environment(org.opensearch.env.Environment) SystemIndices(org.opensearch.indices.SystemIndices)

Example 67 with Environment

use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.

the class MetadataIndexTemplateServiceTests method getMetadataIndexTemplateService.

private MetadataIndexTemplateService getMetadataIndexTemplateService() {
    IndicesService indicesService = getInstanceFromNode(IndicesService.class);
    ClusterService clusterService = getInstanceFromNode(ClusterService.class);
    MetadataCreateIndexService createIndexService = new MetadataCreateIndexService(Settings.EMPTY, clusterService, indicesService, null, null, createTestShardLimitService(randomIntBetween(1, 1000)), new Environment(builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(), null), IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, null, xContentRegistry(), new SystemIndices(Collections.emptyMap()), true);
    return new MetadataIndexTemplateService(clusterService, createIndexService, new AliasValidator(), indicesService, new IndexScopedSettings(Settings.EMPTY, IndexScopedSettings.BUILT_IN_INDEX_SETTINGS), xContentRegistry());
}
Also used : ClusterService(org.opensearch.cluster.service.ClusterService) IndexScopedSettings(org.opensearch.common.settings.IndexScopedSettings) IndicesService(org.opensearch.indices.IndicesService) Environment(org.opensearch.env.Environment) SystemIndices(org.opensearch.indices.SystemIndices)

Example 68 with Environment

use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.

the class InternalSettingsPreparerTests method testDefaultPropertiesDoNothing.

public void testDefaultPropertiesDoNothing() throws Exception {
    Map<String, String> props = Collections.singletonMap("default.setting", "foo");
    Environment env = InternalSettingsPreparer.prepareEnvironment(baseEnvSettings, props, null, () -> "default_node_name");
    assertEquals("foo", env.settings().get("default.setting"));
    assertNull(env.settings().get("setting"));
}
Also used : Environment(org.opensearch.env.Environment) SecureString(org.opensearch.common.settings.SecureString)

Example 69 with Environment

use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.

the class InternalSettingsPreparerTests method testEmptySettings.

public void testEmptySettings() {
    Settings settings = InternalSettingsPreparer.prepareSettings(Settings.EMPTY);
    assertNull(settings.get("node.name"));
    // a cluster name was set
    assertNotNull(settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()));
    int size = settings.names().size();
    String defaultNodeName = randomAlphaOfLength(8);
    Environment env = InternalSettingsPreparer.prepareEnvironment(baseEnvSettings, emptyMap(), null, () -> defaultNodeName);
    settings = env.settings();
    assertEquals(defaultNodeName, settings.get("node.name"));
    // a cluster name was set
    assertNotNull(settings.get(ClusterName.CLUSTER_NAME_SETTING.getKey()));
    assertEquals(settings.toString(), size + 1, /* path.home is in the base settings */
    settings.names().size());
    String home = Environment.PATH_HOME_SETTING.get(baseEnvSettings);
    String configDir = env.configFile().toString();
    assertTrue(configDir, configDir.startsWith(home));
}
Also used : Environment(org.opensearch.env.Environment) SecureString(org.opensearch.common.settings.SecureString) MockSecureSettings(org.opensearch.common.settings.MockSecureSettings) Settings(org.opensearch.common.settings.Settings)

Example 70 with Environment

use of org.opensearch.env.Environment in project OpenSearch by opensearch-project.

the class BlobStoreRepositoryTests method testFsRepositoryCompressDeprecated.

public void testFsRepositoryCompressDeprecated() {
    final Path location = OpenSearchIntegTestCase.randomRepoPath(node().settings());
    final Settings settings = Settings.builder().put(node().settings()).put("location", location).build();
    final RepositoryMetadata metadata = new RepositoryMetadata("test-repo", REPO_TYPE, settings);
    Settings useCompressSettings = Settings.builder().put(node().getEnvironment().settings()).put(FsRepository.REPOSITORIES_COMPRESS_SETTING.getKey(), true).build();
    Environment useCompressEnvironment = new Environment(useCompressSettings, node().getEnvironment().configFile());
    new FsRepository(metadata, useCompressEnvironment, null, BlobStoreTestUtil.mockClusterService(), null);
    assertWarnings("[repositories.fs.compress] setting was deprecated in OpenSearch and will be removed in a future release!" + " See the breaking changes documentation for the next major version.");
}
Also used : Path(java.nio.file.Path) RepositoryMetadata(org.opensearch.cluster.metadata.RepositoryMetadata) Environment(org.opensearch.env.Environment) RecoverySettings(org.opensearch.indices.recovery.RecoverySettings) Settings(org.opensearch.common.settings.Settings) FsRepository(org.opensearch.repositories.fs.FsRepository)

Aggregations

Environment (org.opensearch.env.Environment)142 TestEnvironment (org.opensearch.env.TestEnvironment)98 Path (java.nio.file.Path)80 Settings (org.opensearch.common.settings.Settings)79 Matchers.containsString (org.hamcrest.Matchers.containsString)69 Matchers.hasToString (org.hamcrest.Matchers.hasToString)40 NodeEnvironment (org.opensearch.env.NodeEnvironment)32 IOException (java.io.IOException)27 UserException (org.opensearch.cli.UserException)23 ClusterState (org.opensearch.cluster.ClusterState)22 IndexSettings (org.opensearch.index.IndexSettings)22 MockTerminal (org.opensearch.cli.MockTerminal)19 IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)19 OpenSearchException (org.opensearch.OpenSearchException)18 Map (java.util.Map)16 OptionSet (joptsimple.OptionSet)15 DiscoverySettings (org.opensearch.node.Node.DiscoverySettings)14 Version (org.opensearch.Version)13 Files (java.nio.file.Files)11 Arrays (java.util.Arrays)11