当前位置: 首页>>代码示例>>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;未经允许,请勿转载。