Search in sources :

Example 96 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.

the class MasterServiceTests method createMasterService.

private MasterService createMasterService(boolean makeMaster) {
    final DiscoveryNode localNode = new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
    final MasterService masterService = new MasterService(Settings.builder().put(ClusterName.CLUSTER_NAME_SETTING.getKey(), MasterServiceTests.class.getSimpleName()).put(Node.NODE_NAME_SETTING.getKey(), "test_node").build(), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), threadPool);
    final ClusterState initialClusterState = ClusterState.builder(new ClusterName(MasterServiceTests.class.getSimpleName())).nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).masterNodeId(makeMaster ? localNode.getId() : null)).blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK).build();
    final AtomicReference<ClusterState> clusterStateRef = new AtomicReference<>(initialClusterState);
    masterService.setClusterStatePublisher((event, publishListener, ackListener) -> {
        clusterStateRef.set(event.state());
        publishListener.onResponse(null);
    });
    masterService.setClusterStateSupplier(clusterStateRef::get);
    masterService.start();
    return masterService;
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) ClusterName(org.elasticsearch.cluster.ClusterName) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Example 97 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.

the class NodeRepurposeCommandTests method createNodePaths.

@Before
public void createNodePaths() throws IOException {
    dataMasterSettings = buildEnvSettings(Settings.EMPTY);
    environment = TestEnvironment.newEnvironment(dataMasterSettings);
    try (NodeEnvironment nodeEnvironment = new NodeEnvironment(dataMasterSettings, environment)) {
        nodePaths = nodeEnvironment.nodeDataPaths();
        final String nodeId = randomAlphaOfLength(10);
        try (PersistedClusterStateService.Writer writer = new PersistedClusterStateService(nodePaths, nodeId, xContentRegistry(), BigArrays.NON_RECYCLING_INSTANCE, new ClusterSettings(dataMasterSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), () -> 0L, true).createWriter()) {
            writer.writeFullStateAndCommit(1L, ClusterState.EMPTY_STATE);
        }
    }
    dataNoMasterSettings = Settings.builder().put(dataMasterSettings).put(Node.NODE_MASTER_SETTING.getKey(), false).build();
    noDataNoMasterSettings = Settings.builder().put(dataMasterSettings).put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), false).build();
    noDataMasterSettings = Settings.builder().put(dataMasterSettings).put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true).build();
}
Also used : ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Matchers.containsString(org.hamcrest.Matchers.containsString) PersistedClusterStateService(org.elasticsearch.gateway.PersistedClusterStateService) Before(org.junit.Before)

Example 98 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.

the class OverrideNodeVersionCommandTests method createNodePaths.

@Before
public void createNodePaths() throws IOException {
    final Settings settings = buildEnvSettings(Settings.EMPTY);
    environment = TestEnvironment.newEnvironment(settings);
    try (NodeEnvironment nodeEnvironment = new NodeEnvironment(settings, environment)) {
        nodePaths = nodeEnvironment.nodeDataPaths();
        nodeId = nodeEnvironment.nodeId();
        try (PersistedClusterStateService.Writer writer = new PersistedClusterStateService(nodePaths, nodeId, xContentRegistry(), BigArrays.NON_RECYCLING_INSTANCE, new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), () -> 0L, true).createWriter()) {
            writer.writeFullStateAndCommit(1L, ClusterState.builder(ClusterName.DEFAULT).metadata(Metadata.builder().persistentSettings(Settings.builder().put(Metadata.SETTING_READ_ONLY_SETTING.getKey(), true).build()).build()).build());
        }
    }
}
Also used : ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) PersistedClusterStateService(org.elasticsearch.gateway.PersistedClusterStateService) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) Settings(org.elasticsearch.common.settings.Settings) Before(org.junit.Before)

Example 99 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.

the class IndexShardTestCase method newShard.

/**
 * creates a new initializing shard.
 * @param routing                       shard routing to use
 * @param shardPath                     path to use for shard data
 * @param indexMetadata                 indexMetadata for the shard, including any mapping
 * @param storeProvider                 an optional custom store provider to use. If null a default file based store will be created
 * @param globalCheckpointSyncer        callback for syncing global checkpoints
 * @param indexEventListener            index event listener
 * @param listeners                     an optional set of listeners to add to the shard
 */
protected IndexShard newShard(ShardRouting routing, ShardPath shardPath, IndexMetadata indexMetadata, @Nullable CheckedFunction<IndexSettings, Store, IOException> storeProvider, @Nullable EngineFactory engineFactory, Runnable globalCheckpointSyncer, RetentionLeaseSyncer retentionLeaseSyncer, IndexEventListener indexEventListener, IndexingOperationListener... listeners) throws IOException {
    final Settings nodeSettings = Settings.builder().put("node.name", routing.currentNodeId()).build();
    final IndexSettings indexSettings = new IndexSettings(indexMetadata, nodeSettings);
    final IndexShard indexShard;
    if (storeProvider == null) {
        storeProvider = is -> createStore(is, shardPath);
    }
    final Store store = storeProvider.apply(indexSettings);
    boolean success = false;
    try {
        IndexCache indexCache = new IndexCache(indexSettings, new DisabledQueryCache(indexSettings));
        MapperService mapperService = MapperTestUtils.newMapperService(xContentRegistry(), createTempDir(), indexSettings.getSettings(), "index");
        mapperService.merge(indexMetadata, MapperService.MergeReason.MAPPING_RECOVERY);
        ClusterSettings clusterSettings = new ClusterSettings(nodeSettings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
        CircuitBreakerService breakerService = new HierarchyCircuitBreakerService(nodeSettings, clusterSettings);
        indexShard = new IndexShard(routing, indexSettings, shardPath, store, indexCache, mapperService, engineFactory, indexEventListener, threadPool, BigArrays.NON_RECYCLING_INSTANCE, Arrays.asList(listeners), globalCheckpointSyncer, retentionLeaseSyncer, breakerService);
        indexShard.addShardFailureCallback(DEFAULT_SHARD_FAILURE_HANDLER);
        success = true;
    } finally {
        if (success == false) {
            IOUtils.close(store);
        }
    }
    return indexShard;
}
Also used : ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) IndexSettings(org.elasticsearch.index.IndexSettings) IndexCache(org.elasticsearch.index.cache.IndexCache) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) Store(org.elasticsearch.index.store.Store) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) RecoverySettings(org.elasticsearch.indices.recovery.RecoverySettings) Settings(org.elasticsearch.common.settings.Settings) IndexSettings(org.elasticsearch.index.IndexSettings) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) DisabledQueryCache(org.elasticsearch.index.cache.query.DisabledQueryCache) MapperService(org.elasticsearch.index.mapper.MapperService)

Example 100 with ClusterSettings

use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.

the class MockTransportService method createNewService.

public static MockTransportService createNewService(Settings settings, Version version, ThreadPool threadPool, @Nullable ClusterSettings clusterSettings) {
    var allSettings = Settings.builder().put(TransportSettings.PORT.getKey(), ESTestCase.getPortRange()).put(settings).build();
    var namedWriteableRegistry = new NamedWriteableRegistry(ClusterModule.getNamedWriteables());
    var transport = new Netty4Transport(allSettings, version, threadPool, new NetworkService(List.of()), new PageCacheRecycler(allSettings), namedWriteableRegistry, new NoneCircuitBreakerService(), new NettyBootstrap(), new AlwaysOKAuthentication(name -> User.CRATE_USER), new SslContextProvider(allSettings));
    return new MockTransportService(allSettings, transport, threadPool, boundAddress -> new DiscoveryNode(Node.NODE_NAME_SETTING.get(settings), UUIDs.randomBase64UUID(), boundAddress.publishAddress(), Node.NODE_ATTRIBUTES.getAsMap(settings), DiscoveryNode.getRolesFromSettings(settings), version), clusterSettings);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) Arrays(java.util.Arrays) TransportRequest(org.elasticsearch.transport.TransportRequest) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) Settings(org.elasticsearch.common.settings.Settings) Map(java.util.Map) ThreadPool(org.elasticsearch.threadpool.ThreadPool) Transport(org.elasticsearch.transport.Transport) User(io.crate.user.User) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) UUIDs(org.elasticsearch.common.UUIDs) Set(java.util.Set) PageCacheRecycler(org.elasticsearch.common.util.PageCacheRecycler) ConnectionManager(org.elasticsearch.transport.ConnectionManager) ClusterModule(org.elasticsearch.cluster.ClusterModule) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) AbstractRunnable(org.elasticsearch.common.util.concurrent.AbstractRunnable) Version(org.elasticsearch.Version) TransportAddress(org.elasticsearch.common.transport.TransportAddress) TransportSettings(org.elasticsearch.transport.TransportSettings) TimeValue(io.crate.common.unit.TimeValue) Queue(java.util.Queue) TransportRequestOptions(org.elasticsearch.transport.TransportRequestOptions) SslContextProvider(io.crate.protocols.ssl.SslContextProvider) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) RequestHandlerRegistry(org.elasticsearch.transport.RequestHandlerRegistry) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) Function(java.util.function.Function) Supplier(java.util.function.Supplier) HashSet(java.util.HashSet) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) NetworkService(org.elasticsearch.common.network.NetworkService) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) TcpTransport(org.elasticsearch.transport.TcpTransport) NettyBootstrap(io.crate.netty.NettyBootstrap) Node(org.elasticsearch.node.Node) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) Nullable(javax.annotation.Nullable) ConnectionProfile(org.elasticsearch.transport.ConnectionProfile) Netty4Transport(org.elasticsearch.transport.netty4.Netty4Transport) IOUtils(io.crate.common.io.IOUtils) Plugin(org.elasticsearch.plugins.Plugin) IOException(java.io.IOException) TimeUnit(java.util.concurrent.TimeUnit) ClusterSettings(org.elasticsearch.common.settings.ClusterSettings) LinkedBlockingDeque(java.util.concurrent.LinkedBlockingDeque) AlwaysOKAuthentication(io.crate.auth.AlwaysOKAuthentication) ActionListener(org.elasticsearch.action.ActionListener) AlwaysOKAuthentication(io.crate.auth.AlwaysOKAuthentication) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) PageCacheRecycler(org.elasticsearch.common.util.PageCacheRecycler) Netty4Transport(org.elasticsearch.transport.netty4.Netty4Transport) NetworkService(org.elasticsearch.common.network.NetworkService) SslContextProvider(io.crate.protocols.ssl.SslContextProvider) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) NettyBootstrap(io.crate.netty.NettyBootstrap)

Aggregations

ClusterSettings (org.elasticsearch.common.settings.ClusterSettings)109 Settings (org.elasticsearch.common.settings.Settings)58 ClusterState (org.elasticsearch.cluster.ClusterState)50 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)30 RoutingTable (org.elasticsearch.cluster.routing.RoutingTable)25 Matchers.containsString (org.hamcrest.Matchers.containsString)25 Test (org.junit.Test)25 MetaData (org.elasticsearch.cluster.metadata.MetaData)21 BalancedShardsAllocator (org.elasticsearch.cluster.routing.allocation.allocator.BalancedShardsAllocator)21 AllocationService (org.elasticsearch.cluster.routing.allocation.AllocationService)20 ClusterInfo (org.elasticsearch.cluster.ClusterInfo)18 DiskUsage (org.elasticsearch.cluster.DiskUsage)18 ShardRouting (org.elasticsearch.cluster.routing.ShardRouting)18 ImmutableOpenMap (org.elasticsearch.common.collect.ImmutableOpenMap)18 TestGatewayAllocator (org.elasticsearch.test.gateway.TestGatewayAllocator)18 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)17 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)15 RoutingNode (org.elasticsearch.cluster.routing.RoutingNode)14 HashSet (java.util.HashSet)13 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)13