Search in sources :

Example 11 with IODeviceHandle

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

the class IOManager method createWorkspaceFile.

@Override
public synchronized FileReference createWorkspaceFile(String prefix) throws HyracksDataException {
    IODeviceHandle dev = workspaces.get(workspaceIndex);
    workspaceIndex = (workspaceIndex + 1) % workspaces.size();
    String waPath = dev.getWorkspace();
    File waf;
    try {
        waf = File.createTempFile(prefix, WORKSPACE_FILE_SUFFIX, new File(dev.getMount(), waPath));
    } catch (IOException e) {
        throw new HyracksDataException(e);
    }
    return dev.createFileRef(waPath + File.separator + waf.getName());
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) IOException(java.io.IOException) File(java.io.File) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 12 with IODeviceHandle

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

the class DefaultDeviceResolver method resolve.

@Override
public IODeviceHandle resolve(String relPath, List<IODeviceHandle> devices) throws HyracksDataException {
    int numDevices = devices.size();
    String path = relPath;
    // if number of devices is 1, we return the device
    if (numDevices == 1) {
        return devices.get(0);
    }
    // check if it exists already on a device
    int nextSeparator = path.lastIndexOf(File.separator);
    while (nextSeparator > 0) {
        for (IODeviceHandle dev : devices) {
            if (dev.contains(path)) {
                return dev;
            }
        }
        path = path.substring(0, nextSeparator);
        nextSeparator = path.lastIndexOf(File.separator);
    }
    // one last attempt
    for (IODeviceHandle dev : devices) {
        if (dev.contains(path)) {
            return dev;
        }
    }
    // not on any device, round robin assignment
    return devices.get(next.getAndIncrement() % numDevices);
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle)

Example 13 with IODeviceHandle

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

the class TestStorageManagerComponentHolder method getIOManager.

public static synchronized IOManager getIOManager() throws HyracksDataException {
    if (ioManager == null) {
        List<IODeviceHandle> devices = new ArrayList<>();
        devices.add(new IODeviceHandle(new File(System.getProperty("user.dir") + File.separator + "target"), "iodev_test_wa"));
        ioManager = new IOManager(devices, Executors.newCachedThreadPool(), new DefaultDeviceResolver());
    }
    return ioManager;
}
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) ArrayList(java.util.ArrayList) File(java.io.File)

Example 14 with IODeviceHandle

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

the class TestUtils method createIoManager.

private static IOManager createIoManager() throws HyracksException {
    List<IODeviceHandle> devices = new ArrayList<>();
    devices.add(new IODeviceHandle(new File(System.getProperty("java.io.tmpdir")), "."));
    return new IOManager(devices, Executors.newCachedThreadPool(), new DefaultDeviceResolver());
}
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) ArrayList(java.util.ArrayList) 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