Search in sources :

Example 6 with IODeviceHandle

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

the class LSMRTreeTestHarness 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();
        }
    }
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Example 7 with IODeviceHandle

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

the class IOManagerPathTest method testDuplicates.

@Test(expected = HyracksDataException.class)
public void testDuplicates() throws HyracksDataException {
    IODeviceHandle first = new IODeviceHandle(new File("/tmp/tst/1"), "storage");
    IODeviceHandle second = new IODeviceHandle(new File("/tmp/tst/1"), "storage");
    IOManager ioManager = new IOManager(Arrays.asList(new IODeviceHandle[] { first, second }), 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) File(java.io.File) Test(org.junit.Test)

Example 8 with IODeviceHandle

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

the class LSMIndexFileManagerTest method createIOManager.

private IOManager createIOManager(int numDevices) throws HyracksDataException {
    List<IODeviceHandle> devices = new ArrayList<>();
    for (int i = 0; i < numDevices; i++) {
        String iodevPath = System.getProperty("java.io.tmpdir") + sep + "test_iodev" + i;
        devices.add(new IODeviceHandle(new File(iodevPath), "wa"));
    }
    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)

Example 9 with IODeviceHandle

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

the class LSMInvertedIndexTestHarness 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();
    for (int i = 0; i < numMutableComponents; i++) {
        virtualBufferCaches.get(i).close();
    }
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) FilenameFilter(java.io.FilenameFilter) File(java.io.File)

Example 10 with IODeviceHandle

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

the class VirtualFreePageManagerTest method test01.

@Test
public void test01() throws HyracksDataException {
    VirtualBufferCache bufferCache = new VirtualBufferCache(new HeapBufferAllocator(), 4096, 128);
    bufferCache.open();
    FileReference fileRef = new FileReference(new IODeviceHandle(new File("target"), "workspace"), "tempfile.tmp");
    bufferCache.createFile(fileRef);
    int fileId = bufferCache.getFileMapProvider().lookupFileId(fileRef);
    bufferCache.openFile(fileId);
    VirtualFreePageManager virtualFreePageManager = new VirtualFreePageManager(bufferCache);
    virtualFreePageManager.open(fileId);
    virtualFreePageManager.init(null, null);
    testInMemoryFreePageManager(virtualFreePageManager);
    // We expect exactly the same behavior after a reset().
    virtualFreePageManager.init(null, null);
    testInMemoryFreePageManager(virtualFreePageManager);
}
Also used : IODeviceHandle(org.apache.hyracks.api.io.IODeviceHandle) HeapBufferAllocator(org.apache.hyracks.storage.common.buffercache.HeapBufferAllocator) VirtualBufferCache(org.apache.hyracks.storage.am.lsm.common.impls.VirtualBufferCache) FileReference(org.apache.hyracks.api.io.FileReference) File(java.io.File) VirtualFreePageManager(org.apache.hyracks.storage.am.lsm.common.freepage.VirtualFreePageManager) Test(org.junit.Test)

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