Search in sources :

Example 1 with NodeAgents

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);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Server(com.sun.enterprise.config.serverbeans.Server) Node(com.sun.enterprise.config.serverbeans.Node) NodeAgent(com.sun.enterprise.config.serverbeans.NodeAgent) JmxConnector(com.sun.enterprise.config.serverbeans.JmxConnector) NodeAgents(com.sun.enterprise.config.serverbeans.NodeAgents) Nodes(com.sun.enterprise.config.serverbeans.Nodes) PropertyVetoException(java.beans.PropertyVetoException) PropertyVetoException(java.beans.PropertyVetoException) Domain(com.sun.enterprise.config.serverbeans.Domain) Property(org.jvnet.hk2.config.types.Property)

Aggregations

Domain (com.sun.enterprise.config.serverbeans.Domain)1 JmxConnector (com.sun.enterprise.config.serverbeans.JmxConnector)1 Node (com.sun.enterprise.config.serverbeans.Node)1 NodeAgent (com.sun.enterprise.config.serverbeans.NodeAgent)1 NodeAgents (com.sun.enterprise.config.serverbeans.NodeAgents)1 Nodes (com.sun.enterprise.config.serverbeans.Nodes)1 Server (com.sun.enterprise.config.serverbeans.Server)1 PropertyVetoException (java.beans.PropertyVetoException)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1 Property (org.jvnet.hk2.config.types.Property)1