asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From buyin...@apache.org
Subject [05/16] asterixdb git commit: Add Asterix Extension Manager
Date Sat, 20 Aug 2016 06:15:47 GMT
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataManager.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataManager.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataManager.java
index 242bbe3..0acc027 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataManager.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataManager.java
@@ -39,6 +39,7 @@ import org.apache.asterix.metadata.entities.Index;
 import org.apache.asterix.metadata.entities.Library;
 import org.apache.asterix.metadata.entities.Node;
 import org.apache.asterix.metadata.entities.NodeGroup;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 
 /**
  * A metadata manager provides user access to Asterix metadata (e.g., types,
@@ -56,41 +57,46 @@ public interface IMetadataManager {
 
     /**
      * Initializes the metadata manager, e.g., finds the remote metadata node.
+     *
      * @throws RemoteException
      *             If an error occurred while contacting the proxy for finding
      *             the metadata node.
      */
-    public void init() throws RemoteException, MetadataException;
+    void init() throws RemoteException, MetadataException;
 
     /**
      * Begins a transaction on the metadata node.
+     *
      * @return A globally unique transaction id.
      * @throws ACIDException
      * @throws RemoteException
      */
-    public MetadataTransactionContext beginTransaction() throws ACIDException, RemoteException;
+    MetadataTransactionContext beginTransaction() throws ACIDException, RemoteException;
 
     /**
      * Commits a remote transaction on the metadata node.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @throws ACIDException
      * @throws RemoteException
      */
-    public void commitTransaction(MetadataTransactionContext ctx) throws ACIDException, RemoteException;
+    void commitTransaction(MetadataTransactionContext ctx) throws ACIDException, RemoteException;
 
     /**
      * Aborts a remote transaction running on the metadata node.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @throws ACIDException
      * @throws RemoteException
      */
-    public void abortTransaction(MetadataTransactionContext ctx) throws ACIDException, RemoteException;
+    void abortTransaction(MetadataTransactionContext ctx) throws ACIDException, RemoteException;
 
     /**
      * Locks the metadata in given mode. The lock acquisition is delegated to
      * the metadata node. This method blocks until the lock can be acquired.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param lockMode
@@ -98,19 +104,21 @@ public interface IMetadataManager {
      * @throws ACIDException
      * @throws RemoteException
      */
-    public void lock(MetadataTransactionContext ctx, byte lockMode) throws ACIDException, RemoteException;
+    void lock(MetadataTransactionContext ctx, byte lockMode) throws ACIDException, RemoteException;
 
     /**
      * Releases all locks on the metadata held by the given transaction id.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @throws ACIDException
      * @throws RemoteException
      */
-    public void unlock(MetadataTransactionContext ctx, byte lockMode) throws ACIDException, RemoteException;
+    void unlock(MetadataTransactionContext ctx, byte lockMode) throws ACIDException, RemoteException;
 
     /**
      * Inserts a new dataverse into the metadata.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverse
@@ -118,10 +126,11 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the dataverse already exists.
      */
-    public void addDataverse(MetadataTransactionContext ctx, Dataverse dataverse) throws MetadataException;
+    void addDataverse(MetadataTransactionContext ctx, Dataverse dataverse) throws MetadataException;
 
     /**
      * Retrieves all dataverses
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @return A list of dataverse instances.
@@ -131,6 +140,7 @@ public interface IMetadataManager {
 
     /**
      * Retrieves a dataverse with given name.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -139,10 +149,11 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the dataverse does not exist.
      */
-    public Dataverse getDataverse(MetadataTransactionContext ctx, String dataverseName) throws MetadataException;
+    Dataverse getDataverse(MetadataTransactionContext ctx, String dataverseName) throws MetadataException;
 
     /**
      * Retrieves all datasets belonging to the given dataverse.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -151,22 +162,23 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the dataverse does not exist.
      */
-    public List<Dataset> getDataverseDatasets(MetadataTransactionContext ctx, String dataverseName)
-            throws MetadataException;
+    List<Dataset> getDataverseDatasets(MetadataTransactionContext ctx, String dataverseName) throws MetadataException;
 
     /**
      * Deletes the dataverse with given name, and all it's associated datasets,
      * indexes, and types.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @return A list of dataset instances.
      * @throws MetadataException
      *             For example, if the dataverse does not exist.
      */
-    public void dropDataverse(MetadataTransactionContext ctx, String dataverseName) throws MetadataException;
+    void dropDataverse(MetadataTransactionContext ctx, String dataverseName) throws MetadataException;
 
     /**
      * Inserts a new dataset into the metadata.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataset
@@ -174,10 +186,11 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the dataset already exists.
      */
-    public void addDataset(MetadataTransactionContext ctx, Dataset dataset) throws MetadataException;
+    void addDataset(MetadataTransactionContext ctx, Dataset dataset) throws MetadataException;
 
     /**
      * Retrieves a dataset within a given dataverse.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -188,11 +201,12 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the dataset does not exist.
      */
-    public Dataset getDataset(MetadataTransactionContext ctx, String dataverseName, String datasetName)
+    Dataset getDataset(MetadataTransactionContext ctx, String dataverseName, String datasetName)
             throws MetadataException;
 
     /**
      * Retrieves all indexes of a dataset.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -203,11 +217,12 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the dataset and/or dataverse does not exist.
      */
-    public List<Index> getDatasetIndexes(MetadataTransactionContext ctx, String dataverseName, String datasetName)
+    List<Index> getDatasetIndexes(MetadataTransactionContext ctx, String dataverseName, String datasetName)
             throws MetadataException;
 
     /**
      * Deletes the dataset with given name, and all it's associated indexes.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -217,12 +232,12 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the dataset and/or dataverse does not exist.
      */
-    public void dropDataset(MetadataTransactionContext ctx, String dataverseName, String datasetName)
-            throws MetadataException;
+    void dropDataset(MetadataTransactionContext ctx, String dataverseName, String datasetName) throws MetadataException;
 
     /**
      * Inserts an index into the metadata. The index itself knows its name, and
      * which dataset it belongs to.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param index
@@ -230,10 +245,11 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the index already exists.
      */
-    public void addIndex(MetadataTransactionContext ctx, Index index) throws MetadataException;
+    void addIndex(MetadataTransactionContext ctx, Index index) throws MetadataException;
 
     /**
      * Retrieves the index with given name, in given dataverse and dataset.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -245,11 +261,12 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the index does not exist.
      */
-    public Index getIndex(MetadataTransactionContext ctx, String dataverseName, String datasetName, String indexName)
+    Index getIndex(MetadataTransactionContext ctx, String dataverseName, String datasetName, String indexName)
             throws MetadataException;
 
     /**
      * Deletes the index with given name, in given dataverse and dataset.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -260,11 +277,12 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the index does not exist.
      */
-    public void dropIndex(MetadataTransactionContext ctx, String dataverseName, String datasetName, String indexName)
+    void dropIndex(MetadataTransactionContext ctx, String dataverseName, String datasetName, String indexName)
             throws MetadataException;
 
     /**
      * Inserts a datatype.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param datatype
@@ -272,10 +290,11 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the datatype already exists.
      */
-    public void addDatatype(MetadataTransactionContext ctx, Datatype datatype) throws MetadataException;
+    void addDatatype(MetadataTransactionContext ctx, Datatype datatype) throws MetadataException;
 
     /**
      * Retrieves the datatype with given name in given dataverse.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -286,11 +305,12 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the datatype does not exist.
      */
-    public Datatype getDatatype(MetadataTransactionContext ctx, String dataverseName, String datatypeName)
+    Datatype getDatatype(MetadataTransactionContext ctx, String dataverseName, String datatypeName)
             throws MetadataException;
 
     /**
      * Deletes the given datatype in given dataverse.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -301,11 +321,12 @@ public interface IMetadataManager {
      *             For example, if there are still datasets using the type to be
      *             deleted.
      */
-    public void dropDatatype(MetadataTransactionContext ctx, String dataverseName, String datatypeName)
+    void dropDatatype(MetadataTransactionContext ctx, String dataverseName, String datatypeName)
             throws MetadataException;
 
     /**
      * Inserts a node group.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param nodeGroup
@@ -313,10 +334,11 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the node group already exists.
      */
-    public void addNodegroup(MetadataTransactionContext ctx, NodeGroup nodeGroup) throws MetadataException;
+    void addNodegroup(MetadataTransactionContext ctx, NodeGroup nodeGroup) throws MetadataException;
 
     /**
      * Retrieves a node group.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param nodeGroupName
@@ -324,10 +346,11 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the node group does not exist.
      */
-    public NodeGroup getNodegroup(MetadataTransactionContext ctx, String nodeGroupName) throws MetadataException;
+    NodeGroup getNodegroup(MetadataTransactionContext ctx, String nodeGroupName) throws MetadataException;
 
     /**
      * Deletes a node group.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param nodeGroupName
@@ -336,10 +359,11 @@ public interface IMetadataManager {
      *             For example, there are still datasets partitioned on the node
      *             group to be deleted.
      */
-    public void dropNodegroup(MetadataTransactionContext ctx, String nodeGroupName) throws MetadataException;
+    void dropNodegroup(MetadataTransactionContext ctx, String nodeGroupName) throws MetadataException;
 
     /**
      * Inserts a node (machine).
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param node
@@ -347,7 +371,7 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the node already exists.
      */
-    public void addNode(MetadataTransactionContext ctx, Node node) throws MetadataException;
+    void addNode(MetadataTransactionContext ctx, Node node) throws MetadataException;
 
     /**
      * @param mdTxnCtx
@@ -357,7 +381,7 @@ public interface IMetadataManager {
      *            being added
      * @throws MetadataException
      */
-    public void addFunction(MetadataTransactionContext mdTxnCtx, Function function) throws MetadataException;
+    void addFunction(MetadataTransactionContext mdTxnCtx, Function function) throws MetadataException;
 
     /**
      * @param ctx
@@ -368,8 +392,7 @@ public interface IMetadataManager {
      * @throws MetadataException
      */
 
-    public Function getFunction(MetadataTransactionContext ctx, FunctionSignature functionSignature)
-            throws MetadataException;
+    Function getFunction(MetadataTransactionContext ctx, FunctionSignature functionSignature) throws MetadataException;
 
     /**
      * @param ctx
@@ -378,8 +401,7 @@ public interface IMetadataManager {
      *            the functions signature (unique to the function)
      * @throws MetadataException
      */
-    public void dropFunction(MetadataTransactionContext ctx, FunctionSignature functionSignature)
-            throws MetadataException;
+    void dropFunction(MetadataTransactionContext ctx, FunctionSignature functionSignature) throws MetadataException;
 
     /**
      * @param mdTxnCtx
@@ -389,7 +411,7 @@ public interface IMetadataManager {
      *            added
      * @throws MetadataException
      */
-    public void addAdapter(MetadataTransactionContext mdTxnCtx, DatasourceAdapter adapter) throws MetadataException;
+    void addAdapter(MetadataTransactionContext mdTxnCtx, DatasourceAdapter adapter) throws MetadataException;
 
     /**
      * @param ctx
@@ -401,7 +423,7 @@ public interface IMetadataManager {
      * @return
      * @throws MetadataException
      */
-    public DatasourceAdapter getAdapter(MetadataTransactionContext ctx, String dataverseName, String name)
+    DatasourceAdapter getAdapter(MetadataTransactionContext ctx, String dataverseName, String name)
             throws MetadataException;
 
     /**
@@ -413,14 +435,14 @@ public interface IMetadataManager {
      *            name of the adapter
      * @throws MetadataException
      */
-    public void dropAdapter(MetadataTransactionContext ctx, String dataverseName, String name) throws MetadataException;
+    void dropAdapter(MetadataTransactionContext ctx, String dataverseName, String name) throws MetadataException;
 
     /**
      * @param ctx
      * @param policy
      * @throws MetadataException
      */
-    public void addCompactionPolicy(MetadataTransactionContext ctx, CompactionPolicy policy) throws MetadataException;
+    void addCompactionPolicy(MetadataTransactionContext ctx, CompactionPolicy policy) throws MetadataException;
 
     /**
      * @param ctx
@@ -429,7 +451,7 @@ public interface IMetadataManager {
      * @return
      * @throws MetadataException
      */
-    public CompactionPolicy getCompactionPolicy(MetadataTransactionContext ctx, String dataverse, String policyName)
+    CompactionPolicy getCompactionPolicy(MetadataTransactionContext ctx, String dataverse, String policyName)
             throws MetadataException;
 
     /**
@@ -438,15 +460,14 @@ public interface IMetadataManager {
      * @return
      * @throws MetadataException
      */
-    public List<Function> getDataverseFunctions(MetadataTransactionContext ctx, String dataverseName)
-            throws MetadataException;
+    List<Function> getDataverseFunctions(MetadataTransactionContext ctx, String dataverseName) throws MetadataException;
 
     /**
      * @param ctx
      * @param feed
      * @throws MetadataException
      */
-    public void addFeed(MetadataTransactionContext ctx, Feed feed) throws MetadataException;
+    void addFeed(MetadataTransactionContext ctx, Feed feed) throws MetadataException;
 
     /**
      * @param ctx
@@ -455,7 +476,7 @@ public interface IMetadataManager {
      * @return
      * @throws MetadataException
      */
-    public Feed getFeed(MetadataTransactionContext ctx, String dataverse, String feedName) throws MetadataException;
+    Feed getFeed(MetadataTransactionContext ctx, String dataverse, String feedName) throws MetadataException;
 
     /**
      * @param ctx
@@ -463,14 +484,14 @@ public interface IMetadataManager {
      * @param feedName
      * @throws MetadataException
      */
-    public void dropFeed(MetadataTransactionContext ctx, String dataverse, String feedName) throws MetadataException;
+    void dropFeed(MetadataTransactionContext ctx, String dataverse, String feedName) throws MetadataException;
 
     /**
      * @param ctx
      * @param policy
      * @throws MetadataException
      */
-    public void addFeedPolicy(MetadataTransactionContext ctx, FeedPolicyEntity policy) throws MetadataException;
+    void addFeedPolicy(MetadataTransactionContext ctx, FeedPolicyEntity policy) throws MetadataException;
 
     /**
      * @param ctx
@@ -479,24 +500,25 @@ public interface IMetadataManager {
      * @return
      * @throws MetadataException
      */
-    public FeedPolicyEntity getFeedPolicy(MetadataTransactionContext ctx, String dataverse, String policyName)
+    FeedPolicyEntity getFeedPolicy(MetadataTransactionContext ctx, String dataverse, String policyName)
             throws MetadataException;
 
-    public void initializeDatasetIdFactory(MetadataTransactionContext ctx) throws MetadataException;
+    void initializeDatasetIdFactory(MetadataTransactionContext ctx) throws MetadataException;
 
-    public int getMostRecentDatasetId() throws MetadataException;
+    int getMostRecentDatasetId() throws MetadataException;
 
-    public void acquireWriteLatch();
+    void acquireWriteLatch();
 
-    public void releaseWriteLatch();
+    void releaseWriteLatch();
 
-    public void acquireReadLatch();
+    void acquireReadLatch();
 
-    public void releaseReadLatch();
+    void releaseReadLatch();
 
     /**
      * Removes a library , acquiring local locks on behalf of the given
      * transaction id.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -506,12 +528,12 @@ public interface IMetadataManager {
      *            if the library does not exists.
      * @throws RemoteException
      */
-    public void dropLibrary(MetadataTransactionContext ctx, String dataverseName, String libraryName)
-            throws MetadataException;
+    void dropLibrary(MetadataTransactionContext ctx, String dataverseName, String libraryName) throws MetadataException;
 
     /**
      * Adds a library, acquiring local locks on behalf of the given
      * transaction id.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param library
@@ -520,7 +542,7 @@ public interface IMetadataManager {
      *             for example, if the library is already added.
      * @throws RemoteException
      */
-    public void addLibrary(MetadataTransactionContext ctx, Library library) throws MetadataException;
+    void addLibrary(MetadataTransactionContext ctx, Library library) throws MetadataException;
 
     /**
      * @param ctx
@@ -533,11 +555,12 @@ public interface IMetadataManager {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public Library getLibrary(MetadataTransactionContext ctx, String dataverseName, String libraryName)
+    Library getLibrary(MetadataTransactionContext ctx, String dataverseName, String libraryName)
             throws MetadataException, RemoteException;
 
     /**
      * Retireve libraries installed in a given dataverse.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataverseName
@@ -546,8 +569,7 @@ public interface IMetadataManager {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public List<Library> getDataverseLibraries(MetadataTransactionContext ctx, String dataverseName)
-            throws MetadataException;
+    List<Library> getDataverseLibraries(MetadataTransactionContext ctx, String dataverseName) throws MetadataException;
 
     /**
      * @param mdTxnCtx
@@ -557,8 +579,7 @@ public interface IMetadataManager {
      *            added
      * @throws MetadataException
      */
-    public void addExternalFile(MetadataTransactionContext mdTxnCtx, ExternalFile externalFile)
-            throws MetadataException;
+    void addExternalFile(MetadataTransactionContext mdTxnCtx, ExternalFile externalFile) throws MetadataException;
 
     /**
      * @param mdTxnCtx
@@ -568,7 +589,7 @@ public interface IMetadataManager {
      * @return A list of external files belonging to the dataset
      * @throws MetadataException
      */
-    public List<ExternalFile> getDatasetExternalFiles(MetadataTransactionContext mdTxnCtx, Dataset dataset)
+    List<ExternalFile> getDatasetExternalFiles(MetadataTransactionContext mdTxnCtx, Dataset dataset)
             throws MetadataException;
 
     /**
@@ -579,8 +600,7 @@ public interface IMetadataManager {
      *            dropped
      * @throws MetadataException
      */
-    public void dropExternalFile(MetadataTransactionContext mdTxnCtx, ExternalFile externalFile)
-            throws MetadataException;
+    void dropExternalFile(MetadataTransactionContext mdTxnCtx, ExternalFile externalFile) throws MetadataException;
 
     /**
      * @param mdTxnCtx
@@ -590,10 +610,11 @@ public interface IMetadataManager {
      *            dropped
      * @throws MetadataException
      */
-    public void dropDatasetExternalFiles(MetadataTransactionContext mdTxnCtx, Dataset dataset) throws MetadataException;
+    void dropDatasetExternalFiles(MetadataTransactionContext mdTxnCtx, Dataset dataset) throws MetadataException;
 
     /**
      * Get en external file
+     *
      * @param mdTxnCtx
      * @param dataverseName
      * @param datasetName
@@ -601,11 +622,12 @@ public interface IMetadataManager {
      * @return
      * @throws MetadataException
      */
-    public ExternalFile getExternalFile(MetadataTransactionContext mdTxnCtx, String dataverseName, String datasetName,
+    ExternalFile getExternalFile(MetadataTransactionContext mdTxnCtx, String dataverseName, String datasetName,
             Integer fileNumber) throws MetadataException;
 
     /**
      * update an existing dataset in metadata.
+     *
      * @param ctx
      *            MetadataTransactionContext of an active metadata transaction.
      * @param dataset
@@ -613,12 +635,45 @@ public interface IMetadataManager {
      * @throws MetadataException
      *             For example, if the dataset already exists.
      */
-    public void updateDataset(MetadataTransactionContext ctx, Dataset dataset) throws MetadataException;
+    void updateDataset(MetadataTransactionContext ctx, Dataset dataset) throws MetadataException;
 
     /**
      * Clean up temporary datasets that have not been active for a long time.
+     *
+     * @throws MetadataException
+     */
+    void cleanupTempDatasets() throws MetadataException;
+
+    /**
+     * Add an extension entity to its extension dataset under the ongoing metadata transaction
+     *
+     * @param mdTxnCtx
+     * @param entity
+     * @throws MetadataException
+     */
+    <T extends IExtensionMetadataEntity> void addEntity(MetadataTransactionContext mdTxnCtx, T entity)
+            throws MetadataException;
+
+    /**
+     * Deletes an extension entity from its extension dataset under the ongoing metadata transaction
+     *
+     * @param mdTxnCtx
+     * @param entity
+     * @throws MetadataException
+     */
+    <T extends IExtensionMetadataEntity> void deleteEntity(MetadataTransactionContext mdTxnCtx, T entity)
+            throws MetadataException;
+
+    /**
+     * Gets a list of extension entities matching a search key under the ongoing metadata transaction
+     *
+     * @param mdTxnCtx
+     * @param searchKey
+     * @return
      * @throws MetadataException
+     * @throws HyracksDataException
      */
-    public void cleanupTempDatasets() throws MetadataException;
+    <T extends IExtensionMetadataEntity> List<T> getEntities(MetadataTransactionContext mdTxnCtx,
+            IExtensionMetadataSearchKey searchKey) throws MetadataException, HyracksDataException;
 
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataNode.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataNode.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataNode.java
index ec2e692..41d0b6a 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataNode.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/api/IMetadataNode.java
@@ -59,7 +59,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws ACIDException
      * @throws RemoteException
      */
-    public void beginTransaction(JobId jobId) throws ACIDException, RemoteException;
+    void beginTransaction(JobId jobId) throws ACIDException, RemoteException;
 
     /**
      * Commits a local transaction against the metadata.
@@ -67,7 +67,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws ACIDException
      * @throws RemoteException
      */
-    public void commitTransaction(JobId jobId) throws ACIDException, RemoteException;
+    void commitTransaction(JobId jobId) throws ACIDException, RemoteException;
 
     /**
      * Aborts a local transaction against the metadata.
@@ -75,7 +75,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws ACIDException
      * @throws RemoteException
      */
-    public void abortTransaction(JobId jobId) throws ACIDException, RemoteException;
+    void abortTransaction(JobId jobId) throws ACIDException, RemoteException;
 
     /**
      * Locally locks the entire metadata in given mode on behalf of given
@@ -84,7 +84,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws ACIDException
      * @throws RemoteException
      */
-    public void lock(JobId jobId, byte lockMode) throws ACIDException, RemoteException;
+    void lock(JobId jobId, byte lockMode) throws ACIDException, RemoteException;
 
     /**
      * Releases all local locks of given transaction id.
@@ -92,7 +92,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws ACIDException
      * @throws RemoteException
      */
-    public void unlock(JobId jobId, byte lockMode) throws ACIDException, RemoteException;
+    void unlock(JobId jobId, byte lockMode) throws ACIDException, RemoteException;
 
     /**
      * Inserts a new dataverse into the metadata, acquiring local locks on
@@ -106,7 +106,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the dataverse already exists.
      * @throws RemoteException
      */
-    public void addDataverse(JobId jobId, Dataverse dataverse) throws MetadataException, RemoteException;
+    void addDataverse(JobId jobId, Dataverse dataverse) throws MetadataException, RemoteException;
 
     /**
      * Retrieves all dataverses, acquiring local locks on behalf of
@@ -119,7 +119,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the dataverse does not exist.
      * @throws RemoteException
      */
-    public List<Dataverse> getDataverses(JobId jobId) throws MetadataException, RemoteException;
+    List<Dataverse> getDataverses(JobId jobId) throws MetadataException, RemoteException;
 
     /**
      * Retrieves a dataverse with given name, acquiring local locks on behalf of
@@ -134,7 +134,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the dataverse does not exist.
      * @throws RemoteException
      */
-    public Dataverse getDataverse(JobId jobId, String dataverseName) throws MetadataException, RemoteException;
+    Dataverse getDataverse(JobId jobId, String dataverseName) throws MetadataException, RemoteException;
 
     /**
      * Retrieves all datasets belonging to the given dataverse, acquiring local
@@ -148,8 +148,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      *             For example, if the dataverse does not exist. RemoteException
      */
-    public List<Dataset> getDataverseDatasets(JobId jobId, String dataverseName)
-            throws MetadataException, RemoteException;
+    List<Dataset> getDataverseDatasets(JobId jobId, String dataverseName) throws MetadataException, RemoteException;
 
     /**
      * Deletes the dataverse with given name, and all it's associated datasets,
@@ -163,7 +162,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the dataverse does not exist.
      * @throws RemoteException
      */
-    public void dropDataverse(JobId jobId, String dataverseName) throws MetadataException, RemoteException;
+    void dropDataverse(JobId jobId, String dataverseName) throws MetadataException, RemoteException;
 
     /**
      * Inserts a new dataset into the metadata, acquiring local locks on behalf
@@ -177,7 +176,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the dataset already exists.
      * @throws RemoteException
      */
-    public void addDataset(JobId jobId, Dataset dataset) throws MetadataException, RemoteException;
+    void addDataset(JobId jobId, Dataset dataset) throws MetadataException, RemoteException;
 
     /**
      * Retrieves a dataset within a given dataverse, acquiring local locks on
@@ -194,8 +193,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the dataset does not exist.
      * @throws RemoteException
      */
-    public Dataset getDataset(JobId jobId, String dataverseName, String datasetName)
-            throws MetadataException, RemoteException;
+    Dataset getDataset(JobId jobId, String dataverseName, String datasetName) throws MetadataException, RemoteException;
 
     /**
      * Retrieves all indexes of a dataset, acquiring local locks on behalf of
@@ -212,7 +210,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the dataset and/or dataverse does not exist.
      * @throws RemoteException
      */
-    public List<Index> getDatasetIndexes(JobId jobId, String dataverseName, String datasetName)
+    List<Index> getDatasetIndexes(JobId jobId, String dataverseName, String datasetName)
             throws MetadataException, RemoteException;
 
     /**
@@ -229,8 +227,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the dataset and/or dataverse does not exist.
      * @throws RemoteException
      */
-    public void dropDataset(JobId jobId, String dataverseName, String datasetName)
-            throws MetadataException, RemoteException;
+    void dropDataset(JobId jobId, String dataverseName, String datasetName) throws MetadataException, RemoteException;
 
     /**
      * Inserts an index into the metadata, acquiring local locks on behalf of
@@ -245,7 +242,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the index already exists.
      * @throws RemoteException
      */
-    public void addIndex(JobId jobId, Index index) throws MetadataException, RemoteException;
+    void addIndex(JobId jobId, Index index) throws MetadataException, RemoteException;
 
     /**
      * Retrieves the index with given name, in given dataverse and dataset,
@@ -263,7 +260,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the index does not exist.
      * @throws RemoteException
      */
-    public Index getIndex(JobId jobId, String dataverseName, String datasetName, String indexName)
+    Index getIndex(JobId jobId, String dataverseName, String datasetName, String indexName)
             throws MetadataException, RemoteException;
 
     /**
@@ -281,7 +278,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the index does not exist.
      * @throws RemoteException
      */
-    public void dropIndex(JobId jobId, String dataverseName, String datasetName, String indexName)
+    void dropIndex(JobId jobId, String dataverseName, String datasetName, String indexName)
             throws MetadataException, RemoteException;
 
     /**
@@ -296,7 +293,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the datatype already exists.
      * @throws RemoteException
      */
-    public void addDatatype(JobId jobId, Datatype datatype) throws MetadataException, RemoteException;
+    void addDatatype(JobId jobId, Datatype datatype) throws MetadataException, RemoteException;
 
     /**
      * Retrieves the datatype with given name in given dataverse, acquiring
@@ -313,7 +310,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the datatype does not exist.
      * @throws RemoteException
      */
-    public Datatype getDatatype(JobId jobId, String dataverseName, String datatypeName)
+    Datatype getDatatype(JobId jobId, String dataverseName, String datatypeName)
             throws MetadataException, RemoteException;
 
     /**
@@ -331,8 +328,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             deleted.
      * @throws RemoteException
      */
-    public void dropDatatype(JobId jobId, String dataverseName, String datatypeName)
-            throws MetadataException, RemoteException;
+    void dropDatatype(JobId jobId, String dataverseName, String datatypeName) throws MetadataException, RemoteException;
 
     /**
      * Inserts a node group, acquiring local locks on behalf of the given
@@ -346,7 +342,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the node group already exists.
      * @throws RemoteException
      */
-    public void addNodeGroup(JobId jobId, NodeGroup nodeGroup) throws MetadataException, RemoteException;
+    void addNodeGroup(JobId jobId, NodeGroup nodeGroup) throws MetadataException, RemoteException;
 
     /**
      * Retrieves a node group, acquiring local locks on behalf of the given
@@ -360,7 +356,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the node group does not exist.
      * @throws RemoteException
      */
-    public NodeGroup getNodeGroup(JobId jobId, String nodeGroupName) throws MetadataException, RemoteException;
+    NodeGroup getNodeGroup(JobId jobId, String nodeGroupName) throws MetadataException, RemoteException;
 
     /**
      * Deletes a node group, acquiring local locks on behalf of the given
@@ -375,7 +371,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             group to be deleted.
      * @throws RemoteException
      */
-    public void dropNodegroup(JobId jobId, String nodeGroupName) throws MetadataException, RemoteException;
+    void dropNodegroup(JobId jobId, String nodeGroupName) throws MetadataException, RemoteException;
 
     /**
      * Inserts a node (compute node), acquiring local locks on behalf of the
@@ -389,7 +385,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the node already exists.
      * @throws RemoteException
      */
-    public void addNode(JobId jobId, Node node) throws MetadataException, RemoteException;
+    void addNode(JobId jobId, Node node) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -400,8 +396,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public Function getFunction(JobId jobId, FunctionSignature functionSignature)
-            throws MetadataException, RemoteException;
+    Function getFunction(JobId jobId, FunctionSignature functionSignature) throws MetadataException, RemoteException;
 
     /**
      * Deletes a function, acquiring local locks on behalf of the given
@@ -416,8 +411,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             group to be deleted.
      * @throws RemoteException
      */
-    public void dropFunction(JobId jobId, FunctionSignature functionSignature)
-            throws MetadataException, RemoteException;
+    void dropFunction(JobId jobId, FunctionSignature functionSignature) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -429,7 +423,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             unknown function
      * @throws RemoteException
      */
-    public void addFunction(JobId jobId, Function function) throws MetadataException, RemoteException;
+    void addFunction(JobId jobId, Function function) throws MetadataException, RemoteException;
 
     /**
      * @param ctx
@@ -438,8 +432,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public List<Function> getDataverseFunctions(JobId jobId, String dataverseName)
-            throws MetadataException, RemoteException;
+    List<Function> getDataverseFunctions(JobId jobId, String dataverseName) throws MetadataException, RemoteException;
 
     /**
      * @param ctx
@@ -448,7 +441,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public List<DatasourceAdapter> getDataverseAdapters(JobId jobId, String dataverseName)
+    List<DatasourceAdapter> getDataverseAdapters(JobId jobId, String dataverseName)
             throws MetadataException, RemoteException;
 
     /**
@@ -459,7 +452,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public DatasourceAdapter getAdapter(JobId jobId, String dataverseName, String adapterName)
+    DatasourceAdapter getAdapter(JobId jobId, String dataverseName, String adapterName)
             throws MetadataException, RemoteException;
 
     /**
@@ -475,8 +468,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *            if the adapter does not exists.
      * @throws RemoteException
      */
-    public void dropAdapter(JobId jobId, String dataverseName, String adapterName)
-            throws MetadataException, RemoteException;
+    void dropAdapter(JobId jobId, String dataverseName, String adapterName) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -487,7 +479,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             for example, if the adapter already exists.
      * @throws RemoteException
      */
-    public void addAdapter(JobId jobId, DatasourceAdapter adapter) throws MetadataException, RemoteException;
+    void addAdapter(JobId jobId, DatasourceAdapter adapter) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -495,8 +487,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public void addCompactionPolicy(JobId jobId, CompactionPolicy compactionPolicy)
-            throws MetadataException, RemoteException;
+    void addCompactionPolicy(JobId jobId, CompactionPolicy compactionPolicy) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -506,7 +497,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public CompactionPolicy getCompactionPolicy(JobId jobId, String dataverse, String policy)
+    CompactionPolicy getCompactionPolicy(JobId jobId, String dataverse, String policy)
             throws MetadataException, RemoteException;
 
     /**
@@ -514,14 +505,14 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public void initializeDatasetIdFactory(JobId jobId) throws MetadataException, RemoteException;
+    void initializeDatasetIdFactory(JobId jobId) throws MetadataException, RemoteException;
 
     /**
      * @return
      * @throws MetadataException
      * @throws RemoteException
      */
-    public int getMostRecentDatasetId() throws MetadataException, RemoteException;
+    int getMostRecentDatasetId() throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -529,7 +520,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public void addFeed(JobId jobId, Feed feed) throws MetadataException, RemoteException;
+    void addFeed(JobId jobId, Feed feed) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -539,7 +530,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public Feed getFeed(JobId jobId, String dataverse, String feedName) throws MetadataException, RemoteException;
+    Feed getFeed(JobId jobId, String dataverse, String feedName) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -548,7 +539,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public void dropFeed(JobId jobId, String dataverse, String feedName) throws MetadataException, RemoteException;
+    void dropFeed(JobId jobId, String dataverse, String feedName) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -556,7 +547,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public void addFeedPolicy(JobId jobId, FeedPolicyEntity feedPolicy) throws MetadataException, RemoteException;
+    void addFeedPolicy(JobId jobId, FeedPolicyEntity feedPolicy) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -566,7 +557,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public FeedPolicyEntity getFeedPolicy(JobId jobId, String dataverse, String policy)
+    FeedPolicyEntity getFeedPolicy(JobId jobId, String dataverse, String policy)
             throws MetadataException, RemoteException;
 
     /**
@@ -582,8 +573,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *            if the library does not exists.
      * @throws RemoteException
      */
-    public void dropLibrary(JobId jobId, String dataverseName, String libraryName)
-            throws MetadataException, RemoteException;
+    void dropLibrary(JobId jobId, String dataverseName, String libraryName) throws MetadataException, RemoteException;
 
     /**
      * Adds a library, acquiring local locks on behalf of the given
@@ -597,7 +587,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             for example, if the library is already added.
      * @throws RemoteException
      */
-    public void addLibrary(JobId jobId, Library library) throws MetadataException, RemoteException;
+    void addLibrary(JobId jobId, Library library) throws MetadataException, RemoteException;
 
     /**
      * @param txnId
@@ -610,8 +600,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public Library getLibrary(JobId jobId, String dataverseName, String libraryName)
-            throws MetadataException, RemoteException;
+    Library getLibrary(JobId jobId, String dataverseName, String libraryName) throws MetadataException, RemoteException;
 
     /**
      * Retireve libraries installed in a given dataverse.
@@ -624,8 +613,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public List<Library> getDataverseLibraries(JobId jobId, String dataverseName)
-            throws MetadataException, RemoteException;
+    List<Library> getDataverseLibraries(JobId jobId, String dataverseName) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -634,7 +622,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public List<Feed> getDataverseFeeds(JobId jobId, String dataverseName) throws MetadataException, RemoteException;
+    List<Feed> getDataverseFeeds(JobId jobId, String dataverseName) throws MetadataException, RemoteException;
 
     /**
      * delete a give feed (ingestion) policy
@@ -646,8 +634,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws RemoteException
      * @throws MetadataException
      */
-    public void dropFeedPolicy(JobId jobId, String dataverseName, String policyName)
-            throws MetadataException, RemoteException;
+    void dropFeedPolicy(JobId jobId, String dataverseName, String policyName) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -656,7 +643,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public List<FeedPolicyEntity> getDataversePolicies(JobId jobId, String dataverse)
+    List<FeedPolicyEntity> getDataversePolicies(JobId jobId, String dataverse)
             throws MetadataException, RemoteException;
 
     /**
@@ -668,7 +655,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             for example, if the file already exists.
      * @throws RemoteException
      */
-    public void addExternalFile(JobId jobId, ExternalFile externalFile) throws MetadataException, RemoteException;
+    void addExternalFile(JobId jobId, ExternalFile externalFile) throws MetadataException, RemoteException;
 
     /**
      * @param jobId
@@ -678,7 +665,7 @@ public interface IMetadataNode extends Remote, Serializable {
      * @throws MetadataException
      * @throws RemoteException
      */
-    public List<ExternalFile> getExternalFiles(JobId jobId, Dataset dataset) throws MetadataException, RemoteException;
+    List<ExternalFile> getExternalFiles(JobId jobId, Dataset dataset) throws MetadataException, RemoteException;
 
     /**
      * Deletes an externalFile , acquiring local locks on behalf of the given
@@ -694,7 +681,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *            the id number for the file to be deleted
      * @throws RemoteException
      */
-    public void dropExternalFile(JobId jobId, String dataverseName, String datasetName, int fileNumber)
+    void dropExternalFile(JobId jobId, String dataverseName, String datasetName, int fileNumber)
             throws MetadataException, RemoteException;
 
     /**
@@ -707,7 +694,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *            An external dataset the files belong to.
      * @throws RemoteException
      */
-    public void dropExternalFiles(JobId jobId, Dataset dataset) throws MetadataException, RemoteException;
+    void dropExternalFiles(JobId jobId, Dataset dataset) throws MetadataException, RemoteException;
 
     /**
      * Retrieves the file with given number, in given dataverse and dataset,
@@ -726,7 +713,7 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the index does not exist.
      * @throws RemoteException
      */
-    public ExternalFile getExternalFile(JobId jobId, String dataverseName, String datasetName, Integer fileNumber)
+    ExternalFile getExternalFile(JobId jobId, String dataverseName, String datasetName, Integer fileNumber)
             throws MetadataException, RemoteException;
 
     /**
@@ -741,6 +728,40 @@ public interface IMetadataNode extends Remote, Serializable {
      *             For example, if the dataset already exists.
      * @throws RemoteException
      */
-    public void updateDataset(JobId jobId, Dataset dataset) throws MetadataException, RemoteException;
+    void updateDataset(JobId jobId, Dataset dataset) throws MetadataException, RemoteException;
+
+    /**
+     * Adds an extension entity under the ongoing transaction job id
+     *
+     * @param jobId
+     * @param entity
+     * @throws MetadataException
+     * @throws RemoteException
+     */
+    <T extends IExtensionMetadataEntity> void addEntity(JobId jobId, T entity)
+            throws MetadataException, RemoteException;
+
+    /**
+     * Deletes an extension entity under the ongoing transaction job id
+     *
+     * @param jobId
+     * @param entity
+     * @throws MetadataException
+     * @throws RemoteException
+     */
+    <T extends IExtensionMetadataEntity> void deleteEntity(JobId jobId, T entity)
+            throws MetadataException, RemoteException;
+
+    /**
+     * Gets a list of extension entities matching a search key under the ongoing transaction
+     *
+     * @param jobId
+     * @param searchKey
+     * @return
+     * @throws MetadataException
+     * @throws RemoteException
+     */
+    <T extends IExtensionMetadataEntity> List<T> getEntities(JobId jobId, IExtensionMetadataSearchKey searchKey)
+            throws MetadataException, RemoteException;
 
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataBootstrap.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataBootstrap.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataBootstrap.java
index 757694d..f5ccb9e 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataBootstrap.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataBootstrap.java
@@ -35,7 +35,6 @@ import org.apache.asterix.common.config.AsterixMetadataProperties;
 import org.apache.asterix.common.config.DatasetConfig.DatasetType;
 import org.apache.asterix.common.config.GlobalConfig;
 import org.apache.asterix.common.config.IAsterixPropertiesProvider;
-import org.apache.asterix.common.config.MetadataConstants;
 import org.apache.asterix.common.context.BaseOperationTracker;
 import org.apache.asterix.common.context.CorrelatedPrefixMergePolicyFactory;
 import org.apache.asterix.common.ioopcallbacks.LSMBTreeIOOperationCallbackFactory;
@@ -65,6 +64,7 @@ import org.apache.asterix.metadata.entities.InternalDatasetDetails.PartitioningS
 import org.apache.asterix.metadata.entities.Node;
 import org.apache.asterix.metadata.entities.NodeGroup;
 import org.apache.asterix.metadata.feeds.BuiltinFeedPolicies;
+import org.apache.asterix.metadata.utils.MetadataConstants;
 import org.apache.asterix.om.types.BuiltinType;
 import org.apache.asterix.om.types.IAType;
 import org.apache.asterix.om.util.AsterixClusterProperties;
@@ -75,6 +75,7 @@ import org.apache.asterix.transaction.management.service.transaction.Transaction
 import org.apache.hyracks.api.application.INCApplicationContext;
 import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
 import org.apache.hyracks.api.dataflow.value.ITypeTraits;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.io.FileReference;
 import org.apache.hyracks.api.io.IIOManager;
 import org.apache.hyracks.storage.am.common.frames.LIFOMetaDataFrame;
@@ -103,47 +104,39 @@ import org.apache.hyracks.storage.common.file.LocalResource;
  * stopUniverse() should be called upon application undeployment.
  */
 public class MetadataBootstrap {
-    private static final Logger LOGGER = Logger.getLogger(MetadataBootstrap.class.getName());
     public static final boolean IS_DEBUG_MODE = false;// true
-
+    private static final Logger LOGGER = Logger.getLogger(MetadataBootstrap.class.getName());
     private static IAsterixAppRuntimeContext runtimeContext;
-
     private static IBufferCache bufferCache;
     private static IFileMapProvider fileMapProvider;
     private static IDatasetLifecycleManager dataLifecycleManager;
     private static ILocalResourceRepository localResourceRepository;
     private static IIOManager ioManager;
-
     private static String metadataNodeName;
     private static List<String> nodeNames;
     private static String outputDir;
+    private static boolean isNewUniverse;
 
-    private static IMetadataIndex[] primaryIndexes;
+    private static final IMetadataIndex[] PRIMARY_INDEXES =
+            new IMetadataIndex[] { MetadataPrimaryIndexes.DATAVERSE_DATASET, MetadataPrimaryIndexes.DATASET_DATASET,
+                    MetadataPrimaryIndexes.DATATYPE_DATASET, MetadataPrimaryIndexes.INDEX_DATASET,
+                    MetadataPrimaryIndexes.NODE_DATASET, MetadataPrimaryIndexes.NODEGROUP_DATASET,
+                    MetadataPrimaryIndexes.FUNCTION_DATASET, MetadataPrimaryIndexes.DATASOURCE_ADAPTER_DATASET,
+                    MetadataPrimaryIndexes.FEED_DATASET, MetadataPrimaryIndexes.FEED_POLICY_DATASET,
+                    MetadataPrimaryIndexes.LIBRARY_DATASET, MetadataPrimaryIndexes.COMPACTION_POLICY_DATASET,
+                    MetadataPrimaryIndexes.EXTERNAL_FILE_DATASET };
 
     private static IAsterixPropertiesProvider propertiesProvider;
 
-    private static void initLocalIndexArrays() {
-        primaryIndexes = new IMetadataIndex[] { MetadataPrimaryIndexes.DATAVERSE_DATASET,
-                MetadataPrimaryIndexes.DATASET_DATASET, MetadataPrimaryIndexes.DATATYPE_DATASET,
-                MetadataPrimaryIndexes.INDEX_DATASET, MetadataPrimaryIndexes.NODE_DATASET,
-                MetadataPrimaryIndexes.NODEGROUP_DATASET, MetadataPrimaryIndexes.FUNCTION_DATASET,
-                MetadataPrimaryIndexes.DATASOURCE_ADAPTER_DATASET, MetadataPrimaryIndexes.FEED_DATASET,
-                MetadataPrimaryIndexes.FEED_POLICY_DATASET, MetadataPrimaryIndexes.LIBRARY_DATASET,
-                MetadataPrimaryIndexes.COMPACTION_POLICY_DATASET, MetadataPrimaryIndexes.EXTERNAL_FILE_DATASET };
-    }
-
     public static void startUniverse(IAsterixPropertiesProvider asterixPropertiesProvider,
             INCApplicationContext ncApplicationContext, boolean isNewUniverse) throws Exception {
+        MetadataBootstrap.setNewUniverse(isNewUniverse);
         runtimeContext = (IAsterixAppRuntimeContext) ncApplicationContext.getApplicationObject();
         propertiesProvider = asterixPropertiesProvider;
 
-        MetadataPrimaryIndexes.init();
-        initLocalIndexArrays();
-
         AsterixMetadataProperties metadataProperties = propertiesProvider.getMetadataProperties();
         metadataNodeName = metadataProperties.getMetadataNodeName();
         nodeNames = metadataProperties.getNodeNames();
-
         dataLifecycleManager = runtimeContext.getDatasetLifecycleManager();
         localResourceRepository = runtimeContext.getLocalResourceRepository();
         bufferCache = runtimeContext.getBufferCache();
@@ -156,37 +149,26 @@ public class MetadataBootstrap {
             // Lock the metadata in X mode.
             MetadataManager.INSTANCE.lock(mdTxnCtx, LockMode.X);
 
+            for (int i = 0; i < PRIMARY_INDEXES.length; i++) {
+                enlistMetadataDataset(PRIMARY_INDEXES[i]);
+            }
+            if (LOGGER.isLoggable(Level.INFO)) {
+                LOGGER.info(
+                        "Finished enlistment of metadata B-trees in " + (isNewUniverse ? "new" : "old") + " universe");
+            }
             if (isNewUniverse) {
-                for (int i = 0; i < primaryIndexes.length; i++) {
-                    enlistMetadataDataset(primaryIndexes[i], true, mdTxnCtx);
-                }
-
-                if (LOGGER.isLoggable(Level.INFO)) {
-                    LOGGER.info("Finished enlistment of metadata B-trees in  new universe");
-                }
-
                 insertInitialDataverses(mdTxnCtx);
-                insertInitialDatasets(mdTxnCtx);
-                insertInitialDatatypes(mdTxnCtx);
+                insertMetadataDatasets(mdTxnCtx, PRIMARY_INDEXES);
+                insertMetadataDatatypes(mdTxnCtx);
                 insertNodes(mdTxnCtx);
                 insertInitialGroups(mdTxnCtx);
                 insertInitialAdapters(mdTxnCtx);
                 insertInitialFeedPolicies(mdTxnCtx);
                 insertInitialCompactionPolicies(mdTxnCtx);
-
                 if (LOGGER.isLoggable(Level.INFO)) {
                     LOGGER.info("Finished creating metadata B-trees.");
                 }
-            } else {
-                for (int i = 0; i < primaryIndexes.length; i++) {
-                    enlistMetadataDataset(primaryIndexes[i], false, mdTxnCtx);
-                }
-
-                if (LOGGER.isLoggable(Level.INFO)) {
-                    LOGGER.info("Finished enlistment of metadata B-trees in old universe.");
-                }
             }
-
             // #. initialize datasetIdFactory
             MetadataManager.INSTANCE.initializeDatasetIdFactory(mdTxnCtx);
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
@@ -211,24 +193,26 @@ public class MetadataBootstrap {
         // metadata datasets will be closed when the dataset life cycle manger is closed
     }
 
-    public static void insertInitialDataverses(MetadataTransactionContext mdTxnCtx) throws Exception {
+    private static void insertInitialDataverses(MetadataTransactionContext mdTxnCtx) throws Exception {
         String dataverseName = MetadataPrimaryIndexes.DATAVERSE_DATASET.getDataverseName();
         String dataFormat = NonTaggedDataFormat.NON_TAGGED_DATA_FORMAT;
         MetadataManager.INSTANCE.addDataverse(mdTxnCtx,
                 new Dataverse(dataverseName, dataFormat, IMetadataEntity.PENDING_NO_OP));
     }
 
-    public static void insertInitialDatasets(MetadataTransactionContext mdTxnCtx) throws Exception {
-        for (int i = 0; i < primaryIndexes.length; i++) {
+    public static void insertMetadataDatasets(MetadataTransactionContext mdTxnCtx, IMetadataIndex[] indexes)
+            throws Exception {
+        for (int i = 0; i < indexes.length; i++) {
             IDatasetDetails id = new InternalDatasetDetails(FileStructure.BTREE, PartitioningStrategy.HASH,
-                    primaryIndexes[i].getPartitioningExpr(), primaryIndexes[i].getPartitioningExpr(), null,
-                    primaryIndexes[i].getPartitioningExprType(), false, null, false);
-            MetadataManager.INSTANCE.addDataset(mdTxnCtx, new Dataset(primaryIndexes[i].getDataverseName(),
-                    primaryIndexes[i].getIndexedDatasetName(), primaryIndexes[i].getDataverseName(),
-                    primaryIndexes[i].getPayloadRecordType().getTypeName(), primaryIndexes[i].getNodeGroupName(),
-                    GlobalConfig.DEFAULT_COMPACTION_POLICY_NAME, GlobalConfig.DEFAULT_COMPACTION_POLICY_PROPERTIES, id,
-                    new HashMap<String, String>(), DatasetType.INTERNAL, primaryIndexes[i].getDatasetId().getId(),
-                    IMetadataEntity.PENDING_NO_OP));
+                    indexes[i].getPartitioningExpr(), indexes[i].getPartitioningExpr(), null,
+                    indexes[i].getPartitioningExprType(), false, null, false);
+            MetadataManager.INSTANCE.addDataset(mdTxnCtx,
+                    new Dataset(indexes[i].getDataverseName(), indexes[i].getIndexedDatasetName(),
+                            indexes[i].getDataverseName(), indexes[i].getPayloadRecordType().getTypeName(),
+                            indexes[i].getNodeGroupName(), GlobalConfig.DEFAULT_COMPACTION_POLICY_NAME,
+                            GlobalConfig.DEFAULT_COMPACTION_POLICY_PROPERTIES, id, new HashMap<String, String>(),
+                            DatasetType.INTERNAL, indexes[i].getDatasetId().getId(),
+                            IMetadataEntity.PENDING_NO_OP));
         }
         if (LOGGER.isLoggable(Level.INFO)) {
             LOGGER.info("Finished inserting initial datasets.");
@@ -244,12 +228,12 @@ public class MetadataBootstrap {
     }
 
     public static void getMetadataTypes(ArrayList<IAType> types) throws Exception {
-        for (int i = 0; i < primaryIndexes.length; i++) {
-            types.add(primaryIndexes[i].getPayloadRecordType());
+        for (int i = 0; i < PRIMARY_INDEXES.length; i++) {
+            types.add(PRIMARY_INDEXES[i].getPayloadRecordType());
         }
     }
 
-    public static void insertInitialDatatypes(MetadataTransactionContext mdTxnCtx) throws Exception {
+    public static void insertMetadataDatatypes(MetadataTransactionContext mdTxnCtx) throws Exception {
         String dataverseName = MetadataPrimaryIndexes.DATAVERSE_DATASET.getDataverseName();
         ArrayList<IAType> types = new ArrayList<IAType>();
         getBuiltinTypes(types);
@@ -313,9 +297,9 @@ public class MetadataBootstrap {
     }
 
     private static void insertInitialCompactionPolicies(MetadataTransactionContext mdTxnCtx) throws Exception {
-        String[] builtInCompactionPolicyClassNames = new String[] { ConstantMergePolicyFactory.class.getName(),
-                PrefixMergePolicyFactory.class.getName(), NoMergePolicyFactory.class.getName(),
-                CorrelatedPrefixMergePolicyFactory.class.getName() };
+        String[] builtInCompactionPolicyClassNames =
+                new String[] { ConstantMergePolicyFactory.class.getName(), PrefixMergePolicyFactory.class.getName(),
+                        NoMergePolicyFactory.class.getName(), CorrelatedPrefixMergePolicyFactory.class.getName() };
         CompactionPolicy compactionPolicy;
         for (String policyClassName : builtInCompactionPolicyClassNames) {
             compactionPolicy = getCompactionPolicyEntity(policyClassName);
@@ -330,13 +314,12 @@ public class MetadataBootstrap {
     }
 
     private static CompactionPolicy getCompactionPolicyEntity(String compactionPolicyClassName) throws Exception {
-        String policyName = ((ILSMMergePolicyFactory) (Class.forName(compactionPolicyClassName).newInstance()))
-                .getName();
+        String policyName =
+                ((ILSMMergePolicyFactory) (Class.forName(compactionPolicyClassName).newInstance())).getName();
         return new CompactionPolicy(MetadataConstants.METADATA_DATAVERSE_NAME, policyName, compactionPolicyClassName);
     }
 
-    private static void enlistMetadataDataset(IMetadataIndex index, boolean create, MetadataTransactionContext mdTxnCtx)
-            throws Exception {
+    public static void enlistMetadataDataset(IMetadataIndex index) throws HyracksDataException {
         ClusterPartition metadataPartition = propertiesProvider.getMetadataProperties().getMetadataPartition();
         int metadataDeviceId = metadataPartition.getIODeviceNum();
         String metadataPartitionPath = StoragePathUtil.prepareStoragePartitionPath(
@@ -349,14 +332,14 @@ public class MetadataBootstrap {
         ITypeTraits[] typeTraits = index.getTypeTraits();
         IBinaryComparatorFactory[] comparatorFactories = index.getKeyBinaryComparatorFactory();
         int[] bloomFilterKeyFields = index.getBloomFilterKeyFields();
-        LSMBTree lsmBtree = null;
-        long resourceID = -1;
-        ILSMOperationTracker opTracker = index.isPrimaryIndex()
-                ? runtimeContext.getLSMBTreeOperationTracker(index.getDatasetId().getId())
-                : new BaseOperationTracker(index.getDatasetId().getId(),
-                        dataLifecycleManager.getDatasetInfo(index.getDatasetId().getId()));
+        LSMBTree lsmBtree;
+        long resourceID;
+        ILSMOperationTracker opTracker =
+                index.isPrimaryIndex() ? runtimeContext.getLSMBTreeOperationTracker(index.getDatasetId().getId())
+                        : new BaseOperationTracker(index.getDatasetId().getId(),
+                                dataLifecycleManager.getDatasetInfo(index.getDatasetId().getId()));
         final String absolutePath = file.getFile().getPath();
-        if (create) {
+        if (isNewUniverse()) {
             lsmBtree = LSMBTreeUtils.createLSMTree(virtualBufferCaches, file, bufferCache, fileMapProvider, typeTraits,
                     comparatorFactories, bloomFilterKeyFields, runtimeContext.getBloomFilterFalsePositiveRate(),
                     runtimeContext.getMetadataMergePolicyFactory()
@@ -370,8 +353,8 @@ public class MetadataBootstrap {
                     comparatorFactories, bloomFilterKeyFields, index.isPrimaryIndex(), index.getDatasetId().getId(),
                     runtimeContext.getMetadataMergePolicyFactory(), GlobalConfig.DEFAULT_COMPACTION_POLICY_PROPERTIES,
                     null, null, null, null);
-            ILocalResourceFactoryProvider localResourceFactoryProvider = new PersistentLocalResourceFactoryProvider(
-                    localResourceMetadata, LocalResource.LSMBTreeResource);
+            ILocalResourceFactoryProvider localResourceFactoryProvider =
+                    new PersistentLocalResourceFactoryProvider(localResourceMetadata, LocalResource.LSMBTreeResource);
             ILocalResourceFactory localResourceFactory = localResourceFactoryProvider.getLocalResourceFactory();
             localResourceRepository.insert(localResourceFactory.createLocalResource(resourceID, resourceName,
                     metadataPartition.getPartitionId(), LIFOMetaDataFrame.VERSION, absolutePath));
@@ -379,7 +362,7 @@ public class MetadataBootstrap {
         } else {
             final LocalResource resource = localResourceRepository.getResourceByPath(absolutePath);
             if (resource == null) {
-                throw new Exception("Could not find required metadata indexes. Please delete "
+                throw new HyracksDataException("Could not find required metadata indexes. Please delete "
                         + propertiesProvider.getMetadataProperties().getTransactionLogDirs()
                                 .get(runtimeContext.getTransactionSubsystem().getId())
                         + " to intialize as a new instance. (WARNING: all data will be lost.)");
@@ -398,7 +381,6 @@ public class MetadataBootstrap {
                 dataLifecycleManager.register(absolutePath, lsmBtree);
             }
         }
-
         index.setResourceID(resourceID);
         index.setFile(file);
     }
@@ -418,9 +400,7 @@ public class MetadataBootstrap {
         String datasetName = null;
         String indexName = null;
         MetadataTransactionContext mdTxnCtx = null;
-
         MetadataManager.INSTANCE.acquireWriteLatch();
-
         if (LOGGER.isLoggable(Level.INFO)) {
             LOGGER.info("Starting DDL recovery ...");
         }
@@ -448,8 +428,8 @@ public class MetadataBootstrap {
                                 LOGGER.info("Dropped a pending dataset: " + dataverseName + "." + datasetName);
                             }
                         } else {
-                            List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName,
-                                    datasetName);
+                            List<Index> indexes =
+                                    MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName, datasetName);
                             for (Index index : indexes) {
                                 indexName = index.getIndexName();
                                 if (index.getPendingOp() != IMetadataEntity.PENDING_NO_OP) {
@@ -464,11 +444,11 @@ public class MetadataBootstrap {
                         }
                         if (dataset.getDatasetType() == DatasetType.EXTERNAL) {
                             // if the dataset has no indexes, delete all its files
-                            List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName,
-                                    datasetName);
+                            List<Index> indexes =
+                                    MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName, datasetName);
                             if (indexes.size() == 0) {
-                                List<ExternalFile> files = MetadataManager.INSTANCE.getDatasetExternalFiles(mdTxnCtx,
-                                        dataset);
+                                List<ExternalFile> files =
+                                        MetadataManager.INSTANCE.getDatasetExternalFiles(mdTxnCtx, dataset);
                                 for (ExternalFile file : files) {
                                     MetadataManager.INSTANCE.dropExternalFile(mdTxnCtx, file);
                                     if (LOGGER.isLoggable(Level.INFO)) {
@@ -500,4 +480,12 @@ public class MetadataBootstrap {
             MetadataManager.INSTANCE.releaseWriteLatch();
         }
     }
+
+    public static boolean isNewUniverse() {
+        return isNewUniverse;
+    }
+
+    public static void setNewUniverse(boolean isNewUniverse) {
+        MetadataBootstrap.isNewUniverse = isNewUniverse;
+    }
 }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndex.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndex.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndex.java
index 0a3d622..6c8bebd 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndex.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndex.java
@@ -24,14 +24,13 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import org.apache.asterix.common.config.MetadataConstants;
 import org.apache.asterix.common.transactions.DatasetId;
 import org.apache.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
 import org.apache.asterix.formats.nontagged.AqlBinaryHashFunctionFactoryProvider;
 import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
 import org.apache.asterix.formats.nontagged.AqlTypeTraitProvider;
-import org.apache.asterix.metadata.MetadataException;
 import org.apache.asterix.metadata.api.IMetadataIndex;
+import org.apache.asterix.metadata.utils.MetadataConstants;
 import org.apache.asterix.om.types.ARecordType;
 import org.apache.asterix.om.types.IAType;
 import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
@@ -44,7 +43,9 @@ import org.apache.hyracks.api.io.FileReference;
 /**
  * Descriptor for a primary or secondary index on metadata datasets.
  */
-public final class MetadataIndex implements IMetadataIndex {
+public class MetadataIndex implements IMetadataIndex {
+
+    private static final long serialVersionUID = 1L;
     // Name of dataset that is indexed.
     protected final String datasetName;
     // Name of index. null for primary indexes. non-null for secondary indexes.
@@ -52,6 +53,7 @@ public final class MetadataIndex implements IMetadataIndex {
     // Types of key fields.
     protected final IAType[] keyTypes;
     // Names of key fields. Used to compute partitionExprs.
+    // Note: used list implementation must implement java.io.Serializable
     protected final List<List<String>> keyNames;
     // Field permutation for BTree insert. Auto-created based on numFields.
     protected final int[] fieldPermutation;
@@ -82,13 +84,13 @@ public final class MetadataIndex implements IMetadataIndex {
 
     public MetadataIndex(MetadataIndexImmutableProperties indexImmutableProperties, int numFields, IAType[] keyTypes,
             List<List<String>> keyNames, int numSecondaryIndexKeys, ARecordType payloadType, boolean isPrimaryIndex,
-            int[] primaryKeyIndexes) throws MetadataException {
+            int[] primaryKeyIndexes) {
         // Sanity checks.
         if (keyTypes.length != keyNames.size()) {
-            throw new MetadataException("Unequal number of key types and names given.");
+            throw new AssertionError("Unequal number of key names and key types");
         }
         if (keyTypes.length > numFields) {
-            throw new MetadataException("Number of keys given is greater than total number of fields.");
+            throw new AssertionError("Key size is larger than total number of fields");
         }
         // Set simple fields.
         this.datasetName = indexImmutableProperties.getDatasetName();
@@ -101,7 +103,7 @@ public final class MetadataIndex implements IMetadataIndex {
         for (int i = 0; i < numFields; i++) {
             fieldPermutation[i] = i;
         }
-        // Create serdes for RecordDescriptor;
+        // Create serdes for RecordDescriptor
         @SuppressWarnings("rawtypes")
         ISerializerDeserializer[] serdes = new ISerializerDeserializer[numFields];
         for (int i = 0; i < keyTypes.length; i++) {
@@ -189,7 +191,7 @@ public final class MetadataIndex implements IMetadataIndex {
 
     @Override
     public List<List<String>> getPartitioningExpr() {
-        ArrayList<List<String>> partitioningExpr = new ArrayList<List<String>>();
+        ArrayList<List<String>> partitioningExpr = new ArrayList<>();
         for (int i = 0; i < keyNames.size(); i++) {
             partitioningExpr.add(keyNames.get(i));
         }

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/ab81748a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndexImmutableProperties.java
----------------------------------------------------------------------
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndexImmutableProperties.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndexImmutableProperties.java
index 2c2468c..53a3cbd 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndexImmutableProperties.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataIndexImmutableProperties.java
@@ -18,46 +18,19 @@
  */
 package org.apache.asterix.metadata.bootstrap;
 
-import org.apache.asterix.common.config.MetadataConstants;
-
-public enum MetadataIndexImmutableProperties {
-    METADATA(MetadataConstants.METADATA_DATAVERSE_NAME, 0, 0),
-    DATAVERSE("Dataverse", 1, 1),
-    DATASET("Dataset", 2, 2),
-    DATATYPE("Datatype", 3, 3),
-    INDEX("Index", 4, 4),
-    NODE("Node", 5, 5),
-    NODEGROUP("Nodegroup", 6, 6),
-    FUNCTION("Function", 7, 7),
-    DATASOURCE_ADAPTER("DatasourceAdapter", 8, 8),
-    LIBRARY("Library", 9, 9),
-    FEED("Feed", 10, 10),
-    FEED_ACTIVITY_DATASET_ID("FeedActivity", 11, 11),
-    FEED_POLICY("FeedPolicy", 12, 12),
-    COMPACTION_POLICY("CompactionPolicy", 13, 13),
-    EXTERNAL_FILE("ExternalFile", 14, 14);
-
+public class MetadataIndexImmutableProperties {
     private final String indexName;
     private final int datasetId;
     private final long resourceId;
-    private final MetadataIndexImmutableProperties dataset;
 
+    // TODO(till? should we reconsider these numbers?!)
+    public static final int FIRST_AVAILABLE_EXTENSION_METADATA_DATASET_ID = 52;
     public static final int FIRST_AVAILABLE_USER_DATASET_ID = 100;
 
-    private MetadataIndexImmutableProperties(String indexName, int datasetId, long resourceId) {
+    public MetadataIndexImmutableProperties(String indexName, int datasetId, long resourceId) {
         this.indexName = indexName;
         this.datasetId = datasetId;
         this.resourceId = resourceId;
-        //a primary index's dataset is itself
-        this.dataset = this;
-    }
-
-    private MetadataIndexImmutableProperties(String indexName, MetadataIndexImmutableProperties dataset,
-            long resourceId) {
-        this.indexName = indexName;
-        this.datasetId = dataset.datasetId;
-        this.resourceId = resourceId;
-        this.dataset = dataset;
     }
 
     public long getResourceId() {
@@ -68,11 +41,12 @@ public enum MetadataIndexImmutableProperties {
         return indexName;
     }
 
-    public String getDatasetName() {
-        return dataset.indexName;
+    public int getDatasetId() {
+        return datasetId;
     }
 
-    public int getDatasetId() {
-        return dataset.datasetId;
+    // Right now, we only have primary indexes. Hence, dataset name is always index name
+    public String getDatasetName() {
+        return indexName;
     }
 }


Mime
View raw message