@Override public final String toString() { String cl = ""; if (cluster != null) cl = ", cluster: " + getCluster(); return "name: " + getName() + ", host: " + getHost() + ", port: " + getPort() + cl + ", uptime: " + uptime + ", pid: " + pid; }
public final String getState() { if (state == null) { getFutureResult(); } return state; }
private static String formatPid(InstanceInfo info) { int pid = info.getPid(); return pid < 0 ? "--" : "" + pid; }
public static String format(List<InstanceInfo> infos) { String headings[] = {NAME, HOST, PORT, PID, CLUSTER, STATE}; ColumnFormatter cf = new ColumnFormatter(headings); for (InstanceInfo info : infos) { cf.addRow(new Object[]{ info.getName(), info.getHost(), info.getPort(), formatPid(info), info.getDisplayCluster(), info.getDisplayState() }); } return cf.toString(); }
public static String formatBrief(List<InstanceInfo> infos) { ColumnFormatter cf = new ColumnFormatter(); for (InstanceInfo info : infos) { cf.addRow(new Object[]{ info.getName(), info.getDisplayState() }); } return cf.toString(); }
private void synchronizeDirectory(Payload.Outbound payload, Server server, SyncRequest sr, File dir, List<String> fileSet) throws URISyntaxException { for (ModTime mt : sr.files) { if (fileSet.contains(mt.name)) { // if client has file, remove it from set fileSet.remove(mt.name); syncFile(domainRootUri, dir, mt, payload); } else removeFile(domainRootUri, dir, mt, payload); } // now do all the remaining files the client doesn't have for (String name : fileSet) syncFile(domainRootUri, dir, new ModTime(name, 0), payload); }
/** * Return a SyncRequest with the mod times for all the * files in the specified directory. */ private SyncRequest getModTimes(String dir, SyncLevel level) { SyncRequest sr = new SyncRequest(); sr.instance = instanceName; sr.dir = dir; File fdir = new File(instanceDir, dir); if (!fdir.exists()) return sr; getFileModTimes(fdir, fdir, sr, level); return sr; }
public final String getDisplayState() { StringBuilder display = new StringBuilder(); display.append(isRunning() ? InstanceState.StateType.RUNNING.getDisplayString() : InstanceState.StateType.NOT_RUNNING.getDisplayString()); if (ssState == InstanceState.StateType.RESTART_REQUIRED) { if (isRunning()) { display.append("; ").append(InstanceState.StateType.RESTART_REQUIRED.getDisplayString()); } List<String> failedCmds = stateService.getFailedCommands(name); if (!failedCmds.isEmpty()) { StringBuilder list = new StringBuilder(); for (String z : failedCmds) list.append(z).append("; "); display.append(" [pending config changes are: ").append(list).append("]"); } } return display.toString(); }
public final static String getDasPropsPath(final Node node) { return getNodeDir(node) + "/" + DAS_PROPS_SUBPATH; }
private RemoteType parseType(ParameterMap map) throws CommandValidationException { try { return RemoteType.valueOf(map.getOne(PARAM_TYPE)); } catch (Exception e) { throw new CommandValidationException(e); } } }
public final static String getNodeDir(final Node node) { return getNodesDir(node) + "/" + node.getName(); }
private String formatTime(long uptime) { return Strings.get("instanceinfo.uptime", new Duration(uptime)); } private final ServiceLocator habitat;
public InstanceInfo(ServiceLocator habitat, Server svr, int port0, String host0, String cluster0, Logger logger0, int timeout0, ActionReport report, InstanceStateService stateService) { if (svr == null ) // if (svr == null || host0 == null) throw new NullPointerException("null arguments"); this.habitat = habitat; this.svr = svr; name = svr.getName(); port = port0; if (host0 == null) host="not yet assigned"; else host = host0; logger = logger0; timeoutInMsec = timeout0; this.report = report; this.stateService = stateService; if (!StringUtils.ok(cluster0)) cluster = null; else cluster = cluster0; future = pingInstance(); }
private void populateParametersInternal(ParameterMap map) { map.add("DEFAULT", name); map.add(NodeUtils.PARAM_INSTALLDIR, installdir); map.add(NodeUtils.PARAM_NODEHOST, nodehost); map.add(NodeUtils.PARAM_NODEDIR, nodedir); map.add(NodeUtils.PARAM_REMOTEPORT, remotePort); map.add(NodeUtils.PARAM_REMOTEUSER, remoteUser); map.add(NodeUtils.PARAM_REMOTEPASSWORD, remotePassword); map.add(NodeUtils.PARAM_TYPE, getType().toString()); map.add(NodeUtils.PARAM_INSTALL, Boolean.toString(install)); // let subclasses overwrite our values if they like. populateParameters(map); }
private void synchronizeDirectory(Payload.Outbound payload, Server server, SyncRequest sr, File dir, List<String> fileSet) throws URISyntaxException { for (ModTime mt : sr.files) { if (fileSet.contains(mt.name)) { // if client has file, remove it from set fileSet.remove(mt.name); syncFile(domainRootUri, dir, mt, payload); } else removeFile(domainRootUri, dir, mt, payload); } // now do all the remaining files the client doesn't have for (String name : fileSet) syncFile(domainRootUri, dir, new ModTime(name, 0), payload); }
public final int getPid() { if (pid < 0) { getFutureResult(); } return pid; }
public static String getInstanceDirPath(final Node node, final String instanceName) { if (!StringUtils.ok(instanceName)) throw new IllegalArgumentException(); // don't do that! return getNodeDir(node) + "/" + instanceName; }
/** * Make sure we can make an SSH connection using an existing node. * * @param node Node to connect to * @throws CommandValidationException */ void pingRemoteConnection(Node node) throws CommandValidationException { RemoteType type = RemoteType.valueOf(node.getType()); validateHostName(node.getNodeHost()); switch (type) { case SSH: pingSSHConnection(node); break; default: throw new CommandValidationException("Internal Error: unknown type"); } }
public final long getUptime() { if (uptime == -1) { getFutureResult(); } return uptime; }
public final boolean isRunning() { if (state == null) { getFutureResult(); } return running; }