Search in sources :

Example 6 with NodeSettingsService

use of org.elasticsearch.node.settings.NodeSettingsService in project crate by crate.

the class CrateCircuitBreakerServiceTest method testQueryCircuitBreakerRegistration.

@Test
public void testQueryCircuitBreakerRegistration() throws Exception {
    NodeSettingsService settingsService = new NodeSettingsService(Settings.EMPTY);
    CircuitBreakerService esBreakerService = new HierarchyCircuitBreakerService(Settings.EMPTY, settingsService);
    CrateCircuitBreakerService breakerService = new CrateCircuitBreakerService(Settings.EMPTY, settingsService, esBreakerService);
    CircuitBreaker breaker = breakerService.getBreaker(CrateCircuitBreakerService.QUERY);
    assertThat(breaker, notNullValue());
    assertThat(breaker, instanceOf(CircuitBreaker.class));
    assertThat(breaker.getName(), is(CrateCircuitBreakerService.QUERY));
}
Also used : CircuitBreaker(org.elasticsearch.common.breaker.CircuitBreaker) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) NodeSettingsService(org.elasticsearch.node.settings.NodeSettingsService) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 7 with NodeSettingsService

use of org.elasticsearch.node.settings.NodeSettingsService in project crate by crate.

the class CrateCircuitBreakerServiceTest method testStats.

@Test
public void testStats() throws Exception {
    NodeSettingsService settingsService = new NodeSettingsService(Settings.EMPTY);
    CircuitBreakerService esBreakerService = new HierarchyCircuitBreakerService(Settings.EMPTY, settingsService);
    CrateCircuitBreakerService breakerService = new CrateCircuitBreakerService(Settings.EMPTY, settingsService, esBreakerService);
    CircuitBreakerStats[] stats = breakerService.stats().getAllStats();
    assertThat(stats.length, is(7));
    CircuitBreakerStats queryBreakerStats = breakerService.stats(CrateCircuitBreakerService.QUERY);
    assertThat(queryBreakerStats.getEstimated(), is(0L));
}
Also used : CircuitBreakerStats(org.elasticsearch.indices.breaker.CircuitBreakerStats) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) NodeSettingsService(org.elasticsearch.node.settings.NodeSettingsService) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HierarchyCircuitBreakerService(org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 8 with NodeSettingsService

use of org.elasticsearch.node.settings.NodeSettingsService in project crate by crate.

the class TableStatsServiceTest method testNoUpdateIfLocalNodeNotAvailable.

@Test
public void testNoUpdateIfLocalNodeNotAvailable() throws Exception {
    final ClusterService clusterService = mock(ClusterService.class);
    when(clusterService.localNode()).thenReturn(null);
    SQLOperations sqlOperations = mock(SQLOperations.class);
    SQLOperations.Session session = mock(SQLOperations.Session.class);
    when(sqlOperations.createSession(anyString(), any(), anyInt())).thenReturn(session);
    TableStatsService statsService = new TableStatsService(Settings.EMPTY, threadPool, clusterService, new TableStats(), new NodeSettingsService(Settings.EMPTY), sqlOperations);
    statsService.run();
    Mockito.verify(session, times(0)).sync();
}
Also used : ClusterService(org.elasticsearch.cluster.ClusterService) NodeSettingsService(org.elasticsearch.node.settings.NodeSettingsService) SQLOperations(io.crate.action.sql.SQLOperations) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

NodeSettingsService (org.elasticsearch.node.settings.NodeSettingsService)8 CrateUnitTest (io.crate.test.integration.CrateUnitTest)7 Test (org.junit.Test)7 SQLOperations (io.crate.action.sql.SQLOperations)4 CircuitBreakerService (org.elasticsearch.indices.breaker.CircuitBreakerService)4 HierarchyCircuitBreakerService (org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService)4 ClusterService (org.elasticsearch.cluster.ClusterService)3 CircuitBreaker (org.elasticsearch.common.breaker.CircuitBreaker)3 Settings (org.elasticsearch.common.settings.Settings)2 JobsLogs (io.crate.operation.collect.stats.JobsLogs)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 CircuitBreakerStats (org.elasticsearch.indices.breaker.CircuitBreakerStats)1 NoopClusterService (org.elasticsearch.test.cluster.NoopClusterService)1 ThreadPool (org.elasticsearch.threadpool.ThreadPool)1 Before (org.junit.Before)1