use of org.elasticsearch.cluster.ClusterState in project crate by crate.
the class TransportBulkCreateIndicesActionTest method testRoutingOfIndicesIsNotOverridden.
@Test
public void testRoutingOfIndicesIsNotOverridden() throws Exception {
cluster().client().admin().indices().prepareCreate("index_0").setSettings(Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0)).execute().actionGet();
ensureYellow("index_0");
ClusterState currentState = internalCluster().clusterService().state();
BulkCreateIndicesRequest request = new BulkCreateIndicesRequest(Arrays.asList("index_0", "index_1"), UUID.randomUUID());
currentState = action.executeCreateIndices(currentState, request);
ImmutableOpenIntMap<IndexShardRoutingTable> newRouting = currentState.routingTable().indicesRouting().get("index_0").getShards();
assertTrue("[index_0][0] must be started already", newRouting.get(0).primaryShard().started());
}
use of org.elasticsearch.cluster.ClusterState in project crate by crate.
the class BulkRetryCoordinatorPoolTest method prepare.
@Before
public void prepare() {
MetaData metaData = MetaData.builder().put(IndexMetaData.builder(TEST_INDEX).settings(settings(Version.CURRENT)).numberOfShards(3).numberOfReplicas(0)).build();
RoutingTable routingTable = RoutingTable.builder().addAsNew(metaData.index(TEST_INDEX)).build();
ClusterState state = ClusterState.builder(org.elasticsearch.cluster.ClusterName.DEFAULT).metaData(metaData).routingTable(routingTable).build();
state = ClusterState.builder(state).nodes(DiscoveryNodes.builder().put(newNode(NODE_IDS[0])).localNodeId(NODE_IDS[0])).build();
AllocationService allocationService = createAllocationService();
routingTable = allocationService.reroute(state, "test").routingTable();
state = ClusterState.builder(state).routingTable(routingTable).build();
ClusterService clusterService = new NoopClusterService(state);
this.state = state;
pool = new BulkRetryCoordinatorPool(Settings.EMPTY, clusterService, mock(ThreadPool.class));
pool.start();
}
use of org.elasticsearch.cluster.ClusterState in project crate by crate.
the class DefaultTemplateServiceTest method testAddDefaultTemplate.
@Test
public void testAddDefaultTemplate() throws Exception {
ClusterState state = ClusterState.builder(new ClusterName("foo")).build();
ClusterState newState = DefaultTemplateService.addDefaultTemplate(state);
assertThat(newState.getMetaData().templates().containsKey(DefaultTemplateService.TEMPLATE_NAME), is(true));
// verify that it doesn't fail it the template already exists
newState = DefaultTemplateService.addDefaultTemplate(newState);
assertThat(newState.getMetaData().templates().containsKey(DefaultTemplateService.TEMPLATE_NAME), is(true));
}
use of org.elasticsearch.cluster.ClusterState in project crate by crate.
the class CreateAlterTableStatementAnalyzerTest method init.
@Before
public void init() throws Exception {
String analyzerSettings = FulltextAnalyzerResolver.encodeSettings(Settings.builder().put("search", "foobar").build()).toUtf8();
MetaData metaData = MetaData.builder().persistentSettings(Settings.builder().put("crate.analysis.custom.analyzer.ft_search", analyzerSettings).build()).build();
ClusterState state = ClusterState.builder(ClusterName.DEFAULT).nodes(DiscoveryNodes.builder().put(new DiscoveryNode("n1", DummyTransportAddress.INSTANCE, org.elasticsearch.Version.CURRENT)).put(new DiscoveryNode("n2", DummyTransportAddress.INSTANCE, org.elasticsearch.Version.CURRENT)).put(new DiscoveryNode("n3", DummyTransportAddress.INSTANCE, org.elasticsearch.Version.CURRENT)).localNodeId("n1")).metaData(metaData).build();
e = SQLExecutor.builder(new NoopClusterService(state)).enableDefaultTables().build();
}
use of org.elasticsearch.cluster.ClusterState in project crate by crate.
the class SnapshotRestoreAnalyzerTest method before.
@Before
public void before() throws Exception {
RepositoriesMetaData repositoriesMetaData = new RepositoriesMetaData(new RepositoryMetaData("my_repo", "fs", Settings.builder().put("location", "/tmp/my_repo").build()));
ClusterState clusterState = ClusterState.builder(new ClusterName("testing")).metaData(MetaData.builder().putCustom(RepositoriesMetaData.TYPE, repositoriesMetaData)).build();
NoopClusterService clusterService = new NoopClusterService(clusterState);
executor = SQLExecutor.builder(clusterService).addDocTable(USER_TABLE_INFO).addDocTable(TEST_DOC_LOCATIONS_TABLE_INFO).addDocTable(TEST_PARTITIONED_TABLE_INFO).build();
}
Aggregations