use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class ChangeSecret method updateHdfs.
private static void updateHdfs(VolumeManager fs, Instance inst, String newInstanceId) throws IOException {
// Need to recreate the instanceId on all of them to keep consistency
for (Volume v : fs.getVolumes()) {
final Path instanceId = ServerConstants.getInstanceIdLocation(v);
if (!v.getFileSystem().delete(instanceId, true)) {
throw new IOException("Could not recursively delete " + instanceId);
}
if (!v.getFileSystem().mkdirs(instanceId)) {
throw new IOException("Could not create directory " + instanceId);
}
v.getFileSystem().create(new Path(instanceId, newInstanceId)).close();
}
}
use of org.apache.accumulo.core.volume.Volume in project accumulo by apache.
the class AccumuloTest method testUpdateAccumuloVersion.
@Test
public void testUpdateAccumuloVersion() throws Exception {
Volume v1 = createMock(Volume.class);
FileSystem fs1 = createMock(FileSystem.class);
Path baseVersion1 = new Path("hdfs://volume1/accumulo/version");
Path oldVersion1 = new Path("hdfs://volume1/accumulo/version/7");
Path newVersion1 = new Path("hdfs://volume1/accumulo/version/" + Integer.toString(ServerConstants.DATA_VERSION));
FileStatus[] files1 = mockPersistentVersion("7");
expect(fs1.listStatus(baseVersion1)).andReturn(files1);
replay(fs1);
FSDataOutputStream fsdos1 = createMock(FSDataOutputStream.class);
expect(v1.getFileSystem()).andReturn(fs1);
expect(v1.prefixChild(ServerConstants.VERSION_DIR)).andReturn(baseVersion1).times(2);
replay(v1);
fsdos1.close();
replay(fsdos1);
Volume v2 = createMock(Volume.class);
FileSystem fs2 = createMock(FileSystem.class);
Path baseVersion2 = new Path("hdfs://volume2/accumulo/version");
Path oldVersion2 = new Path("hdfs://volume2/accumulo/version/7");
Path newVersion2 = new Path("hdfs://volume2/accumulo/version/" + Integer.toString(ServerConstants.DATA_VERSION));
FileStatus[] files2 = mockPersistentVersion("7");
expect(fs2.listStatus(baseVersion2)).andReturn(files2);
replay(fs2);
FSDataOutputStream fsdos2 = createMock(FSDataOutputStream.class);
expect(v2.getFileSystem()).andReturn(fs2);
expect(v2.prefixChild(ServerConstants.VERSION_DIR)).andReturn(baseVersion2).times(2);
replay(v2);
fsdos2.close();
replay(fsdos2);
VolumeManager vm = createMock(VolumeManager.class);
expect(vm.getVolumes()).andReturn(Sets.newHashSet(v1, v2));
expect(vm.delete(oldVersion1)).andReturn(true);
expect(vm.create(newVersion1)).andReturn(fsdos1);
expect(vm.delete(oldVersion2)).andReturn(true);
expect(vm.create(newVersion2)).andReturn(fsdos2);
replay(vm);
Accumulo.updateAccumuloVersion(vm, 7);
}
Aggregations