[NO ISSUE][MTD] Restrict Metadata Catalog Update to Synonym Dataset

- Only allow Metadata.Synonym datasets to be added to
  an existing cluster. This is done to detect the case
  when another metadata dataset that is expected to be
  there but is not found.

Change-Id: I142d2537816cc302ef9e02e7faf18af03cb72350
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/5604
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Reviewed-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
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 c3926a4..69fc396 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
@@ -361,6 +361,9 @@
         } else {
             resource = localResourceRepository.get(file.getRelativePath());
             createMetadataDataset = resource == null;
+            if (createMetadataDataset) {
+                ensureCatalogUpgradability(index);
+            }
         }
         if (createMetadataDataset) {
             final double bloomFilterFalsePositiveRate =
@@ -489,4 +492,10 @@
         MetadataBootstrap.isNewUniverse = isNewUniverse;
     }
 
+    private static void ensureCatalogUpgradability(IMetadataIndex index) {
+        if (index != MetadataPrimaryIndexes.SYNONYM_DATASET) {
+            throw new IllegalStateException(
+                    "attempt to create metadata index " + index.getIndexName() + ". Index should already exist");
+        }
+    }
 }