use of org.elasticsearch.cluster.ClusterService in project crate by crate.
the class PingTaskTest method prepare.
@Before
public void prepare() throws Exception {
clusterService = mock(ClusterService.class);
clusterIdService = mock(ClusterIdService.class);
DiscoveryNode discoveryNode = mock(DiscoveryNode.class);
SettableFuture<ClusterId> clusterIdFuture = SettableFuture.create();
clusterIdFuture.set(new ClusterId());
when(clusterIdService.clusterId()).thenReturn(clusterIdFuture);
when(clusterService.localNode()).thenReturn(discoveryNode);
when(discoveryNode.isMasterNode()).thenReturn(true);
extendedNodeInfo = mock(ExtendedNodeInfo.class);
when(extendedNodeInfo.networkInfo()).thenReturn(new ExtendedNetworkInfo(ExtendedNetworkInfo.NA_INTERFACE));
when(extendedNodeInfo.osInfo()).thenReturn(new ExtendedOsInfo(Collections.emptyMap()));
}
use of org.elasticsearch.cluster.ClusterService in project crate by crate.
the class SelectStatementAnalyzerTest method init.
@Before
public void init() throws Exception {
DocTableInfo fooUserTableInfo = TestingTableInfo.builder(new TableIdent("foo", "users"), SHARD_ROUTING).add("id", DataTypes.LONG, null).add("name", DataTypes.STRING, null).addPrimaryKey("id").build();
DocTableInfoFactory fooTableFactory = new TestingDocTableInfoFactory(ImmutableMap.of(fooUserTableInfo.ident(), fooUserTableInfo));
ClusterService clusterService = new NoopClusterService();
sqlExecutor = SQLExecutor.builder(clusterService).enableDefaultTables().addSchema(new DocSchemaInfo("foo", clusterService, fooTableFactory)).build();
}
use of org.elasticsearch.cluster.ClusterService in project crate by crate.
the class SysShardsExpressionsTest method prepare.
@Before
public void prepare() throws Exception {
ClusterService clusterService = new NoopClusterService();
indexShard = mockIndexShard();
schemas = new Schemas(Settings.EMPTY, ImmutableMap.of("sys", new SysSchemaInfo(clusterService)), clusterService, new DocSchemaInfoFactory(new TestingDocTableInfoFactory(Collections.emptyMap())));
ShardReferenceResolver shardRefResolver = new ShardReferenceResolver(clusterService, schemas, indexShard);
resolver = new RecoveryShardReferenceResolver(shardRefResolver, indexShard);
}
use of org.elasticsearch.cluster.ClusterService in project crate by crate.
the class TableStatsServiceTest method testStatsQueriesCorrectly.
@Test
public void testStatsQueriesCorrectly() throws Throwable {
ClusterService clusterService = mock(ClusterService.class);
when(clusterService.localNode()).thenReturn(mock(DiscoveryNode.class));
final SQLOperations sqlOperations = mock(SQLOperations.class);
SQLOperations.SQLDirectExecutor sqlDirectExecutor = mock(SQLOperations.SQLDirectExecutor.class);
when(sqlOperations.createSQLDirectExecutor(eq("sys"), eq(TableStatsService.TABLE_STATS), eq(TableStatsService.STMT), eq(TableStatsService.DEFAULT_SOFT_LIMIT))).thenReturn(sqlDirectExecutor);
TableStatsService statsService = new TableStatsService(Settings.EMPTY, threadPool, clusterService, new TableStats(), new NodeSettingsService(Settings.EMPTY), sqlOperations);
statsService.run();
verify(sqlDirectExecutor, times(1)).execute(any(TableStatsService.TableStatsResultReceiver.class), eq(Collections.emptyList()));
}
use of org.elasticsearch.cluster.ClusterService in project crate by crate.
the class TableStatsServiceTest method testSettingsChanges.
@Test
public void testSettingsChanges() {
ClusterService clusterService = mock(ClusterService.class);
// Initially disabled
TableStatsService statsService = new TableStatsService(Settings.builder().put(CrateSettings.STATS_SERVICE_REFRESH_INTERVAL.settingName(), 0).build(), threadPool, clusterService, new TableStats(), new NodeSettingsService(Settings.EMPTY), mock(SQLOperations.class, Answers.RETURNS_MOCKS.get()));
assertThat(statsService.lastRefreshInterval, is(TimeValue.timeValueMinutes(0)));
assertThat(statsService.refreshScheduledTask, is(nullValue()));
// Default setting
statsService = new TableStatsService(Settings.EMPTY, threadPool, clusterService, new TableStats(), new NodeSettingsService(Settings.EMPTY), mock(SQLOperations.class, Answers.RETURNS_MOCKS.get()));
assertThat(statsService.lastRefreshInterval, is(CrateSettings.STATS_SERVICE_REFRESH_INTERVAL.defaultValue()));
assertThat(statsService.refreshScheduledTask, is(notNullValue()));
// Update setting
statsService.onRefreshSettings(Settings.builder().put(CrateSettings.STATS_SERVICE_REFRESH_INTERVAL.settingName(), "10m").build());
assertThat(statsService.lastRefreshInterval, is(TimeValue.timeValueMinutes(10)));
assertThat(statsService.refreshScheduledTask, is(notNullValue()));
// Disable
statsService.onRefreshSettings(Settings.builder().put(CrateSettings.STATS_SERVICE_REFRESH_INTERVAL.settingName(), 0).build());
assertThat(statsService.lastRefreshInterval, is(TimeValue.timeValueMillis(0)));
assertThat(statsService.refreshScheduledTask, is(nullValue()));
// Reset setting
statsService.onRefreshSettings(Settings.builder().build());
assertThat(statsService.lastRefreshInterval, is(CrateSettings.STATS_SERVICE_REFRESH_INTERVAL.defaultValue()));
assertThat(statsService.refreshScheduledTask, is(notNullValue()));
}
Aggregations