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;
}
}
}
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);
}
}
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;
}
Aggregations