private static String parseValue(final String arg, final String key) { int splitPos = key.length(); if (arg.length() <= splitPos + 1 || arg.charAt(splitPos) != '=') { System.err.println(MESSAGES.argumentHasNoValue(arg, usageNote())); return null; } else { return arg.substring(splitPos + 1); } }
void setAgentLib(String agentLib) { if (agentPath != null) { throw MESSAGES.attemptingToSet("agent-lib", "agent-path"); } this.agentLib = agentLib; }
@Override public HostFileRepository getRemoteFileRepository() { if (hostControllerInfo.isMasterDomainController()) { throw MESSAGES.cannotAccessRemoteFileRepository(); } return remoteFileRepository; }
while ((cause = cause.getCause()) != null) { if (cause instanceof SaslException) { throw MESSAGES.authenticationFailureUnableToConnect(cause); } else if (cause instanceof SSLHandshakeException) { throw MESSAGES.sslFailureUnableToConnect(cause); } else if (cause instanceof SlaveRegistrationException) { throw new IOException(cause); throw MESSAGES.connectionToMasterTimeout(e, retries, timeout); retries++; } catch (InterruptedException ie) { throw MESSAGES.connectionToMasterInterrupted();
pmPort = Integer.valueOf(port); } catch (NumberFormatException e) { System.err.println(MESSAGES.invalidValue(CommandLineConstants.PROCESS_CONTROLLER_BIND_PORT, "Integer", port, usageNote())); return null; pmAddress = InetAddress.getByName(addr); } catch (UnknownHostException e) { System.err.println(MESSAGES.unknownHostValue(CommandLineConstants.PROCESS_CONTROLLER_BIND_ADDR, addr, usageNote())); return null; System.err.println(MESSAGES.argumentExpected(arg, usageNote())); return null; System.err.println(MESSAGES.argumentExpected(arg, usageNote())); return null; System.err.println(MESSAGES.argumentExpected(arg, usageNote())); return null; System.err.println(MESSAGES.argumentExpected(arg, usageNote())); return null; System.err.println(MESSAGES.invalidOption(arg, usageNote())); return null; System.err.println(MESSAGES.argumentExpected(arg, usageNote())); return null;
@Override public void handleRequest(DataInput input, ActiveOperation.ResultHandler<File> resultHandler, ManagementRequestContext<Void> context) throws IOException { final File localPath; switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { localPath = localFileRepository.getFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { localPath = localFileRepository.getConfigurationFile(filePath); break; } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); localPath = localFileRepository.getDeploymentRoot(hash); break; } default: { localPath = null; } } try { DomainRemoteFileRequestAndHandler.INSTANCE.handleResponse(input, localPath, ROOT_LOGGER, resultHandler, context); } catch (CannotCreateLocalDirectoryException e) { throw MESSAGES.cannotCreateLocalDirectory(e.getDir()); } catch (DidNotReadEntireFileException e) { throw MESSAGES.didNotReadEntireFile(e.getMissing()); } } }
private InetAddress getBindAddress() { if (bindAddress == null) { throw MESSAGES.cannotObtainValidDefaultAddress(uhe, defaultBindAddress, CommandLineConstants.INTERPROCESS_HC_ADDRESS); } return bindAddress; }
private static Map<String, String> getHostSystemProperties() { final Map<String, String> hostSystemProperties = new HashMap<String, String>(); try { RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); for (String arg : runtime.getInputArguments()) { if (arg != null && arg.length() > 2 && arg.startsWith("-D")) { arg = arg.substring(2); String[] split = arg.split("="); if (!hostSystemProperties.containsKey(split[0])) { String val = split.length == 2 ? split[1] : null; hostSystemProperties.put(split[0], val); } } } } catch (Exception e) { System.err.println(MESSAGES.cannotAccessJvmInputArgument(e)); } return hostSystemProperties; }
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ServerStatus origStatus = serverInventory.determineServerStatus(serverName); if (origStatus != ServerStatus.STARTED) { throw new OperationFailedException(new ModelNode(MESSAGES.cannotRestartServer(serverName, origStatus))); } final ServerStatus status = serverInventory.restartServer(serverName, -1, model, blocking); context.getResult().set(status.toString()); context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME);
throw HostControllerMessages.MESSAGES.cannotIgnoreTypeHost(ModelDescriptionConstants.HOST);
void setAgentPath(String agentPath) { if (agentLib != null) { throw MESSAGES.attemptingToSet("agent-path", "agent-lib"); } this.agentPath = agentPath; }
/** * Validates that param {@code value} does not begin with the character {@code -}. For use in cases where * the legal value for an argument would not begin with that character. Usage is to detect missing argument * values, where the command line includes another argument instead of the value for the last argument. * * @param argument the last argument, whose value should be {@code value} * @param value the next item in the command line arguments, which should be the value for {@code argument} * @return {@code value} if it is valid, or {@code null} if it is not */ private static String checkValueIsNotAnArg(String argument, String value) { if (value.startsWith("-")) { System.err.println(MESSAGES.argumentHasNoValue(argument, usageNote())); return null; } return value; }