本文整理汇总了Java中com.appdynamics.extensions.http.UrlBuilder类的典型用法代码示例。如果您正苦于以下问题:Java UrlBuilder类的具体用法?Java UrlBuilder怎么用?Java UrlBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UrlBuilder类属于com.appdynamics.extensions.http包,在下文中一共展示了UrlBuilder类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: fetchMetrics
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
private void fetchMetrics(String displayName) {
if (catEndPoints != null && !catEndPoints.isEmpty()) {
CatMetricsClient catMetricsClient = new CatMetricsClient();
Map<String,String> metrics = Maps.newHashMap();
for (Map catApiConfig : catEndPoints) {
String endPoint = (String) catApiConfig.get("endPoint");
String metricPrefix = (String) catApiConfig.get("metricPrefix");
List<String> metricKeys = (List<String>) catApiConfig.get("metricKeys");
try {
UrlBuilder urlBuilder = UrlBuilder.fromYmlServerConfig(server).path(endPoint);
String url = urlBuilder.build();
String response = HttpClientUtils.getResponseAsStr(configuration.getHttpClient(), url);
metrics.putAll(catMetricsClient.extractMetrics(response, metricKeys, metricPrefix));
} catch (Exception e) {
logger.error("Unable to execute the request " + endPoint + " Failed with Error :" + e);
}
}
printMetrics(displayName, metrics);
} else {
logger.warn("catEndPoints in config.yml is not configured for Elastic Search server " + displayName);
}
}
开发者ID:Appdynamics,项目名称:elasticsearch-monitoring-extension,代码行数:25,代码来源:ElasticSearchMonitorTask.java
示例2: collectAndPrintServerStats
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
protected void collectAndPrintServerStats(Map<String, String> requestMap) {
String statsUrlPath = (String) apacheServer.get("statsUrlPath");
if (Strings.isNullOrEmpty(statsUrlPath)) {
logger.info("Not collecting mod_status stats as statsUrlPath is null for " + requestMap.get("host") + ":" + requestMap.get("port"));
return;
}
String url = UrlBuilder.builder(requestMap).path(statsUrlPath).build();
CloseableHttpClient httpClient = configuration.getHttpClient();
List<String> responseAsLines = HttpClientUtils.getResponseAsLines(httpClient, url);
Map<String, String> metrics = parse(responseAsLines, COLON_SPLIT_PATTERN);
print(metrics, metricPrefix);
}
开发者ID:Appdynamics,项目名称:apache-monitoring-extension,代码行数:18,代码来源:ApacheMonitoringTask.java
示例3: runTask
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
private void runTask() {
MetricConfig metricConfig = (MetricConfig) configuration.getMetricsXmlConfiguration();
Stat[] stats = metricConfig.getStats();
if (stats != null && stats.length > 0) {
for (Stat stat : stats) {
String urlPath = stat.getUrl();
if (urlPath != null) {
String fullUrl = UrlBuilder.fromYmlServerConfig(server)
.path(urlPath).build();
JsonNode response = getResponseAsJson(fullUrl);
if (response != null) {
parseResponse(stat, response);
} else {
logger.error("The url [{}] returned no data ", fullUrl);
}
}
}
}
printSchedulerMetrics();
printJobTypeMonitoring();
}
开发者ID:Appdynamics,项目名称:hadoop-monitoring-extension,代码行数:22,代码来源:ResourceMgrMetricsFetcherTask.java
示例4: fetchMetrics
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
private void fetchMetrics(String serverPrefix) {
Stat [] stats = getStats();
if (stats != null && stats.length != 0) {
for (Stat stat : getStats()) {
if(!Strings.isNullOrEmpty(stat.getUrl())) {
logger.debug("Started fetching metrics for endpoint " + stat.getUrl());
UrlBuilder urlBuilder = UrlBuilder.fromYmlServerConfig(server).path(stat.getUrl() + "&format=json");
String url = urlBuilder.build();
JsonNode node = HttpClientUtils.getResponseAsJson(configuration.getHttpClient(), url, JsonNode.class);
MetricGroup [] metricGroups = stat.getMetricGroups();
for (MetricGroup metricGroup : metricGroups) {
String xpath = metricGroup.getXpath();
String metricGroupPrefix = metricGroup.getPrefix();
JsonNode jsonNode = JsonUtils.getNestedObject(node.path(stat.getEntryNode()), xpath.split("\\|"));
Metric [] metrics = metricGroup.getMetrics();
for (Metric metric : metrics) {
String metricName = getMetricPath(metricGroupPrefix, metric, jsonNode);
printMetric(serverPrefix + metricName, extractMetricValueFromNode(jsonNode, metric.getXpath()), stat);
}
}
} else {
logger.debug("uri for stat in metrics.xml is not configured");
}
}
} else {
logger.debug("Stat in metrics.xml is empty");
}
}
开发者ID:Appdynamics,项目名称:marklogic-monitoring-extension,代码行数:30,代码来源:MarkLogicMonitorTask.java
示例5: collectAndPrintJKStats
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
private void collectAndPrintJKStats(Map<String, String> requestMap) {
String jkStatusPath = (String) apacheServer.get("jkStatusPath");
if (Strings.isNullOrEmpty(jkStatusPath)) {
logger.info("Not collecting mod_jk stats as jkStatusPath is null for " + requestMap.get("host") + ":" + requestMap.get("port"));
return;
}
String url = UrlBuilder.builder(requestMap).path(jkStatusPath).build();
CloseableHttpClient httpClient = configuration.getHttpClient();
List<String> responseAsLines = HttpClientUtils.getResponseAsLines(httpClient, url + "?mime=prop");
Multimap<String, String> jkStatusMetrics = buildMap(responseAsLines);
Set<String> strings = jkStatusMetrics.keySet();
Collection<String> workerNames = new ArrayList<String>();
for (String key : strings) {
if (key.contains("balance_workers")) {
Collection<String> names = jkStatusMetrics.get(key);
workerNames.addAll(names);
}
}
logger.debug("Found workers " + workerNames);
if (workerNames.size() > 0) {
printJKWorkerMetrics(jkStatusMetrics, workerNames);
}
}
开发者ID:Appdynamics,项目名称:apache-monitoring-extension,代码行数:32,代码来源:ApacheMonitoringTask.java
示例6: getAppsOfTypeResponse
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
/**
* http://192.168.1.216:8088/ws/v1/cluster/apps?monitoringTimePeriod=15&applicationTypes=MAPREDUCE
*
* @param monitoringPeriod
* @param application
*/
private JsonNode getAppsOfTypeResponse(long monitoringPeriod, Map<String, ?> application) {
String type = (String) application.get("type");
UrlBuilder path = UrlBuilder.fromYmlServerConfig(server)
.path("/ws/v1/cluster/apps")
.query("applicationTypes", type)
.query("startedTimeBegin", String.valueOf(monitoringPeriod));
return getResponseAsJson(path.build());
}
开发者ID:Appdynamics,项目名称:hadoop-monitoring-extension,代码行数:15,代码来源:ResourceMgrMetricsFetcherTask.java
示例7: run
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
public void run() {
try {
String url = UrlBuilder.fromYmlServerConfig(server)
.path("clusters").query("fields=Clusters,hosts,services").build();
fetchMetrics(url);
} catch (Exception e) {
logger.error("Unexpected error while fetching the data", e);
}
}
开发者ID:Appdynamics,项目名称:hadoop-monitoring-extension,代码行数:10,代码来源:AmbariMetricsFetcherTask.java
示例8: populate
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
private Map<String, String> populate() throws IOException, TaskExecutionException {
CloseableHttpClient httpClient = configuration.getHttpClient();
CloseableHttpResponse response = null;
try {
String url = UrlBuilder.fromYmlServerConfig(server).build();
HttpGet get = new HttpGet(url);
response = httpClient.execute(get);
HttpEntity entity = response.getEntity();
String responseBody = EntityUtils.toString(entity, "UTF-8");
Map<String, String> resultMap = new HashMap<String, String>();
if(responseBody == null) {
logger.error("Response body doesn't exist");
}
else {
String header = response.getFirstHeader("Content-Type").getValue();
if (header != null && header.contains("application/json")) {
JSONResponseParser jsonParser = new JSONResponseParser();
resultMap = jsonParser.parseResponse(responseBody);
} else {
if (header != null && header.contains("text/plain")) {
PlainTextResponseParser plainTextParser = new PlainTextResponseParser();
resultMap = plainTextParser.parseResponse(responseBody);
} else {
logger.error("Invalid content type [ " + header + " ] for URL " + url);
throw new TaskExecutionException();
}
}
}
return resultMap;
}
finally {
if(response != null) {
response.close();
}
}
}
开发者ID:Appdynamics,项目名称:nginx-monitoring-extension,代码行数:37,代码来源:NGinXMonitorTask.java
示例9: CouchBaseMonitorTask
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
public CouchBaseMonitorTask(MonitorConfiguration configuration, MetricWriteHelper metricWriteHelper, Map<String, String> server){
this.configuration = configuration;
this.metricWriteHelper = metricWriteHelper;
this.server = server;
this.serverURL = UrlBuilder.fromYmlServerConfig(server).build();
this.clusterName = server.get("name");
AssertUtils.assertNotNull(clusterName, "Name of the cluster should not be null");
configMap = configuration.getConfigYml();
metricsMap = (Map<String, ?>) configMap.get("metrics");
AssertUtils.assertNotNull(metricsMap, "The 'metrics' section in config.yml is either null or empty");
}
开发者ID:Appdynamics,项目名称:couchbase-monitoring-extension,代码行数:12,代码来源:CouchBaseMonitorTask.java
示例10: SolrStats
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
SolrStats(Map server, String contextRoot, CloseableHttpClient httpClient) {
this.httpClient = httpClient;
this.contextRoot = contextRoot;
this.serverUrl = UrlBuilder.fromYmlServerConfig(server).build();
}
开发者ID:Appdynamics,项目名称:solr-monitoring-extension,代码行数:6,代码来源:SolrStats.java
示例11: generateURIFromConfig
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
private String generateURIFromConfig () {
return UrlBuilder.fromYmlServerConfig(server).build();
}
开发者ID:Appdynamics,项目名称:solr-monitoring-extension,代码行数:4,代码来源:CoreContext.java
示例12: collectAndPrintCustomStats
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
private void collectAndPrintCustomStats(Map<String, String> requestMap) {
List<Map> customStatsConfigs = (List<Map>) apacheServer.get("customStats");
if (customStatsConfigs == null || customStatsConfigs.size() <= 0) {
logger.debug("Ignoring custom stats as no custom stat configuration is provided");
return;
}
for (Map customStatsConfig : customStatsConfigs) {
String metricPath = (String) customStatsConfig.get("metricPath");
String metricGroup = (String) customStatsConfig.get("metricGroup");
if (Strings.isNullOrEmpty(metricPath)) {
logger.debug("Not collecting custom stats as custom metricPath is null for " + requestMap.get("host") + ":" + requestMap.get("port") + " and metricGroup " + metricGroup);
continue;
}
String keyValueSeparator = (String) customStatsConfig.get("keyValueSeparator");
List<String> metricsToCollect = (List<String>) customStatsConfig.get("metricsToCollect");
List<String> deltaMetrics = (List<String>) customStatsConfig.get("deltaMetrics");
Pattern splitPattern = null;
if (COLON.equals(keyValueSeparator)) {
splitPattern = COLON_SPLIT_PATTERN;
} else if (EQUAL.equals(keyValueSeparator)) {
splitPattern = EQUAL_SPLIT_PATTERN;
} else {
splitPattern = Pattern.compile(keyValueSeparator, Pattern.LITERAL);
}
CloseableHttpClient httpClient = configuration.getHttpClient();
String url = UrlBuilder.builder(requestMap).path(metricPath).build();
List<String> responseAsLines = HttpClientUtils.getResponseAsLines(httpClient, url);
Map<String, String> customMetrics = parse(responseAsLines, splitPattern);
for (Map.Entry<String, String> metric : customMetrics.entrySet()) {
String metricKey = metric.getKey();
if (metricsToCollect.contains(metricKey)) {
String customMetricPath = metricPrefix + "|" + metricGroup + "|" + metricKey;
BigDecimal bigValue = toBigDecimal(metric.getValue());
printMetric(customMetricPath, bigValue, DEFAULT_METRIC_TYPE);
if (deltaMetrics.contains(metricKey)) {
BigDecimal deltaMetricValue = deltaCalculator.calculateDelta(customMetricPath, bigValue);
printMetric(customMetricPath + " Delta", deltaMetricValue, DEFAULT_METRIC_TYPE);
}
}
}
}
}
开发者ID:Appdynamics,项目名称:apache-monitoring-extension,代码行数:63,代码来源:ApacheMonitoringTask.java
示例13: getSchedulerResponse
import com.appdynamics.extensions.http.UrlBuilder; //导入依赖的package包/类
protected JsonNode getSchedulerResponse() {
UrlBuilder path = UrlBuilder.fromYmlServerConfig(server).path("/ws/v1/cluster/scheduler");
return getResponseAsJson(path.build());
}
开发者ID:Appdynamics,项目名称:hadoop-monitoring-extension,代码行数:5,代码来源:ResourceMgrMetricsFetcherTask.java
注:本文中的com.appdynamics.extensions.http.UrlBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论