Examples of IStreamHandler


Examples of com.dianping.cosmos.hive.server.queryengine.cmdline.streamhandler.IStreamHandler

   
    hiveCmd = hiveCmd.toLowerCase().trim();
    if(hiveCmd.startsWith("select"))
      returnResult = true;

    IStreamHandler statusHandler = StreamHandlerFactory.createStatusHandler(statusLocation);
    IStreamHandler resultHandler = null;

    if(returnResult){
      if(storeResultToFile){
        resultHandler = StreamHandlerFactory.createFileResultHandler(resultLocation);
      }
      else{
        resultHandler = StreamHandlerFactory.createMemResultHandler()
        hiveCmd = joinString(hiveCmd, " limit ", ""+limit);
      }
      resultHandler.setLimit(limit);
    }
   
    if(!storeResultToFile && !hiveCmd.contains(" limit ")){
      hiveCmd = joinString(hiveCmd, " limit ", ""+limit);
    }
    if(!hiveCmd.endsWith(";")){
      hiveCmd += ";";
    }
    String cmd = joinString("sudo -u ", username," sh -c \"source /etc/profile;" ,HIVE_CMD, " -e \\\"", hiveCmd, "\\\"");
    //add hiveconf
    for(String hiveConf: s_hiveConfigSet){
      cmd = joinString(cmd, " -hiveconf ", hiveConf, " \"");
    }
    //execute cmd
    int exitCode = -1;
    try {
      exitCode = ShellCmdExecutor.getInstance().execute(cmd, key, resultHandler, statusHandler);
    } catch (ShellCmdExecException e) {
      s_logger.error("Exceptions occurs in executing hive command!", e);
      return null;
    }
    if(exitCode != 0){
      s_logger.error("Hive Command is NOT executed successfully! The exit code of hive command is " + exitCode);
      return null;
    }

    return resultHandler.getResult();
  }
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.