Ejemplo n.º 1
0
 private static CommandManager startGemFire() {
   Properties pr = new Properties();
   pr.put("jmx-manager", "true");
   pr.put("jmx-manager-start", "true");
   DistributedSystem ds = DistributedSystem.connect(pr);
   Cache cache = new CacheFactory().create();
   GemFireCacheImpl impl = (GemFireCacheImpl) cache;
   ManagementService service = ManagementService.getManagementService(cache);
   CommandManager manager = CommandManager.getExisting();
   return manager;
 }
Ejemplo n.º 2
0
  private static void iterateCommands(CommandManager mgr) throws IOException {
    Map<String, CommandTarget> commandMap = mgr.getCommands();
    StringBuilder serviceString = new StringBuilder("include \"");
    serviceString.append(MGMT_STRUCT_THRIFT_FILE).append("\"\n");
    serviceString.append("include \"");
    serviceString.append(MGMT_CMDRESULT_THRIFT_FILE).append("\"\n");
    serviceString.append("namespace java ").append(MGMT_SERVICE_PACKAGE).append("\n");
    serviceString.append(EXCEPTION_DECLARATION);
    serviceString.append("\nservice GeodeCommandService {\n");

    StringBuilder structString = new StringBuilder();
    structString.append("namespace java ").append(MGMT_STRUCT_PACKAGE).append("\n");

    int size = commandMap.size();
    for (String command : commandMap.keySet()) {
      CommandTarget tgr = commandMap.get(command);
      boolean argsStructRequired = argsStructRequired(tgr);
      boolean commandSupported = commandSupported(tgr);
      if (commandSupported) {
        if (argsStructRequired) {
          boolean commandProcessed = processCommand(tgr, structString);
          if (commandProcessed) {
            serviceString
                .append("\n\tcommandResult.CommandResult ")
                .append(getProperName(tgr.getCommandName(), METHOD_NAME));
            serviceString
                .append("(")
                .append("1:structs.")
                .append(getProperName(tgr.getCommandName(), STRUCT_NAME));
            serviceString.append(" arguments)");
            serviceString.append(EXCEPTION_METHOD_SIGNATURE);
            if (size > 1) serviceString.append(",");
          }
        } else {
          serviceString
              .append("\n\tcommandResult.CommandResult ")
              .append(getProperName(tgr.getCommandName(), METHOD_NAME));
          serviceString.append("()");
          serviceString.append(EXCEPTION_METHOD_SIGNATURE);
          if (size > 1) serviceString.append(",");
        }
      }
      size--;
    }
    serviceString.append("\n}");
    writeToFile(structString, MGMT_STRUCT_THRIFT_FILE);
    writeToFile(serviceString, MGMT_SERVICE_THRIFT_FILE);
  }