org.elasticsearch.http.HttpStats Java Examples

The following examples show how to use org.elasticsearch.http.HttpStats. 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: NodeStats.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public NodeStats(DiscoveryNode node, long timestamp, @Nullable NodeIndicesStats indices,
                 @Nullable OsStats os, @Nullable ProcessStats process, @Nullable JvmStats jvm, @Nullable ThreadPoolStats threadPool,
                 @Nullable FsInfo fs, @Nullable TransportStats transport, @Nullable HttpStats http,
                 @Nullable AllCircuitBreakerStats breaker,
                 @Nullable ScriptStats scriptStats) {
    super(node);
    this.timestamp = timestamp;
    this.indices = indices;
    this.os = os;
    this.process = process;
    this.jvm = jvm;
    this.threadPool = threadPool;
    this.fs = fs;
    this.transport = transport;
    this.http = http;
    this.breaker = breaker;
    this.scriptStats = scriptStats;
}
 
Example #2
Source File: NodeStatsContextFieldResolver.java    From crate with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
NodeStatsContextFieldResolver(Supplier<DiscoveryNode> localNode,
                              MonitorService monitorService,
                              Supplier<TransportAddress> boundHttpAddress,
                              Supplier<HttpStats> httpStatsSupplier,
                              ThreadPool threadPool,
                              ExtendedNodeInfo extendedNodeInfo,
                              Supplier<ConnectionStats> psqlStats,
                              Supplier<TransportAddress> boundPostgresAddress,
                              LongSupplier numOpenTransportConnections,
                              LongSupplier clusterStateVersion) {
    this.localNode = localNode;
    processService = monitorService.processService();
    osService = monitorService.osService();
    jvmService = monitorService.jvmService();
    fsService = monitorService.fsService();
    this.httpStatsSupplier = httpStatsSupplier;
    this.boundHttpAddress = boundHttpAddress;
    this.threadPool = threadPool;
    this.extendedNodeInfo = extendedNodeInfo;
    this.psqlStats = psqlStats;
    this.boundPostgresAddress = boundPostgresAddress;
    this.numOpenTransportConnections = numOpenTransportConnections;
    this.clusterStateVersion = clusterStateVersion;
}
 
Example #3
Source File: NodeStatsContextFieldResolverTest.java    From crate with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws UnknownHostException {
    final OsService osService = mock(OsService.class);
    final OsStats osStats = mock(OsStats.class);
    final MonitorService monitorService = mock(MonitorService.class);

    when(monitorService.osService()).thenReturn(osService);
    when(osService.stats()).thenReturn(osStats);
    DiscoveryNode discoveryNode = newNode("node_name", "node_id");

    postgresAddress = new TransportAddress(Inet4Address.getLocalHost(), 5432);
    resolver = new NodeStatsContextFieldResolver(
        () -> discoveryNode,
        monitorService,
        () -> null,
        () -> new HttpStats(20L, 30L),
        mock(ThreadPool.class),
        new ExtendedNodeInfo(),
        () -> new ConnectionStats(2L, 4L),
        () -> postgresAddress,
        () -> 12L,
        () -> 1L
    );
}
 
Example #4
Source File: NodeStats.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    timestamp = in.readVLong();
    if (in.readBoolean()) {
        indices = NodeIndicesStats.readIndicesStats(in);
    }
    if (in.readBoolean()) {
        os = OsStats.readOsStats(in);
    }
    if (in.readBoolean()) {
        process = ProcessStats.readProcessStats(in);
    }
    if (in.readBoolean()) {
        jvm = JvmStats.readJvmStats(in);
    }
    if (in.readBoolean()) {
        threadPool = ThreadPoolStats.readThreadPoolStats(in);
    }
    if (in.readBoolean()) {
        fs = FsInfo.readFsInfo(in);
    }
    if (in.readBoolean()) {
        transport = TransportStats.readTransportStats(in);
    }
    if (in.readBoolean()) {
        http = HttpStats.readHttpStats(in);
    }
    breaker = AllCircuitBreakerStats.readOptionalAllCircuitBreakerStats(in);
    scriptStats = in.readOptionalStreamable(new ScriptStats());

}
 
Example #5
Source File: NodeStatsContext.java    From crate with Apache License 2.0 5 votes vote down vote up
public NodeStatsContext(StreamInput in, boolean complete) throws IOException {
    this.complete = complete;
    this.id = DataTypes.STRING.readValueFrom(in);
    this.name = DataTypes.STRING.readValueFrom(in);
    this.hostname = DataTypes.STRING.readValueFrom(in);
    this.timestamp = in.readLong();
    this.version = in.readBoolean() ? Version.readVersion(in) : null;
    this.build = in.readBoolean() ? Build.readBuild(in) : null;
    this.restUrl = DataTypes.STRING.readValueFrom(in);
    this.pgPort = in.readOptionalVInt();
    this.httpPort = in.readOptionalVInt();
    this.transportPort = in.readOptionalVInt();
    this.jvmStats = in.readOptionalWriteable(JvmStats::new);
    this.osInfo = in.readOptionalWriteable(OsInfo::new);
    this.processStats = in.readOptionalWriteable(ProcessStats::new);
    this.osStats = in.readOptionalWriteable(OsStats::new);
    this.fsInfo = in.readOptionalWriteable(FsInfo::new);
    this.extendedOsStats = in.readOptionalWriteable(ExtendedOsStats::new);
    this.threadPools = in.readOptionalWriteable(ThreadPoolStats::new);
    this.httpStats = in.readOptionalWriteable(HttpStats::new);
    this.psqlStats = in.readOptionalWriteable(ConnectionStats::new);
    this.openTransportConnections = in.readLong();
    this.clusterStateVersion = in.readLong();

    this.osName = DataTypes.STRING.readValueFrom(in);
    this.osArch = DataTypes.STRING.readValueFrom(in);
    this.osVersion = DataTypes.STRING.readValueFrom(in);
    this.javaVersion = DataTypes.STRING.readValueFrom(in);
    this.jvmName = DataTypes.STRING.readValueFrom(in);
    this.jvmVendor = DataTypes.STRING.readValueFrom(in);
    this.jvmVersion = DataTypes.STRING.readValueFrom(in);
}
 
Example #6
Source File: Connections.java    From crate with Apache License 2.0 5 votes vote down vote up
public Connections(Supplier<HttpStats> httpStats,
                   Supplier<ConnectionStats> psqlStats,
                   LongSupplier transportConnections) {
    this.httpStats = httpStats;
    this.psqlStats = psqlStats;
    this.transportConnections = transportConnections;
}
 
Example #7
Source File: NettyHttpServerTransport.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public HttpStats stats() {
    OpenChannelsHandler channels = serverOpenChannels;
    return new HttpStats(channels == null ? 0 : channels.numberOfOpenChannels(), channels == null ? 0 : channels.totalChannels());
}
 
Example #8
Source File: NodeStats.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Nullable
public HttpStats getHttp() {
    return this.http;
}
 
Example #9
Source File: PrometheusMetricsCollector.java    From elasticsearch-prometheus-exporter with Apache License 2.0 4 votes vote down vote up
private void updateHTTPMetrics(HttpStats http) {
    if (http != null) {
        catalog.setNodeGauge("http_open_server_number", http.getServerOpen());
        catalog.setNodeGauge("http_open_total_count", http.getTotalOpen());
    }
}
 
Example #10
Source File: HttpStatsMonitor.java    From Raigad with Apache License 2.0 4 votes vote down vote up
@Override
public void execute() throws Exception {
    // If Elasticsearch is started then only start the monitoring
    if (!ElasticsearchProcessMonitor.isElasticsearchRunning()) {
        String exceptionMsg = "Elasticsearch is not yet started, check back again later";
        logger.info(exceptionMsg);
        return;
    }

    HttpStatsBean httpStatsBean = new HttpStatsBean();

    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("HTTP stats is not available (node stats are not available)");
            return;
        }

        HttpStats httpStats = nodeStats.getHttp();

        if (httpStats == null) {
            logger.info("HTTP stats is not available");
            return;
        }

        httpStatsBean.serverOpen = httpStats.getServerOpen();
        httpStatsBean.totalOpen = httpStats.getTotalOpen();
    } catch (Exception e) {
        logger.warn("Failed to load HTTP stats data", e);
    }

    httpStatsReporter.httpStatsBean.set(httpStatsBean);
}
 
Example #11
Source File: GraphiteReporter.java    From elasticsearch-graphite-plugin with Do What The F*ck You Want To Public License 4 votes vote down vote up
private void sendNodeHttpStats(HttpStats httpStats) {
    String type = buildMetricName("node.http");
    sendInt(type, "serverOpen", httpStats.getServerOpen());
    sendInt(type, "totalOpen", httpStats.getTotalOpen());
}
 
Example #12
Source File: Netty4HttpServerTransport.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public HttpStats stats() {
    Netty4OpenChannelsHandler channels = serverOpenChannels;
    return new HttpStats(channels == null ? 0 : channels.numberOfOpenChannels(), channels == null ? 0 : channels.totalChannels());
}
 
Example #13
Source File: NodeStatsContext.java    From crate with Apache License 2.0 4 votes vote down vote up
public HttpStats httpStats() {
    return httpStats;
}
 
Example #14
Source File: MockHttpTransport.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public HttpStats stats() {
    return DUMMY_HTTP_STATS;
}
 
Example #15
Source File: Connections.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public long getHttpOpen() {
    HttpStats httpStats = this.httpStats.get();
    return httpStats == null ? 0L : httpStats.getServerOpen();
}
 
Example #16
Source File: Connections.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public long getHttpTotal() {
    HttpStats httpStats = this.httpStats.get();
    return httpStats == null ? 0L : httpStats.getTotalOpen();
}