set proxy for MetadataNode after MetadataBootstrap is done
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index 96d0617..3502abb 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -129,16 +129,26 @@
isMetadataNode = nodeId.equals(metadataProperties.getMetadataNodeName());
if (isMetadataNode) {
- registerRemoteMetadataNode(proxy);
-
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Bootstrapping metadata");
}
- MetadataManager.INSTANCE = new MetadataManager(proxy, metadataProperties);
- MetadataManager.INSTANCE.init();
+ MetadataNode.INSTANCE.initialize(runtimeContext);
+
+ // This is a special case, we just give the metadataNode directly.
+ // This way we can delay the registration of the metadataNode until
+ // it is completely initialized.
+ MetadataManager.INSTANCE = new MetadataManager(proxy, MetadataNode.INSTANCE);
MetadataBootstrap.startUniverse(((IAsterixPropertiesProvider) runtimeContext), ncApplicationContext,
systemState == SystemState.NEW_UNIVERSE);
MetadataBootstrap.startDDLRecovery();
+
+ IMetadataNode stub = null;
+ stub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE, 0);
+ proxy.setMetadataNode(stub);
+
+ if (LOGGER.isLoggable(Level.INFO)) {
+ LOGGER.info("Metadata node bound");
+ }
}
if (LOGGER.isLoggable(Level.INFO)) {
@@ -166,17 +176,6 @@
// reclaim storage for orphaned index artifacts in NCs.
}
- public void registerRemoteMetadataNode(IAsterixStateProxy proxy) throws RemoteException {
- IMetadataNode stub = null;
- MetadataNode.INSTANCE.initialize(runtimeContext);
- stub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE, 0);
- proxy.setMetadataNode(stub);
-
- if (LOGGER.isLoggable(Level.INFO)) {
- LOGGER.info("Metadata node bound");
- }
- }
-
/**
* Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop} method.
*/
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java
index 924a89c..bba6660 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java
@@ -89,6 +89,16 @@
this.metadataLatch = new ReentrantReadWriteLock(true);
}
+ public MetadataManager(IAsterixStateProxy proxy, IMetadataNode metadataNode) {
+ if (metadataNode == null) {
+ throw new Error("Null metadataNode given to MetadataManager.");
+ }
+ this.proxy = proxy;
+ this.metadataProperties = null;
+ this.metadataNode = metadataNode;
+ this.metadataLatch = new ReentrantReadWriteLock(true);
+ }
+
@Override
public void init() throws RemoteException, MetadataException {
// Could be synchronized on any object. Arbitrarily chose proxy.
@@ -99,7 +109,7 @@
try {
int retry = 0;
int sleep = 64;
- while (retry++ < 5) {
+ while (retry++ < 10) {
metadataNode = proxy.getMetadataNode();
if (metadataNode != null) {
break;