use of com.sun.enterprise.config.serverbeans.NodeAgents in project Payara by payara.
the class NodeAgentConfigUpgrade method postConstruct.
public void postConstruct() {
final NodeAgents nodeAgents = domain.getNodeAgents();
if (nodeAgents == null) {
createDefaultNodeList();
return;
}
final List<NodeAgent> agList = nodeAgents.getNodeAgent();
if (agList.size() == 0) {
createDefaultNodeList();
return;
}
try {
ConfigSupport.apply(new SingleConfigCode<Domain>() {
public Object run(Domain d) throws PropertyVetoException, TransactionFailure {
Nodes nodes = d.createChild(Nodes.class);
Transaction t = Transaction.getTransaction(d);
if (t == null)
return null;
for (NodeAgent na : agList) {
String host = null;
Node node = nodes.createChild(Node.class);
node.setName(na.getName());
node.setType("CONFIG");
JmxConnector jc = na.getJmxConnector();
if (jc != null) {
// get the properties and see if host name is specified
List<Property> agentProp = jc.getProperty();
for (Property p : agentProp) {
String name = p.getName();
if (name.equals("client-hostname")) {
// create the node with a host name
node.setNodeHost(p.getValue());
node.setInstallDir("${com.sun.aas.productRoot}");
}
}
}
nodes.getNode().add(node);
}
// Now add the builtin localhost node
createDefaultNode(d, nodes);
d.setNodes(nodes);
List<Server> serverList = servers.getServer();
if (serverList.size() <= 0)
return null;
for (Server s : serverList) {
s = t.enroll(s);
s.setNodeRef(s.getNodeAgentRef());
s.setNodeAgentRef(null);
}
// remove the node-agent element
// d.getNodeAgents().getNodeAgent().clear();
d.setNodeAgents(null);
return null;
}
}, domain);
} catch (Exception e) {
Logger.getAnonymousLogger().log(Level.SEVERE, "Failure while upgrading node-agent from V2 to V3", e);
throw new RuntimeException(e);
}
}
Aggregations