Search in sources :

Example 6 with DatabusRequest

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

the class BufferInfoRequestProcessor method processInboundRequest.

private void processInboundRequest(DatabusRequest request, PhysicalPartition pPart) throws IOException, DatabusException {
    DbusEventBuffer evb = _eventBufferMult.getOneBuffer(pPart);
    if (null == evb) {
        LOG.error("BufferInfoRequest : Buffer not available for physical partition :" + pPart);
        throw new BufferNotFoundException("Buffer not available for partition :" + pPart);
    }
    BufferInfoResponse response = new BufferInfoResponse();
    response.setMinScn(evb.getMinScn());
    response.setMaxScn(evb.lastWrittenScn());
    response.setTimestampFirstEvent(evb.getTimestampOfFirstEvent());
    response.setTimestampLatestEvent(evb.getTimestampOfLatestDataEvent());
    writeJsonObjectToResponse(response, request);
}
Also used : BufferNotFoundException(com.linkedin.databus2.core.BufferNotFoundException) DbusEventBuffer(com.linkedin.databus.core.DbusEventBuffer) BufferInfoResponse(com.linkedin.databus.core.BufferInfoResponse)

Example 7 with DatabusRequest

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

the class BufferInfoRequestProcessor method process.

@Override
public DatabusRequest process(DatabusRequest request) throws IOException, RequestProcessingException, DatabusException {
    String category = request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME);
    if (null == category) {
        throw new InvalidRequestParamValueException(COMMAND_NAME, "category", "null");
    }
    if (category.startsWith(INBOUND_VIEW)) {
        String sourceIdStr = category.substring(INBOUND_VIEW.length());
        sourceIdStr = sourceIdStr.replace('/', ':');
        PhysicalPartition pPartition = PhysicalPartition.parsePhysicalPartitionString(sourceIdStr, ":");
        processInboundRequest(request, pPartition);
    } else {
        throw new InvalidRequestParamValueException(COMMAND_NAME, "category", category);
    }
    return request;
}
Also used : InvalidRequestParamValueException(com.linkedin.databus2.core.container.request.InvalidRequestParamValueException) PhysicalPartition(com.linkedin.databus.core.data_model.PhysicalPartition)

Example 8 with DatabusRequest

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

the class ControlSourceEventsRequestProcessor method doStatus.

private void doStatus(DatabusRequest request) throws IOException {
    Set<String> sources = getSourcesParam(request);
    for (EventProducer producer : _eventProducers) {
        if (sources == null || sources.contains(producer.getName())) {
            String state;
            if (producer.isRunning()) {
                state = "running";
            } else if (producer.isPaused()) {
                state = "paused";
            } else {
                state = "shutdown";
            }
            write(request, String.format("{\"name\" : \"%s\", \"status\" : \"%s\", \"SCN\" : %d}", producer.getName(), state, producer.getSCN()));
        }
    }
}
Also used : EventProducer(com.linkedin.databus2.producers.EventProducer)

Example 9 with DatabusRequest

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

the class ControlSourceEventsRequestProcessor method doShutdown.

private void doShutdown(DatabusRequest request) throws IOException {
    Set<String> sources = getSourcesParam(request);
    for (EventProducer producer : _eventProducers) {
        if (sources == null || sources.contains(producer.getName())) {
            producer.shutdown();
        }
    }
    doStatus(request);
}
Also used : EventProducer(com.linkedin.databus2.producers.EventProducer)

Example 10 with DatabusRequest

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

the class ControlSourceEventsRequestProcessor method process.

/*
   * @see com.linkedin.databus.container.request.RequestProcessor#process(com.linkedin.databus.container.request.DatabusRequest)
   */
@Override
public DatabusRequest process(DatabusRequest request) throws IOException, RequestProcessingException {
    // Read the action from the request
    Actions action;
    try {
        String strAction = request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME, "");
        action = Actions.valueOf(strAction.toUpperCase());
    } catch (Exception ex) {
        throw new InvalidRequestParamValueException(COMMAND_NAME, "request path", request.getParams().getProperty(DatabusRequest.PATH_PARAM_NAME, ""));
    }
    switch(action) {
        case STATUS:
            doStatus(request);
            break;
        case PAUSE:
            doPause(request);
            break;
        case SHUTDOWN:
            doShutdown(request);
            break;
        case START:
            doStart(request);
            break;
        case UNPAUSE:
            doUnpause(request);
            break;
    }
    return null;
}
Also used : InvalidRequestParamValueException(com.linkedin.databus2.core.container.request.InvalidRequestParamValueException) InvalidRequestParamValueException(com.linkedin.databus2.core.container.request.InvalidRequestParamValueException) IOException(java.io.IOException) RequestProcessingException(com.linkedin.databus2.core.container.request.RequestProcessingException)

Aggregations

InvalidRequestParamValueException (com.linkedin.databus2.core.container.request.InvalidRequestParamValueException)20 RequestProcessingException (com.linkedin.databus2.core.container.request.RequestProcessingException)17 ArrayList (java.util.ArrayList)9 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)9 LogicalSource (com.linkedin.databus.core.data_model.LogicalSource)8 DatabusRequest (com.linkedin.databus2.core.container.request.DatabusRequest)8 IOException (java.io.IOException)8 Properties (java.util.Properties)8 DbusHttpTotalStats (com.linkedin.databus2.core.container.monitoring.mbean.DbusHttpTotalStats)6 List (java.util.List)6 RegistrationId (com.linkedin.databus.client.pub.RegistrationId)5 RegisterRequestProcessor (com.linkedin.databus.container.request.RegisterRequestProcessor)5 PhysicalPartition (com.linkedin.databus.core.data_model.PhysicalPartition)5 ChunkedWritableByteChannel (com.linkedin.databus2.core.container.ChunkedWritableByteChannel)5 EventProducer (com.linkedin.databus2.producers.EventProducer)5 SchemaRegistryService (com.linkedin.databus2.schemas.SchemaRegistryService)5 SourceIdNameRegistry (com.linkedin.databus2.schemas.SourceIdNameRegistry)5 HashMap (java.util.HashMap)5 DatabusRegistration (com.linkedin.databus.client.pub.DatabusRegistration)4 DatabusV3Registration (com.linkedin.databus.client.pub.DatabusV3Registration)4