abdullah alamoudi has uploaded a new change for review.

  https://asterix-gerrit.ics.uci.edu/2791

Change subject: [NO ISSUE][STO] Log more information on File is already mapped
......................................................................

[NO ISSUE][STO] Log more information on File is already mapped

Change-Id: Ifcc1d56a29c67e0cfc999defc00894f456c92ca9
---
M 
hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/io/FileReference.java
M 
hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
M 
hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/file/FileMapManager.java
3 files changed, 22 insertions(+), 3 deletions(-)


  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb 
refs/changes/91/2791/1

diff --git 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/io/FileReference.java
 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/io/FileReference.java
index 0375e9e..3d64d60 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/io/FileReference.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/io/FileReference.java
@@ -20,6 +20,7 @@
 
 import java.io.File;
 import java.io.Serializable;
+import java.util.Date;
 
 /**
  * A device handle and a relative path.
@@ -31,6 +32,7 @@
     private final File file;
     private final IODeviceHandle dev;
     private final String path;
+    private long registrationTime = 0L;
 
     public FileReference(IODeviceHandle dev, String path) {
         file = new File(dev.getMount(), path);
@@ -90,4 +92,16 @@
     public FileReference getChild(String name) {
         return new FileReference(dev, path + File.separator + name);
     }
+
+    public void register() {
+        if (registrationTime != 0) {
+            throw new IllegalStateException(
+                    "File " + toString() + " was already registered at " + new 
Date(registrationTime));
+        }
+        registrationTime = System.currentTimeMillis();
+    }
+
+    public long registrationTime() {
+        return registrationTime;
+    }
 }
diff --git 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
index ef07038..bf73b91 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
+++ 
b/hyracks-fullstack/hyracks/hyracks-api/src/main/resources/errormsg/en.properties
@@ -97,7 +97,7 @@
 78 = Failed to purge the bloom filter since it is active
 79 = Cannot bulk-load a non-empty tree
 80 = Cannot create index because it already exists
-81 = File %1$s is already mapped
+81 = File %1$s is already mapped as %2$s registered at %3$s
 82 = Failed to create the file %1$s because it already exists
 83 = No index found with resourceID %1$s
 84 = Files with overlapping non-contained timestamp intervals were found in 
%1$s
diff --git 
a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/file/FileMapManager.java
 
b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/file/FileMapManager.java
index 26df884..323252c 100644
--- 
a/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/file/FileMapManager.java
+++ 
b/hyracks-fullstack/hyracks/hyracks-storage-common/src/main/java/org/apache/hyracks/storage/common/file/FileMapManager.java
@@ -18,6 +18,7 @@
  */
 package org.apache.hyracks.storage.common.file;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -72,10 +73,14 @@
 
     @Override
     public int registerFile(FileReference fileRef) throws HyracksDataException 
{
-        if (isMapped(fileRef)) {
-            throw HyracksDataException.create(ErrorCode.FILE_ALREADY_MAPPED, 
fileRef);
+        Integer existingKey = name2IdMap.get(fileRef);
+        if (existingKey != null) {
+            FileReference prevFile = id2nameMap.get(existingKey);
+            throw HyracksDataException.create(ErrorCode.FILE_ALREADY_MAPPED, 
fileRef, prevFile,
+                    new Date(prevFile.registrationTime()).toString());
         }
         int fileId = idCounter++;
+        fileRef.register();
         id2nameMap.put(fileId, fileRef);
         name2IdMap.put(fileRef, fileId);
         return fileId;

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/2791
To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifcc1d56a29c67e0cfc999defc00894f456c92ca9
Gerrit-PatchSet: 1
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Owner: abdullah alamoudi <[email protected]>

Reply via email to