Search in sources :

Example 76 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class OverrideConfigResource method deleteOverrideConfig.

@DELETE
@Path("/override-config/delete")
public Response deleteOverrideConfig(@NotNull @QueryParam("id") long id) {
    OverrideConfigManager overrideConfigDAO = DAO_REGISTRY.getOverrideConfigDAO();
    overrideConfigDAO.deleteById(id);
    return Response.ok().build();
}
Also used : OverrideConfigManager(com.linkedin.thirdeye.datalayer.bao.OverrideConfigManager) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE)

Example 77 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class OverrideConfigResource method createOverrideConfig.

@POST
@Path("/override-config/create")
public Response createOverrideConfig(@NotNull @QueryParam("startTime") long startTimeMillis, @NotNull @QueryParam("endTime") long endTimeMillis, @QueryParam("targetLevel") String targetLevelJson, @NotNull @QueryParam("targetEntity") String targetEntity, @QueryParam("overrideProperties") String overridePropertiesJson, @QueryParam("active") boolean active) {
    Map<String, List<String>> targetLevel;
    if (StringUtils.isEmpty(targetLevelJson)) {
        targetLevel = Collections.emptyMap();
    } else {
        try {
            targetLevel = OBJECT_MAPPER.readValue(targetLevelJson, HashMap.class);
        } catch (IOException e) {
            LOG.error("Invalid JSON string {}", targetLevelJson);
            return Response.status(Response.Status.NOT_ACCEPTABLE).build();
        }
    }
    if (StringUtils.isEmpty(targetEntity)) {
        LOG.error("Received null for one of the mandatory params \"targetEntity\": {}", targetEntity);
        return Response.status(Response.Status.NOT_ACCEPTABLE).build();
    }
    Map<String, String> overrideProperties;
    if (StringUtils.isEmpty(overridePropertiesJson)) {
        overrideProperties = Collections.emptyMap();
    } else {
        try {
            overrideProperties = OBJECT_MAPPER.readValue(overridePropertiesJson, HashMap.class);
        } catch (IOException e) {
            LOG.error("Invalid JSON string {}", overridePropertiesJson);
            return Response.status(Response.Status.NOT_ACCEPTABLE).build();
        }
    }
    OverrideConfigDTO overrideConfigDTO = new OverrideConfigDTO();
    overrideConfigDTO.setStartTime(startTimeMillis);
    overrideConfigDTO.setEndTime(endTimeMillis);
    overrideConfigDTO.setTargetLevel(targetLevel);
    overrideConfigDTO.setTargetEntity(targetEntity);
    overrideConfigDTO.setOverrideProperties(overrideProperties);
    overrideConfigDTO.setActive(active);
    OverrideConfigManager overrideConfigDAO = DAO_REGISTRY.getOverrideConfigDAO();
    // Check if there exists any duplicate override config
    List<OverrideConfigDTO> existingOverrideConfigDTOs = overrideConfigDAO.findAllConflictByTargetType(targetEntity, startTimeMillis, endTimeMillis);
    for (OverrideConfigDTO existingOverrideConfig : existingOverrideConfigDTOs) {
        if (existingOverrideConfig.equals(overrideConfigDTO)) {
            LOG.error("Exists a duplicate override config: {}", existingOverrideConfig.toString());
            return Response.status(Response.Status.NOT_ACCEPTABLE).build();
        }
    }
    overrideConfigDAO.save(overrideConfigDTO);
    return Response.ok().build();
}
Also used : OverrideConfigDTO(com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO) HashMap(java.util.HashMap) List(java.util.List) IOException(java.io.IOException) OverrideConfigManager(com.linkedin.thirdeye.datalayer.bao.OverrideConfigManager) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 78 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class AnomaliesResource method getAnomaliesByDashboardId.

/**
   * Find anomalies by dashboard id
   * @param startTime
   * @param endTime
   * @param dashboardId
   * @param functionName
   * @return
   * @throws Exception
   */
@GET
@Path("search/dashboardId/{startTime}/{endTime}/{pageNumber}")
public AnomaliesWrapper getAnomaliesByDashboardId(@PathParam("startTime") Long startTime, @PathParam("endTime") Long endTime, @PathParam("pageNumber") int pageNumber, @QueryParam("dashboardId") String dashboardId, @QueryParam("functionName") String functionName) throws Exception {
    DashboardConfigDTO dashboardConfig = dashboardConfigDAO.findById(Long.valueOf(dashboardId));
    String metricIdsString = Joiner.on(COMMA_SEPARATOR).join(dashboardConfig.getMetricIds());
    return getAnomaliesByMetricIds(startTime, endTime, pageNumber, metricIdsString, functionName);
}
Also used : DashboardConfigDTO(com.linkedin.thirdeye.datalayer.dto.DashboardConfigDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 79 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class AnomaliesResource method getAnomaliesByTime.

/**
   * Search anomalies only by time
   * @param startTime
   * @param endTime
   * @return
   * @throws Exception
   */
@GET
@Path("search/time/{startTime}/{endTime}/{pageNumber}")
public AnomaliesWrapper getAnomaliesByTime(@PathParam("startTime") Long startTime, @PathParam("endTime") Long endTime, @PathParam("pageNumber") int pageNumber) throws Exception {
    List<MergedAnomalyResultDTO> mergedAnomalies = mergedAnomalyResultDAO.findByTime(startTime, endTime);
    try {
        mergedAnomalies = AlertFilterHelper.applyFiltrationRule(mergedAnomalies, alertFilterFactory);
    } catch (Exception e) {
        LOG.warn("Failed to apply alert filters on anomalies in start:{}, end:{}, exception:{}", new DateTime(startTime), new DateTime(endTime), e);
    }
    AnomaliesWrapper anomaliesWrapper = constructAnomaliesWrapperFromMergedAnomalies(mergedAnomalies, pageNumber);
    return anomaliesWrapper;
}
Also used : MergedAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO) AnomaliesWrapper(com.linkedin.thirdeye.dashboard.resources.v2.pojo.AnomaliesWrapper) TimeoutException(java.util.concurrent.TimeoutException) JSONException(org.json.JSONException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) DateTime(org.joda.time.DateTime) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 80 with Path

use of javax.ws.rs.Path in project pinot by linkedin.

the class AnomaliesResource method getAnomaliesByMetricIds.

/**
   * Find anomalies by metric ids
   * @param startTime
   * @param endTime
   * @param metricIdsString
   * @param functionName
   * @return
   * @throws Exception
   */
@GET
@Path("search/metricIds/{startTime}/{endTime}/{pageNumber}")
public AnomaliesWrapper getAnomaliesByMetricIds(@PathParam("startTime") Long startTime, @PathParam("endTime") Long endTime, @PathParam("pageNumber") int pageNumber, @QueryParam("metricIds") String metricIdsString, @QueryParam("functionName") String functionName) throws Exception {
    String[] metricIdsList = metricIdsString.split(COMMA_SEPARATOR);
    List<Long> metricIds = new ArrayList<>();
    for (String metricId : metricIdsList) {
        metricIds.add(Long.valueOf(metricId));
    }
    List<MergedAnomalyResultDTO> mergedAnomalies = getAnomaliesForMetricIdsInRange(metricIds, startTime, endTime);
    AnomaliesWrapper anomaliesWrapper = constructAnomaliesWrapperFromMergedAnomalies(mergedAnomalies, pageNumber);
    return anomaliesWrapper;
}
Also used : MergedAnomalyResultDTO(com.linkedin.thirdeye.datalayer.dto.MergedAnomalyResultDTO) ArrayList(java.util.ArrayList) AnomaliesWrapper(com.linkedin.thirdeye.dashboard.resources.v2.pojo.AnomaliesWrapper) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

Path (javax.ws.rs.Path)6273 Produces (javax.ws.rs.Produces)3678 GET (javax.ws.rs.GET)3072 POST (javax.ws.rs.POST)1783 Consumes (javax.ws.rs.Consumes)1440 ApiOperation (io.swagger.annotations.ApiOperation)1213 ApiResponses (io.swagger.annotations.ApiResponses)997 PUT (javax.ws.rs.PUT)850 IOException (java.io.IOException)677 DELETE (javax.ws.rs.DELETE)662 ArrayList (java.util.ArrayList)591 WebApplicationException (javax.ws.rs.WebApplicationException)556 Response (javax.ws.rs.core.Response)540 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)490 HashMap (java.util.HashMap)394 Timed (com.codahale.metrics.annotation.Timed)383 URI (java.net.URI)374 List (java.util.List)287 Map (java.util.Map)259 NotFoundException (javax.ws.rs.NotFoundException)258