org.elasticsearch.indices.breaker.CircuitBreakerStats Java Examples

The following examples show how to use org.elasticsearch.indices.breaker.CircuitBreakerStats. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CircuitBreakerTest.java    From siren-join with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testCircuitBreakerOnShard() throws Exception {
  // Update circuit breaker settings
  Settings settings = settingsBuilder()
          .put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, "8b")
          .build();
  assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings));

  SearchRequestBuilder searchRequest = new CoordinateSearchRequestBuilder(client()).setIndices("index1").setQuery(
          QueryBuilders.filterJoin("foreign_key").indices("index2").types("type").path("id").query(
                  boolQuery().filter(termQuery("tag", "aaa"))
          ).termsEncoding(TermsByQueryRequest.TermsEncoding.LONG)
  );
  assertFailures(searchRequest, RestStatus.INTERNAL_SERVER_ERROR,
          containsString("Data too large, data for [<terms_set>] would be larger than limit of [8/8b]"));

  NodesStatsResponse stats = client().admin().cluster().prepareNodesStats().setBreaker(true).get();
  int breaks = 0;
  for (NodeStats stat : stats.getNodes()) {
    CircuitBreakerStats breakerStats = stat.getBreaker().getStats(CircuitBreaker.REQUEST);
    breaks += breakerStats.getTrippedCount();
  }
  assertThat(breaks, greaterThanOrEqualTo(1));
}
 
Example #2
Source File: CircuitBreakerTest.java    From siren-join with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void testCircuitBreakerOnCoordinator() throws Exception {
  // Update circuit breaker settings
  Settings settings = settingsBuilder()
          .put(HierarchyCircuitBreakerService.REQUEST_CIRCUIT_BREAKER_LIMIT_SETTING, "60b")
          .build();
  assertAcked(client().admin().cluster().prepareUpdateSettings().setTransientSettings(settings));

  SearchRequestBuilder searchRequest = new CoordinateSearchRequestBuilder(client()).setIndices("index1").setQuery(
          QueryBuilders.filterJoin("foreign_key").indices("index2").types("type").path("id").query(
                  boolQuery().filter(termQuery("tag", "aaa"))
          ).termsEncoding(TermsByQueryRequest.TermsEncoding.LONG)
  );
  assertFailures(searchRequest, RestStatus.INTERNAL_SERVER_ERROR,
          containsString("Data too large, data for [<terms_set>] would be larger than limit of [60/60b]"));

  NodesStatsResponse stats = client().admin().cluster().prepareNodesStats().setBreaker(true).get();
  int breaks = 0;
  for (NodeStats stat : stats.getNodes()) {
    CircuitBreakerStats breakerStats = stat.getBreaker().getStats(CircuitBreaker.REQUEST);
    breaks += breakerStats.getTrippedCount();
  }
  assertThat(breaks, greaterThanOrEqualTo(1));
}
 
Example #3
Source File: PrometheusMetricsCollector.java    From elasticsearch-prometheus-exporter with Apache License 2.0 5 votes vote down vote up
private void updateCircuitBreakersMetrics(AllCircuitBreakerStats acbs) {
    if (acbs != null) {
        for (CircuitBreakerStats cbs : acbs.getAllStats()) {
            String name = cbs.getName();
            catalog.setNodeGauge("circuitbreaker_estimated_bytes", cbs.getEstimated(), name);
            catalog.setNodeGauge("circuitbreaker_limit_bytes", cbs.getLimit(), name);
            catalog.setNodeGauge("circuitbreaker_overhead_ratio", cbs.getOverhead(), name);
            catalog.setNodeGauge("circuitbreaker_tripped_count", cbs.getTrippedCount(), name);
        }
    }
}
 
Example #4
Source File: CrateCircuitBreakerServiceTest.java    From crate with Apache License 2.0 5 votes vote down vote up
@Test
public void testStats() throws Exception {
    CircuitBreakerService breakerService = new HierarchyCircuitBreakerService(
        Settings.EMPTY, clusterSettings);

    CircuitBreakerStats queryBreakerStats = breakerService.stats(HierarchyCircuitBreakerService.QUERY);
    assertThat(queryBreakerStats.getUsed(), is(0L));
}
 
Example #5
Source File: CircuitBreakers.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public CircuitBreakerStats getOperationsLog() {
    return circuitBreakerService.stats(HierarchyCircuitBreakerService.OPERATIONS_LOG);
}
 
Example #6
Source File: CrateCircuitBreakerService.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public CircuitBreakerStats stats(String name) {
    return esCircuitBreakerService.stats(name);
}
 
Example #7
Source File: CircuitBreakers.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public CircuitBreakerStats getJobsLog() {
    return circuitBreakerService.stats(HierarchyCircuitBreakerService.JOBS_LOG);
}
 
Example #8
Source File: CircuitBreakers.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public CircuitBreakerStats getQuery() {
    return circuitBreakerService.stats(HierarchyCircuitBreakerService.QUERY);
}
 
Example #9
Source File: CircuitBreakers.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public CircuitBreakerStats getRequest() {
    return circuitBreakerService.stats(CircuitBreaker.REQUEST);
}
 
Example #10
Source File: CircuitBreakers.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public CircuitBreakerStats getInFlightRequests() {
    return circuitBreakerService.stats(CircuitBreaker.IN_FLIGHT_REQUESTS);
}
 
Example #11
Source File: CircuitBreakers.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public CircuitBreakerStats getFieldData() {
    return circuitBreakerService.stats(CircuitBreaker.FIELDDATA);
}
 
Example #12
Source File: CircuitBreakers.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public CircuitBreakerStats getParent() {
    return circuitBreakerService.stats(CircuitBreaker.PARENT);
}
 
Example #13
Source File: AllCircuitBreakerStatsMonitor.java    From Raigad with Apache License 2.0 4 votes vote down vote up
@Override
public void execute() throws Exception {
    // Only start monitoring if Elasticsearch is started
    if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) {
        String exceptionMsg = "Elasticsearch is not yet started, check back again later";
        logger.info(exceptionMsg);
        return;
    }

    AllCircuitBreakerStatsBean allCircuitBreakerStatsBean = new AllCircuitBreakerStatsBean();

    try {
        NodesStatsResponse nodesStatsResponse = ElasticsearchTransportClient.getNodesStatsResponse(config);
        NodeStats nodeStats = null;

        List<NodeStats> nodeStatsList = nodesStatsResponse.getNodes();

        if (nodeStatsList.size() > 0) {
            nodeStats = nodeStatsList.get(0);
        }

        if (nodeStats == null) {
            logger.info("Circuit breaker stats is not available (node stats is not available)");
            return;
        }

        AllCircuitBreakerStats allCircuitBreakerStats = nodeStats.getBreaker();
        if (allCircuitBreakerStats == null) {
            logger.info("Circuit breaker stats is not available");
            return;
        }

        CircuitBreakerStats[] circuitBreakerStats = allCircuitBreakerStats.getAllStats();
        if (circuitBreakerStats == null || circuitBreakerStats.length == 0) {
            logger.info("Circuit breaker stats is not available (stats are empty)");
            return;
        }

        for (CircuitBreakerStats circuitBreakerStat : circuitBreakerStats) {
            if (CircuitBreaker.FIELDDATA.equals(circuitBreakerStat.getName())) {
                allCircuitBreakerStatsBean.fieldDataEstimatedSizeInBytes = circuitBreakerStat.getEstimated();
                allCircuitBreakerStatsBean.fieldDataLimitMaximumSizeInBytes = circuitBreakerStat.getLimit();
                allCircuitBreakerStatsBean.fieldDataOverhead = circuitBreakerStat.getOverhead();
                allCircuitBreakerStatsBean.fieldDataTrippedCount = circuitBreakerStat.getTrippedCount();
            }

            if (CircuitBreaker.REQUEST.equals(circuitBreakerStat.getName())) {
                allCircuitBreakerStatsBean.requestEstimatedSizeInBytes = circuitBreakerStat.getEstimated();
                allCircuitBreakerStatsBean.requestLimitMaximumSizeInBytes = circuitBreakerStat.getLimit();
                allCircuitBreakerStatsBean.requestOverhead = circuitBreakerStat.getOverhead();
                allCircuitBreakerStatsBean.requestTrippedCount = circuitBreakerStat.getTrippedCount();
            }
        }
    } catch (Exception e) {
        logger.warn("Failed to load circuit breaker stats data", e);
    }

    allCircuitBreakerStatsReporter.allCircuitBreakerStatsBean.set(allCircuitBreakerStatsBean);
}
 
Example #14
Source File: CircuitBreakersMXBean.java    From crate with Apache License 2.0 votes vote down vote up
CircuitBreakerStats getOperationsLog(); 
Example #15
Source File: CircuitBreakersMXBean.java    From crate with Apache License 2.0 votes vote down vote up
CircuitBreakerStats getJobsLog(); 
Example #16
Source File: CircuitBreakersMXBean.java    From crate with Apache License 2.0 votes vote down vote up
CircuitBreakerStats getQuery(); 
Example #17
Source File: CircuitBreakersMXBean.java    From crate with Apache License 2.0 votes vote down vote up
CircuitBreakerStats getRequest(); 
Example #18
Source File: CircuitBreakersMXBean.java    From crate with Apache License 2.0 votes vote down vote up
CircuitBreakerStats getInFlightRequests(); 
Example #19
Source File: CircuitBreakersMXBean.java    From crate with Apache License 2.0 votes vote down vote up
CircuitBreakerStats getFieldData(); 
Example #20
Source File: CircuitBreakersMXBean.java    From crate with Apache License 2.0 votes vote down vote up
CircuitBreakerStats getParent();