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