Search in sources :

Example 1 with IngraphMetricConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO in project pinot by linkedin.

the class IngraphMetricConfigResource method updateMetricConfig.

@GET
@Path("/update")
public String updateMetricConfig(@NotNull @QueryParam("id") long ingraphMetricConfigId, @QueryParam("rrdName") String rrdName, @QueryParam("metricName") String metricName, @QueryParam("dashboardName") String dashboardName, @QueryParam("metricDataType") String metricDataType, @QueryParam("metricSourceType") String metricSourceType, @QueryParam("container") String container) {
    try {
        IngraphMetricConfigDTO ingraphMetricConfigDTO = ingraphMetricConfigDao.findById(ingraphMetricConfigId);
        ingraphMetricConfigDTO.setRrdName(rrdName);
        ingraphMetricConfigDTO.setMetricName(metricName);
        ingraphMetricConfigDTO.setDashboardName(dashboardName);
        ingraphMetricConfigDTO.setContainer(container);
        ingraphMetricConfigDTO.setMetricDataType(metricDataType);
        ingraphMetricConfigDTO.setMetricSourceType(metricSourceType);
        int numRowsUpdated = ingraphMetricConfigDao.update(ingraphMetricConfigDTO);
        if (numRowsUpdated == 1) {
            return JsonResponseUtil.buildResponseJSON(ingraphMetricConfigDTO).toString();
        } else {
            return JsonResponseUtil.buildErrorResponseJSON("Failed to update metric id:" + ingraphMetricConfigId).toString();
        }
    } catch (Exception e) {
        return JsonResponseUtil.buildErrorResponseJSON("Failed to update metric id:" + ingraphMetricConfigId + ". Exception:" + e.getMessage()).toString();
    }
}
Also used : IngraphMetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 2 with IngraphMetricConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO in project pinot by linkedin.

the class IngraphMetricConfigManagerImpl method findByDashboard.

@Override
public List<IngraphMetricConfigDTO> findByDashboard(String dashboardName) {
    Predicate predicate = Predicate.EQ("dashboardName", dashboardName);
    List<IngraphMetricConfigBean> list = genericPojoDao.get(predicate, IngraphMetricConfigBean.class);
    List<IngraphMetricConfigDTO> result = new ArrayList<>();
    for (IngraphMetricConfigBean abstractBean : list) {
        IngraphMetricConfigDTO dto = MODEL_MAPPER.map(abstractBean, IngraphMetricConfigDTO.class);
        result.add(dto);
    }
    return result;
}
Also used : IngraphMetricConfigBean(com.linkedin.thirdeye.datalayer.pojo.IngraphMetricConfigBean) ArrayList(java.util.ArrayList) IngraphMetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 3 with IngraphMetricConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO in project pinot by linkedin.

the class TestIngraphMetricConfigManager method testCreateIngraphMetric.

@Test
public void testCreateIngraphMetric() {
    IngraphMetricConfigDTO ingraphMetricConfigDTO1 = getTestIngraphMetricConfig(rrd1, metric1, dashboard1);
    ingraphMetricConfigId1 = ingraphMetricConfigDAO.save(ingraphMetricConfigDTO1);
    Assert.assertNotNull(ingraphMetricConfigId1);
    IngraphMetricConfigDTO ingraphMetricConfigDTO2 = getTestIngraphMetricConfig(rrd2, metric2, dashboard2);
    ingraphMetricConfigId2 = ingraphMetricConfigDAO.save(ingraphMetricConfigDTO2);
    Assert.assertNotNull(ingraphMetricConfigId2);
}
Also used : IngraphMetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO) Test(org.testng.annotations.Test)

Example 4 with IngraphMetricConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO in project pinot by linkedin.

the class IngraphMetricConfigManagerImpl method findByDashboardAndMetricName.

@Override
public IngraphMetricConfigDTO findByDashboardAndMetricName(String dashboardName, String metricName) {
    Predicate dashboardPredicate = Predicate.EQ("dashboardName", dashboardName);
    Predicate metricPredicate = Predicate.EQ("metricName", metricName);
    List<IngraphMetricConfigBean> list = genericPojoDao.get(Predicate.AND(dashboardPredicate, metricPredicate), IngraphMetricConfigBean.class);
    IngraphMetricConfigDTO result = null;
    if (CollectionUtils.isNotEmpty(list)) {
        result = MODEL_MAPPER.map(list.get(0), IngraphMetricConfigDTO.class);
    }
    return result;
}
Also used : IngraphMetricConfigBean(com.linkedin.thirdeye.datalayer.pojo.IngraphMetricConfigBean) IngraphMetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Example 5 with IngraphMetricConfigDTO

use of com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO in project pinot by linkedin.

the class IngraphMetricConfigManagerImpl method findByRrdName.

@Override
public IngraphMetricConfigDTO findByRrdName(String rrdName) {
    Predicate dashboardPredicate = Predicate.EQ("rrdName", rrdName);
    List<IngraphMetricConfigBean> list = genericPojoDao.get(dashboardPredicate, IngraphMetricConfigBean.class);
    IngraphMetricConfigDTO result = null;
    if (CollectionUtils.isNotEmpty(list)) {
        result = MODEL_MAPPER.map(list.get(0), IngraphMetricConfigDTO.class);
    }
    return result;
}
Also used : IngraphMetricConfigBean(com.linkedin.thirdeye.datalayer.pojo.IngraphMetricConfigBean) IngraphMetricConfigDTO(com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO) Predicate(com.linkedin.thirdeye.datalayer.util.Predicate)

Aggregations

IngraphMetricConfigDTO (com.linkedin.thirdeye.datalayer.dto.IngraphMetricConfigDTO)11 Test (org.testng.annotations.Test)4 IngraphMetricConfigBean (com.linkedin.thirdeye.datalayer.pojo.IngraphMetricConfigBean)3 Predicate (com.linkedin.thirdeye.datalayer.util.Predicate)3 GET (javax.ws.rs.GET)3 Path (javax.ws.rs.Path)3 ArrayList (java.util.ArrayList)1 Produces (javax.ws.rs.Produces)1 ObjectNode (org.codehaus.jackson.node.ObjectNode)1