use of com.sun.appserv.management.client.AppserverConnectionSource in project Payara by payara.
the class AppserverConnectionSourceTest method testConnect.
private static void testConnect(final String host, final int port, final String protocol, final String user, final String password) throws IOException {
final AppserverConnectionSource source = new AppserverConnectionSource(protocol, host, port, user, password, null);
source.getMBeanServerConnection(true);
}
use of com.sun.appserv.management.client.AppserverConnectionSource in project Payara by payara.
the class ReferencesTest method testCreateAndRemoveResourceRefStandaloneServer.
public void testCreateAndRemoveResourceRefStandaloneServer() throws Exception {
if (!checkNotOffline("testCreateRemove")) {
return;
}
final Map<String, AppserverConnectionSource> nodeAgents = getNodeAgents();
if (nodeAgents.keySet().size() == 0) {
warning("testCreateAndRemoveResourceRefStandaloneServer: no Node Agents--SKIPPING TEST");
return;
}
final String nodeAgentName = nodeAgents.keySet().iterator().next();
final ConfigSetup setup = new ConfigSetup(getDomainRoot());
ensureMailResourceConfig();
final String serverName = "testCreateAndRemoveResourceRefStandaloneServer";
final String configName = serverName + "-config";
final ConfigConfig config = setup.createConfig(configName);
try {
final int basePort = 34770;
final StandaloneServerConfig server = setup.createServer(serverName, basePort, nodeAgentName, configName);
try {
final ResourceRefConfig ref = server.createResourceRefConfig(MAIL_RESOURCE_NAME);
assert (ref != null);
server.removeResourceRefConfig(ref.getName());
} catch (Exception e) {
setup.removeServer(serverName);
throw e;
} finally {
removeMailResourceConfig();
}
} catch (Exception e) {
setup.removeConfig(configName);
throw e;
}
}
use of com.sun.appserv.management.client.AppserverConnectionSource in project Payara by payara.
the class TestRunner method testAppserverConnectionSource.
/**
* Comment in call to this for hard-coded test.
*/
private void testAppserverConnectionSource(final String host, final String user, final String password) throws IOException {
MBeanServerConnection conn = null;
final TestClientTrustStoreTrustManager tm = new TestClientTrustStoreTrustManager();
final HandshakeCompletedListenerImpl hcl = new HandshakeCompletedListenerImpl();
tm.setPrompt(true);
final TLSParams tlsParams = new TLSParams(new X509TrustManager[] { tm }, hcl);
println("\ntestAppserverConnectionSource: testing: " + AppserverConnectionSource.PROTOCOL_RMI);
final ConnectionSource rmiSource = new AppserverConnectionSource(AppserverConnectionSource.PROTOCOL_RMI, host, 8686, user, password, null);
conn = rmiSource.getMBeanServerConnection(true);
conn.isRegistered(JMXUtil.getMBeanServerDelegateObjectName());
println(AppserverConnectionSource.PROTOCOL_RMI + " OK using " + rmiSource);
println("\ntestAppserverConnectionSource: testing: " + AppserverConnectionSource.PROTOCOL_HTTP);
final Map<String, String> env = Collections.emptyMap();
final ConnectionSource httpSource = new AppserverConnectionSource(AppserverConnectionSource.PROTOCOL_HTTP, host, 1234, user, password, tlsParams, env);
conn = httpSource.getMBeanServerConnection(true);
assert conn.isRegistered(JMXUtil.getMBeanServerDelegateObjectName());
println(AppserverConnectionSource.PROTOCOL_HTTP + " OK using " + httpSource);
}
use of com.sun.appserv.management.client.AppserverConnectionSource in project Payara by payara.
the class TestMain method getConnectionSource.
private AppserverConnectionSource getConnectionSource(final PropertyGetter getter, boolean retry) throws Exception {
AppserverConnectionSource conn = null;
final long PAUSE_MILLIS = 3 * 1000;
for (int i = 0; i < 5; ++i) {
try {
conn = _getConnectionSource(getter);
break;
} catch (Exception e) {
final Throwable rootCause = ExceptionUtil.getRootCause(e);
if (rootCause instanceof java.net.ConnectException) {
println("ConnectException: " + rootCause.getMessage() + "...retry...");
Thread.sleep(PAUSE_MILLIS);
continue;
}
throw e;
}
}
return (conn);
}
use of com.sun.appserv.management.client.AppserverConnectionSource in project Payara by payara.
the class TestMain method getNodeAgentConnections.
public Map<String, AppserverConnectionSource> getNodeAgentConnections(final DomainRoot domainRoot, final PropertyGetter getter) {
final NodeAgentsConfig nacs = domainRoot.getDomainConfig().getNodeAgentsConfig();
if (nacs == null)
return null;
final Map<String, NodeAgentConfig> nodeAgentConfigs = nacs.getNodeAgentConfigMap();
final Map<String, AppserverConnectionSource> nodeAgentConnections = new HashMap<String, AppserverConnectionSource>();
println("");
println("Contacting node agents...");
for (final NodeAgentConfig nodeAgentConfig : nodeAgentConfigs.values()) {
final String nodeAgentName = nodeAgentConfig.getName();
final JMXConnectorConfig connConfig = nodeAgentConfig.getJMXConnectorConfig();
final AttributeResolverHelper r = new AttributeResolverHelper(connConfig);
if (!r.resolveBoolean("Enabled")) {
println(nodeAgentName + ": DISABLED CONNECTOR");
continue;
}
final String address = connConfig.getAddress();
final int port = r.resolveInt("Port");
final boolean tlsEnabled = r.resolveBoolean("SecurityEnabled");
final String protocol = connConfig.getProtocol();
if (!RMI_PROTOCOL_IN_CONFIG.equals(protocol)) {
println(nodeAgentName + ": UNSUPPORTED CONNECTOR PROTOCOL: " + protocol);
continue;
}
// See if we can connect
try {
final AppserverConnectionSource asConn = _getConnectionSource(getter, address, port);
final MBeanServerConnection conn = asConn.getMBeanServerConnection(false);
final boolean alive = conn.isRegistered(JMXUtil.getMBeanServerDelegateObjectName());
assert (alive);
nodeAgentConnections.put(nodeAgentName, asConn);
println(nodeAgentName + ": ALIVE");
} catch (Exception e) {
println("Node agent " + nodeAgentConfig.getName() + " could not be contacted: " + e.getClass().getName());
println(nodeAgentName + ": COULD NOT BE CONTACTED");
continue;
}
}
println("");
return nodeAgentConnections;
}
Aggregations