Search in sources :

Example 6 with LongConverter

use of org.apache.hadoop.yarn.server.timelineservice.storage.common.LongConverter in project hadoop by apache.

the class TestHBaseStorageFlowRunCompaction method testProcessSummationOneCell.

@Test
public void testProcessSummationOneCell() throws IOException {
    FlowScanner fs = getFlowScannerForTestingCompaction();
    // note down the current timestamp
    long currentTimestamp = System.currentTimeMillis();
    // try for 1 cell with tag SUM
    List<Tag> tags = new ArrayList<>();
    Tag t = new Tag(AggregationOperation.SUM.getTagType(), "application_123458888888_999888");
    tags.add(t);
    byte[] tagByteArray = Tag.fromList(tags);
    SortedSet<Cell> currentColumnCells = new TreeSet<Cell>(KeyValue.COMPARATOR);
    Cell c1 = HBaseTimelineStorageUtils.createNewCell(aRowKey, aFamily, aQualifier, currentTimestamp, Bytes.toBytes(1110L), tagByteArray);
    currentColumnCells.add(c1);
    List<Cell> cells = fs.processSummationMajorCompaction(currentColumnCells, new LongConverter(), currentTimestamp);
    assertNotNull(cells);
    // we expect the same cell back
    assertEquals(1, cells.size());
    Cell c2 = cells.get(0);
    assertEquals(c1, c2);
    assertEquals(currentTimestamp, c2.getTimestamp());
}
Also used : LongConverter(org.apache.hadoop.yarn.server.timelineservice.storage.common.LongConverter) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Tag(org.apache.hadoop.hbase.Tag) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Example 7 with LongConverter

use of org.apache.hadoop.yarn.server.timelineservice.storage.common.LongConverter in project hadoop by apache.

the class TestHBaseStorageFlowRunCompaction method checkProcessSummationMoreCellsSumFinalMany.

// tests with many cells
// of type SUM and SUM_FINAL
// all cells of SUM_FINAL will expire
@Test
public void checkProcessSummationMoreCellsSumFinalMany() throws IOException {
    FlowScanner fs = getFlowScannerForTestingCompaction();
    int count = 200000;
    long cellValueFinal = 1000L;
    long cellValueNotFinal = 28L;
    // note down the current timestamp
    long currentTimestamp = System.currentTimeMillis();
    long cellTsFinalStart = 10001120L;
    long cellTsFinal = cellTsFinalStart;
    long cellTsNotFinalStart = currentTimestamp - 5;
    long cellTsNotFinal = cellTsNotFinalStart;
    SortedSet<Cell> currentColumnCells = new TreeSet<Cell>(KeyValue.COMPARATOR);
    List<Tag> tags = null;
    Tag t = null;
    Cell c1 = null;
    // insert SUM_FINAL cells
    for (int i = 0; i < count; i++) {
        tags = new ArrayList<>();
        t = new Tag(AggregationOperation.SUM_FINAL.getTagType(), "application_123450000" + i + "01_19" + i);
        tags.add(t);
        byte[] tagByteArray = Tag.fromList(tags);
        // create a cell with a VERY old timestamp and attribute SUM_FINAL
        c1 = HBaseTimelineStorageUtils.createNewCell(aRowKey, aFamily, aQualifier, cellTsFinal, Bytes.toBytes(cellValueFinal), tagByteArray);
        currentColumnCells.add(c1);
        cellTsFinal++;
    }
    // add SUM cells
    for (int i = 0; i < count; i++) {
        tags = new ArrayList<>();
        t = new Tag(AggregationOperation.SUM.getTagType(), "application_1987650000" + i + "83_911" + i);
        tags.add(t);
        byte[] tagByteArray = Tag.fromList(tags);
        // create a cell with attribute SUM
        c1 = HBaseTimelineStorageUtils.createNewCell(aRowKey, aFamily, aQualifier, cellTsNotFinal, Bytes.toBytes(cellValueNotFinal), tagByteArray);
        currentColumnCells.add(c1);
        cellTsNotFinal++;
    }
    List<Cell> cells = fs.processSummationMajorCompaction(currentColumnCells, new LongConverter(), currentTimestamp);
    assertNotNull(cells);
    // we should be getting back count + 1 cells
    // one is the flow sum cell
    // others are the cells with SUM attribute
    assertEquals(count + 1, cells.size());
    for (int i = 0; i < cells.size(); i++) {
        Cell returnedCell = cells.get(0);
        assertNotNull(returnedCell);
        long returnTs = returnedCell.getTimestamp();
        long returnValue = Bytes.toLong(CellUtil.cloneValue(returnedCell));
        if (returnValue == (count * cellValueFinal)) {
            assertTrue(returnTs > (cellTsFinalStart + count));
            assertTrue(returnTs >= currentTimestamp);
        } else if ((returnValue >= cellValueNotFinal) && (returnValue <= cellValueNotFinal * count)) {
            assertTrue(returnTs >= cellTsNotFinalStart);
            assertTrue(returnTs <= cellTsNotFinalStart * count);
        } else {
            // raise a failure since we expect only these values back
            Assert.fail();
        }
    }
}
Also used : LongConverter(org.apache.hadoop.yarn.server.timelineservice.storage.common.LongConverter) TreeSet(java.util.TreeSet) Tag(org.apache.hadoop.hbase.Tag) Cell(org.apache.hadoop.hbase.Cell) Test(org.junit.Test)

Aggregations

Cell (org.apache.hadoop.hbase.Cell)7 LongConverter (org.apache.hadoop.yarn.server.timelineservice.storage.common.LongConverter)7 Test (org.junit.Test)7 TreeSet (java.util.TreeSet)6 Tag (org.apache.hadoop.hbase.Tag)6 ArrayList (java.util.ArrayList)4