use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.
the class ProjectingRowConsumerTest method prepare.
@Before
public void prepare() {
nodeCtx = createNodeContext();
memoryManager = new OnHeapMemoryManager(usedBytes -> {
});
projectorFactory = new ProjectionToProjectorVisitor(clusterService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), new NoneCircuitBreakerService(), nodeCtx, THREAD_POOL, Settings.EMPTY, mock(TransportActionProvider.class, Answers.RETURNS_DEEP_STUBS), new InputFactory(nodeCtx), new EvaluatingNormalizer(nodeCtx, RowGranularity.SHARD, r -> Literal.ofUnchecked(r.valueType(), r.valueType().implicitCast("1")), null), t -> null, t -> null, Version.CURRENT, new ShardId("dummy", UUID.randomUUID().toString(), 0), Map.of(LocalFsFileOutputFactory.NAME, new LocalFsFileOutputFactory()));
}
use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.
the class SysNodeChecksTest method test_max_shard_per_node_check.
@Test
public void test_max_shard_per_node_check() {
var nodeId = "node_1";
var node = new DiscoveryNode(nodeId, nodeId, buildNewFakeTransportAddress(), Map.of(), Set.of(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE), Version.CURRENT);
var discoveryNodes = DiscoveryNodes.builder().add(node).masterNodeId(nodeId).localNodeId(nodeId).build();
var numberOfShards = 85;
var indexRoutingTableBuilder = IndexRoutingTable.builder(new Index("test", UUID.randomUUID().toString()));
// Create a routing table for 85 shards on the same node
for (int i = 1; i <= numberOfShards; i++) {
indexRoutingTableBuilder.addShard(TestShardRouting.newShardRouting("test", i, nodeId, true, ShardRoutingState.STARTED));
}
var routingTable = RoutingTable.builder().add(indexRoutingTableBuilder).build();
var meta = IndexMetadata.builder("test").settings(settings(Version.CURRENT)).numberOfShards(numberOfShards).numberOfReplicas(0);
var clusterState = ClusterState.builder(new ClusterName("crate")).version(1L).metadata(Metadata.builder().put(meta)).routingTable(routingTable).nodes(discoveryNodes).build();
// Validate that with `cluster.max_shards_per_node = 100` and 85 shards the check passes
var setting = Settings.builder().put(ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey(), 100).build();
var clusterSettings = new ClusterSettings(setting, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
var clusterService = mock(ClusterService.class, Answers.RETURNS_DEEP_STUBS);
when(clusterService.state()).thenReturn(clusterState);
when(clusterService.getClusterSettings()).thenReturn(clusterSettings);
var maxShardsPerNodeSysCheck = new MaxShardsPerNodeSysCheck(clusterService);
assertThat(maxShardsPerNodeSysCheck.id(), is(8));
assertThat(maxShardsPerNodeSysCheck.severity(), is(SysCheck.Severity.MEDIUM));
assertThat(maxShardsPerNodeSysCheck.isValid(), is(true));
// Validate that with `cluster.max_shards_per_node = 90` and 85 shards the check fails
setting = Settings.builder().put(ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE.getKey(), 90).build();
clusterSettings = new ClusterSettings(setting, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
when(clusterService.state()).thenReturn(clusterState);
when(clusterService.getClusterSettings()).thenReturn(clusterSettings);
maxShardsPerNodeSysCheck = new MaxShardsPerNodeSysCheck(clusterService);
assertThat(maxShardsPerNodeSysCheck.isValid(), is(false));
}
use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.
the class NodeDisconnectJobMonitorServiceTest method testOnParticipatingNodeDisconnectedKillsJob.
@Test
public void testOnParticipatingNodeDisconnectedKillsJob() throws Exception {
TasksService tasksService = tasksInstance();
DiscoveryNode coordinator = newNode("coordinator");
DiscoveryNode dataNode = newNode("dataNode");
RootTask.Builder builder = tasksService.newBuilder(UUID.randomUUID(), "dummy-user", coordinator.getId(), Arrays.asList(coordinator.getId(), dataNode.getId()));
builder.addTask(new DummyTask());
tasksService.createTask(builder);
// add a second job that is coordinated by the other node to make sure the the broadcast logic is run
// even though there are jobs coordinated by the disconnected node
builder = tasksService.newBuilder(UUID.randomUUID(), "dummy-user", dataNode.getId(), Collections.emptySet());
builder.addTask(new DummyTask());
tasksService.createTask(builder);
AtomicInteger broadcasts = new AtomicInteger(0);
TransportKillJobsNodeAction killAction = new TransportKillJobsNodeAction(tasksService, clusterService, mock(TransportService.class)) {
@Override
public void broadcast(KillJobsRequest request, ActionListener<Long> listener, Collection<String> excludedNodeIds) {
broadcasts.incrementAndGet();
}
};
NodeDisconnectJobMonitorService monitorService = new NodeDisconnectJobMonitorService(tasksService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), mock(TransportService.class), killAction);
monitorService.onNodeDisconnected(dataNode, mock(Transport.Connection.class));
assertThat(broadcasts.get(), is(1));
monitorService.close();
}
use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.
the class NodeDisconnectJobMonitorServiceTest method testOnNodeDisconnectedKillsJobOriginatingFromThatNode.
@Test
public void testOnNodeDisconnectedKillsJobOriginatingFromThatNode() throws Exception {
TasksService tasksService = tasksInstance();
RootTask.Builder builder = tasksService.newBuilder(UUID.randomUUID());
builder.addTask(new DummyTask());
RootTask context = tasksService.createTask(builder);
NodeDisconnectJobMonitorService monitorService = new NodeDisconnectJobMonitorService(tasksService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), mock(TransportService.class), mock(TransportKillJobsNodeAction.class));
monitorService.onNodeDisconnected(new DiscoveryNode(NODE_ID, buildNewFakeTransportAddress(), Version.CURRENT), mock(Transport.Connection.class));
expectedException.expect(TaskMissing.class);
tasksService.getTask(context.jobId());
monitorService.close();
}
use of org.elasticsearch.common.settings.ClusterSettings in project crate by crate.
the class NodeJoinTests method setupRealMasterServiceAndCoordinator.
private void setupRealMasterServiceAndCoordinator(long term, ClusterState initialState) {
MasterService masterService = new MasterService(Settings.builder().put(Node.NODE_NAME_SETTING.getKey(), "test_node").build(), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), threadPool);
AtomicReference<ClusterState> clusterStateRef = new AtomicReference<>(initialState);
masterService.setClusterStatePublisher((event, publishListener, ackListener) -> {
clusterStateRef.set(event.state());
publishListener.onResponse(null);
});
setupMasterServiceAndCoordinator(term, initialState, masterService, threadPool, new Random(Randomness.get().nextLong()));
masterService.setClusterStateSupplier(clusterStateRef::get);
masterService.start();
}
Aggregations