Search in sources :

Example 16 with Volume

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();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Volume(org.apache.accumulo.core.volume.Volume) IOException(java.io.IOException)

Example 17 with Volume

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);
}
Also used : Path(org.apache.hadoop.fs.Path) VolumeManager(org.apache.accumulo.server.fs.VolumeManager) FileStatus(org.apache.hadoop.fs.FileStatus) Volume(org.apache.accumulo.core.volume.Volume) FileSystem(org.apache.hadoop.fs.FileSystem) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) Test(org.junit.Test)

Aggregations

Volume (org.apache.accumulo.core.volume.Volume)17 NonConfiguredVolume (org.apache.accumulo.core.volume.NonConfiguredVolume)10 FileSystem (org.apache.hadoop.fs.FileSystem)7 Path (org.apache.hadoop.fs.Path)6 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)6 IOException (java.io.IOException)5 NotImplementedException (org.apache.commons.lang.NotImplementedException)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 URI (java.net.URI)1 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)1 FileSKVIterator (org.apache.accumulo.core.file.FileSKVIterator)1 VolumeChooserException (org.apache.accumulo.server.fs.VolumeChooser.VolumeChooserException)1 VolumeManager (org.apache.accumulo.server.fs.VolumeManager)1 CreateFlag (org.apache.hadoop.fs.CreateFlag)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 Test (org.junit.Test)1