use of org.glassfish.api.admin.CommandException in project Payara by payara.
the class StartDeploymentGroupCommand method execute.
@Override
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
Logger logger = context.getLogger();
logger.info(Strings.get("start.dg", deploymentGroup));
// Require that we be a DAS
if (!env.isDas()) {
String msg = Strings.get("cluster.command.notDas");
logger.warning(msg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(msg);
return;
}
ClusterCommandHelper clusterHelper = new ClusterCommandHelper(domain, runner);
try {
// Run start-instance against each instance in the cluster
String commandName = "start-instance";
clusterHelper.runCommand(commandName, null, deploymentGroup, context, verbose);
} catch (CommandException e) {
String msg = e.getLocalizedMessage();
logger.warning(msg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setMessage(msg);
return;
}
}
use of org.glassfish.api.admin.CommandException in project Payara by payara.
the class ChangeNodeMasterPasswordCommand method getInstanceDirs.
/**
* This will get all the instances for a given node
* @param parent node
* @return The list of instances for a node
* @throws CommandException
*/
private ArrayList<String> getInstanceDirs(File parent) throws CommandException {
ArrayList<String> instancesList = new ArrayList<String>();
File[] files = parent.listFiles(new FileFilter() {
public boolean accept(File f) {
return f.isDirectory();
}
});
if (files == null || files.length == 0) {
throw new CommandException(strings.get("Instance.noInstanceDirs", parent));
}
for (File f : files) {
if (!f.getName().equals("agent"))
instancesList.add(f.getName());
}
return instancesList;
}
use of org.glassfish.api.admin.CommandException in project Payara by payara.
the class ChangeNodeMasterPasswordCommand method createMasterPasswordFile.
/**
* Create the master password keystore. This routine can also modify the master password
* if the keystore already exists
*
* @throws CommandException
*/
protected void createMasterPasswordFile() throws CommandException {
final File pwdFile = new File(this.getServerDirs().getAgentDir(), MASTER_PASSWORD_ALIAS);
try {
PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), MASTER_PASSWORD_ALIAS.toCharArray());
p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, newPassword.getBytes());
FileProtectionUtility.chmod0600(pwdFile);
} catch (Exception ex) {
throw new CommandException(strings.get("masterPasswordFileNotCreated", pwdFile), ex);
}
}
use of org.glassfish.api.admin.CommandException in project Payara by payara.
the class CreateLocalInstanceCommand method rendezvousOccurred.
private boolean rendezvousOccurred() {
boolean rendezvousOccurred = false;
RemoteCLICommand rc = null;
try {
rc = new RemoteCLICommand("get", this.programOpts, this.env);
String s = rc.executeAndReturnOutput("get", RENDEZVOUS_DOTTED_NAME);
String val = s.substring(s.indexOf("=") + 1);
rendezvousOccurred = Boolean.parseBoolean(val);
logger.log(Level.FINER, "rendezvousOccurred = {0} for instance {1}", new Object[] { val, instanceName });
} catch (CommandException ce) {
logger.log(Level.FINER, RENDEZVOUS_PROPERTY_NAME + " property may not be set yet on {0}", instanceName);
}
return rendezvousOccurred;
}
use of org.glassfish.api.admin.CommandException in project Payara by payara.
the class CreateLocalInstanceCommand method createMasterPasswordFile.
/**
* Create the master password keystore. This routine can also modify the master password
* if the keystore already exists
* @param masterPassword
* @throws CommandException
*/
protected void createMasterPasswordFile(String masterPassword) throws CommandException {
final File pwdFile = new File(this.getServerDirs().getAgentDir(), MASTER_PASSWORD_ALIAS);
try {
PasswordAdapter p = new PasswordAdapter(pwdFile.getAbsolutePath(), MASTER_PASSWORD_ALIAS.toCharArray());
p.setPasswordForAlias(MASTER_PASSWORD_ALIAS, masterPassword.getBytes());
FileProtectionUtility.chmod0600(pwdFile);
} catch (Exception ex) {
throw new CommandException(Strings.get("masterPasswordFileNotCreated", pwdFile), ex);
}
}
Aggregations