Search in sources :

Example 1 with IODeviceHandle

use of org.apache.hyracks.api.io.IODeviceHandle in project asterixdb by apache.

the class LangExecutionUtil method checkNcStore.

// For each NC, check whether data files are uniformly distributed among io devices.
private static void checkNcStore(NodeControllerService nc) throws Exception {
    List<IODeviceHandle> ioDevices = nc.getIoManager().getIODevices();
    int expectedPartitionNum = -1;
    for (IODeviceHandle ioDevice : ioDevices) {
        File[] dataDirs = ioDevice.getMount().listFiles();
        for (File dataDir : dataDirs) {
            String dirName = dataDir.getName();
            if (!dirName.equals(ClusterProperties.DEFAULT_STORAGE_DIR_NAME)) {
                // Skips non-storage directories.
                continue;
            }
            int numPartitions = getNumResidentPartitions(dataDir.listFiles());
            if (expectedPartitionNum < 0) {
                // Sets the expected number of partitions to the number of partitions on the first io device.
                expectedPartitionNum = numPartitions;
            } else {
                // Checks whether the number of partitions of the current io device is expected.
                if (expectedPartitionNum != numPartitions) {
                    throw new Exception("Non-uniform data distribution on io devices: " + dataDir.getAbsolutePath() + " number of partitions: " + numPartitions + " expected number of partitions: " + expectedPartitionNum);
                }
            }
        }
    }
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) File(java.io.File) IOException(java.io.IOException)

Example 2 with IODeviceHandle

use of org.apache.hyracks.api.io.IODeviceHandle in project asterixdb by apache.

the class AsterixVirtualBufferCacheProvider method getDeviceId.

public static int getDeviceId(IIOManager ioManager, FileReference fileRef) {
    IODeviceHandle device = fileRef.getDeviceHandle();
    List<IODeviceHandle> devices = ioManager.getIODevices();
    int deviceId = 0;
    for (int i = 0; i < devices.size(); i++) {
        IODeviceHandle next = devices.get(i);
        if (next == device) {
            deviceId = i;
        }
    }
    return deviceId;
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle)

Example 3 with IODeviceHandle

use of org.apache.hyracks.api.io.IODeviceHandle in project asterixdb by apache.

the class IOManager method resolveAbsolutePath.

@Override
public FileReference resolveAbsolutePath(String path) throws HyracksDataException {
    IODeviceHandle devHandle = getDevice(path);
    if (devHandle == null) {
        throw HyracksDataException.create(ErrorCode.FILE_WITH_ABSOULTE_PATH_NOT_WITHIN_ANY_IO_DEVICE, path);
    }
    String relativePath = devHandle.getRelativePath(path);
    return new FileReference(devHandle, relativePath);
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) FileReference(org.apache.hyracks.api.io.FileReference)

Example 4 with IODeviceHandle

use of org.apache.hyracks.api.io.IODeviceHandle in project asterixdb by apache.

the class IOManagerPathTest method testPrefixNames.

@Test
public void testPrefixNames() throws HyracksDataException {
    IODeviceHandle shorter = new IODeviceHandle(new File("/tmp/tst/1"), "storage");
    IODeviceHandle longer = new IODeviceHandle(new File("/tmp/tst/11"), "storage");
    IOManager ioManager = new IOManager(Arrays.asList(new IODeviceHandle[] { shorter, longer }), new DefaultDeviceResolver());
    FileReference f = ioManager.resolveAbsolutePath("/tmp/tst/11/storage/Foo_idx_foo/my_btree");
    Assert.assertEquals("/tmp/tst/11/storage/Foo_idx_foo/my_btree", f.getAbsolutePath());
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) DefaultDeviceResolver(org.apache.hyracks.control.nc.io.DefaultDeviceResolver) IOManager(org.apache.hyracks.control.nc.io.IOManager) FileReference(org.apache.hyracks.api.io.FileReference) File(java.io.File) Test(org.junit.Test)

Example 5 with IODeviceHandle

use of org.apache.hyracks.api.io.IODeviceHandle in project asterixdb by apache.

the class LSMBTreeTestHarness method tearDown.

public void tearDown() throws HyracksDataException {
    diskBufferCache.close();
    IODeviceHandle dev = ioManager.getIODevices().get(ioDeviceId);
    File dir = new File(dev.getMount(), onDiskDir);
    FilenameFilter filter = new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            return !name.startsWith(".");
        }
    };
    String[] files = dir.list(filter);
    if (files != null) {
        for (String fileName : files) {
            File file = new File(dir.getPath() + File.separator + fileName);
            file.delete();
        }
    }
    dir.delete();
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Aggregations

IODeviceHandle (org.apache.hyracks.api.io.IODeviceHandle)14 File (java.io.File)11 DefaultDeviceResolver (org.apache.hyracks.control.nc.io.DefaultDeviceResolver)5 IOManager (org.apache.hyracks.control.nc.io.IOManager)5 FilenameFilter (java.io.FilenameFilter)3 ArrayList (java.util.ArrayList)3 FileReference (org.apache.hyracks.api.io.FileReference)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 VirtualFreePageManager (org.apache.hyracks.storage.am.lsm.common.freepage.VirtualFreePageManager)1 VirtualBufferCache (org.apache.hyracks.storage.am.lsm.common.impls.VirtualBufferCache)1 HeapBufferAllocator (org.apache.hyracks.storage.common.buffercache.HeapBufferAllocator)1