@Test public void testFindOverlappingTablets() throws Exception { MockTabletLocator locator = new MockTabletLocator(); FileSystem fs = FileSystem.getLocal(new Configuration()); ServerContext context = EasyMock.createMock(ServerContext.class); ConfigurationCopy conf = new ConfigurationCopy(DefaultConfiguration.getInstance()); conf.set(Property.INSTANCE_VOLUMES, "file: EasyMock.expect(context.getConfiguration()).andReturn(conf).anyTimes(); EasyMock.expect(context.getCryptoService()).andReturn(CryptoServiceFactory.newDefaultInstance()) .anyTimes(); EasyMock.replay(context); String file = "target/testFile.rf"; fs.delete(new Path(file), true); FileSKVWriter writer = FileOperations.getInstance().newWriterBuilder() .forFile(file, fs, fs.getConf(), CryptoServiceFactory.newDefaultInstance()) .withTableConfiguration(context.getConfiguration()).build(); writer.startDefaultLocalityGroup(); Value empty = new Value(new byte[] {}); writer.append(new Key("a", "cf", "cq"), empty); writer.append(new Key("a", "cf", "cq1"), empty); writer.append(new Key("a", "cf", "cq2"), empty); writer.append(new Key("a", "cf", "cq3"), empty); writer.append(new Key("a", "cf", "cq4"), empty); writer.append(new Key("a", "cf", "cq5"), empty); writer.append(new Key("d", "cf", "cq"), empty); writer.append(new Key("d", "cf", "cq1"), empty); writer.append(new Key("d", "cf", "cq2"), empty); writer.append(new Key("d", "cf", "cq3"), empty); writer.append(new Key("d", "cf", "cq4"), empty); writer.append(new Key("d", "cf", "cq5"), empty); writer.append(new Key("dd", "cf", "cq1"), empty); writer.append(new Key("ichabod", "cf", "cq"), empty); writer.append(new Key("icky", "cf", "cq1"), empty); writer.append(new Key("iffy", "cf", "cq2"), empty); writer.append(new Key("internal", "cf", "cq3"), empty); writer.append(new Key("is", "cf", "cq4"), empty); writer.append(new Key("iterator", "cf", "cq5"), empty); writer.append(new Key("xyzzy", "cf", "cq"), empty); writer.close(); try (var vm = VolumeManagerImpl.get(context.getConfiguration(), new Configuration())) { List<TabletLocation> overlaps = BulkImporter.findOverlappingTablets(context, vm, locator, new Path(file)); assertEquals(5, overlaps.size()); Collections.sort(overlaps); assertEquals(new KeyExtent(tableId, new Text("a"), null), overlaps.get(0).tablet_extent); assertEquals(new KeyExtent(tableId, new Text("d"), new Text("cm")), overlaps.get(1).tablet_extent); assertEquals(new KeyExtent(tableId, new Text("dm"), new Text("d")), overlaps.get(2).tablet_extent); assertEquals(new KeyExtent(tableId, new Text("j"), new Text("i")), overlaps.get(3).tablet_extent); assertEquals(new KeyExtent(tableId, null, new Text("l")), overlaps.get(4).tablet_extent); List<TabletLocation> overlaps2 = BulkImporter.findOverlappingTablets(context, vm, locator, new Path(file), new KeyExtent(tableId, new Text("h"), new Text("b"))); assertEquals(3, overlaps2.size()); assertEquals(new KeyExtent(tableId, new Text("d"), new Text("cm")), overlaps2.get(0).tablet_extent); assertEquals(new KeyExtent(tableId, new Text("dm"), new Text("d")), overlaps2.get(1).tablet_extent); assertEquals(new KeyExtent(tableId, new Text("j"), new Text("i")), overlaps2.get(2).tablet_extent); assertEquals(locator.invalidated, 1); } }
public static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs, TabletLocator locator, Path file) throws Exception { return findOverlappingTablets(context, fs, locator, file, null, null); }
BulkImporter { public static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs, TabletLocator locator, Path file) throws Exception { return findOverlappingTablets(context, fs, locator, file, null, null); } }
BulkImporter { public static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs, TabletLocator locator, Path file) throws Exception { return findOverlappingTablets(context, fs, locator, file, null, null); } BulkImporter(ServerContext context, long tid, String tableId, boolean setTime); }
BulkImporter { public static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs, TabletLocator locator, Path file) throws Exception { return findOverlappingTablets(context, fs, locator, file, null, null); } BulkImporter(ServerContext context, long tid, String tableId, boolean setTime); static List<String> bulkLoad(ServerContext context, long tid, String tableId,
      List<String> files, boolean setTime); AssignmentStats importFiles(List<String> files); static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs,
      TabletLocator locator, Path file); static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs,
      TabletLocator locator, Path file, KeyExtent failed); static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager vm,
      TabletLocator locator, Path file, Text startRow, Text endRow); }
BulkImporter { public static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs, TabletLocator locator, Path file) throws Exception { return findOverlappingTablets(context, fs, locator, file, null, null); } BulkImporter(ServerContext context, long tid, String tableId, boolean setTime); static List<String> bulkLoad(ServerContext context, long tid, String tableId,
      List<String> files, boolean setTime); AssignmentStats importFiles(List<String> files); static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs,
      TabletLocator locator, Path file); static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager fs,
      TabletLocator locator, Path file, KeyExtent failed); static List<TabletLocation> findOverlappingTablets(ServerContext context, VolumeManager vm,
      TabletLocator locator, Path file, Text startRow, Text endRow);  }