Search in sources :

Example 1 with WebhookSendInfo

use of com.navercorp.pinpoint.web.vo.WebhookSendInfo in project pinpoint by naver.

the class AlarmServiceImpl method updateRuleWithWebhooks.

@Override
public void updateRuleWithWebhooks(Rule rule, List<String> webhookIds) {
    updateRule(rule);
    List<WebhookSendInfo> oldListofWebhookInfos = webhookSendInfoDao.selectWebhookSendInfoByRuleId(rule.getRuleId());
    for (WebhookSendInfo webhookSendInfo : oldListofWebhookInfos) {
        // remove already existing webhook mapping to this alarm from webhookIds
        if (!webhookIds.remove(webhookSendInfo.getWebhookId())) {
            // webhook not linked to this alarm anymore, so delete from mysql
            webhookSendInfoDao.deleteWebhookSendInfo(webhookSendInfo);
        }
    }
    // adds newly mapped webhooks to this alarm
    for (String webhookId : webhookIds) {
        webhookSendInfoDao.insertWebhookSendInfo(new WebhookSendInfo("", webhookId, rule.getRuleId()));
    }
}
Also used : WebhookSendInfo(com.navercorp.pinpoint.web.vo.WebhookSendInfo)

Example 2 with WebhookSendInfo

use of com.navercorp.pinpoint.web.vo.WebhookSendInfo in project pinpoint by naver.

the class MemoryWebhookSendInfoDao method selectWebhookSendInfoByApplicationId.

@Override
public List<WebhookSendInfo> selectWebhookSendInfoByApplicationId(String applicationId) {
    List<WebhookSendInfo> selectedWebhookSendInfos = new LinkedList<>();
    List<Webhook> webhooks = webhookDao.selectWebhookByApplicationId(applicationId);
    for (Webhook webhook : webhooks) {
        for (WebhookSendInfo webhookSendInfo : webhookSendInfos.values()) {
            if (webhook.getWebhookId().equals(webhookSendInfo.getWebhookId())) {
                selectedWebhookSendInfos.add(webhookSendInfo);
            }
        }
    }
    return selectedWebhookSendInfos;
}
Also used : Webhook(com.navercorp.pinpoint.web.vo.Webhook) WebhookSendInfo(com.navercorp.pinpoint.web.vo.WebhookSendInfo) LinkedList(java.util.LinkedList)

Example 3 with WebhookSendInfo

use of com.navercorp.pinpoint.web.vo.WebhookSendInfo in project pinpoint by naver.

the class WebhookSendInfoServiceImplTest method deleteAndSelectWebhookSendInfoByWebhookIdTest.

@Test
public void deleteAndSelectWebhookSendInfoByWebhookIdTest() {
    WebhookSendInfoDao webhookSendInfoDao = new MemoryWebhookSendInfoDao(mock(WebhookDao.class));
    WebhookSendInfoService webhookSendInfoService = new WebhookSendInfoServiceImpl(webhookSendInfoDao);
    for (WebhookSendInfo webhookSendInfo : webhookSendInfoList) {
        webhookSendInfoService.insertWebhookSendInfo(webhookSendInfo);
    }
    List<WebhookSendInfo> selectedWebhookSendInfos = webhookSendInfoService.selectWebhookSendInfoByWebhookId("5134");
    assertEquals(2, selectedWebhookSendInfos.size());
    webhookSendInfoService.deleteWebhookSendInfoByWebhookId("5134");
    selectedWebhookSendInfos = webhookSendInfoService.selectWebhookSendInfoByWebhookId("5134");
    assertEquals(0, selectedWebhookSendInfos.size());
}
Also used : WebhookSendInfoDao(com.navercorp.pinpoint.web.dao.WebhookSendInfoDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) MemoryWebhookDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao) WebhookDao(com.navercorp.pinpoint.web.dao.WebhookDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) WebhookSendInfo(com.navercorp.pinpoint.web.vo.WebhookSendInfo) Test(org.junit.Test)

Example 4 with WebhookSendInfo

use of com.navercorp.pinpoint.web.vo.WebhookSendInfo in project pinpoint by naver.

the class WebhookSendInfoServiceImplTest method before.

@Before
public void before() {
    webhookSendInfoList = new ArrayList<>(3);
    webhookSendInfoList.add(new WebhookSendInfo("0", "1340", "4115234"));
    webhookSendInfoList.add(new WebhookSendInfo("1", "5134", "4115234"));
    webhookSendInfoList.add(new WebhookSendInfo("2", "5134", "4115230"));
    webhookList = new ArrayList<>(2);
    webhookList.add(new Webhook("1340", "webhook", "testUrl", "testApp", "testGroup"));
    webhookList.add(new Webhook("1341", "webhook1", "testUrl1", "testApp", "testGroup"));
}
Also used : Webhook(com.navercorp.pinpoint.web.vo.Webhook) WebhookSendInfo(com.navercorp.pinpoint.web.vo.WebhookSendInfo) Before(org.junit.Before)

Example 5 with WebhookSendInfo

use of com.navercorp.pinpoint.web.vo.WebhookSendInfo in project pinpoint by naver.

the class WebhookSendInfoServiceImplTest method deleteAndSelectWebhookSendInfoByRuleIdTest.

@Test
public void deleteAndSelectWebhookSendInfoByRuleIdTest() {
    WebhookSendInfoDao webhookSendInfoDao = new MemoryWebhookSendInfoDao(mock(WebhookDao.class));
    WebhookSendInfoService webhookSendInfoService = new WebhookSendInfoServiceImpl(webhookSendInfoDao);
    for (WebhookSendInfo webhookSendInfo : webhookSendInfoList) {
        webhookSendInfoService.insertWebhookSendInfo(webhookSendInfo);
    }
    List<WebhookSendInfo> selectedWebhookSendInfos = webhookSendInfoService.selectWebhookSendInfoByRuleId("4115234");
    assertEquals(2, selectedWebhookSendInfos.size());
    webhookSendInfoService.deleteWebhookSendInfoByRuleId("4115234");
    selectedWebhookSendInfos = webhookSendInfoService.selectWebhookSendInfoByWebhookId("4115234");
    assertEquals(0, selectedWebhookSendInfos.size());
}
Also used : WebhookSendInfoDao(com.navercorp.pinpoint.web.dao.WebhookSendInfoDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) MemoryWebhookDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao) WebhookDao(com.navercorp.pinpoint.web.dao.WebhookDao) MemoryWebhookSendInfoDao(com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao) WebhookSendInfo(com.navercorp.pinpoint.web.vo.WebhookSendInfo) Test(org.junit.Test)

Aggregations

WebhookSendInfo (com.navercorp.pinpoint.web.vo.WebhookSendInfo)10 WebhookDao (com.navercorp.pinpoint.web.dao.WebhookDao)6 WebhookSendInfoDao (com.navercorp.pinpoint.web.dao.WebhookSendInfoDao)6 MemoryWebhookDao (com.navercorp.pinpoint.web.dao.memory.MemoryWebhookDao)6 MemoryWebhookSendInfoDao (com.navercorp.pinpoint.web.dao.memory.MemoryWebhookSendInfoDao)6 Test (org.junit.Test)6 Webhook (com.navercorp.pinpoint.web.vo.Webhook)3 LinkedList (java.util.LinkedList)2 Before (org.junit.Before)1