|
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.Cell;
|
|
|
import org.apache.hadoop.hbase.CellUtil;
|
|
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
|
|
import org.apache.hadoop.hbase.KeyValue;
|
|
|
+import org.apache.hadoop.hbase.TableName;
|
|
|
import org.apache.hadoop.hbase.Tag;
|
|
|
import org.apache.hadoop.hbase.client.Connection;
|
|
|
import org.apache.hadoop.hbase.client.ConnectionFactory;
|
|
@@ -44,9 +45,7 @@ import org.apache.hadoop.hbase.client.Result;
|
|
|
import org.apache.hadoop.hbase.client.ResultScanner;
|
|
|
import org.apache.hadoop.hbase.client.Scan;
|
|
|
import org.apache.hadoop.hbase.client.Table;
|
|
|
-import org.apache.hadoop.hbase.regionserver.Region;
|
|
|
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
|
|
-import org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest;
|
|
|
import org.apache.hadoop.hbase.util.Bytes;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntities;
|
|
@@ -327,20 +326,15 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
}
|
|
|
|
|
|
// check in flow run table
|
|
|
- HRegionServer server = util.getRSForFirstRegionInTable(
|
|
|
- BaseTableRW.getTableName(c1, FlowRunTableRW.TABLE_NAME_CONF_NAME,
|
|
|
- FlowRunTableRW.DEFAULT_TABLE_NAME));
|
|
|
- List<Region> regions = server.getOnlineRegions(
|
|
|
- BaseTableRW.getTableName(c1,
|
|
|
- FlowRunTableRW.TABLE_NAME_CONF_NAME,
|
|
|
- FlowRunTableRW.DEFAULT_TABLE_NAME));
|
|
|
- assertTrue("Didn't find any regions for primary table!",
|
|
|
- regions.size() > 0);
|
|
|
+ TableName flowRunTable = BaseTableRW.getTableName(c1,
|
|
|
+ FlowRunTableRW.TABLE_NAME_CONF_NAME, FlowRunTableRW.DEFAULT_TABLE_NAME);
|
|
|
+ HRegionServer server = util.getRSForFirstRegionInTable(flowRunTable);
|
|
|
+
|
|
|
// flush and compact all the regions of the primary table
|
|
|
- for (Region region : regions) {
|
|
|
- region.flush(true);
|
|
|
- region.compact(true);
|
|
|
- }
|
|
|
+ int regionNum = HBaseTimelineServerUtils.flushCompactTableRegions(
|
|
|
+ server, flowRunTable);
|
|
|
+ assertTrue("Didn't find any regions for primary table!",
|
|
|
+ regionNum > 0);
|
|
|
|
|
|
// check flow run for one flow many apps
|
|
|
checkFlowRunTable(cluster, user, flow, runid, c1, 4);
|
|
@@ -392,13 +386,10 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
private FlowScanner getFlowScannerForTestingCompaction() {
|
|
|
// create a FlowScanner object with the sole purpose of invoking a process
|
|
|
// summation;
|
|
|
- CompactionRequest request = new CompactionRequest();
|
|
|
- request.setIsMajor(true, true);
|
|
|
// okay to pass in nulls for the constructor arguments
|
|
|
// because all we want to do is invoke the process summation
|
|
|
FlowScanner fs = new FlowScanner(null, null,
|
|
|
- (request.isMajor() ? FlowScannerOperation.MAJOR_COMPACTION
|
|
|
- : FlowScannerOperation.MINOR_COMPACTION));
|
|
|
+ FlowScannerOperation.MAJOR_COMPACTION);
|
|
|
assertNotNull(fs);
|
|
|
return fs;
|
|
|
}
|
|
@@ -423,40 +414,45 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
SortedSet<Cell> currentColumnCells = new TreeSet<Cell>(KeyValue.COMPARATOR);
|
|
|
|
|
|
List<Tag> tags = new ArrayList<>();
|
|
|
- Tag t = new Tag(AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
+ Tag t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
"application_1234588888_91188");
|
|
|
tags.add(t);
|
|
|
- byte[] tagByteArray = Tag.fromList(tags);
|
|
|
+ byte[] tagByteArray =
|
|
|
+ HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
// create a cell with a VERY old timestamp and attribute SUM_FINAL
|
|
|
Cell c1 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily,
|
|
|
aQualifier, cell1Ts, Bytes.toBytes(cellValue1), tagByteArray);
|
|
|
currentColumnCells.add(c1);
|
|
|
|
|
|
tags = new ArrayList<>();
|
|
|
- t = new Tag(AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
+ t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
"application_12700000001_29102");
|
|
|
tags.add(t);
|
|
|
- tagByteArray = Tag.fromList(tags);
|
|
|
+ tagByteArray = HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
// create a cell with a recent timestamp and attribute SUM_FINAL
|
|
|
Cell c2 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily,
|
|
|
aQualifier, cell2Ts, Bytes.toBytes(cellValue2), tagByteArray);
|
|
|
currentColumnCells.add(c2);
|
|
|
|
|
|
tags = new ArrayList<>();
|
|
|
- t = new Tag(AggregationOperation.SUM.getTagType(),
|
|
|
+ t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM.getTagType(),
|
|
|
"application_191780000000001_8195");
|
|
|
tags.add(t);
|
|
|
- tagByteArray = Tag.fromList(tags);
|
|
|
+ tagByteArray = HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
// create a cell with a VERY old timestamp but has attribute SUM
|
|
|
Cell c3 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily,
|
|
|
aQualifier, cell3Ts, Bytes.toBytes(cellValue3), tagByteArray);
|
|
|
currentColumnCells.add(c3);
|
|
|
|
|
|
tags = new ArrayList<>();
|
|
|
- t = new Tag(AggregationOperation.SUM.getTagType(),
|
|
|
+ t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM.getTagType(),
|
|
|
"application_191780000000001_98104");
|
|
|
tags.add(t);
|
|
|
- tagByteArray = Tag.fromList(tags);
|
|
|
+ tagByteArray = HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
// create a cell with a VERY old timestamp but has attribute SUM
|
|
|
Cell c4 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily,
|
|
|
aQualifier, cell4Ts, Bytes.toBytes(cellValue4), tagByteArray);
|
|
@@ -523,10 +519,12 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
// insert SUM_FINAL cells
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
tags = new ArrayList<>();
|
|
|
- t = new Tag(AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
+ t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
"application_123450000" + i + "01_19" + i);
|
|
|
tags.add(t);
|
|
|
- byte[] tagByteArray = Tag.fromList(tags);
|
|
|
+ byte[] tagByteArray =
|
|
|
+ HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
// create a cell with a VERY old timestamp and attribute SUM_FINAL
|
|
|
c1 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily, aQualifier,
|
|
|
cellTsFinal, Bytes.toBytes(cellValueFinal), tagByteArray);
|
|
@@ -537,10 +535,12 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
// add SUM cells
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
tags = new ArrayList<>();
|
|
|
- t = new Tag(AggregationOperation.SUM.getTagType(),
|
|
|
+ t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM.getTagType(),
|
|
|
"application_1987650000" + i + "83_911" + i);
|
|
|
tags.add(t);
|
|
|
- byte[] tagByteArray = Tag.fromList(tags);
|
|
|
+ byte[] tagByteArray =
|
|
|
+ HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
// create a cell with attribute SUM
|
|
|
c1 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily, aQualifier,
|
|
|
cellTsNotFinal, Bytes.toBytes(cellValueNotFinal), tagByteArray);
|
|
@@ -614,10 +614,12 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
// insert SUM_FINAL cells which will expire
|
|
|
for (int i = 0; i < countFinal; i++) {
|
|
|
tags = new ArrayList<>();
|
|
|
- t = new Tag(AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
+ t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
"application_123450000" + i + "01_19" + i);
|
|
|
tags.add(t);
|
|
|
- byte[] tagByteArray = Tag.fromList(tags);
|
|
|
+ byte[] tagByteArray =
|
|
|
+ HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
// create a cell with a VERY old timestamp and attribute SUM_FINAL
|
|
|
c1 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily, aQualifier,
|
|
|
cellTsFinal, Bytes.toBytes(cellValueFinal), tagByteArray);
|
|
@@ -628,10 +630,12 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
// insert SUM_FINAL cells which will NOT expire
|
|
|
for (int i = 0; i < countFinalNotExpire; i++) {
|
|
|
tags = new ArrayList<>();
|
|
|
- t = new Tag(AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
+ t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
"application_123450000" + i + "01_19" + i);
|
|
|
tags.add(t);
|
|
|
- byte[] tagByteArray = Tag.fromList(tags);
|
|
|
+ byte[] tagByteArray =
|
|
|
+ HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
// create a cell with a VERY old timestamp and attribute SUM_FINAL
|
|
|
c1 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily, aQualifier,
|
|
|
cellTsFinalNotExpire, Bytes.toBytes(cellValueFinal), tagByteArray);
|
|
@@ -642,10 +646,12 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
// add SUM cells
|
|
|
for (int i = 0; i < countNotFinal; i++) {
|
|
|
tags = new ArrayList<>();
|
|
|
- t = new Tag(AggregationOperation.SUM.getTagType(),
|
|
|
+ t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM.getTagType(),
|
|
|
"application_1987650000" + i + "83_911" + i);
|
|
|
tags.add(t);
|
|
|
- byte[] tagByteArray = Tag.fromList(tags);
|
|
|
+ byte[] tagByteArray =
|
|
|
+ HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
// create a cell with attribute SUM
|
|
|
c1 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily, aQualifier,
|
|
|
cellTsNotFinal, Bytes.toBytes(cellValueNotFinal), tagByteArray);
|
|
@@ -697,10 +703,12 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
long cellValue2 = 28L;
|
|
|
|
|
|
List<Tag> tags = new ArrayList<>();
|
|
|
- Tag t = new Tag(AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
+ Tag t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
"application_1234588888_999888");
|
|
|
tags.add(t);
|
|
|
- byte[] tagByteArray = Tag.fromList(tags);
|
|
|
+ byte[] tagByteArray =
|
|
|
+ HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
SortedSet<Cell> currentColumnCells = new TreeSet<Cell>(KeyValue.COMPARATOR);
|
|
|
|
|
|
// create a cell with a VERY old timestamp and attribute SUM_FINAL
|
|
@@ -709,10 +717,11 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
currentColumnCells.add(c1);
|
|
|
|
|
|
tags = new ArrayList<>();
|
|
|
- t = new Tag(AggregationOperation.SUM.getTagType(),
|
|
|
+ t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM.getTagType(),
|
|
|
"application_100000000001_119101");
|
|
|
tags.add(t);
|
|
|
- tagByteArray = Tag.fromList(tags);
|
|
|
+ tagByteArray = HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
|
|
|
// create a cell with a VERY old timestamp but has attribute SUM
|
|
|
Cell c2 = HBaseTimelineServerUtils.createNewCell(aRowKey, aFamily,
|
|
@@ -755,10 +764,12 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
// note down the current timestamp
|
|
|
long currentTimestamp = System.currentTimeMillis();
|
|
|
List<Tag> tags = new ArrayList<>();
|
|
|
- Tag t = new Tag(AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
+ Tag t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM_FINAL.getTagType(),
|
|
|
"application_123458888888_999888");
|
|
|
tags.add(t);
|
|
|
- byte[] tagByteArray = Tag.fromList(tags);
|
|
|
+ byte[] tagByteArray =
|
|
|
+ HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
SortedSet<Cell> currentColumnCells = new TreeSet<Cell>(KeyValue.COMPARATOR);
|
|
|
|
|
|
// create a cell with a VERY old timestamp
|
|
@@ -793,10 +804,12 @@ public class TestHBaseStorageFlowRunCompaction {
|
|
|
|
|
|
// try for 1 cell with tag SUM
|
|
|
List<Tag> tags = new ArrayList<>();
|
|
|
- Tag t = new Tag(AggregationOperation.SUM.getTagType(),
|
|
|
+ Tag t = HBaseTimelineServerUtils.createTag(
|
|
|
+ AggregationOperation.SUM.getTagType(),
|
|
|
"application_123458888888_999888");
|
|
|
tags.add(t);
|
|
|
- byte[] tagByteArray = Tag.fromList(tags);
|
|
|
+ byte[] tagByteArray =
|
|
|
+ HBaseTimelineServerUtils.convertTagListToByteArray(tags);
|
|
|
|
|
|
SortedSet<Cell> currentColumnCells = new TreeSet<Cell>(KeyValue.COMPARATOR);
|
|
|
|