use of org.apache.hadoop.mapred.Reporter in project hbase by apache.
the class TestGroupingTableMap method shouldCreateNewKeyAlthoughExtraKey.
@Test
@SuppressWarnings({ "deprecation", "unchecked" })
public void shouldCreateNewKeyAlthoughExtraKey() throws Exception {
GroupingTableMap gTableMap = null;
try {
Result result = mock(Result.class);
Reporter reporter = mock(Reporter.class);
gTableMap = new GroupingTableMap();
Configuration cfg = new Configuration();
cfg.set(GroupingTableMap.GROUP_COLUMNS, "familyA:qualifierA familyB:qualifierB");
JobConf jobConf = new JobConf(cfg);
gTableMap.configure(jobConf);
byte[] row = {};
List<Cell> keyValues = ImmutableList.<Cell>of(new KeyValue(row, "familyA".getBytes(), "qualifierA".getBytes(), Bytes.toBytes("1111")), new KeyValue(row, "familyB".getBytes(), "qualifierB".getBytes(), Bytes.toBytes("2222")), new KeyValue(row, "familyC".getBytes(), "qualifierC".getBytes(), Bytes.toBytes("3333")));
when(result.listCells()).thenReturn(keyValues);
OutputCollector<ImmutableBytesWritable, Result> outputCollectorMock = mock(OutputCollector.class);
gTableMap.map(null, result, outputCollectorMock, reporter);
verify(result).listCells();
verify(outputCollectorMock, times(1)).collect(any(ImmutableBytesWritable.class), any(Result.class));
verifyNoMoreInteractions(outputCollectorMock);
} finally {
if (gTableMap != null)
gTableMap.close();
}
}
use of org.apache.hadoop.mapred.Reporter in project hbase by apache.
the class TestIdentityTableMap method shouldCollectPredefinedTimes.
@Test
@SuppressWarnings({ "deprecation", "unchecked" })
public void shouldCollectPredefinedTimes() throws IOException {
int recordNumber = 999;
Result resultMock = mock(Result.class);
IdentityTableMap identityTableMap = null;
try {
Reporter reporterMock = mock(Reporter.class);
identityTableMap = new IdentityTableMap();
ImmutableBytesWritable bytesWritableMock = mock(ImmutableBytesWritable.class);
OutputCollector<ImmutableBytesWritable, Result> outputCollectorMock = mock(OutputCollector.class);
for (int i = 0; i < recordNumber; i++) identityTableMap.map(bytesWritableMock, resultMock, outputCollectorMock, reporterMock);
verify(outputCollectorMock, times(recordNumber)).collect(Mockito.any(ImmutableBytesWritable.class), Mockito.any(Result.class));
} finally {
if (identityTableMap != null)
identityTableMap.close();
}
}
use of org.apache.hadoop.mapred.Reporter in project hbase by apache.
the class TestRowCounter method shouldRegInReportEveryIncomingRow.
@Test
@SuppressWarnings({ "deprecation", "unchecked" })
public void shouldRegInReportEveryIncomingRow() throws IOException {
int iterationNumber = 999;
RowCounter.RowCounterMapper mapper = new RowCounter.RowCounterMapper();
Reporter reporter = mock(Reporter.class);
for (int i = 0; i < iterationNumber; i++) mapper.map(mock(ImmutableBytesWritable.class), mock(Result.class), mock(OutputCollector.class), reporter);
Mockito.verify(reporter, times(iterationNumber)).incrCounter(any(Enum.class), anyInt());
}
use of org.apache.hadoop.mapred.Reporter in project hbase by apache.
the class TestTableSnapshotInputFormat method verifyWithMockedMapReduce.
private void verifyWithMockedMapReduce(JobConf job, int numRegions, int expectedNumSplits, byte[] startRow, byte[] stopRow) throws IOException, InterruptedException {
TableSnapshotInputFormat tsif = new TableSnapshotInputFormat();
InputSplit[] splits = tsif.getSplits(job, 0);
Assert.assertEquals(expectedNumSplits, splits.length);
HBaseTestingUtility.SeenRowTracker rowTracker = new HBaseTestingUtility.SeenRowTracker(startRow, stopRow);
for (int i = 0; i < splits.length; i++) {
// validate input split
InputSplit split = splits[i];
Assert.assertTrue(split instanceof TableSnapshotInputFormat.TableSnapshotRegionSplit);
// validate record reader
OutputCollector collector = mock(OutputCollector.class);
Reporter reporter = mock(Reporter.class);
RecordReader<ImmutableBytesWritable, Result> rr = tsif.getRecordReader(split, job, reporter);
// validate we can read all the data back
ImmutableBytesWritable key = rr.createKey();
Result value = rr.createValue();
while (rr.next(key, value)) {
verifyRowFromMap(key, value);
rowTracker.addRow(key.copyBytes());
}
rr.close();
}
// validate all rows are seen
rowTracker.validate();
}
use of org.apache.hadoop.mapred.Reporter in project hive by apache.
the class StaticPartitionFileRecordWriterContainer method close.
@Override
public void close(TaskAttemptContext context) throws IOException, InterruptedException {
Reporter reporter = InternalUtil.createReporter(context);
getBaseRecordWriter().close(reporter);
}
Aggregations