當前位置: 首頁>>代碼示例>>Java>>正文


Java EventBuilder類代碼示例

本文整理匯總了Java中com.appdynamics.extensions.alerts.customevents.EventBuilder的典型用法代碼示例。如果您正苦於以下問題:Java EventBuilder類的具體用法?Java EventBuilder怎麽用?Java EventBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EventBuilder類屬於com.appdynamics.extensions.alerts.customevents包,在下文中一共展示了EventBuilder類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processAnEvent

import com.appdynamics.extensions.alerts.customevents.EventBuilder; //導入依賴的package包/類
/**
 * Creates an AppDynamics event from the command line arguments, builds a Slack
 * payload from the health rule event and posts it to Slack.
 *
 * @param args
 * @return false incase of an error else true;
 */
public boolean processAnEvent(String[] args) {
    Event event = new EventBuilder().build(args);
    if (event != null) {
        AlertBuilder alertBuilder = new AlertBuilder();
        Alert payload = alertBuilder.createPayload(config, event);

        if(payload != null) {
            try {
                HttpHandler httpHandler = new HttpHandler(config);
                String json = alertBuilder.convertIntoJsonString(payload);
                logger.debug("Starting posting data to Slack :: " + json);

                Response response = httpHandler.postAlert(json);
                if (response != null && response.getStatus() == HttpURLConnection.HTTP_OK) {
                    logger.info("Data successfully posted to Slack");
                    return true;
                }
                logger.error("Data post to Slack failed with HTTP status code: " + response.getStatus());
            } catch (JsonProcessingException e) {
                logger.error("Cannot serialized object into Json." + e);
            }
        }
    }
    return false;
}
 
開發者ID:Appdynamics,項目名稱:slack-alerting-extension,代碼行數:33,代碼來源:SlackAlertExtension.java

示例2: processAnEvent

import com.appdynamics.extensions.alerts.customevents.EventBuilder; //導入依賴的package包/類
public boolean processAnEvent(String[] args) {
    Event event = new EventBuilder().build(args);
    if (event != null) {
        try {
            HttpHandler handler = new HttpHandler(config);
            String jsonPayload;
            String issueId = FileSystemStore.INSTANCE.getFromStore(alertBuilder.getEventId(event));
            if (issueId == null) {
                // create
                AlertForCreatingIssue alert = alertBuilder.buildAlert(event, config);
                jsonPayload = alertBuilder.convertIntoJsonString(alert);
                String response = handler.postAlertDataToJira(jsonPayload);
                if (!Strings.isNullOrEmpty(response)) {
                    FileSystemStore.INSTANCE.putInStore(alert.getAlertId(), getIssueIDFromResponse(response));
                }
            } else {
                //update
                AlertForUpdatingIssue alertUpdate = alertBuilder.buildAlertForUpdatingIssue(event);
                jsonPayload = alertBuilder.convertIntoJsonString(alertUpdate);
                handler.putAlertDataToJira(jsonPayload, issueId);
            }
            return true;
        } catch (Exception e) {
            logger.error("Error while processing event data " + event, e);
        } finally {
            FileSystemStore.INSTANCE.closeStore();
        }
    }
    return false;
}
 
開發者ID:Appdynamics,項目名稱:jira-alerting-extension,代碼行數:31,代碼來源:JiraAlertExtension.java


注:本文中的com.appdynamics.extensions.alerts.customevents.EventBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。