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


Java J4pClient类代码示例

本文整理汇总了Java中org.jolokia.client.J4pClient的典型用法代码示例。如果您正苦于以下问题:Java J4pClient类的具体用法?Java J4pClient怎么用?Java J4pClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


J4pClient类属于org.jolokia.client包,在下文中一共展示了J4pClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createJolokiaClient

import org.jolokia.client.J4pClient; //导入依赖的package包/类
public static J4pClient createJolokiaClient(String jolokiaUrl, String username, String password) {
    J4pClientBuilder builder = J4pClientBuilderFactory.url(jolokiaUrl);
    boolean auth = false;
    if (isNotEmpty(username)) {
        builder = builder.user(username);
        auth = true;
    }
    if (isNotEmpty(password)) {
        builder = builder.password(password);
        auth = true;
    }
    if (auth) {
        builder = builder.authenticator(new BasicAuthenticator(true));
    }
    return builder.build();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:JolokiaClientFactory.java

示例2: openSession

import org.jolokia.client.J4pClient; //导入依赖的package包/类
/** @see org.hawkular.agent.monitor.protocol.EndpointService#openSession() */
@Override
public JMXSession openSession() {
    Driver<JMXNodeLocation> driver;

    if (this.clientFactory != null) {
        // remote JMX access via Jolokia
        J4pClient client = clientFactory.createClient();
        driver = new JolokiaJMXDriver(getDiagnostics(), client);
    } else {
        // local JMX access via JMX API
        MBeanServerConnection mbs = getMBeanServerConnection();
        driver = new MBeanServerConnectionJMXDriver(getDiagnostics(), mbs);
    }

    return new JMXSession(getFeedId(), getMonitoredEndpoint(), getResourceTypeManager(), driver,
            getLocationResolver());
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:19,代码来源:JMXEndpointService.java

示例3: testExecData

import org.jolokia.client.J4pClient; //导入依赖的package包/类
@Test
public void testExecData() throws Exception {
	J4pClient j4pClient = new J4pClient("http://localhost:8080/jolokia-war-1.1.3");
	// J4pReadRequest req = new
	// J4pReadRequest("jboss.system:type=ServerInfo","ActiveThreadCount",
	// "ActiveThreadGroupCount", "MaxMemory", "HostName",
	// "TotalMemory","FreeMemory");
	List<String> attributes = Arrays.asList(new String[] { "DetailedStatus" });
	//
	// J4pReadRequest req = new
	// J4pReadRequest("jboss.ws:context=*,endpoint=*",
	// attributes.toArray(new String[]{}));

	J4pExecRequest req = new J4pExecRequest("se.arbetsformedlingen.utils.probe:service=TestWebService2", "checkStatus");

	J4pExecResponse resp = j4pClient.execute(req);
	Map<String, Object> v = (Map<String, Object>) resp.getValue();
	System.out.println(v);
	for (String attrib : attributes) {
		try {
			System.out.println(attrib + "=" + v.get(attrib));
		} catch (Exception ignore) {
		}
	}

}
 
开发者ID:cwikman,项目名称:elasticsearch-river-jolokia,代码行数:27,代码来源:JolokiaTest.java

示例4: fetchMbeanMetadata

import org.jolokia.client.J4pClient; //导入依赖的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);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:10,代码来源:Jolokia.java

示例5: createJolokiaClient

import org.jolokia.client.J4pClient; //导入依赖的package包/类
private void createJolokiaClient() {
    client = J4pClient
            .url(url)
            .user(user)
            .password(password)
            .pooledConnections()
            .build();
}
 
开发者ID:HendrikSP,项目名称:jolokia-csv,代码行数:9,代码来源:JolokiaGatherer.java

示例6: init

import org.jolokia.client.J4pClient; //导入依赖的package包/类
@PostConstruct
public void init() {
    client = J4pClient.url(jolokiaUrl)
            // a dummy value for user is needed, because otherwise, J4pClient will not attempt to use Authenticator
            .user(jolokiaAuthUser)
            //.password(properties.getProperty(Config.JOLOKIA_AUTH_PASSWORD))
            .authenticator(authenticator)
            .useProxyFromEnvironment()
            .build();
}
 
开发者ID:stropa,项目名称:datapipes,代码行数:11,代码来源:JolokiaCollector.java

示例7: MetricsClient

import org.jolokia.client.J4pClient; //导入依赖的package包/类
/**
 * Wraps the connection to Jolokia.
 *
 * @param URL the URL to connect to the Jolokia agent on.
 */
@SuppressWarnings("SameParameterValue")
public MetricsClient(String URL) {
    client = J4pClient.url(URL)
            .socketTimeout(5000)
            .build();

    this.URL = URL;
}
 
开发者ID:GeoNet,项目名称:app-server-metrics,代码行数:14,代码来源:MetricsClient.java

示例8: doStop

import org.jolokia.client.J4pClient; //导入依赖的package包/类
@Override
protected void doStop(MutableManagedProcess process) throws Exception {
    // [TODO] #55 Topology should manage ProcessRegistration instead of just ProcessIdentity
    // Every managed process also creates an agent with the same id as the process
    // Obtain the jolokia endpoint URL from the ProcessRegistration
    AgentIdentity agentId = AgentIdentity.create(process.getIdentity().getName());
    AgentTopology topology = ManagementUtils.getMXBeanProxy(getMBeanServer(), AgentTopology.OBJECT_NAME, AgentTopology.class);
    AgentRegistration remoteAgent = topology.getAgentRegistration(agentId);
    String serviceURL = remoteAgent.getJolokiaEndpoint();
    J4pClient client = new J4pClient(serviceURL);
    ObjectName oname = getFrameworkMBeanName(client);
    J4pExecRequest execReq = new J4pExecRequest(oname, "shutdownFramework");
    client.execute(execReq);
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:15,代码来源:KarafProcessHandler.java

示例9: getSingleLogbackContext

import org.jolokia.client.J4pClient; //导入依赖的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());
}
 
开发者ID:IDgis,项目名称:geo-publisher,代码行数:12,代码来源:LogbackContext.java

示例10: testReadData

import org.jolokia.client.J4pClient; //导入依赖的package包/类
@Test
public void testReadData() throws Exception {
	J4pClient j4pClient = new J4pClient("http://localhost:8080/jolokia-war-1.1.3");
	// J4pReadRequest req = new
	// J4pReadRequest("jboss.system:type=ServerInfo","ActiveThreadCount",
	// "ActiveThreadGroupCount", "MaxMemory", "HostName",
	// "TotalMemory","FreeMemory");
	List<String> attributes = Arrays.asList(new String[] { "Status" });
	//
	// J4pReadRequest req = new
	// J4pReadRequest("jboss.ws:context=*,endpoint=*",
	// attributes.toArray(new String[]{}));

	try {
		J4pReadRequest req = new J4pReadRequest("af-probe:probe=*", attributes.toArray(new String[] {}));
		
		J4pReadResponse resp = j4pClient.execute(req);
		System.out.println(resp.getValue());

		for (ObjectName o : resp.getObjectNames()) {
			for (String attrib : attributes) {
				try {
					Object v = resp.getValue(o, attrib);
					System.out.println(o.getDomain() + " " + o.getCanonicalName() + " " + attrib + "=" + v);
				} catch (Exception ignore) {
				}
			}
		}
	} catch (Exception e) {
		System.out.println(e);
	}

}
 
开发者ID:cwikman,项目名称:elasticsearch-river-jolokia,代码行数:34,代码来源:JolokiaTest.java

示例11: using

import org.jolokia.client.J4pClient; //导入依赖的package包/类
@Override
public void using(J4pClient client) {
    this.jolokia = client;
    this.url = null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:DefaultJolokiaCamelController.java

示例12: startFilter

import org.jolokia.client.J4pClient; //导入依赖的package包/类
@Override
protected void startFilter() {
    //
    // Non-rules based modifiers
    //
    m_actions.clear();
    Modifier defModifier = Modifier.create(DEFAULT_MODIFIER, variables(), config());
    if (!defModifier.isEmpty()) {
        m_actions.put(DEFAULT_MODIFIER, defModifier);
    }
    //
    // Jolokia URL(s)
    //
    JsonArray urls = config().getArray(CONF_KEY_JOLOKIA_URLS, new JsonArray());
    for (int i = 0; i < urls.size(); i++) {
        String url = urls.get(i).toString();
        logger().info("Connecting to: {}", url);
        m_clients.add(J4pClient.url(url)
                .user(config().getString(CONF_KEY_USER_NAME))
                .password(config().getString(CONF_KEY_USER_PASSWORD))
                .authenticator(new BasicAuthenticator(config().getBoolean(CONF_KEY_AUTH_PREEMPTIVE, DEF_AUTH_PREEMPTIVE)))
                .build());
    }
    //
    // Build requests
    //
    m_config = new RequestConfig();
    JsonArray requests = config().getArray(CONF_KEY_REQUESTS, new JsonArray());
    for (int i = 0; i < requests.size(); i++) {

        JsonObject request = requests.get(i);
        String mbean = request.getString(CONF_KEY_MBEAN);
        List<String> attributes
                = (List<String>) request.getArray(CONF_KEY_ATTRIBUTES, new JsonArray()).toList();

        // Dstypes
        Map<String, Object> types = request.getObject(CONF_KEY_DSTYPES, new JsonObject()).toMap();
        m_config.setDstypes(mbean, types);

        String path = request.getString(CONF_KEY_PATH, "");
        int len = attributes.size();
        if (!Strings.isNullOrEmpty(mbean)
                && len > 0) {

            try {
                String[] attrs = attributes.toArray(new String[len]);
                logger().debug("Request mbean: {} attributes: {}", mbean, attrs);
                J4pReadRequest readRequest = new J4pReadRequest(mbean, attrs);

                if (!Strings.isNullOrEmpty(path)) {
                    logger().debug("Request path: {}", path);
                    readRequest.setPath(path);
                }

                m_config.addRequest(readRequest);

            } catch (MalformedObjectNameException e) {
                logger().error("Failed to build Jolokia request: {}:{}:{}",
                        mbean, attributes, path, e);
            }
        }
    }

    m_fetchJavaLangMbeanMetadata = config().getBoolean(
            CONF_KEY_FETCH_JAVA_LANG_MBEAN_METADATA,
            DEF_FETCH_JAVA_LANG_MBEAN_METADATA);

    if (m_fetchJavaLangMbeanMetadata) {
        logger().debug("Fetching metadata of {} (JBoss 4.x/5.x bug circumvention)",
                MBEAN_JAVA_LANG_MEMORY);
    }
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:73,代码来源:Jolokia.java

示例13: createClient

import org.jolokia.client.J4pClient; //导入依赖的package包/类
public J4pClient createClient() {
    J4pAuthenticator authenticator;

    ConnectionData cnData = endpoint.getConnectionData();
    SSLContext sslContext = endpoint.getSSLContext();

    SSLConnectionSocketFactory sslFactory;

    boolean useBearerAuth = false;
    if (cnData.getUsername() != null) {
        if (cnData.getUsername().equalsIgnoreCase(BEARER_TOKEN_USER_ID)) {
            if (cnData.getPassword() == null) {
                throw new IllegalStateException("Bearer token is missing. Must be specified as the password");
            }
            useBearerAuth = true;
        }
    }

    if (sslContext != null && cnData.getUri().getScheme().equalsIgnoreCase("https")) {
        sslFactory = new SSLConnectionSocketFactory(sslContext);
        if (useBearerAuth) {
            authenticator = new SecureBearerAuthenticator(sslContext);
        } else {
            authenticator = new SecureBasicAuthenticator(sslContext).preemptive();
        }
    } else {
        sslFactory = null;
        if (useBearerAuth) {
            authenticator = new BearerAuthenticator();
        } else {
            authenticator = new BasicAuthenticator().preemptive();
        }
    }

    J4pClient client = J4pClient
            .url(cnData.getUri().toString())
            .user(cnData.getUsername())
            .password(cnData.getPassword())
            .authenticator(authenticator)
            .connectionTimeout(60000)
            .sslConnectionSocketFactory(sslFactory)
            .build();
    return client;
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:45,代码来源:JolokiaClientFactory.java

示例14: getClient

import org.jolokia.client.J4pClient; //导入依赖的package包/类
public J4pClient getClient() {
    return client;
}
 
开发者ID:hawkular,项目名称:hawkular-agent,代码行数:4,代码来源:JolokiaJMXDriver.java

示例15: MXBeanInvocationHandler

import org.jolokia.client.J4pClient; //导入依赖的package包/类
private MXBeanInvocationHandler(String serviceURL, ObjectName objectName) {
    this.client = new J4pClient(serviceURL);
    this.objectName = objectName;
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:5,代码来源:JolokiaMXBeanProxy.java


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