use of javax.ws.rs.Produces in project jersey by jersey.
the class MessageStreamResource method getMessageStream.
/**
* Get the new SSE message stream channel.
*
* @return new SSE message stream channel.
*/
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput getMessageStream() {
LOGGER.info("--> SSE connection received.");
final EventOutput eventOutput = new EventOutput();
broadcaster.add(eventOutput);
return eventOutput;
}
use of javax.ws.rs.Produces in project pinot by linkedin.
the class AnomalyResource method viewRawAnomaliesInRange.
//View raw anomalies for collection
@GET
@Path("/raw-anomalies/view")
@Produces(MediaType.APPLICATION_JSON)
public String viewRawAnomaliesInRange(@QueryParam("functionId") String functionId, @QueryParam("dataset") String dataset, @QueryParam("startTimeIso") String startTimeIso, @QueryParam("endTimeIso") String endTimeIso, @QueryParam("metric") String metric) throws JsonProcessingException {
if (StringUtils.isBlank(functionId) && StringUtils.isBlank(dataset)) {
throw new IllegalArgumentException("must provide dataset or functionId");
}
DateTime endTime = DateTime.now();
if (StringUtils.isNotEmpty(endTimeIso)) {
endTime = ISODateTimeFormat.dateTimeParser().parseDateTime(endTimeIso);
}
DateTime startTime = endTime.minusDays(7);
if (StringUtils.isNotEmpty(startTimeIso)) {
startTime = ISODateTimeFormat.dateTimeParser().parseDateTime(startTimeIso);
}
List<RawAnomalyResultDTO> rawAnomalyResults = new ArrayList<>();
if (StringUtils.isNotBlank(functionId)) {
rawAnomalyResults = rawAnomalyResultDAO.findAllByTimeAndFunctionId(startTime.getMillis(), endTime.getMillis(), Long.valueOf(functionId));
} else if (StringUtils.isNotBlank(dataset)) {
List<AnomalyFunctionDTO> anomalyFunctions = anomalyFunctionDAO.findAllByCollection(dataset);
List<Long> functionIds = new ArrayList<>();
for (AnomalyFunctionDTO anomalyFunction : anomalyFunctions) {
if (StringUtils.isNotBlank(metric) && !anomalyFunction.getTopicMetric().equals(metric)) {
continue;
}
functionIds.add(anomalyFunction.getId());
}
for (Long id : functionIds) {
rawAnomalyResults.addAll(rawAnomalyResultDAO.findAllByTimeAndFunctionId(startTime.getMillis(), endTime.getMillis(), id));
}
}
String response = new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(rawAnomalyResults);
return response;
}
use of javax.ws.rs.Produces in project pinot by linkedin.
the class DatasetConfigResource method viewDatsetConfig.
@GET
@Path("/list")
@Produces(MediaType.APPLICATION_JSON)
public String viewDatsetConfig(@DefaultValue("0") @QueryParam("jtStartIndex") int jtStartIndex, @DefaultValue("100") @QueryParam("jtPageSize") int jtPageSize) {
List<DatasetConfigDTO> datasetConfigDTOs = datasetConfigDao.findAll();
List<DatasetConfigDTO> subList = Utils.sublist(datasetConfigDTOs, jtStartIndex, jtPageSize);
ObjectNode rootNode = JsonResponseUtil.buildResponseJSON(subList);
return rootNode.toString();
}
use of javax.ws.rs.Produces in project pinot by linkedin.
the class JobResource method listTasksForJob.
@GET
@Path("/listTasksForJob")
@Produces(MediaType.APPLICATION_JSON)
public String listTasksForJob(@NotNull @QueryParam("jobId") long jobId) {
Map<String, Object> filters = new HashMap<>();
filters.put("jobId", jobId);
List<TaskDTO> taskDTOs = taskDao.findByParams(filters);
ObjectNode rootNode = JsonResponseUtil.buildResponseJSON(taskDTOs);
return rootNode.toString();
}
use of javax.ws.rs.Produces in project pinot by linkedin.
the class JobResource method listJobsForDataset.
@GET
@Path("/listJobsForDataset")
@Produces(MediaType.APPLICATION_JSON)
public String listJobsForDataset(@NotNull @QueryParam("dataset") String dataset, @DefaultValue("0") @QueryParam("jtStartIndex") int jtStartIndex, @DefaultValue("10") @QueryParam("jtPageSize") int jtPageSize) {
// Map<String, Object> filters = new HashMap<>();
// filters.put("dataset", dataset);
// List<JobDTO> jobDTOs = jobDao.findByParams(filters);
//TODO: we don't have enough info to find jobs for a dataset, may be we should change this to functions?
List<JobDTO> jobDTOs = Collections.emptyList();
ObjectNode rootNode = JsonResponseUtil.buildResponseJSON(jobDTOs);
return rootNode.toString();
}
Aggregations