本文整理汇总了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;
}
示例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;
}