Package org.apache.hadoop.hive.ql.session

Examples of org.apache.hadoop.hive.ql.session.SessionState


        ctx = new Context(conf);
        cleanContext = true;
      }

      // Need to remove this static hack. But this is the way currently to get a session.
      SessionState ss = SessionState.get();
      session = ss.getTezSession();
      session = TezSessionPoolManager.getInstance().getSession(session, conf, false);
      ss.setTezSession(session);

      // jobConf will hold all the configuration for hadoop, tez, and hive
      JobConf jobConf = utils.createConfiguration(conf);

      // Get all user jars from work (e.g. input format stuff).
      String[] inputOutputJars = work.configureJobConfAndExtractJars(jobConf);

      // we will localize all the files (jars, plans, hashtables) to the
      // scratch dir. let's create this and tmp first.
      Path scratchDir = ctx.getMRScratchDir();

      // create the tez tmp dir
      scratchDir = utils.createTezDir(scratchDir, conf);

      // If we have any jars from input format, we need to restart the session because
      // AM will need them; so, AM has to be restarted. What a mess...
      if (!session.hasResources(inputOutputJars) && session.isOpen()) {
        LOG.info("Tez session being reopened to pass custom jars to AM");
        session.close(false);
        session = TezSessionPoolManager.getInstance().getSession(null, conf, false);
        ss.setTezSession(session);
      }

      if (!session.isOpen()) {
        // can happen if the user sets the tez flag after the session was
        // established
View Full Code Here


   * and calls execute(), which is overridden in each task
   * @return return value of execute()
   */
  public int executeTask() {
    try {
      SessionState ss = SessionState.get();
      this.setStarted();
      if (ss != null) {
        ss.getHiveHistory().logPlanProgress(queryPlan);
      }
      int retval = execute();
      this.setDone();
      if (ss != null) {
        ss.getHiveHistory().logPlanProgress(queryPlan);
      }
      return retval;
    } catch (IOException e) {
      throw new RuntimeException(e.getMessage());
    }
View Full Code Here

 
  public int run(String command) {
    String[] tokens = command.split("\\s+");

    try {
      SessionState ss = SessionState.get();
      PrintStream oldOut = System.out;

      if(ss != null && ss.out != null) {
        System.setOut(ss.out);
      }
View Full Code Here

      return false;
    throw new IllegalArgumentException(prefix + "'" + value + "' is not a boolean");
  }

  private void dumpOptions(Properties p) {
    SessionState ss = SessionState.get();

    ss.out.println("silent=" + (ss.getIsSilent() ? "on" : "off"));
    for(Object one: p.keySet()) {
      String oneProp = (String)one;
      String oneValue = p.getProperty(oneProp);
      ss.out.println(oneProp+"="+oneValue);
    }
View Full Code Here

      ss.out.println(oneProp+"="+oneValue);
    }
  }

  private void dumpOption(Properties p, String s) {
    SessionState ss = SessionState.get();
   
    if(p.getProperty(s) != null) {
      ss.out.println(s+"="+p.getProperty(s));
    } else {
      ss.out.println(s+" is undefined");
View Full Code Here

  public void init() {
  }
 
  public int run(String command) {
    SessionState ss = SessionState.get();

    String nwcmd = command.trim();
    if(nwcmd.equals("")) {
      dumpOptions(ss.getConf().getChangedProperties());
      return 0;
    }

    if(nwcmd.equals("-v")) {
      dumpOptions(ss.getConf().getAllProperties());
      return 0;
    }

    String[] part = new String [2];

    int eqIndex = nwcmd.indexOf('=');
    if(eqIndex == -1) {
      // no equality sign - print the property out
      dumpOption(ss.getConf().getAllProperties(), nwcmd);
      return (0);
    } else if (eqIndex == nwcmd.length()-1) {
      part[0] = nwcmd.substring(0, nwcmd.length()-1);
      part[1] = "";
    } else {
      part[0] = nwcmd.substring(0, eqIndex).trim();
      part[1] = nwcmd.substring(eqIndex+1).trim();
    }

    try {
      if (part[0].equals("silent")) {
        boolean val = getBoolean(part[1]);
        ss.setIsSilent(val);
      } else {
        ss.getConf().set(part[0], part[1]);
      }
    } catch (IllegalArgumentException err) {
      ss.err.println(err.getMessage());
      return 1;
    }
View Full Code Here

  public void init() {
  }
 
  public int run(String command) {
    SessionState ss = SessionState.get();
    String[] tokens = command.split("\\s+");
    SessionState.ResourceType t;
    if (tokens.length < 2 || (t = SessionState.find_resource_type(tokens[0])) == null) {
      console.printError("Usage: add [" +
                         StringUtils.join(SessionState.ResourceType.values(),"|") +
                         "] <value> [<value>]*");
      return 1;
    }
    for (int i = 1; i < tokens.length; i++) {
      ss.add_resource(t, tokens[i]);
    }
    return 0;
  }
View Full Code Here

  public void init() {
  }
 
  public int run(String command) {
    SessionState ss = SessionState.get();
    String[] tokens = command.split("\\s+");

    SessionState.ResourceType t;
    if(tokens.length < 1 || (t = SessionState.find_resource_type(tokens[0])) == null) {
      console.printError("Usage: delete [" +
                         StringUtils.join(SessionState.ResourceType.values(),"|") +
                         "] <value> [<value>]*");
      return 1;
    }

    if (tokens.length >= 2) {
      for(int i = 1; i < tokens.length; i++) {
        ss.delete_resource(t, tokens[i]);
      }
    } else {
      ss.delete_resource(t);
    }
   
    return 0;
  }
View Full Code Here

  /**
   * Called at the start of job Driver.run()
   */
  public void startQuery(String cmd, String id) {
    SessionState ss = SessionState.get();
    if (ss == null)
      return;
    QueryInfo ji = new QueryInfo();

    ji.hm.put(Keys.QUERY_ID.name(), id);
View Full Code Here

   *
   * @param task
   */
  public void startTask(String queryId, Task<? extends Serializable> task,
      String taskName) {
    SessionState ss = SessionState.get();
    if (ss == null)
      return;
    TaskInfo ti = new TaskInfo();

    ti.hm.put(Keys.QUERY_ID.name(), ss.getQueryId());
    ti.hm.put(Keys.TASK_ID.name(), task.getId());
    ti.hm.put(Keys.TASK_NAME.name(), taskName);

    String id = queryId + ":" + task.getId();
    taskInfoMap.put(id, ti);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hive.ql.session.SessionState

Copyright © 2018 www.massapicom. 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.