public Response processQuery(Query query) throws IOException {
   // TODO process query
   ProcessQuery queryProcessor = new ProcessQuery();
   Object obj = queryProcessor.processQuery(requestCredentials, query);
   if (obj instanceof Response) {
     return (Response) obj;
   }
   System.err.println("improper format for request");
   return null;
 }
 public long findPid(ProcessQuery query) throws IOException {
   logger.debug("trying to find process by query [ {} ]", query);
   String regex = Pattern.quote(query.getCommand()) + ".*" + Pattern.quote(query.getArgument());
   Pattern commandPattern = Pattern.compile(regex);
   for (String line : execute(psCommand())) {
     Matcher lineMatcher = PS_OUTPUT_LINE.matcher(line);
     if (lineMatcher.matches()) {
       String command = lineMatcher.group(2);
       Matcher commandMatcher = commandPattern.matcher(command);
       if (commandMatcher.find()) {
         final long pid = Long.parseLong(lineMatcher.group(1));
         logger.debug("found process for query [ {} ] with pid [ {} ]", query, pid);
         return pid;
       }
     }
   }
   logger.warn("no process found for query [ {} ]", query);
   return PID_NOT_FOUND;
 }