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);
}
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;
}
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()));
}
}
}
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);
}
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;
}
Aggregations