getLogger().log(Level.FINE, "Attempting to Rendezvous with local DAS...");
AgentConfig agentConfig = getNodeAgentConfig();
File root = new File(
new File(agentConfig.getRepositoryRoot()).getParentFile(),
"domains");
NodeAgentPropertyReader naReader = getNodeAgentPropertyReader();
DASPropertyReader dasReader = getDASPropertyReader();
ConfigContext goodConfigContext = null;
boolean tooMany = false;
String dasHost2 = dasReader.getHost();
String dasPort2 = dasReader.getPort();
if (root.exists()) {
//Find all the domains with the same parent as this node agent
File[] domains = root.listFiles();
if (domains != null) {
for (int i = 0; i < domains.length; i++) {
File domainXml = new File(new File(domains[i], "config"),
PEFileLayout.DOMAIN_XML_FILE);
getLogger().log(Level.FINE, "Looking for " +
domainXml.getAbsolutePath());
if (domainXml.exists()) {
ConfigContext configContext =
ConfigFactory.createConfigContext(
domainXml.getAbsolutePath());
String dasName =
ServerHelper.getDAS(configContext).getName();
Config dasConfig = ServerHelper.getConfigForServer(
configContext, dasName);
JMXConnectorConfig dasInfo =
ServerHelper.getJMXConnectorInfo(configContext,
dasName);
String dasPort =
dasConfig.getHttpService().getHttpListenerById(
"admin-listener").getPort();
String dasHost = dasInfo.getHost();
getLogger().log(Level.FINE, "dasHost: " + dasHost +
" dasPort: " + dasPort + " dasHost2: " + dasHost2
+ " dasPort2: " + dasPort2);
// Look for the first domain matching the specified host
// and port. There must be exactly one or we error out.
if (dasPort.equals(dasPort2) && (dasHost.equals(dasHost2) ||
PortConflictCheckerConfigBean.isLocalHost(dasHost2))) {
if (goodConfigContext != null) {
tooMany = true;
break; //we have found more than 1 matching domain
}
goodConfigContext = configContext;
getLogger().log(Level.INFO,
"nodeagent.attemptingRendezvousedWithDAS",
domainXml.getAbsolutePath());
}
}
}
}
}
if (tooMany) {
// There were more than one domain matching the specified host & port
throw new AgentException(_strMgr.getString(
"nodeAgent.attemptLocalRendezvous.TooManyLocalDomains",
dasHost2 + ":" + dasPort2, root.getAbsolutePath()));
} else if (goodConfigContext == null) {
// There were no domains matching the specified host
// and port NoLocalDomains
throw new AgentException(_strMgr.getString(
"nodeAgent.attemptLocalRendezvous.NoLocalDomains",
dasHost2 + ":" + dasPort2, root.getAbsolutePath()));
} else {
// There was exactly one domain, flush out its domain.xml
NodeAgentsConfigBean ncb =
new NodeAgentsConfigBean(goodConfigContext);
String retDasString = ncb.rendezvousWithDAS(
naReader.getHost(), naReader.getPort(), getNodeAgentName(),
naReader.getProtocol(), naReader.getClientHost());
goodConfigContext.flush();
markAsBound(retDasString);
}
}