Search in sources :

Example 1 with OverrideConfigManager

use of com.linkedin.thirdeye.datalayer.bao.OverrideConfigManager 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 2 with OverrideConfigManager

use of com.linkedin.thirdeye.datalayer.bao.OverrideConfigManager 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 3 with OverrideConfigManager

use of com.linkedin.thirdeye.datalayer.bao.OverrideConfigManager in project pinot by linkedin.

the class OverrideConfigResource method updateOverrideConfig.

@POST
@Path("/override-config/update")
public Response updateOverrideConfig(@NotNull @QueryParam("id") long id, @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();
        }
    }
    OverrideConfigManager overrideConfigDAO = DAO_REGISTRY.getOverrideConfigDAO();
    OverrideConfigDTO overrideConfigDTO = overrideConfigDAO.findById(id);
    if (overrideConfigDTO == null) {
        LOG.error("Unable to find override config with id {}", id);
        return Response.status(Response.Status.NOT_ACCEPTABLE).build();
    }
    overrideConfigDTO.setStartTime(startTimeMillis);
    overrideConfigDTO.setEndTime(endTimeMillis);
    overrideConfigDTO.setTargetLevel(targetLevel);
    overrideConfigDTO.setTargetEntity(targetEntity);
    overrideConfigDTO.setOverrideProperties(overrideProperties);
    overrideConfigDTO.setActive(active);
    overrideConfigDAO.update(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)

Aggregations

OverrideConfigManager (com.linkedin.thirdeye.datalayer.bao.OverrideConfigManager)3 Path (javax.ws.rs.Path)3 OverrideConfigDTO (com.linkedin.thirdeye.datalayer.dto.OverrideConfigDTO)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 POST (javax.ws.rs.POST)2 DELETE (javax.ws.rs.DELETE)1