Search in sources :

Example 36 with Node

use of com.sun.enterprise.config.serverbeans.Node in project Payara by payara.

the class DeleteNodeRemoteCommand method executeInternal.

protected final void executeInternal(AdminCommandContext context) {
    ActionReport report = context.getActionReport();
    logger = context.getLogger();
    Node node = nodes.getNode(name);
    if (node == null) {
        // No node to delete nothing to do here
        String msg = Strings.get("noSuchNode", name);
        logger.warning(msg);
        report.setActionExitCode(FAILURE);
        report.setMessage(msg);
        return;
    }
    String type = node.getType();
    if (type == null || type.equals("CONFIG")) {
        // No node to delete nothing to do here
        String msg = Strings.get("notRemoteNodeType", name);
        logger.warning(msg);
        report.setActionExitCode(FAILURE);
        report.setMessage(msg);
        return;
    }
    ParameterMap info = new ParameterMap();
    if (uninstall) {
        // Store needed info for uninstall
        SshConnector sshC = node.getSshConnector();
        SshAuth sshAuth = sshC.getSshAuth();
        if (sshAuth.getPassword() != null) {
            info.add(PARAM_SSHPASSWORD, sshAuth.getPassword());
        }
        if (sshAuth.getKeyPassphrase() != null) {
            info.add(PARAM_SSHKEYPASSPHRASE, sshAuth.getKeyPassphrase());
        }
        if (sshAuth.getKeyfile() != null) {
            info.add(PARAM_SSHKEYFILE, sshAuth.getKeyfile());
        }
        info.add(PARAM_INSTALLDIR, node.getInstallDir());
        info.add(PARAM_REMOTEPORT, sshC.getSshPort());
        info.add(PARAM_REMOTEUSER, sshAuth.getUserName());
        info.add(PARAM_NODEHOST, node.getNodeHost());
        info.add(PARAM_WINDOWS_DOMAIN, node.getWindowsDomain());
    }
    CommandInvocation commandInvocation = commandRunner.getCommandInvocation("_delete-node", report, context.getSubject());
    ParameterMap commandParameters = new ParameterMap();
    commandParameters.add("DEFAULT", name);
    commandInvocation.parameters(commandParameters);
    commandInvocation.execute();
    // Uninstall Payara after deleting the node
    if (uninstall) {
        if (!uninstallNode(context, info, node) && !force) {
            report.setActionExitCode(FAILURE);
            return;
        }
    }
}
Also used : SshConnector(com.sun.enterprise.config.serverbeans.SshConnector) Node(com.sun.enterprise.config.serverbeans.Node) ParameterMap(org.glassfish.api.admin.ParameterMap) SshAuth(com.sun.enterprise.config.serverbeans.SshAuth) ActionReport(org.glassfish.api.ActionReport) CommandInvocation(org.glassfish.api.admin.CommandRunner.CommandInvocation)

Example 37 with Node

use of com.sun.enterprise.config.serverbeans.Node in project Payara by payara.

the class PingNodeRemoteCommand method executeInternal.

protected final void executeInternal(AdminCommandContext context) {
    ActionReport report = context.getActionReport();
    StringBuilder msg = new StringBuilder();
    Node theNode = null;
    Logger logger = context.getLogger();
    NodeUtils nodeUtils = new NodeUtils(habitat, logger);
    // Make sure Node is valid
    theNode = nodes.getNode(name);
    if (theNode == null) {
        String m = Strings.get("noSuchNode", name);
        logger.warning(m);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(m);
        return;
    }
    String err = validateSubType(theNode);
    if (err != null) {
        logger.warning(err);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setMessage(err);
        return;
    }
    try {
        String version = "";
        if (validate) {
            // Validates all parameters
            nodeUtils.validate(theNode);
            version = Strings.get("ping.glassfish.version", theNode.getInstallDir(), nodeUtils.getGlassFishVersionOnNode(theNode, context));
        } else {
            // Just does a basic connection check
            nodeUtils.pingRemoteConnection(theNode);
        }
        String m1 = Strings.get("ping.node.success", name, theNode.getNodeHost(), theNode.getType());
        if (StringUtils.ok(version)) {
            m1 = m1 + NL + version;
        }
        report.setMessage(m1);
        report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    } catch (CommandValidationException e) {
        String m1 = Strings.get("ping.node.failure", name, theNode.getNodeHost(), theNode.getType());
        msg.append(StringUtils.cat(NL, m1, e.getMessage()));
        report.setMessage(msg.toString());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
    }
}
Also used : Node(com.sun.enterprise.config.serverbeans.Node) ActionReport(org.glassfish.api.ActionReport) Logger(java.util.logging.Logger)

Example 38 with Node

use of com.sun.enterprise.config.serverbeans.Node in project Payara by payara.

the class IiopFolbGmsClient method getClusterInstanceInfo.

private ClusterInstanceInfo getClusterInstanceInfo(Server server, Config config, boolean assumeInstanceIsRunning) {
    if (server == null) {
        return null;
    }
    if (!assumeInstanceIsRunning) {
        if (!server.isRunning()) {
            return null;
        }
    }
    fineLog("getClusterInstanceInfo: server {0}, config {1}", server, config);
    final String name = server.getName();
    fineLog("getClusterInstanceInfo: name {0}", name);
    final int weight = Integer.parseInt(server.getLbWeight());
    fineLog("getClusterInstanceInfo: weight {0}", weight);
    final IiopService iservice = config.getExtensionByType(IiopService.class);
    fineLog("getClusterInstanceInfo: iservice {0}", iservice);
    final String nodeName = server.getNodeRef();
    String hostName = nodeName;
    if (nodes != null) {
        Node node = nodes.getNode(nodeName);
        if (node != null) {
            // System level, use the local host name
            if ((node.isLocal() && !Boolean.getBoolean(USE_NODE_HOST_FOR_LOCAL_NODE_SYSTEM_PROPERTY)) && (node.isLocal() && !Boolean.parseBoolean(iservice.getOrb().getPropertyValue(USE_NODE_HOST_FOR_LOCAL_NODE_PROPERTY, "false")))) {
                try {
                    hostName = InetAddress.getLocalHost().getHostName();
                } catch (UnknownHostException exc) {
                    fineLog("getClusterInstanceInfo: caught exception for localhost lookup {0}", exc);
                }
            } else {
                hostName = node.getNodeHost();
            }
        }
    }
    fineLog("getClusterInstanceInfo: host {0}", hostName);
    final List<IiopListener> listeners = iservice.getIiopListener();
    fineLog("getClusterInstanceInfo: listeners {0}", listeners);
    final List<SocketInfo> sinfos = new ArrayList<SocketInfo>();
    for (IiopListener il : listeners) {
        SocketInfo sinfo = new SocketInfo(il.getId(), hostName, resolvePort(server, il));
        sinfos.add(sinfo);
    }
    fineLog("getClusterInstanceInfo: sinfos {0}", sinfos);
    final ClusterInstanceInfo result = new ClusterInstanceInfo(name, weight, sinfos);
    fineLog("getClusterInstanceInfo: result {0}", result);
    return result;
}
Also used : IiopListener(org.glassfish.orb.admin.config.IiopListener) UnknownHostException(java.net.UnknownHostException) IiopService(org.glassfish.orb.admin.config.IiopService) Node(com.sun.enterprise.config.serverbeans.Node) SocketInfo(com.sun.corba.ee.spi.folb.SocketInfo) ArrayList(java.util.ArrayList) ClusterInstanceInfo(com.sun.corba.ee.spi.folb.ClusterInstanceInfo)

Aggregations

Node (com.sun.enterprise.config.serverbeans.Node)38 Server (com.sun.enterprise.config.serverbeans.Server)15 ActionReport (org.glassfish.api.ActionReport)13 File (java.io.File)9 ArrayList (java.util.ArrayList)7 Properties (java.util.Properties)7 ParameterMap (org.glassfish.api.admin.ParameterMap)7 Nodes (com.sun.enterprise.config.serverbeans.Nodes)6 IOException (java.io.IOException)6 Logger (java.util.logging.Logger)5 Domain (com.sun.enterprise.config.serverbeans.Domain)4 JsonObject (javax.json.JsonObject)4 CommandInvocation (org.glassfish.api.admin.CommandRunner.CommandInvocation)4 Test (org.junit.Test)4 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)4 WindowsRemoteFile (com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFile)3 WindowsRemoteFileSystem (com.sun.enterprise.util.cluster.windows.io.WindowsRemoteFileSystem)3 WindowsException (com.sun.enterprise.util.cluster.windows.process.WindowsException)3 SFTPv3DirectoryEntry (com.trilead.ssh2.SFTPv3DirectoryEntry)3 PropertyVetoException (java.beans.PropertyVetoException)3