Search in sources :

Example 66 with ShowCompactResponseElement

use of org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement in project hive by apache.

the class TestCompactionTxnHandler method testRevokeTimedOutWorkers.

@Test
public void testRevokeTimedOutWorkers() throws Exception {
    CompactionRequest rqst = new CompactionRequest("foo", "bar", CompactionType.MINOR);
    txnHandler.compact(rqst);
    rqst = new CompactionRequest("foo", "baz", CompactionType.MINOR);
    txnHandler.compact(rqst);
    assertNotNull(txnHandler.findNextToCompact(aFindNextCompactRequest("fred-193892", WORKER_VERSION)));
    Thread.sleep(200);
    assertNotNull(txnHandler.findNextToCompact(aFindNextCompactRequest("fred-193892", WORKER_VERSION)));
    txnHandler.revokeTimedoutWorkers(100);
    ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest());
    List<ShowCompactResponseElement> compacts = rsp.getCompacts();
    assertEquals(2, compacts.size());
    boolean sawWorking = false, sawInitiated = false;
    for (ShowCompactResponseElement c : compacts) {
        if (c.getState().equals("working"))
            sawWorking = true;
        else if (c.getState().equals("initiated"))
            sawInitiated = true;
        else
            fail("Unexpected state");
    }
    assertTrue(sawWorking);
    assertTrue(sawInitiated);
}
Also used : ShowCompactResponse(org.apache.hadoop.hive.metastore.api.ShowCompactResponse) ShowCompactRequest(org.apache.hadoop.hive.metastore.api.ShowCompactRequest) CompactionRequest(org.apache.hadoop.hive.metastore.api.CompactionRequest) ShowCompactResponseElement(org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement) Test(org.junit.Test)

Example 67 with ShowCompactResponseElement

use of org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement in project hive by apache.

the class TestCompactionTxnHandler method testRevokeFromLocalWorkers.

@Test
public void testRevokeFromLocalWorkers() throws Exception {
    CompactionRequest rqst = new CompactionRequest("foo", "bar", CompactionType.MINOR);
    txnHandler.compact(rqst);
    rqst = new CompactionRequest("foo", "baz", CompactionType.MINOR);
    txnHandler.compact(rqst);
    rqst = new CompactionRequest("foo", "bazzoo", CompactionType.MINOR);
    txnHandler.compact(rqst);
    assertNotNull(txnHandler.findNextToCompact(aFindNextCompactRequest("fred-193892", WORKER_VERSION)));
    assertNotNull(txnHandler.findNextToCompact(aFindNextCompactRequest("bob-193892", WORKER_VERSION)));
    assertNotNull(txnHandler.findNextToCompact(aFindNextCompactRequest("fred-193893", WORKER_VERSION)));
    txnHandler.revokeFromLocalWorkers("fred");
    ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest());
    List<ShowCompactResponseElement> compacts = rsp.getCompacts();
    assertEquals(3, compacts.size());
    boolean sawWorkingBob = false;
    int initiatedCount = 0;
    for (ShowCompactResponseElement c : compacts) {
        if (c.getState().equals("working")) {
            assertEquals("bob-193892", c.getWorkerid());
            sawWorkingBob = true;
        } else if (c.getState().equals("initiated")) {
            initiatedCount++;
        } else {
            fail("Unexpected state");
        }
    }
    assertTrue(sawWorkingBob);
    assertEquals(2, initiatedCount);
}
Also used : ShowCompactResponse(org.apache.hadoop.hive.metastore.api.ShowCompactResponse) ShowCompactRequest(org.apache.hadoop.hive.metastore.api.ShowCompactRequest) CompactionRequest(org.apache.hadoop.hive.metastore.api.CompactionRequest) ShowCompactResponseElement(org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement) Test(org.junit.Test)

Example 68 with ShowCompactResponseElement

use of org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement in project hive by apache.

the class TestCompactionTxnHandler method testEnqueueTimeEvenAfterFailed.

@Test
public void testEnqueueTimeEvenAfterFailed() throws Exception {
    final String dbName = "foo";
    final String tableName = "bar";
    final String partitionName = "ds=today";
    CompactionRequest rqst = new CompactionRequest(dbName, tableName, CompactionType.MINOR);
    rqst.setPartitionname(partitionName);
    long before = System.currentTimeMillis();
    txnHandler.compact(rqst);
    long after = System.currentTimeMillis();
    ShowCompactResponse showCompactResponse = txnHandler.showCompact(new ShowCompactRequest());
    ShowCompactResponseElement element = showCompactResponse.getCompacts().get(0);
    assertTrue(element.isSetEnqueueTime());
    long enqueueTime = element.getEnqueueTime();
    assertTrue(enqueueTime <= after);
    assertTrue(enqueueTime >= before);
    CompactionInfo ci = txnHandler.findNextToCompact(aFindNextCompactRequest("fred", WORKER_VERSION));
    txnHandler.markFailed(ci);
    checkEnqueueTime(enqueueTime);
}
Also used : ShowCompactResponse(org.apache.hadoop.hive.metastore.api.ShowCompactResponse) ShowCompactRequest(org.apache.hadoop.hive.metastore.api.ShowCompactRequest) CompactionRequest(org.apache.hadoop.hive.metastore.api.CompactionRequest) ShowCompactResponseElement(org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement) Test(org.junit.Test)

Example 69 with ShowCompactResponseElement

use of org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement in project hive by apache.

the class TestTxnHandler method testCompactMinorNoPartition.

@Test
public void testCompactMinorNoPartition() throws Exception {
    CompactionRequest rqst = new CompactionRequest("foo", "bar", CompactionType.MINOR);
    rqst.setRunas("fred");
    txnHandler.compact(rqst);
    ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest());
    List<ShowCompactResponseElement> compacts = rsp.getCompacts();
    assertEquals(1, compacts.size());
    ShowCompactResponseElement c = compacts.get(0);
    assertEquals("foo", c.getDbname());
    assertEquals("bar", c.getTablename());
    assertNull(c.getPartitionname());
    assertEquals(CompactionType.MINOR, c.getType());
    assertEquals("initiated", c.getState());
    assertEquals(0L, c.getStart());
    assertEquals("fred", c.getRunAs());
}
Also used : ShowCompactResponse(org.apache.hadoop.hive.metastore.api.ShowCompactResponse) ShowCompactRequest(org.apache.hadoop.hive.metastore.api.ShowCompactRequest) CompactionRequest(org.apache.hadoop.hive.metastore.api.CompactionRequest) ShowCompactResponseElement(org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement) Test(org.junit.Test)

Example 70 with ShowCompactResponseElement

use of org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement in project hive by apache.

the class TestTxnCommands2 method countCompacts.

private static CompactionsByState countCompacts(TxnStore txnHandler) throws MetaException {
    ShowCompactResponse resp = txnHandler.showCompact(new ShowCompactRequest());
    CompactionsByState compactionsByState = new CompactionsByState();
    compactionsByState.total = resp.getCompactsSize();
    for (ShowCompactResponseElement compact : resp.getCompacts()) {
        if (TxnStore.FAILED_RESPONSE.equals(compact.getState())) {
            compactionsByState.failed++;
        } else if (TxnStore.CLEANING_RESPONSE.equals(compact.getState())) {
            compactionsByState.readyToClean++;
        } else if (TxnStore.INITIATED_RESPONSE.equals(compact.getState())) {
            compactionsByState.initiated++;
        } else if (TxnStore.SUCCEEDED_RESPONSE.equals(compact.getState())) {
            compactionsByState.succeeded++;
        } else if (TxnStore.WORKING_RESPONSE.equals(compact.getState())) {
            compactionsByState.working++;
        } else if (TxnStore.DID_NOT_INITIATE_RESPONSE.equals(compact.getState())) {
            compactionsByState.didNotInitiate++;
        } else {
            throw new IllegalStateException("Unexpected state: " + compact.getState());
        }
    }
    return compactionsByState;
}
Also used : ShowCompactResponse(org.apache.hadoop.hive.metastore.api.ShowCompactResponse) ShowCompactRequest(org.apache.hadoop.hive.metastore.api.ShowCompactRequest) ShowCompactResponseElement(org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement)

Aggregations

ShowCompactResponseElement (org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement)100 ShowCompactResponse (org.apache.hadoop.hive.metastore.api.ShowCompactResponse)87 Test (org.junit.Test)81 ShowCompactRequest (org.apache.hadoop.hive.metastore.api.ShowCompactRequest)79 Table (org.apache.hadoop.hive.metastore.api.Table)58 CompactionRequest (org.apache.hadoop.hive.metastore.api.CompactionRequest)46 ArrayList (java.util.ArrayList)42 Partition (org.apache.hadoop.hive.metastore.api.Partition)27 LockComponent (org.apache.hadoop.hive.metastore.api.LockComponent)26 LockRequest (org.apache.hadoop.hive.metastore.api.LockRequest)26 FileSystem (org.apache.hadoop.fs.FileSystem)25 LockResponse (org.apache.hadoop.hive.metastore.api.LockResponse)25 Path (org.apache.hadoop.fs.Path)24 FileStatus (org.apache.hadoop.fs.FileStatus)20 CommitTxnRequest (org.apache.hadoop.hive.metastore.api.CommitTxnRequest)17 TxnStore (org.apache.hadoop.hive.metastore.txn.TxnStore)16 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)11 CompactionInfo (org.apache.hadoop.hive.metastore.txn.CompactionInfo)11 IOException (java.io.IOException)9 List (java.util.List)9