当前位置: 首页>>代码示例>>Java>>正文


Java SimpleHttpClient类代码示例

本文整理汇总了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;
}
 
开发者ID:Appdynamics,项目名称:pagerduty-alerting-extension,代码行数:21,代码来源:HttpHandler.java

示例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;
}
 
开发者ID:Appdynamics,项目名称:slack-alerting-extension,代码行数:15,代码来源:HttpHandler.java

示例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");
}
 
开发者ID:Appdynamics,项目名称:haproxy-monitoring-extension,代码行数:33,代码来源:HAProxyMonitor.java


注:本文中的com.appdynamics.extensions.http.SimpleHttpClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。