本文整理匯總了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;
}