Query Service.

it is the synchronized method.

@param commands
the StringCommand list.
@return
the ModelServiceInstance list.
762286
public List<ModelServiceInstance> queryService(List<StringCommand> commands){

        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.QueryService);

        List<QueryCommand> cs = new ArrayList<QueryCommand>();
        for(StringCommand c : commands){
            cs.add(c.getStringCommand());
        }

        QueryServiceProtocol p = new QueryServiceProtocol(cs);
        QueryServiceResponse resp ;
        resp = (QueryServiceResponse) connection.submitRequest(header, p,  null);
        return resp.getInstances();
    }
3099
protected CommandServices getCommandServices() {
		if (commandServices == null) {
			commandServices = ValkyrieRepository.getInstance().getApplicationConfig().commandServices();
		}
		return this.commandServices;
	}
791903
public String getCommand()
    {
        String command = "";
        synchronized(this)
        {
            if (commandQueue.size() > 0)
            {
                command = commandQueue.remove(0).command;
            }
        }
        return command;
    }
738083
public List<ModelServiceInstance> getModelInstances(String serviceName){
        ModelService service = getModelService(serviceName);
        if(service == null || service.getServiceInstances().size() == 0){
            return Collections.emptyList();
        }else{
            return new ArrayList<ModelServiceInstance>(service.getServiceInstances());
        }
    }
803920
public static String[] partitionCommandLine(final String command) {
    final ArrayList<String> commands = new ArrayList<>();

    int index = 0;

    StringBuffer buffer = new StringBuffer(command.length());

    boolean isApos = false;
    boolean isQuote = false;
    while (index < command.length()) {
      final char c = command.charAt(index);

      switch (c) {
        case ' ':
          if (!isQuote && !isApos) {
            final String arg = buffer.toString();
            buffer = new StringBuffer(command.length() - index);
            if (arg.length() > 0) {
              commands.add(arg);
            }
          } else {
            buffer.append(c);
          }
          break;
        case '\'':
          if (!isQuote) {
            isApos = !isApos;
          } else {
            buffer.append(c);
          }
          break;
        case '"':
          if (!isApos) {
            isQuote = !isQuote;
          } else {
            buffer.append(c);
          }
          break;
        default:
          buffer.append(c);
      }

      index++;
    }

    if (buffer.length() > 0) {
      final String arg = buffer.toString();
      commands.add(arg);
    }

    return commands.toArray(new String[commands.size()]);
  }
1327954
def cmd(commands, opts={})
      results = {}
      threads = clouds.collect do |name, c|
        Thread.new{ results[ name ] = c.cmd(commands, opts) }
      end
      threads.each{ |aThread| aThread.join }
      results
    end
1275152
public synchronized int submitCommand(final String command) {
    final Integer id = scheduler.assignTaskId();
    scheduler.addTask(new TaskEntity(id, command));

    if (state == State.READY) {
      notify(); // Wake up at {waitForCommands}
    } else if (state == State.RUNNING && nMaxEval > nActiveEval + nRequestedEval) {
      requestEvaluator(1);
    }
    return id;
  }
1300733
private void initRemoteCommands()
   {
      if (rpcService != null)
      {
         // register commands
         suspend = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager-suspend-"
                  + dataContainer.getUniqueName();
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               suspendLocally();
               return null;
            }
         });

         resume = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager-resume-"
                  + dataContainer.getUniqueName();
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               resumeLocally();
               return null;
            }
         });

         requestForResponsibleForResuming = rpcService.registerCommand(new RemoteCommand()
         {

            public String getId()
            {
               return "org.exoplatform.services.jcr.impl.dataflow.persistent.CacheableWorkspaceDataManager"
                  + "-requestForResponsibilityForResuming-" + dataContainer.getUniqueName();
            }

            public Serializable execute(Serializable[] args) throws Throwable
            {
               return isResponsibleForResuming.get();
            }
         });
      }
   }
585209
public List<CommandCallback> buildCommandCallback(CommandContext ctx, ClassLoader cl) {
        List<CommandCallback> callbackList = new ArrayList<CommandCallback>();
        if (ctx != null && ctx.getData("callbacks") != null) {
            logger.debug("Callback: {}", ctx.getData("callbacks"));
            String[] callbacksArray = ((String) ctx.getData("callbacks")).split(",");
            List<String> callbacks = (List<String>) Arrays.asList(callbacksArray);
            for (String callbackName : callbacks) {
                CommandCallback handler = findCommandCallback(callbackName.trim(), cl);
                callbackList.add(handler);
            }
        }
        return callbackList;
    }
1243404
@Override
  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/2222")
  public List<ServerServiceDefinition> getServices() {
    return Collections.unmodifiableList(new ArrayList<>(services.values()));
  }
1050230
public Command findCommand(String name, ClassLoader cl) {
        synchronized (commandCache) {
            
            if (!commandCache.containsKey(name)) {
                
                try {
                    Command commandInstance = (Command) Class.forName(name, true, cl).newInstance();
                    commandCache.put(name, commandInstance);
                } catch (Exception ex) {
                    throw new IllegalArgumentException("Unknown Command implementation with name '" + name + "'");
                }
    
            } else {
                Command cmd = commandCache.get(name);
                if (!cmd.getClass().getClassLoader().equals(cl)) {
                    commandCache.remove(name);
                    try {
                        Command commandInstance = (Command) Class.forName(name, true, cl).newInstance();
                        commandCache.put(name, commandInstance);
                    } catch (Exception ex) {
                        throw new IllegalArgumentException("Unknown Command implementation with name '" + name + "'");
                    } 
                }
            }

       
        }
        return commandCache.get(name);
    }
601626
public List<ModelServiceInstance> getAllModelServiceInstance() {
        return getData() == null ? Collections.<ModelServiceInstance>emptyList() : getData().getServiceInstances();
    }
203343
public static String command(Command command) throws Exception {
        // Check Service
        if (!IS_BIND)
            bindService();

        // Return
        try {
            return commandRun(command);
        } catch (Exception e) {
            e.printStackTrace();
            restart();
            throw e;
        }
    }
754351
public String executeCommandOnServlet(String command) {
    try {
      return getCommandResponseAsString(command);
    } catch (IOException e) {
      if (e instanceof ConnectException) {
        throw new SeleniumException(e.getMessage(), e);
      }
      e.printStackTrace();
      throw new UnsupportedOperationException("Catch body broken: IOException from " + command +
          " -> " + e, e);
    }
  }
839625
public List<Model> executeList(CommandContext commandContext, Map<String, Object> parameterMap, int firstResult, int maxResults) {
    return commandContext.getModelEntityManager().findModelsByNativeQuery(parameterMap, firstResult, maxResults);
  }
751967
public void runCommands(final String[] commands) throws IOException {
		doLines(0, new LineReader() {
			private int commandC = 0;

			@Override
			public String getNextLine(String prompt) {
				if (commandC >= commands.length) {
					return null;
				} else {
					return commands[commandC++];
				}
			}
		}, true);
	}
59788
public void queryService(List<StringCommand> commands, final QueryServiceCallback cb, Object context){
        ProtocolHeader header = new ProtocolHeader();
        header.setType(ProtocolType.QueryService);

        List<QueryCommand> cs = new ArrayList<QueryCommand>();
        for(StringCommand c : commands){
            cs.add(c.getStringCommand());
        }

        QueryServiceProtocol p = new QueryServiceProtocol(cs);

        ProtocolCallback pcb = new ProtocolCallback(){

            @Override
            public void call(boolean result, Response response,
                    ErrorCode error, Object ctx) {
                List<ModelServiceInstance> rsp = null;
                if(response != null){
                    rsp = ((QueryServiceResponse) response).getInstances();
                }
                cb.call(result, rsp, error, ctx);
            }

        };

        connection.submitCallbackRequest(header, p, pcb, context);
    }