use of org.apache.accumulo.server.fs.VolumeManager in project accumulo by apache.
the class GarbageCollectWriteAheadLogsTest method testRemoveUnusedLog.
@Test
public void testRemoveUnusedLog() throws Exception {
AccumuloServerContext context = EasyMock.createMock(AccumuloServerContext.class);
VolumeManager fs = EasyMock.createMock(VolumeManager.class);
WalStateManager marker = EasyMock.createMock(WalStateManager.class);
LiveTServerSet tserverSet = EasyMock.createMock(LiveTServerSet.class);
GCStatus status = new GCStatus(null, null, null, new GcCycleStats());
EasyMock.expect(tserverSet.getCurrentServers()).andReturn(Collections.singleton(server1));
EasyMock.expect(marker.getAllMarkers()).andReturn(markers).once();
EasyMock.expect(marker.state(server1, id)).andReturn(new Pair<>(WalState.UNREFERENCED, path));
EasyMock.expect(fs.deleteRecursively(path)).andReturn(true).once();
marker.removeWalMarker(server1, id);
EasyMock.expectLastCall().once();
EasyMock.replay(context, fs, marker, tserverSet);
GarbageCollectWriteAheadLogs gc = new GarbageCollectWriteAheadLogs(context, fs, false, tserverSet, marker, tabletOnServer1List) {
@Override
protected int removeReplicationEntries(Map<UUID, TServerInstance> candidates) throws IOException, KeeperException, InterruptedException {
return 0;
}
};
gc.collect(status);
EasyMock.verify(context, fs, marker, tserverSet);
}
use of org.apache.accumulo.server.fs.VolumeManager in project accumulo by apache.
the class FileUtilTest method testCleanupIndexOpWithoutCommonParentVolumeWithDepth.
@Test
public void testCleanupIndexOpWithoutCommonParentVolumeWithDepth() throws IOException {
// Make some directories to simulate multiple volumes
File v1 = new File(accumuloDir, "v1"), v2 = new File(accumuloDir, "v2");
assertTrue(v1.mkdirs() || v1.isDirectory());
assertTrue(v2.mkdirs() || v2.isDirectory());
// And a "unique" tmp directory for each volume
// Make sure we can handle nested directories (a single tmpdir with potentially multiple unique dirs)
File tmp1 = new File(new File(v1, "tmp"), "tmp_1"), tmp2 = new File(new File(v2, "tmp"), "tmp_1");
assertTrue(tmp1.mkdirs() || tmp1.isDirectory());
assertTrue(tmp2.mkdirs() || tmp2.isDirectory());
Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
HashMap<Property, String> testProps = new HashMap<>();
testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
FileUtil.cleanupIndexOp(tmpPath1, fs, new ArrayList<>());
Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
FileUtil.cleanupIndexOp(tmpPath2, fs, new ArrayList<>());
Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
}
use of org.apache.accumulo.server.fs.VolumeManager in project accumulo by apache.
the class FileUtilTest method testCleanupIndexOpWithCommonParentVolumeWithDepth.
@Test
public void testCleanupIndexOpWithCommonParentVolumeWithDepth() throws IOException {
File volumeDir = new File(accumuloDir, "volumes");
assertTrue(volumeDir.mkdirs() || volumeDir.isDirectory());
// Make some directories to simulate multiple volumes
File v1 = new File(volumeDir, "v1"), v2 = new File(volumeDir, "v2");
assertTrue(v1.mkdirs() || v1.isDirectory());
assertTrue(v2.mkdirs() || v2.isDirectory());
// And a "unique" tmp directory for each volume
// Make sure we can handle nested directories (a single tmpdir with potentially multiple unique dirs)
File tmp1 = new File(new File(v1, "tmp"), "tmp_1"), tmp2 = new File(new File(v2, "tmp"), "tmp_1");
assertTrue(tmp1.mkdirs() || tmp1.isDirectory());
assertTrue(tmp2.mkdirs() || tmp2.isDirectory());
Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
HashMap<Property, String> testProps = new HashMap<>();
testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
FileUtil.cleanupIndexOp(tmpPath1, fs, new ArrayList<>());
Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
FileUtil.cleanupIndexOp(tmpPath2, fs, new ArrayList<>());
Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
}
use of org.apache.accumulo.server.fs.VolumeManager in project accumulo by apache.
the class FileUtilTest method testCleanupIndexOpWithoutCommonParentVolume.
@Test
public void testCleanupIndexOpWithoutCommonParentVolume() throws IOException {
// Make some directories to simulate multiple volumes
File v1 = new File(accumuloDir, "v1"), v2 = new File(accumuloDir, "v2");
assertTrue(v1.mkdirs() || v1.isDirectory());
assertTrue(v2.mkdirs() || v2.isDirectory());
// And a "unique" tmp directory for each volume
File tmp1 = new File(v1, "tmp"), tmp2 = new File(v2, "tmp");
assertTrue(tmp1.mkdirs() || tmp1.isDirectory());
assertTrue(tmp2.mkdirs() || tmp2.isDirectory());
Path tmpPath1 = new Path(tmp1.toURI()), tmpPath2 = new Path(tmp2.toURI());
HashMap<Property, String> testProps = new HashMap<>();
testProps.put(Property.INSTANCE_VOLUMES, v1.toURI().toString() + "," + v2.toURI().toString());
VolumeManager fs = VolumeManagerImpl.getLocal(accumuloDir.getAbsolutePath());
FileUtil.cleanupIndexOp(tmpPath1, fs, new ArrayList<>());
Assert.assertFalse("Expected " + tmp1 + " to be cleaned up but it wasn't", tmp1.exists());
FileUtil.cleanupIndexOp(tmpPath2, fs, new ArrayList<>());
Assert.assertFalse("Expected " + tmp2 + " to be cleaned up but it wasn't", tmp2.exists());
}
use of org.apache.accumulo.server.fs.VolumeManager in project accumulo by apache.
the class BulkImporterTest method testFindOverlappingTablets.
@Test
public void testFindOverlappingTablets() throws Exception {
MockTabletLocator locator = new MockTabletLocator();
FileSystem fs = FileSystem.getLocal(CachedConfiguration.getInstance());
ClientContext context = EasyMock.createMock(ClientContext.class);
EasyMock.expect(context.getConfiguration()).andReturn(DefaultConfiguration.getInstance()).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()).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();
VolumeManager vm = VolumeManagerImpl.get(context.getConfiguration());
List<TabletLocation> overlaps = BulkImporter.findOverlappingTablets(context, vm, locator, new Path(file));
Assert.assertEquals(5, overlaps.size());
Collections.sort(overlaps);
Assert.assertEquals(new KeyExtent(tableId, new Text("a"), null), overlaps.get(0).tablet_extent);
Assert.assertEquals(new KeyExtent(tableId, new Text("d"), new Text("cm")), overlaps.get(1).tablet_extent);
Assert.assertEquals(new KeyExtent(tableId, new Text("dm"), new Text("d")), overlaps.get(2).tablet_extent);
Assert.assertEquals(new KeyExtent(tableId, new Text("j"), new Text("i")), overlaps.get(3).tablet_extent);
Assert.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")));
Assert.assertEquals(3, overlaps2.size());
Assert.assertEquals(new KeyExtent(tableId, new Text("d"), new Text("cm")), overlaps2.get(0).tablet_extent);
Assert.assertEquals(new KeyExtent(tableId, new Text("dm"), new Text("d")), overlaps2.get(1).tablet_extent);
Assert.assertEquals(new KeyExtent(tableId, new Text("j"), new Text("i")), overlaps2.get(2).tablet_extent);
Assert.assertEquals(locator.invalidated, 1);
}
Aggregations