本文整理汇总了Java中com.appdynamics.extensions.http.SimpleHttpClient类的典型用法代码示例。如果您正苦于以下问题:Java SimpleHttpClient类的具体用法?Java SimpleHttpClient怎么用?Java SimpleHttpClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleHttpClient类属于com.appdynamics.extensions.http包,在下文中一共展示了SimpleHttpClient类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: postAlert
import com.appdynamics.extensions.http.SimpleHttpClient; //导入依赖的package包/类
/**
* Posts the data on VictorOps Endpoint.
* @param data
* @return
*/
public Response postAlert(String data) {
Map<String, String> httpConfigMap = createHttpConfigMap();
logger.debug("Building the httpClient");
SimpleHttpClient simpleHttpClient = SimpleHttpClient.builder(httpConfigMap)
.connectionTimeout(Integer.parseInt(config.getConnectTimeout()))
.socketTimeout(Integer.parseInt(config.getSocketTimeout()))
.build();
String targetUrl = buildTargetUrl();
logger.debug("Posting data to VO at " + targetUrl);
Response response = simpleHttpClient.target(targetUrl)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.post(data);
logger.debug("HTTP Response status from VO " + response.getStatus());
return response;
}
示例2: postAlert
import com.appdynamics.extensions.http.SimpleHttpClient; //导入依赖的package包/类
public Response postAlert(String data) {
Map<String, String> httpConfigMap = createHttpConfigMap();
logger.debug("Building the httpClient");
SimpleHttpClient simpleHttpClient = SimpleHttpClient.builder(httpConfigMap)
.connectionTimeout(config.getConnectTimeout())
.socketTimeout(config.getSocketTimeout())
.build();
String targetUrl = config.getWebhookUrl();
Response response = simpleHttpClient.target(targetUrl)
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.post(data);
logger.debug("HTTP Response status from slack " + response.getStatus());
return response;
}
示例3: execute
import com.appdynamics.extensions.http.SimpleHttpClient; //导入依赖的package包/类
public TaskOutput execute(Map<String, String> taskArguments, TaskExecutionContext arg1) throws TaskExecutionException {
if (taskArguments != null) {
logger.info("Starting the HAProxy Monitoring Task");
try {
taskArguments = ArgumentsValidator.validateArguments(taskArguments, DEFAULT_ARGS);
String password = CryptoUtil.getPassword(taskArguments);
if (Strings.isNullOrEmpty(password)) {
taskArguments.put("password", password);
}
SimpleHttpClient httpClient = SimpleHttpClient.builder(taskArguments).build();
String csvPath = taskArguments.get(CSV_EXPORT_URI);
String responseString = httpClient.target().path(csvPath).get().string();
// reads the csv output and writes the response to a spreadsheet
// which is used inturn to get the metrics
writeResponseToWorkbook(responseString);
Map<Integer, String> allProxies = getAllProxyAndTypes(dictionary.get("# pxname"));
Map<Integer, String> proxyTypes = getAllProxyAndTypes(dictionary.get("svname"));
Map<Integer, String> proxiesToBeMonitored = filterProxies(taskArguments, allProxies);
printStats(taskArguments, proxiesToBeMonitored, proxyTypes);
logger.info("HAProxy Monitoring Task completed successfully");
return new TaskOutput("HAProxy Monitoring Task completed successfully");
} catch (Exception e) {
logger.error("HAProxy Metrics collection failed", e);
}
}
throw new TaskExecutionException("HAProxy Monitor task completed with failures");
}