Exemplo n.º 1
0
  public static void Run(String[] args) throws Exception {

    try {
      NCache = ToolsRPCService.GetRPCService();

      Object param = new RemoveClientNodeParam();
      tangible.RefObject<Object> tempRef_param = new tangible.RefObject<Object>(param);
      CommandLineArgumentParser.CommandLineParser(tempRef_param, args);
      param = tempRef_param.argvalue;
      cParam = (RemoveClientNodeParam) param;
      if (cParam.getIsUsage()) {
        AssemblyUsage.PrintUsage();
        return;
      }

      if (!ValidateParameters()) {
        return;
      }

      if (cParam.getPort() != -1) {
        NCache.setPort(cParam.getPort());
      }

      if (cParam.getServer() != null && !cParam.getServer().equals("")) {
        NCache.setServerName(cParam.getServer());
      }

      cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 30));

      if (cacheServer == null) {
        throw new Exception("TayzGrid service can not be contacted");
      }
      config = cacheServer.GetNewConfiguration(cParam.getCacheId());
      if (config == null) {
        System.err.println("Error : The cache doesnot exist");
        return;
      }
      if (config.getCacheSettings().getCacheType().equals("clustered-cache")) {
        for (Address node : config.getCacheDeployment().getServers().GetAllConfiguredNodes()) {
          currentServerNodes.add(node.getIpAddress().getHostName().toString());
        }
      } else {
        System.err.println("Error: Client nodes cannot be added to local caches");
        return;
      }

      if (UpdateConfigs()) {
        System.out.println("Info: Client node(s) successfully removed...");
      }
    } catch (Exception ex) {
      System.err.println("Error: " + ex.getMessage());
    } finally {
      if (cacheServer != null) {
        cacheServer.dispose();
      }
    }
  }
Exemplo n.º 2
0
  private static boolean ValidateParameters() {
    // Validating CacheId

    AssemblyUsage.PrintLogo(cParam.getIsLogo());

    if (tangible.DotNetToJavaStringHelper.isNullOrEmpty(cParam.getCacheId())) {
      System.err.println("Error: Cache Name not specified");
      return false;
    }

    if (tangible.DotNetToJavaStringHelper.isNullOrEmpty(cParam.getClientNode())) {
      System.err.println("Error: Client Node not specified");
      return false;
    }

    return true;
  }