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());
}
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);
}
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;
}
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());
}
Aggregations