is replacing indexArtifactMap interface with localResourceRepository
git-svn-id: https://asterixdb.googlecode.com/svn/branches/asterix_lsm_stabilization@745 eaa15691-b419-025a-1212-ee371bd00084
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java
index aa03bd1..2f8cbd0 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixAppRuntimeContext.java
@@ -17,7 +17,6 @@
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.ConstantMergePolicy;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.FlushController;
import edu.uci.ics.hyracks.storage.am.lsm.common.impls.ImmediateScheduler;
-import edu.uci.ics.hyracks.storage.am.lsm.common.impls.RefCountingOperationTracker;
import edu.uci.ics.hyracks.storage.common.TransientIndexArtifactMap;
import edu.uci.ics.hyracks.storage.common.buffercache.BufferCache;
import edu.uci.ics.hyracks.storage.common.buffercache.ClockPageReplacementStrategy;
@@ -27,14 +26,16 @@
import edu.uci.ics.hyracks.storage.common.buffercache.IPageReplacementStrategy;
import edu.uci.ics.hyracks.storage.common.file.IFileMapManager;
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
-import edu.uci.ics.hyracks.storage.common.file.IIndexArtifactMap;
+import edu.uci.ics.hyracks.storage.common.file.ILocalResourceRepository;
+import edu.uci.ics.hyracks.storage.common.file.ILocalResourceRepositoryFactory;
+import edu.uci.ics.hyracks.storage.common.file.IndexLocalResourceRepositoryFactory;
public class AsterixAppRuntimeContext {
private static final int DEFAULT_BUFFER_CACHE_PAGE_SIZE = 32768;
private static final int DEFAULT_LIFECYCLEMANAGER_MEMORY_BUDGET = 1024 * 1024 * 1024; // 1GB
private final INCApplicationContext ncApplicationContext;
- private IIndexArtifactMap indexArtifactMap;
+ private ILocalResourceRepository localResourceRepository;
private IIndexLifecycleManager indexLifecycleManager;
private IFileMapManager fileMapManager;
private IBufferCache bufferCache;
@@ -52,8 +53,7 @@
public void initialize() throws IOException, ACIDException {
int pageSize = getBufferCachePageSize();
int numPages = getBufferCacheNumPages();
-
- indexArtifactMap = new TransientIndexArtifactMap();
+
fileMapManager = new AsterixFileMapManager();
ICacheMemoryAllocator allocator = new HeapBufferAllocator();
IPageReplacementStrategy prs = new ClockPageReplacementStrategy();
@@ -66,7 +66,8 @@
lsmIOScheduler = ImmediateScheduler.INSTANCE;
mergePolicy = new ConstantMergePolicy(lsmIOScheduler, 3);
opTracker = new RefCountingOperationTracker();
-
+ ILocalResourceRepositoryFactory indexLocalResourceRepositoryFactory = new IndexLocalResourceRepositoryFactory(ioMgr);
+ localResourceRepository = indexLocalResourceRepositoryFactory.createRepository();
}
private int getBufferCachePageSize() {
@@ -132,8 +133,8 @@
return indexLifecycleManager;
}
- public IIndexArtifactMap getIndexArtifactMap() {
- return indexArtifactMap;
+ public ILocalResourceRepository getLocalResourceRepository() {
+ return localResourceRepository;
}
public ILSMFlushController getFlushController() {
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixRuntimeComponentsProvider.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixRuntimeComponentsProvider.java
index 4c133e8..e667610 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixRuntimeComponentsProvider.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/AsterixRuntimeComponentsProvider.java
@@ -14,7 +14,7 @@
import edu.uci.ics.hyracks.storage.common.IStorageManagerInterface;
import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
-import edu.uci.ics.hyracks.storage.common.file.IIndexArtifactMap;
+import edu.uci.ics.hyracks.storage.common.file.ILocalResourceRepository;
public enum AsterixRuntimeComponentsProvider implements IIndexLifecycleManagerProvider, IStorageManagerInterface,
ILSMIOOperationSchedulerProvider, ILSMFlushControllerProvider, ILSMOperationTrackerProvider,
@@ -58,9 +58,9 @@
}
@Override
- public IIndexArtifactMap getIndexArtifactMap(IHyracksTaskContext ctx) {
+ public ILocalResourceRepository getLocalResourceRepository(IHyracksTaskContext ctx) {
return ((AsterixAppRuntimeContext) ctx.getJobletContext().getApplicationContext().getApplicationObject())
- .getIndexArtifactMap();
+ .getLocalResourceRepository();
}
@Override
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
index 68d2053..e298d77 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
@@ -64,7 +64,7 @@
import edu.uci.ics.hyracks.storage.common.buffercache.HeapBufferAllocator;
import edu.uci.ics.hyracks.storage.common.buffercache.IBufferCache;
import edu.uci.ics.hyracks.storage.common.file.IFileMapProvider;
-import edu.uci.ics.hyracks.storage.common.file.IIndexArtifactMap;
+import edu.uci.ics.hyracks.storage.common.file.ILocalResourceRepository;
import edu.uci.ics.hyracks.storage.common.file.TransientFileMapManager;
/**
@@ -86,7 +86,7 @@
private static IBufferCache bufferCache;
private static IFileMapProvider fileMapProvider;
private static IIndexLifecycleManager indexLifecycleManager;
- private static IIndexArtifactMap indexArtifactMap;
+ private static ILocalResourceRepository localResourceRepository;
private static IIOManager ioManager;
private static String metadataNodeName;
@@ -138,7 +138,7 @@
}
indexLifecycleManager = runtimeContext.getIndexLifecycleManager();
- indexArtifactMap = runtimeContext.getIndexArtifactMap();
+ localResourceRepository = runtimeContext.getLocalResourceRepository();
bufferCache = runtimeContext.getBufferCache();
fileMapProvider = runtimeContext.getFileMapManager();
ioManager = ncApplicationContext.getRootContext().getIOManager();
@@ -187,12 +187,14 @@
public static void stopUniverse() throws HyracksDataException {
// Close all BTree files in BufferCache.
for (int i = 0; i < primaryIndexes.length; i++) {
- long resourceID = indexArtifactMap.get(primaryIndexes[i].getFile().getFile().getPath());
+ long resourceID = localResourceRepository
+ .getResourceByName(primaryIndexes[i].getFile().getFile().getPath()).getResourceId();
indexLifecycleManager.close(resourceID);
indexLifecycleManager.unregister(resourceID);
}
for (int i = 0; i < secondaryIndexes.length; i++) {
- long resourceID = indexArtifactMap.get(secondaryIndexes[i].getFile().getFile().getPath());
+ long resourceID = localResourceRepository.getResourceByName(
+ secondaryIndexes[i].getFile().getFile().getPath()).getResourceId();
indexLifecycleManager.close(resourceID);
indexLifecycleManager.unregister(resourceID);
}
@@ -302,7 +304,7 @@
lsmBtree.create();
resourceID = indexArtifactMap.create(file.getFile().getPath(), ioManager.getIODevices());
} else {
- resourceID = indexArtifactMap.get(file.getFile().getPath());
+ resourceID = localResourceRepository.getResourceByName(file.getFile().getPath()).getResourceId();
}
index.setResourceID(resourceID);
index.setFile(file);