Exemplo n.º 1
0
 @Override
 public String getTailByHostAddress(
     final String serviceName,
     final String applicationName,
     final String hostAddress,
     final int numLines)
     throws CLIException {
   final String url =
       SERVICE_CONTROLLER_URL
           + "applications/"
           + applicationName
           + "/services/"
           + serviceName
           + "/address/"
           + hostAddress
           + "/lines/"
           + numLines
           + "/tail";
   try {
     @SuppressWarnings("unchecked")
     String response = (String) client.get(url);
     return response;
   } catch (final ErrorStatusException e) {
     throw new CLIStatusException(e, e.getReasonCode(), e.getArgs());
   }
 }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public void doConnect(final String user, final String password, final String url)
      throws CLIException {
    String formattedURL = url;
    if (!formattedURL.endsWith("/")) {
      formattedURL = formattedURL + '/';
    }
    if (!formattedURL.startsWith("http://")) {
      formattedURL = "http://" + formattedURL;
    }

    URL urlObj;
    try {
      urlObj = new URL(formattedURL);
      if (urlObj.getPort() == -1) {
        urlObj = getUrlWithDefaultPort(urlObj);
      }
    } catch (final MalformedURLException e) {
      throw new CLIStatusException("could_not_parse_url", url, e);
    }

    try {
      client = new GSRestClient(user, password, urlObj);
      // test connection
      client.get(SERVICE_CONTROLLER_URL + "testrest");
    } catch (final ErrorStatusException e) {
      throw new CLIStatusException(e, e.getReasonCode(), e.getArgs());
    } catch (final RestException e) {
      throw new CLIException(e);
    }
  }
Exemplo n.º 3
0
 /** {@inheritDoc} */
 @Override
 public List<String> getApplicationsList() throws CLIException {
   try {
     @SuppressWarnings("unchecked")
     List<String> applications = (List<String>) client.get("/service/applications");
     return applications;
   } catch (final ErrorStatusException e) {
     throw new CLIStatusException(e, e.getReasonCode(), e.getArgs());
   }
 }
Exemplo n.º 4
0
  /** {@inheritDoc} */
  public Map<String, String> dumpAgent(final String ip) throws CLIException {

    final String url = SERVICE_CONTROLLER_URL + "dump/" + ip;
    try {
      @SuppressWarnings("unchecked")
      Map<String, String> response = (Map<String, String>) client.get(url);
      return response;
    } catch (final ErrorStatusException e) {
      throw new CLIStatusException(e, e.getReasonCode(), e.getArgs());
    }
  }
Exemplo n.º 5
0
 /** {@inheritDoc} */
 @Override
 public List<String> getServicesList(final String applicationName) throws CLIException {
   try {
     @SuppressWarnings("unchecked")
     List<String> services =
         (List<String>) client.get("/service/applications/" + applicationName + "/services");
     return services;
   } catch (final ErrorStatusException ese) {
     throw new CLIStatusException(ese, ese.getReasonCode(), ese.getArgs());
   }
 }
Exemplo n.º 6
0
  /** {@inheritDoc} */
  @Override
  public Map<String, Object> getInstanceList(final String applicationName, final String serviceName)
      throws CLIException {

    final String url =
        SERVICE_CONTROLLER_URL
            + "applications/"
            + applicationName
            + "/services/"
            + serviceName
            + "/instances";
    try {
      @SuppressWarnings("unchecked")
      Map<String, Object> instances = (Map<String, Object>) client.get(url);
      return instances;
    } catch (final ErrorStatusException e) {
      throw new CLIStatusException(e, e.getReasonCode(), e.getArgs());
    }
  }