asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amo...@apache.org
Subject [01/12] asterixdb git commit: Cleanup FileSplit and FileReference
Date Thu, 24 Nov 2016 06:30:05 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master be75f51ff -> 163c3be3e


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/163c3be3/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java
b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java
index e85ff9e..c58d83c 100644
--- a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheRegressionTest.java
@@ -18,6 +18,8 @@
  */
 package org.apache.hyracks.storage.common;
 
+import static org.junit.Assert.fail;
+
 import java.io.File;
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -25,9 +27,9 @@ import java.nio.ByteBuffer;
 import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.io.FileReference;
 import org.apache.hyracks.api.io.IFileHandle;
-import org.apache.hyracks.api.io.IIOManager;
 import org.apache.hyracks.api.io.IIOManager.FileReadWriteMode;
 import org.apache.hyracks.api.io.IIOManager.FileSyncMode;
+import org.apache.hyracks.control.nc.io.IOManager;
 import org.apache.hyracks.storage.common.buffercache.BufferCache;
 import org.apache.hyracks.storage.common.buffercache.IBufferCache;
 import org.apache.hyracks.storage.common.buffercache.ICachedPage;
@@ -39,8 +41,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
-
 public class BufferCacheRegressionTest {
     protected static final String tmpDir = System.getProperty("java.io.tmpdir");
     protected static final String sep = System.getProperty("file.separator");
@@ -81,8 +81,9 @@ public class BufferCacheRegressionTest {
 
         IBufferCache bufferCache = TestStorageManagerComponentHolder.getBufferCache(ctx);
         IFileMapProvider fmp = TestStorageManagerComponentHolder.getFileMapProvider(ctx);
+        IOManager ioManager = TestStorageManagerComponentHolder.getIOManager();
 
-        FileReference firstFileRef = new FileReference(new File(fileName));
+        FileReference firstFileRef = ioManager.getFileRef(fileName, false);
         bufferCache.createFile(firstFileRef);
         int firstFileId = fmp.lookupFileId(firstFileRef);
         bufferCache.openFile(firstFileId);
@@ -106,7 +107,7 @@ public class BufferCacheRegressionTest {
         }
 
         // Create a file with the same name.
-        FileReference secondFileRef = new FileReference(new File(fileName));
+        FileReference secondFileRef = ioManager.getFileRef(fileName, false);
         bufferCache.createFile(secondFileRef);
         int secondFileId = fmp.lookupFileId(secondFileRef);
 
@@ -122,8 +123,7 @@ public class BufferCacheRegressionTest {
         // ask the BufferCache to pin the page, because it would return the same
         // physical memory again, and for performance reasons pages are never
         // reset with 0's.
-        IIOManager ioManager = ctx.getIOManager();
-        FileReference testFileRef = new FileReference(new File(fileName));
+        FileReference testFileRef = ioManager.getFileRef(fileName, false);
         IFileHandle testFileHandle = ioManager.open(testFileRef, FileReadWriteMode.READ_ONLY,
                 FileSyncMode.METADATA_SYNC_DATA_SYNC);
         ByteBuffer testBuffer = ByteBuffer.allocate(PAGE_SIZE + BufferCache.RESERVED_HEADER_BYTES);

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/163c3be3/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java
----------------------------------------------------------------------
diff --git a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java
b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java
index 3e410ad..b96d114 100644
--- a/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-tests/hyracks-storage-common-test/src/test/java/org/apache/hyracks/storage/common/BufferCacheTest.java
@@ -27,22 +27,24 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Test;
-
 import org.apache.hyracks.api.context.IHyracksTaskContext;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.api.exceptions.HyracksException;
 import org.apache.hyracks.api.io.FileReference;
+import org.apache.hyracks.api.io.IIOManager;
+import org.apache.hyracks.control.nc.io.IOManager;
 import org.apache.hyracks.storage.common.buffercache.IBufferCache;
 import org.apache.hyracks.storage.common.buffercache.ICachedPage;
 import org.apache.hyracks.storage.common.file.BufferedFileHandle;
 import org.apache.hyracks.storage.common.file.IFileMapProvider;
 import org.apache.hyracks.test.support.TestStorageManagerComponentHolder;
 import org.apache.hyracks.test.support.TestUtils;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
 
 public class BufferCacheTest {
-    protected static final List<String> openedFiles = new ArrayList<String>();
+    protected static final List<String> openedFiles = new ArrayList<>();
     protected static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("ddMMyy-hhmmssSS");
     protected static final String tmpDir = System.getProperty("java.io.tmpdir");
     protected static final String sep = System.getProperty("file.separator");
@@ -62,12 +64,13 @@ public class BufferCacheTest {
     }
 
     @Test
-    public void simpleOpenPinCloseTest() throws HyracksDataException {
+    public void simpleOpenPinCloseTest() throws HyracksException {
         TestStorageManagerComponentHolder.init(PAGE_SIZE, NUM_PAGES, MAX_OPEN_FILES);
         IBufferCache bufferCache = TestStorageManagerComponentHolder.getBufferCache(ctx);
         IFileMapProvider fmp = TestStorageManagerComponentHolder.getFileMapProvider(ctx);
+        IOManager ioManager = TestStorageManagerComponentHolder.getIOManager();
         String fileName = getFileName();
-        FileReference file = new FileReference(new File(fileName));
+        FileReference file = ioManager.getFileRef(fileName, false);
         bufferCache.createFile(file);
         int fileId = fmp.lookupFileId(file);
         int num = 10;
@@ -143,16 +146,18 @@ public class BufferCacheTest {
     }
 
     @Test
-    public void simpleMaxOpenFilesTest() throws HyracksDataException {
+    public void simpleMaxOpenFilesTest() throws HyracksException {
         TestStorageManagerComponentHolder.init(PAGE_SIZE, NUM_PAGES, MAX_OPEN_FILES);
         IBufferCache bufferCache = TestStorageManagerComponentHolder.getBufferCache(ctx);
         IFileMapProvider fmp = TestStorageManagerComponentHolder.getFileMapProvider(ctx);
+        IOManager ioManager = TestStorageManagerComponentHolder.getIOManager();
 
-        List<Integer> fileIds = new ArrayList<Integer>();
+        List<Integer> fileIds = new ArrayList<>();
 
         for (int i = 0; i < MAX_OPEN_FILES; i++) {
             String fileName = getFileName();
-            FileReference file = new FileReference(new File(fileName));
+
+            FileReference file = ioManager.getFileRef(fileName, false);
             bufferCache.createFile(file);
             int fileId = fmp.lookupFileId(file);
             bufferCache.openFile(fileId);
@@ -164,7 +169,7 @@ public class BufferCacheTest {
         // since all files are open, next open should fail
         try {
             String fileName = getFileName();
-            FileReference file = new FileReference(new File(fileName));
+            FileReference file = ioManager.getFileRef(fileName, false);
             bufferCache.createFile(file);
             int fileId = fmp.lookupFileId(file);
             bufferCache.openFile(fileId);
@@ -182,7 +187,7 @@ public class BufferCacheTest {
         exceptionThrown = false;
         try {
             String fileName = getFileName();
-            FileReference file = new FileReference(new File(fileName));
+            FileReference file = ioManager.getFileRef(fileName, false);
             bufferCache.createFile(file);
             int fileId = fmp.lookupFileId(file);
             bufferCache.openFile(fileId);
@@ -201,20 +206,21 @@ public class BufferCacheTest {
     }
 
     @Test
-    public void contentCheckingMaxOpenFilesTest() throws HyracksDataException {
+    public void contentCheckingMaxOpenFilesTest() throws HyracksException {
         TestStorageManagerComponentHolder.init(PAGE_SIZE, NUM_PAGES, MAX_OPEN_FILES);
         IBufferCache bufferCache = TestStorageManagerComponentHolder.getBufferCache(ctx);
         IFileMapProvider fmp = TestStorageManagerComponentHolder.getFileMapProvider(ctx);
+        IIOManager ioManager = TestStorageManagerComponentHolder.getIOManager();
 
-        List<Integer> fileIds = new ArrayList<Integer>();
-        Map<Integer, ArrayList<Integer>> pageContents = new HashMap<Integer,
ArrayList<Integer>>();
+        List<Integer> fileIds = new ArrayList<>();
+        Map<Integer, ArrayList<Integer>> pageContents = new HashMap<>();
         int num = 10;
         int testPageId = 0;
 
         // open max number of files and write some stuff into their first page
         for (int i = 0; i < MAX_OPEN_FILES; i++) {
             String fileName = getFileName();
-            FileReference file = new FileReference(new File(fileName));
+            FileReference file = ioManager.getFileRef(fileName, false);
             bufferCache.createFile(file);
             int fileId = fmp.lookupFileId(file);
             bufferCache.openFile(fileId);
@@ -224,7 +230,7 @@ public class BufferCacheTest {
             page = bufferCache.pin(BufferedFileHandle.getDiskPageId(fileId, testPageId),
true);
             page.acquireWriteLatch();
             try {
-                ArrayList<Integer> values = new ArrayList<Integer>();
+                ArrayList<Integer> values = new ArrayList<>();
                 for (int j = 0; j < num; j++) {
                     int x = Math.abs(rnd.nextInt());
                     page.getBuffer().putInt(j * 4, x);
@@ -242,7 +248,7 @@ public class BufferCacheTest {
         // since all files are open, next open should fail
         try {
             String fileName = getFileName();
-            FileReference file = new FileReference(new File(fileName));
+            FileReference file = ioManager.getFileRef(fileName, false);
             bufferCache.createFile(file);
             int fileId = fmp.lookupFileId(file);
             bufferCache.openFile(fileId);
@@ -252,7 +258,7 @@ public class BufferCacheTest {
         Assert.assertTrue(exceptionThrown);
 
         // close a few random files
-        ArrayList<Integer> closedFileIds = new ArrayList<Integer>();
+        ArrayList<Integer> closedFileIds = new ArrayList<>();
         int filesToClose = 5;
         for (int i = 0; i < filesToClose; i++) {
             int ix = Math.abs(rnd.nextInt()) % fileIds.size();
@@ -264,7 +270,7 @@ public class BufferCacheTest {
         // now open a few new files
         for (int i = 0; i < filesToClose; i++) {
             String fileName = getFileName();
-            FileReference file = new FileReference(new File(fileName));
+            FileReference file = ioManager.getFileRef(fileName, false);
             bufferCache.createFile(file);
             int fileId = fmp.lookupFileId(file);
             bufferCache.openFile(fileId);
@@ -274,7 +280,7 @@ public class BufferCacheTest {
         // since all files are open, next open should fail
         try {
             String fileName = getFileName();
-            FileReference file = new FileReference(new File(fileName));
+            FileReference file = ioManager.getFileRef(fileName, false);
             bufferCache.createFile(file);
             int fileId = fmp.lookupFileId(file);
             bufferCache.openFile(fileId);


Mime
View raw message