本文整理汇总了Java中org.jolokia.client.exception.J4pException类的典型用法代码示例。如果您正苦于以下问题:Java J4pException类的具体用法?Java J4pException怎么用?Java J4pException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
J4pException类属于org.jolokia.client.exception包,在下文中一共展示了J4pException类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ping
import org.jolokia.client.exception.J4pException; //导入依赖的package包/类
@Override
public boolean ping() {
if (jolokia == null) {
throw new IllegalStateException("Need to connect to remote jolokia first");
}
J4pVersionResponse vr;
try {
vr = jolokia.execute(new J4pVersionRequest());
return vr != null && vr.getValue() != null;
} catch (J4pException e) {
return false;
}
}
示例2: fetchMbeanMetadata
import org.jolokia.client.exception.J4pException; //导入依赖的package包/类
private void fetchMbeanMetadata(final J4pClient client) {
try {
J4pListRequest request = new J4pListRequest(new ObjectName(MBEAN_JAVA_LANG_MEMORY));
logger().trace("Listing: {}", MBEAN_JAVA_LANG_MEMORY);
client.execute(request); // Ignore response
} catch (J4pException | MalformedObjectNameException e) {
logger().error("Failed to execute list request: {}", MBEAN_JAVA_LANG_MEMORY, e);
}
}
示例3: serverType
import org.jolokia.client.exception.J4pException; //导入依赖的package包/类
/**
* Connects to Jolokia and tries to introspect the server type e.g., Jetty, Tomcat etc.
*
* @return the server type
* @throws nz.org.geonet.metrics.exception.ConnectionException
*
* @see ServerType
*/
String serverType() throws ConnectionException {
String result = ServerType.UnknownJVM.name();
try {
J4pVersionRequest request = new J4pVersionRequest();
J4pVersionResponse response = client.execute(request);
if (response != null && response.getValue() != null) {
HashMap responseMap = response.getValue();
if (responseMap.containsKey("info")) {
HashMap info = (HashMap) responseMap.get("info");
// TODO - don't check the version at the moment. Don't know how important this is yet.
// e.g., {"product":"tomcat","vendor":"Apache","version":"6.0.37"}
if (info.containsKey("product") && ServerType.Jetty.name().toLowerCase().matches(info.get("product").toString().toLowerCase())) {
result = ServerType.Jetty.name();
} else if (info.containsKey("product") && ServerType.Tomcat.name().toLowerCase().matches(info.get("product").toString().toLowerCase())) {
result = ServerType.Tomcat.name();
}
}
}
} catch (J4pException e) {
throw new ConnectionException("problem connecting to the Jolokia agent " + URL);
}
return result;
}
示例4: getSingleLogbackContext
import org.jolokia.client.exception.J4pException; //导入依赖的package包/类
public static LogbackContext getSingleLogbackContext(J4pClient client) throws J4pException {
Objects.requireNonNull(client, "client should not be null");
Map<String, Object> logbacks = client.execute(new J4pListRequest(LOGBACK_PATH)).getValue();
if(logbacks.size() != 1) {
throw new IllegalStateException("expected: a single logback context");
}
return new LogbackContext(client, LOGBACK_PATH + ":" + logbacks.keySet().iterator().next());
}
示例5: fetchData
import org.jolokia.client.exception.J4pException; //导入依赖的package包/类
private Iterable<?> fetchData() throws MalformedObjectNameException, J4pException {
final List<J4pReadRequest> requests = getRequests();
final List<J4pResponse<J4pReadRequest>> response = client.execute(requests);
return toValues(response);
}