Examples of CommandProcessor


Examples of org.apache.felix.service.command.CommandProcessor

        waitForCommandService(command);

        String response;
        final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        final PrintStream printStream = new PrintStream(byteArrayOutputStream);
        final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
        final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);

        final Callable<String> commandCallable = new Callable<String>() {
            @Override
            public String call() throws Exception {
                try {
View Full Code Here

Examples of org.apache.felix.service.command.CommandProcessor

        waitForCommandService(command);

        String response;
        final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        final PrintStream printStream = new PrintStream(byteArrayOutputStream);
        final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
        final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);

        final Callable<String> commandCallable = new Callable<String>() {
            @Override
            public String call() throws Exception {
                try {
View Full Code Here

Examples of org.apache.felix.service.command.CommandProcessor

            public String call() throws Exception {
                try {
                    if (!silent) {
                        System.err.println(command);
                    }
                    final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
                    final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);
                    commandSession.execute(command);
                } catch (Exception e) {
                    throw new RuntimeException(e.getMessage(), e);
                }
                printStream.flush();
View Full Code Here

Examples of org.apache.felix.service.command.CommandProcessor

   */
  protected String executeCommand(final String command, final Long timeout, final Boolean silent) {
    String response;
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    final PrintStream printStream = new PrintStream(byteArrayOutputStream);
    final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
    final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);
    FutureTask<String> commandFuture = new FutureTask<String>(
        new Callable<String>() {
          @Override
          public String call() {
            try {
View Full Code Here

Examples of org.apache.felix.service.command.CommandProcessor

   */
  protected String executeCommands(final String... commands) {
    String response;
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    final PrintStream printStream = new PrintStream(byteArrayOutputStream);
    final CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
    final CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);
    FutureTask<String> commandFuture = new FutureTask<String>(
        new Callable<String>() {
          public String call() {
            try {
              for (String command : commands) {
View Full Code Here

Examples of org.apache.felix.service.command.CommandProcessor

                    public int read(byte[] b, int off, int len) throws IOException {
                        return -1;
                    }
                };

                CommandProcessor cp = (CommandProcessor) shell;
                if(sessionOp == null) {
                    if("asadmin-osgi-shell".equals(cmdName)) {
                        out.println("gogo");
                    } else {
                        CommandSession session = cp.createSession(in, out, err);
                        session.execute(cmd);
                        session.close();
                    }
                } else if("new".equals(sessionOp)) {
                    CommandSession session = cp.createSession(null, null, null);
                    RemoteCommandSession remote = new RemoteCommandSession(session);

                    log.log(Level.FINE, "Remote session established: {0}",
                            remote.getId());
View Full Code Here

Examples of org.apache.hadoop.hive.ql.processors.CommandProcessor

      int ret = 0;
      String errorMessage = "";
      String SQLState = null;

      try {
        CommandProcessor proc = CommandProcessorFactory.get(tokens[0]);
        CommandProcessorResponse response = null;
        if (proc != null) {
          if (proc instanceof Driver) {
            ((Driver)proc).destroy();
            isHiveQuery = true;
            response = driver.run(cmd);
          } else {
            isHiveQuery = false;
            response = proc.run(cmd_1);
          }

          ret = response.getResponseCode();
          SQLState = response.getSQLState();
          errorMessage = response.getErrorMessage();
View Full Code Here

Examples of org.apache.hadoop.hive.ql.processors.CommandProcessor

          ss.out.println(StringUtils.join(s, "\n"));
        }
      }

    } else {
      CommandProcessor proc = CommandProcessorFactory.get(tokens[0], (HiveConf)conf);
      if (proc != null) {
        if (proc instanceof Driver) {
          Driver qp = (Driver) proc;
          PrintStream out = ss.out;
          long start = System.currentTimeMillis();

          ret = qp.run(cmd).getResponseCode();
          if (ret != 0) {
            qp.close();
            return ret;
          }

          ArrayList<String> res = new ArrayList<String>();
         
          if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_CLI_PRINT_HEADER)) {
            // Print the column names
            boolean first_col = true;
            Schema sc = qp.getSchema();
            for (FieldSchema fs : sc.getFieldSchemas()) {
              if (!first_col) {
                out.print('\t');
              }
              out.print(fs.getName());
              first_col = false;
            }
            out.println();
          }

          try {
            while (qp.getResults(res)) {
              for (String r : res) {
                out.println(r);
              }
              res.clear();
              if (out.checkError()) {
                break;
              }
            }
          } catch (IOException e) {
            console.printError("Failed with exception " + e.getClass().getName() + ":"
                + e.getMessage(), "\n" + org.apache.hadoop.util.StringUtils.stringifyException(e));
            ret = 1;
          }

          int cret = qp.close();
          if (ret == 0) {
            ret = cret;
          }

          long end = System.currentTimeMillis();
          if (end > start) {
            double timeTaken = (end - start) / 1000.0;
            console.printInfo("Time taken: " + timeTaken + " seconds", null);
          }

        } else {
          ret = proc.run(cmd_1).getResponseCode();
        }
      }
    }

    return ret;
View Full Code Here

Examples of org.apache.hadoop.hive.ql.processors.CommandProcessor

          err.println("[Thrift Error]: Hive server is not cleaned due to thrift exception: "
              + errMsg);
        }
      }
    } else { // local mode
      CommandProcessor proc = CommandProcessorFactory.get(tokens[0], (HiveConf) conf);
      ret = processLocalCmd(cmd, proc, ss);
    }

    return ret;
  }
View Full Code Here

Examples of org.apache.hadoop.hive.ql.processors.CommandProcessor

          err.println("[Thrift Error]: Hive server is not cleaned due to thrift exception: "
              + errMsg);
        }
      }
    } else { // local mode
      CommandProcessor proc = CommandProcessorFactory.get(tokens[0], (HiveConf)conf);
      int tryCount = 0;
      boolean needRetry;

      do {
        try {
          needRetry = false;
          if (proc != null) {
            if (proc instanceof Driver) {
              Driver qp = (Driver) proc;
              PrintStream out = ss.out;
              long start = System.currentTimeMillis();
              if (ss.getIsVerbose()) {
                out.println(cmd);
              }

              qp.setTryCount(tryCount);
              ret = qp.run(cmd).getResponseCode();
              if (ret != 0) {
                qp.close();
                return ret;
              }

              ArrayList<String> res = new ArrayList<String>();

              if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_CLI_PRINT_HEADER)) {
                // Print the column names
                boolean first_col = true;
                Schema sc = qp.getSchema();
                for (FieldSchema fs : sc.getFieldSchemas()) {
                  if (!first_col) {
                    out.print('\t');
                  }
                  out.print(fs.getName());
                  first_col = false;
                }
                out.println();
              }

              try {
                while (qp.getResults(res)) {
                  for (String r : res) {
                    out.println(r);
                  }
                  res.clear();
                  if (out.checkError()) {
                    break;
                  }
                }
              } catch (IOException e) {
                console.printError("Failed with exception " + e.getClass().getName() + ":"
                    + e.getMessage(), "\n"
                    + org.apache.hadoop.util.StringUtils.stringifyException(e));
                ret = 1;
              }

              int cret = qp.close();
              if (ret == 0) {
                ret = cret;
              }

              long end = System.currentTimeMillis();
              if (end > start) {
                double timeTaken = (end - start) / 1000.0;
                console.printInfo("Time taken: " + timeTaken + " seconds", null);
              }

            } else {
              if (ss.getIsVerbose()) {
                ss.out.println(tokens[0] + " " + cmd_1);
              }
              ret = proc.run(cmd_1).getResponseCode();
            }
          }
        } catch (CommandNeedRetryException e) {
          console.printInfo("Retry query with a different approach...");
          tryCount++;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.