Package org.apache.hive.service.cli

Examples of org.apache.hive.service.cli.OperationStatus


  }

  @Override
  protected QueryStatus fetchStatus(OperationHandle operationHandle)
    throws HiveSQLException, ExploreException, HandleNotFoundException {
    OperationStatus operationStatus = getCliService().getOperationStatus(operationHandle);
    return new QueryStatus(QueryStatus.OpStatus.valueOf(operationStatus.getState().toString()),
                           operationHandle.hasResultSet());
  }
View Full Code Here


  }

  @Override
  protected QueryStatus fetchStatus(OperationHandle handle)
    throws HiveSQLException, ExploreException, HandleNotFoundException {
    OperationStatus operationStatus = getCliService().getOperationStatus(handle);
    return new QueryStatus(QueryStatus.OpStatus.valueOf(operationStatus.getState().toString()),
                           handle.hasResultSet());
  }
View Full Code Here

    queryString = "SELECT ID FROM TEST_EXEC_THRIFT";
    OperationHandle opHandle = client.executeStatement(sessHandle,
        queryString, opConf);
    assertNotNull(opHandle);

    OperationStatus opStatus = client.getOperationStatus(opHandle);
    assertNotNull(opStatus);

    OperationState state = opStatus.getState();
    // Expect query to be completed now
    assertEquals("Query should be finished", OperationState.FINISHED, state);

    // Cleanup
    queryString = "DROP TABLE TEST_EXEC_THRIFT";
View Full Code Here

        PASSWORD, opConf);
    // Session handle should not be null
    assertNotNull("Session handle should not be null", sessHandle);

    OperationHandle opHandle;
    OperationStatus opStatus;
    OperationState state = null;

    // Change lock manager to embedded mode
    String queryString = "SET hive.lock.manager=" +
        "org.apache.hadoop.hive.ql.lockmgr.EmbeddedLockManager";
    client.executeStatement(sessHandle, queryString, opConf);

    // Drop the table if it exists
    queryString = "DROP TABLE IF EXISTS TEST_EXEC_ASYNC_THRIFT";
    client.executeStatement(sessHandle, queryString, opConf);

    // Create a test table
    queryString = "CREATE TABLE TEST_EXEC_ASYNC_THRIFT(ID STRING)";
    client.executeStatement(sessHandle, queryString, opConf);

    // Execute another query
    queryString = "SELECT ID FROM TEST_EXEC_ASYNC_THRIFT";
    System.out.println("Will attempt to execute: " + queryString);
    opHandle = client.executeStatementAsync(sessHandle,
        queryString, opConf);
    assertNotNull(opHandle);

    // Poll on the operation status till the query is completed
    boolean isQueryRunning = true;
    long pollTimeout = System.currentTimeMillis() + 100000;

    while(isQueryRunning) {
      // Break if polling times out
      if (System.currentTimeMillis() > pollTimeout) {
        System.out.println("Polling timed out");
        break;
      }
      opStatus = client.getOperationStatus(opHandle);
      assertNotNull(opStatus);
      state = opStatus.getState();
      System.out.println("Current state: " + state);

      if (state == OperationState.CANCELED ||
          state == OperationState.CLOSED ||
          state == OperationState.FINISHED ||
          state == OperationState.ERROR) {
        isQueryRunning = false;
      }
      Thread.sleep(1000);
    }

    // Expect query to be successfully completed now
    assertEquals("Query should be finished",  OperationState.FINISHED, state);

    // Execute a malformed query
    // This query will give a runtime error
    queryString = "CREATE TABLE NON_EXISTING_TAB (ID STRING) location 'hdfs://localhost:10000/a/b/c'";
    System.out.println("Will attempt to execute: " + queryString);
    opHandle = client.executeStatementAsync(sessHandle, queryString, opConf);
    assertNotNull(opHandle);
    opStatus = client.getOperationStatus(opHandle);
    assertNotNull(opStatus);
    isQueryRunning = true;
    while(isQueryRunning) {
      // Break if polling times out
      if (System.currentTimeMillis() > pollTimeout) {
        System.out.println("Polling timed out");
        break;
      }
      state = opStatus.getState();
      System.out.println("Current state: " + state);
      if (state == OperationState.CANCELED ||
          state == OperationState.CLOSED ||
          state == OperationState.FINISHED ||
          state == OperationState.ERROR) {
        isQueryRunning = false;
      }
      Thread.sleep(1000);
      opStatus = client.getOperationStatus(opHandle);
    }
    // Expect query to return an error state
    assertEquals("Operation should be in error state",
        OperationState.ERROR, state);
    // sqlState, errorCode should be set to appropriate values
    assertEquals(opStatus.getOperationException().getSQLState(), "08S01");
    assertEquals(opStatus.getOperationException().getErrorCode(), 1);

    // Cleanup
    queryString = "DROP TABLE TEST_EXEC_ASYNC_THRIFT";
    client.executeStatement(sessHandle, queryString, opConf);
View Full Code Here

    queryString = "SELECT ID+1 FROM TEST_EXEC_THRIFT";
    OperationHandle opHandle = client.executeStatement(sessHandle,
        queryString, opConf);
    assertNotNull(opHandle);

    OperationStatus opStatus = client.getOperationStatus(opHandle);
    assertNotNull(opStatus);

    OperationState state = opStatus.getState();
    // Expect query to be completed now
    assertEquals("Query should be finished", OperationState.FINISHED, state);

    // Cleanup
    queryString = "DROP TABLE TEST_EXEC_THRIFT";
View Full Code Here

        PASSWORD, opConf);
    // Session handle should not be null
    assertNotNull("Session handle should not be null", sessHandle);

    OperationHandle opHandle;
    OperationStatus opStatus;
    OperationState state = null;

    // Change lock manager to embedded mode
    String queryString = "SET hive.lock.manager=" +
        "org.apache.hadoop.hive.ql.lockmgr.EmbeddedLockManager";
    client.executeStatement(sessHandle, queryString, opConf);

    // Drop the table if it exists
    queryString = "DROP TABLE IF EXISTS TEST_EXEC_ASYNC_THRIFT";
    client.executeStatement(sessHandle, queryString, opConf);

    // Create a test table
    queryString = "CREATE TABLE TEST_EXEC_ASYNC_THRIFT(ID STRING)";
    client.executeStatement(sessHandle, queryString, opConf);

    // Execute another query
    queryString = "SELECT ID+1 FROM TEST_EXEC_ASYNC_THRIFT";
    System.out.println("Will attempt to execute: " + queryString);
    opHandle = client.executeStatementAsync(sessHandle,
        queryString, opConf);
    assertNotNull(opHandle);

    // Poll on the operation status till the query is completed
    boolean isQueryRunning = true;
    long pollTimeout = System.currentTimeMillis() + 100000;

    while(isQueryRunning) {
      // Break if polling times out
      if (System.currentTimeMillis() > pollTimeout) {
        System.out.println("Polling timed out");
        break;
      }
      opStatus = client.getOperationStatus(opHandle);
      assertNotNull(opStatus);
      state = opStatus.getState();
      System.out.println("Current state: " + state);

      if (state == OperationState.CANCELED ||
          state == OperationState.CLOSED ||
          state == OperationState.FINISHED ||
          state == OperationState.ERROR) {
        isQueryRunning = false;
      }
      Thread.sleep(1000);
    }

    // Expect query to be successfully completed now
    assertEquals("Query should be finished",  OperationState.FINISHED, state);

    // Execute a malformed query
    // This query will give a runtime error
    queryString = "CREATE TABLE NON_EXISTING_TAB (ID STRING) location 'hdfs://localhost:10000/a/b/c'";
    System.out.println("Will attempt to execute: " + queryString);
    opHandle = client.executeStatementAsync(sessHandle, queryString, opConf);
    assertNotNull(opHandle);
    opStatus = client.getOperationStatus(opHandle);
    assertNotNull(opStatus);
    isQueryRunning = true;
    pollTimeout = System.currentTimeMillis() + 100000;
    while(isQueryRunning) {
      // Break if polling times out
      if (System.currentTimeMillis() > pollTimeout) {
        System.out.println("Polling timed out");
        break;
      }
      state = opStatus.getState();
      System.out.println("Current state: " + state);
      if (state == OperationState.CANCELED ||
          state == OperationState.CLOSED ||
          state == OperationState.FINISHED ||
          state == OperationState.ERROR) {
        isQueryRunning = false;
      }
      Thread.sleep(1000);
      opStatus = client.getOperationStatus(opHandle);
    }
    // Expect query to return an error state
    assertEquals("Operation should be in error state",
        OperationState.ERROR, state);
    // sqlState, errorCode should be set to appropriate values
    assertEquals(opStatus.getOperationException().getSQLState(), "08S01");
    assertEquals(opStatus.getOperationException().getErrorCode(), 1);

    // Cleanup
    queryString = "DROP TABLE TEST_EXEC_ASYNC_THRIFT";
    client.executeStatement(sessHandle, queryString, opConf);
View Full Code Here

    OperationHandle operationHandle = client.executeStatementAsync(sessionHandle, sql, null);

    // Poll on the operation status till the query is completed
    boolean isQueryRunning = true;
    long pollTimeout = System.currentTimeMillis() + 100000;
    OperationStatus opStatus;
    OperationState state = null;
    RowSet rowSetAccumulated = null;
    StringBuilder logs = new StringBuilder();

    while (isQueryRunning) {
      // Break if polling times out
      if (System.currentTimeMillis() > pollTimeout) {
        break;
      }
      opStatus = client.getOperationStatus(operationHandle);
      Assert.assertNotNull(opStatus);
      state = opStatus.getState();

      rowSetAccumulated = client.fetchResults(operationHandle, FetchOrientation.FETCH_NEXT, 1000,
          FetchType.LOG);
      for (Object[] row : rowSetAccumulated) {
        logs.append(row[0]);
View Full Code Here

  public OperationType getType() {
    return opHandle.getOperationType();
  }

  public OperationStatus getStatus() {
    return new OperationStatus(state, operationException);
  }
View Full Code Here

      OperationState opState = OperationState.getOperationState(resp.getOperationState());
      HiveSQLException opException = null;
      if (opState == OperationState.ERROR) {
        opException = new HiveSQLException(resp.getErrorMessage(), resp.getSqlState(), resp.getErrorCode());
      }
      return new OperationStatus(opState, opException);
    } catch (HiveSQLException e) {
      throw e;
    } catch (Exception e) {
      throw new HiveSQLException(e);
    }
View Full Code Here

  public OperationType getType() {
    return opHandle.getOperationType();
  }

  public OperationStatus getStatus() {
    return new OperationStatus(state, operationException);
  }
View Full Code Here

TOP

Related Classes of org.apache.hive.service.cli.OperationStatus

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.