use of org.apache.accumulo.server.fs.VolumeChooserEnvironment in project accumulo by apache.
the class ImportTableTest method testTabletDir.
@Test
public void testTabletDir() {
Master master = EasyMock.createMock(Master.class);
VolumeManager volumeManager = EasyMock.createMock(VolumeManager.class);
ImportedTableInfo iti = new ImportedTableInfo();
iti.tableId = Table.ID.of("5");
// Different volumes with different paths
String[] tableDirs = new String[] { "hdfs://nn1:8020/apps/accumulo1/tables", "hdfs://nn2:8020/applications/accumulo/tables" };
// This needs to be unique WRT the importtable command
String tabletDir = "/c-00000001";
EasyMock.expect(master.getFileSystem()).andReturn(volumeManager);
// Choose the 2nd element
VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(iti.tableId);
EasyMock.expect(volumeManager.choose(EasyMock.eq(chooserEnv), EasyMock.eq(tableDirs))).andReturn(tableDirs[1]);
EasyMock.replay(master, volumeManager);
PopulateMetadataTable pmt = new PopulateMetadataTable(iti);
Assert.assertEquals(tableDirs[1] + "/" + iti.tableId + "/" + tabletDir, pmt.getClonedTabletDir(master, tableDirs, tabletDir));
EasyMock.verify(master, volumeManager);
}
use of org.apache.accumulo.server.fs.VolumeChooserEnvironment in project accumulo by apache.
the class PopulateMetadataTable method getClonedTabletDir.
/**
* Given options for tables (across multiple volumes), construct an absolute path using the unique name within the chosen volume
*
* @return An absolute, unique path for the imported table
*/
protected String getClonedTabletDir(Master master, String[] tableDirs, String tabletDir) {
// We can try to spread out the tablet dirs across all volumes
VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(tableInfo.tableId);
String tableDir = master.getFileSystem().choose(chooserEnv, tableDirs);
// Build up a full hdfs://localhost:8020/accumulo/tables/$id/c-XXXXXXX
return tableDir + "/" + tableInfo.tableId + "/" + tabletDir;
}
Aggregations