Search in sources :

Example 36 with RequestProcessingException

use of com.linkedin.databus2.core.container.request.RequestProcessingException in project databus by linkedin.

the class RelayStatsRequestProcessor method processOutboundHttpClientStats.

private void processOutboundHttpClientStats(DatabusRequest request) throws IOException, RequestProcessingException {
    String category = request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME);
    String client = category.substring(OUTBOUND_HTTP_CLIENT_PREFIX.length());
    DbusHttpTotalStats clientStats = _relay.getHttpStatisticsCollector().getPeerStats(client);
    if (null == clientStats) {
        throw new InvalidRequestParamValueException(request.getName(), OUTBOUND_HTTP_CLIENT_PREFIX, client);
    }
    writeJsonObjectToResponse(clientStats, request);
    if (request.getRequestType() == HttpMethod.PUT || request.getRequestType() == HttpMethod.POST) {
        enableOrResetStatsMBean(clientStats, request);
    }
}
Also used : DbusHttpTotalStats(com.linkedin.databus2.core.container.monitoring.mbean.DbusHttpTotalStats) InvalidRequestParamValueException(com.linkedin.databus2.core.container.request.InvalidRequestParamValueException)

Example 37 with RequestProcessingException

use of com.linkedin.databus2.core.container.request.RequestProcessingException in project databus by linkedin.

the class ClientStatsRequestProcessor method processEventsSourceStats.

private void processEventsSourceStats(DbusEventsStatisticsCollector statsCollector, String prefix, DatabusRequest request) throws IOException, RequestProcessingException {
    if (null == statsCollector)
        return;
    String category = request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME);
    String sourceIdStr = category.substring(prefix.length());
    int sourceId = -1;
    try {
        sourceId = Integer.valueOf(sourceIdStr);
    } catch (NumberFormatException nfe) {
        throw new InvalidRequestParamValueException(request.getName(), prefix, sourceIdStr);
    }
    DbusEventsTotalStats sourceStats = statsCollector.getSourceStats(sourceId);
    if (null == sourceStats) {
        throw new InvalidRequestParamValueException(request.getName(), prefix, sourceIdStr);
    }
    writeJsonObjectToResponse(sourceStats, request);
    if (request.getRequestType() == HttpMethod.PUT || request.getRequestType() == HttpMethod.POST) {
        enableOrResetStatsMBean(sourceStats, request);
    }
}
Also used : DbusEventsTotalStats(com.linkedin.databus.core.monitoring.mbean.DbusEventsTotalStats) InvalidRequestParamValueException(com.linkedin.databus2.core.container.request.InvalidRequestParamValueException)

Example 38 with RequestProcessingException

use of com.linkedin.databus2.core.container.request.RequestProcessingException in project databus by linkedin.

the class ClientStatsRequestProcessor method processOutboundHttpSourceStats.

private void processOutboundHttpSourceStats(DatabusRequest request) throws IOException, RequestProcessingException {
    String category = request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME);
    String sourceIdStr = category.substring(INBOUND_HTTP_SOURCE_PREFIX.length());
    int sourceId = -1;
    try {
        sourceId = Integer.valueOf(sourceIdStr);
    } catch (NumberFormatException nfe) {
        throw new InvalidRequestParamValueException(request.getName(), INBOUND_HTTP_SOURCE_PREFIX, sourceIdStr);
    }
    DbusHttpTotalStats sourceStats = _client.getHttpStatsCollector().getSourceStats(sourceId);
    if (null == sourceStats) {
        throw new InvalidRequestParamValueException(request.getName(), INBOUND_HTTP_SOURCE_PREFIX, sourceIdStr);
    }
    writeJsonObjectToResponse(sourceStats, request);
    if (request.getRequestType() == HttpMethod.PUT || request.getRequestType() == HttpMethod.POST) {
        enableOrResetStatsMBean(sourceStats, request);
    }
}
Also used : DbusHttpTotalStats(com.linkedin.databus2.core.container.monitoring.mbean.DbusHttpTotalStats) InvalidRequestParamValueException(com.linkedin.databus2.core.container.request.InvalidRequestParamValueException)

Aggregations

RequestProcessingException (com.linkedin.databus2.core.container.request.RequestProcessingException)20 InvalidRequestParamValueException (com.linkedin.databus2.core.container.request.InvalidRequestParamValueException)18 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)7 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)6 DatabusRegistration (com.linkedin.databus.client.pub.DatabusRegistration)5 LogicalSource (com.linkedin.databus.core.data_model.LogicalSource)5 DatabusException (com.linkedin.databus2.core.DatabusException)5 HttpStatisticsCollector (com.linkedin.databus2.core.container.monitoring.mbean.HttpStatisticsCollector)5 DbusPartitionInfo (com.linkedin.databus.client.pub.DbusPartitionInfo)4 RegistrationId (com.linkedin.databus.client.pub.RegistrationId)4 Checkpoint (com.linkedin.databus.core.Checkpoint)4 PhysicalPartition (com.linkedin.databus.core.data_model.PhysicalPartition)4 DbusHttpTotalStats (com.linkedin.databus2.core.container.monitoring.mbean.DbusHttpTotalStats)4 StringWriter (java.io.StringWriter)4 SQLException (java.sql.SQLException)4 BootstrapHttpStatsCollector (com.linkedin.databus.bootstrap.common.BootstrapHttpStatsCollector)3 DatabusV3Registration (com.linkedin.databus.client.pub.DatabusV3Registration)3 DbusEventsStatisticsCollector (com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector)3 BootstrapDatabaseTooOldException (com.linkedin.databus2.core.container.request.BootstrapDatabaseTooOldException)3