Separate static cluster properties from runtime state
This change includes the following:
- Remove cluster static properties from AsterixClusterProperties.
- Add new ClusterProperties class for static cluster properties.
- Rename AsterixClusterProperties to ClusterStateManager.
- Refactor cluster static properties.
Change-Id: I3da72f639476f081ba8a0ef21ec176d32ff8bdec
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1183
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: abdullah alamoudi <bamousaa@gmail.com>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AbstractLangTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AbstractLangTranslator.java
index 10b601b..db33184 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AbstractLangTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/AbstractLangTranslator.java
@@ -38,7 +38,7 @@
import org.apache.asterix.metadata.utils.MetadataConstants;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.runtime.util.AsterixAppContextInfo;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.algebricks.common.utils.Pair;
/**
@@ -53,12 +53,12 @@
public void validateOperation(Dataverse defaultDataverse, Statement stmt) throws AsterixException {
- if (!(AsterixClusterProperties.INSTANCE.getState().equals(ClusterState.ACTIVE)
- && AsterixClusterProperties.INSTANCE.isGlobalRecoveryCompleted())) {
+ if (!(ClusterStateManager.INSTANCE.getState().equals(ClusterState.ACTIVE)
+ && ClusterStateManager.INSTANCE.isGlobalRecoveryCompleted())) {
int maxWaitCycles = AsterixAppContextInfo.INSTANCE.getExternalProperties().getMaxWaitClusterActive();
int waitCycleCount = 0;
try {
- while (!AsterixClusterProperties.INSTANCE.getState().equals(ClusterState.ACTIVE)
+ while (!ClusterStateManager.INSTANCE.getState().equals(ClusterState.ACTIVE)
&& waitCycleCount < maxWaitCycles) {
Thread.sleep(1000);
waitCycleCount++;
@@ -68,7 +68,7 @@
LOGGER.warning("Thread interrupted while waiting for cluster to be " + ClusterState.ACTIVE);
}
}
- if (!AsterixClusterProperties.INSTANCE.getState().equals(ClusterState.ACTIVE)) {
+ if (!ClusterStateManager.INSTANCE.getState().equals(ClusterState.ACTIVE)) {
throw new AsterixException(" Asterix Cluster is in " + ClusterState.UNUSABLE + " state."
+ "\n One or more Node Controllers have left or haven't joined yet.\n");
} else {
@@ -78,16 +78,16 @@
}
}
- if (AsterixClusterProperties.INSTANCE.getState().equals(ClusterState.UNUSABLE)) {
+ if (ClusterStateManager.INSTANCE.getState().equals(ClusterState.UNUSABLE)) {
throw new AsterixException(" Asterix Cluster is in " + ClusterState.UNUSABLE + " state."
+ "\n One or more Node Controllers have left.\n");
}
- if (!AsterixClusterProperties.INSTANCE.isGlobalRecoveryCompleted()) {
+ if (!ClusterStateManager.INSTANCE.isGlobalRecoveryCompleted()) {
int maxWaitCycles = AsterixAppContextInfo.INSTANCE.getExternalProperties().getMaxWaitClusterActive();
int waitCycleCount = 0;
try {
- while (!AsterixClusterProperties.INSTANCE.isGlobalRecoveryCompleted()
+ while (!ClusterStateManager.INSTANCE.isGlobalRecoveryCompleted()
&& waitCycleCount < maxWaitCycles) {
Thread.sleep(1000);
waitCycleCount++;
@@ -97,7 +97,7 @@
LOGGER.warning("Thread interrupted while waiting for cluster to complete global recovery ");
}
}
- if (!AsterixClusterProperties.INSTANCE.isGlobalRecoveryCompleted()) {
+ if (!ClusterStateManager.INSTANCE.isGlobalRecoveryCompleted()) {
throw new AsterixException(" Asterix Cluster Global recovery is not yet complete and The system is in "
+ ClusterState.ACTIVE + " state");
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterAPIServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterAPIServlet.java
index 86b6602..64cde54 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterAPIServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ClusterAPIServlet.java
@@ -32,7 +32,7 @@
import org.apache.asterix.app.result.ResultUtil;
import org.apache.asterix.common.config.AbstractAsterixProperties;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -90,7 +90,7 @@
protected JSONObject getClusterStateJSON(HttpServletRequest request, String pathToNode)
throws JSONException {
JSONObject json;
- json = AsterixClusterProperties.INSTANCE.getClusterStateDescription();
+ json = ClusterStateManager.INSTANCE.getClusterStateDescription();
Map<String, Object> allProperties = getAllClusterProperties();
json.put("config", allProperties);
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
index 7d2a272..d8cb553 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/http/servlet/ShutdownAPIServlet.java
@@ -32,7 +32,7 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.asterix.common.config.GlobalConfig;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.api.client.IHyracksClientConnection;
import org.json.JSONObject;
@@ -61,7 +61,7 @@
try {
jsonObject.put("status", "SHUTTING_DOWN");
jsonObject.put("date", new Date());
- jsonObject.put("cluster", AsterixClusterProperties.INSTANCE.getClusterStateDescription());
+ jsonObject.put("cluster", ClusterStateManager.INSTANCE.getClusterStateDescription());
final PrintWriter writer = response.getWriter();
writer.print(jsonObject.toString(4));
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/AsterixResourceIdManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/AsterixResourceIdManager.java
index a773bab..99db723 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/AsterixResourceIdManager.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/AsterixResourceIdManager.java
@@ -23,7 +23,7 @@
import java.util.concurrent.atomic.AtomicLong;
import org.apache.asterix.common.transactions.IAsterixResourceIdManager;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
public class AsterixResourceIdManager implements IAsterixResourceIdManager {
@@ -36,7 +36,7 @@
if (!allReported) {
synchronized (this) {
if (!allReported) {
- if (reportedNodes.size() < AsterixClusterProperties.getNumberOfNodes()) {
+ if (reportedNodes.size() < ClusterStateManager.getNumberOfNodes()) {
return -1;
} else {
reportedNodes = null;
@@ -58,7 +58,7 @@
if (!allReported) {
globalResourceId.set(Math.max(maxResourceId, globalResourceId.get()));
reportedNodes.add(nodeId);
- if (reportedNodes.size() == AsterixClusterProperties.getNumberOfNodes()) {
+ if (reportedNodes.size() == ClusterStateManager.getNumberOfNodes()) {
reportedNodes = null;
allReported = true;
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedOperations.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedOperations.java
index 110ace6..1d98aac 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedOperations.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/external/FeedOperations.java
@@ -42,7 +42,7 @@
import org.apache.asterix.file.JobSpecificationUtils;
import org.apache.asterix.metadata.declared.AqlMetadataProvider;
import org.apache.asterix.metadata.entities.Feed;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraintHelper;
@@ -160,7 +160,7 @@
public static JobSpecification buildRemoveFeedStorageJob(Feed feed) throws Exception {
JobSpecification spec = JobSpecificationUtils.createJobSpecification();
- AlgebricksAbsolutePartitionConstraint allCluster = AsterixClusterProperties.INSTANCE.getClusterLocations();
+ AlgebricksAbsolutePartitionConstraint allCluster = ClusterStateManager.INSTANCE.getClusterLocations();
Set<String> nodes = new TreeSet<>();
for (String node : allCluster.getLocations()) {
nodes.add(node);
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/AsterixNCAppRuntimeContext.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/AsterixNCAppRuntimeContext.java
index ce20c9c..343fdb3 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/AsterixNCAppRuntimeContext.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/nc/AsterixNCAppRuntimeContext.java
@@ -44,6 +44,7 @@
import org.apache.asterix.common.config.AsterixReplicationProperties;
import org.apache.asterix.common.config.AsterixStorageProperties;
import org.apache.asterix.common.config.AsterixTransactionProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.config.IAsterixPropertiesProvider;
import org.apache.asterix.common.config.MessagingProperties;
import org.apache.asterix.common.context.AsterixFileMapManager;
@@ -71,7 +72,6 @@
import org.apache.asterix.replication.recovery.RemoteRecoveryManager;
import org.apache.asterix.replication.storage.ReplicaResourcesManager;
import org.apache.asterix.runtime.transaction.GlobalResourceIdFactoryProvider;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepositoryFactory;
import org.apache.asterix.transaction.management.service.transaction.TransactionSubsystem;
@@ -161,8 +161,7 @@
txnProperties = new AsterixTransactionProperties(propertiesAccessor);
feedProperties = new AsterixFeedProperties(propertiesAccessor);
buildProperties = new AsterixBuildProperties(propertiesAccessor);
- replicationProperties = new AsterixReplicationProperties(propertiesAccessor,
- AsterixClusterProperties.INSTANCE.getCluster());
+ replicationProperties = new AsterixReplicationProperties(propertiesAccessor);
messagingProperties = new MessagingProperties(propertiesAccessor);
this.metadataRmiPort = metadataRmiPort;
libraryManager = new ExternalLibraryManager();
@@ -220,7 +219,7 @@
activeManager = new ActiveManager(ncApplicationContext.getNodeId(),
feedProperties.getMemoryComponentGlobalBudget(), compilerProperties.getFrameSize());
- if (replicationProperties.isReplicationEnabled()) {
+ if (ClusterProperties.INSTANCE.isReplicationEnabled()) {
String nodeId = ncApplicationContext.getNodeId();
replicaResourcesManager = new ReplicaResourcesManager(localResourceRepository, metadataProperties);
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
index 90bf6f6..27f7ca6 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/translator/QueryTranslator.java
@@ -55,6 +55,7 @@
import org.apache.asterix.app.result.ResultUtil;
import org.apache.asterix.common.app.SessionConfig;
import org.apache.asterix.common.config.AsterixExternalProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
import org.apache.asterix.common.config.DatasetConfig.ExternalDatasetTransactionState;
import org.apache.asterix.common.config.DatasetConfig.ExternalFilePendingOp;
@@ -160,7 +161,6 @@
import org.apache.asterix.om.types.TypeSignature;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.asterix.runtime.util.AsterixAppContextInfo;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
import org.apache.asterix.transaction.management.service.transaction.DatasetIdFactory;
import org.apache.asterix.translator.AbstractLangTranslator;
import org.apache.asterix.translator.CompiledStatements.CompiledConnectFeedStatement;
@@ -3030,8 +3030,7 @@
String fromDatasetName, String toDataverseName, String toDatasetName) {
// Constructs AsterixDB parameters, e.g., URL, source dataset and sink dataset.
AsterixExternalProperties externalProperties = AsterixAppContextInfo.INSTANCE.getExternalProperties();
- AsterixClusterProperties clusterProperties = AsterixClusterProperties.INSTANCE;
- String clientIP = clusterProperties.getCluster().getMasterNode().getClientIp();
+ String clientIP = ClusterProperties.INSTANCE.getCluster().getMasterNode().getClientIp();
StringBuilder asterixdbParameterBuilder = new StringBuilder();
asterixdbParameterBuilder.append(
"pregelix.asterixdb.url=" + "http://" + clientIP + ":" + externalProperties.getAPIServerPort() + ",");
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
index bd910a5..f6dfe4a 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
@@ -53,6 +53,7 @@
import org.apache.asterix.common.config.AsterixExtension;
import org.apache.asterix.common.config.AsterixExternalProperties;
import org.apache.asterix.common.config.AsterixMetadataProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.library.ILibraryManager;
import org.apache.asterix.common.utils.ServletUtil.Servlets;
import org.apache.asterix.event.service.ILookupService;
@@ -63,7 +64,6 @@
import org.apache.asterix.metadata.bootstrap.AsterixStateProxy;
import org.apache.asterix.metadata.cluster.ClusterManager;
import org.apache.asterix.runtime.util.AsterixAppContextInfo;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
import org.apache.hyracks.api.application.ICCApplicationContext;
import org.apache.hyracks.api.application.ICCApplicationEntryPoint;
import org.apache.hyracks.api.client.HyracksConnection;
@@ -324,7 +324,7 @@
ILookupService zookeeperService = ClusterManager.getLookupService();
if (zookeeperService != null) {
// Our asterix app runtimes tests don't use zookeeper
- zookeeperService.reportClusterState(AsterixClusterProperties.INSTANCE.getCluster().getInstanceName(),
+ zookeeperService.reportClusterState(ClusterProperties.INSTANCE.getCluster().getInstanceName(),
ClusterState.ACTIVE);
}
}
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ClusterLifecycleListener.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ClusterLifecycleListener.java
index 5fc91a4..4eaab2d 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ClusterLifecycleListener.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ClusterLifecycleListener.java
@@ -31,6 +31,7 @@
import org.apache.asterix.common.api.IClusterManagementWork;
import org.apache.asterix.common.api.IClusterManagementWorkResponse;
import org.apache.asterix.common.api.IClusterManagementWorkResponse.Status;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.event.schema.cluster.Node;
import org.apache.asterix.metadata.MetadataManager;
@@ -39,7 +40,7 @@
import org.apache.asterix.metadata.cluster.ClusterManager;
import org.apache.asterix.metadata.cluster.RemoveNodeWork;
import org.apache.asterix.metadata.cluster.RemoveNodeWorkResponse;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.api.application.IClusterLifecycleListener;
public class ClusterLifecycleListener implements IClusterLifecycleListener {
@@ -67,9 +68,9 @@
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("NC: " + nodeId + " joined");
}
- AsterixClusterProperties.INSTANCE.addNCConfiguration(nodeId, ncConfiguration);
+ ClusterStateManager.INSTANCE.addNCConfiguration(nodeId, ncConfiguration);
//if metadata node rejoining, we need to rebind the proxy connection when it is active again.
- MetadataManager.INSTANCE.rebindMetadataNode = !AsterixClusterProperties.INSTANCE.isMetadataNodeActive();
+ MetadataManager.INSTANCE.rebindMetadataNode = !ClusterStateManager.INSTANCE.isMetadataNodeActive();
Set<String> nodeAddition = new HashSet<String>();
nodeAddition.add(nodeId);
@@ -92,10 +93,10 @@
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("NC: " + deadNode + " left");
}
- AsterixClusterProperties.INSTANCE.removeNCConfiguration(deadNode);
+ ClusterStateManager.INSTANCE.removeNCConfiguration(deadNode);
//if metadata node failed, we need to rebind the proxy connection when it is active again
- MetadataManager.INSTANCE.rebindMetadataNode = !AsterixClusterProperties.INSTANCE.isMetadataNodeActive();
+ MetadataManager.INSTANCE.rebindMetadataNode = !ClusterStateManager.INSTANCE.isMetadataNodeActive();
}
updateProgress(ClusterEventType.NODE_FAILURE, deadNodeIds);
Set<IClusterEventsSubscriber> subscribers = ClusterManager.INSTANCE.getRegisteredClusterEventSubscribers();
@@ -160,9 +161,9 @@
}
List<String> addedNodes = new ArrayList<String>();
- String asterixInstanceName = AsterixClusterProperties.INSTANCE.getCluster().getInstanceName();
+ String asterixInstanceName = ClusterProperties.INSTANCE.getCluster().getInstanceName();
for (int i = 0; i < nodesToAdd; i++) {
- Node node = AsterixClusterProperties.INSTANCE.getAvailableSubstitutionNode();
+ Node node = ClusterStateManager.INSTANCE.getAvailableSubstitutionNode();
if (node != null) {
try {
ClusterManager.INSTANCE.addNode(node);
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ClusterWorkExecutor.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ClusterWorkExecutor.java
index 0e3bb3b..f41c4f6 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ClusterWorkExecutor.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/ClusterWorkExecutor.java
@@ -30,7 +30,7 @@
import org.apache.asterix.metadata.cluster.AddNodeWork;
import org.apache.asterix.metadata.cluster.ClusterManager;
import org.apache.asterix.metadata.cluster.RemoveNodeWork;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
public class ClusterWorkExecutor implements Runnable {
@@ -68,7 +68,7 @@
Set<Node> addedNodes = new HashSet<Node>();
for (int i = 0; i < nodesToAdd; i++) {
- Node node = AsterixClusterProperties.INSTANCE.getAvailableSubstitutionNode();
+ Node node = ClusterStateManager.INSTANCE.getAvailableSubstitutionNode();
if (node != null) {
try {
ClusterManager.INSTANCE.addNode(node);
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/GlobalRecoveryManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/GlobalRecoveryManager.java
index 7dde284..77374bf 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/GlobalRecoveryManager.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/GlobalRecoveryManager.java
@@ -41,7 +41,7 @@
import org.apache.asterix.metadata.entities.ExternalDatasetDetails;
import org.apache.asterix.metadata.entities.Index;
import org.apache.asterix.metadata.utils.MetadataConstants;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.api.client.HyracksConnection;
import org.apache.hyracks.api.job.JobId;
import org.apache.hyracks.api.job.JobSpecification;
@@ -60,8 +60,8 @@
@Override
public Set<IClusterManagementWork> notifyNodeFailure(Set<String> deadNodeIds) {
- setState(AsterixClusterProperties.INSTANCE.getState());
- AsterixClusterProperties.INSTANCE.setGlobalRecoveryCompleted(false);
+ setState(ClusterStateManager.INSTANCE.getState());
+ ClusterStateManager.INSTANCE.setGlobalRecoveryCompleted(false);
return Collections.emptySet();
}
@@ -90,7 +90,7 @@
@Override
public void startGlobalRecovery() {
// perform global recovery if state changed to active
- final ClusterState newState = AsterixClusterProperties.INSTANCE.getState();
+ final ClusterState newState = ClusterStateManager.INSTANCE.getState();
boolean needToRecover = !newState.equals(state) && (newState == ClusterState.ACTIVE);
if (needToRecover) {
Thread recoveryThread = new Thread(new Runnable() {
@@ -211,7 +211,7 @@
throw new IllegalStateException(e1);
}
}
- AsterixClusterProperties.INSTANCE.setGlobalRecoveryCompleted(true);
+ ClusterStateManager.INSTANCE.setGlobalRecoveryCompleted(true);
LOGGER.info("Global Recovery Completed");
}
}, "RecoveryThread");
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index c11b875..0a12bf2 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -33,11 +33,11 @@
import org.apache.asterix.common.config.AsterixExtension;
import org.apache.asterix.common.config.AsterixMetadataProperties;
import org.apache.asterix.common.config.AsterixTransactionProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.config.IAsterixPropertiesProvider;
import org.apache.asterix.common.config.MessagingProperties;
import org.apache.asterix.common.replication.IRemoteRecoveryManager;
import org.apache.asterix.common.transactions.IRecoveryManager;
-import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
import org.apache.asterix.common.transactions.IRecoveryManager.SystemState;
import org.apache.asterix.common.utils.StoragePathUtil;
import org.apache.asterix.event.schema.cluster.Cluster;
@@ -46,7 +46,7 @@
import org.apache.asterix.messaging.NCMessageBroker;
import org.apache.asterix.metadata.bootstrap.MetadataBootstrap;
import org.apache.asterix.runtime.message.ReportMaxResourceIdMessage;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
import org.apache.asterix.transaction.management.service.recovery.RecoveryManager;
import org.apache.commons.io.FileUtils;
import org.apache.hyracks.api.application.INCApplicationContext;
@@ -127,8 +127,8 @@
(NCMessageBroker) messageBroker, messagingProperties);
ncApplicationContext.setMessagingChannelInterfaceFactory(interfaceFactory);
- boolean replicationEnabled = AsterixClusterProperties.INSTANCE.isReplicationEnabled();
- boolean autoFailover = AsterixClusterProperties.INSTANCE.isAutoFailoverEnabled();
+ boolean replicationEnabled = ClusterProperties.INSTANCE.isReplicationEnabled();
+ boolean autoFailover = ClusterProperties.INSTANCE.isAutoFailoverEnabled();
if (initialRun) {
LOGGER.info("System is being initialized. (first run)");
} else {
@@ -225,7 +225,7 @@
PersistentLocalResourceRepository localResourceRepository =
(PersistentLocalResourceRepository) runtimeContext
.getLocalResourceRepository();
- localResourceRepository.initializeNewUniverse(AsterixClusterProperties.INSTANCE.getStorageDirectoryName());
+ localResourceRepository.initializeNewUniverse(ClusterProperties.INSTANCE.getStorageDirectoryName());
}
isMetadataNode = nodeId.equals(metadataProperties.getMetadataNodeName());
@@ -274,7 +274,7 @@
runtimeContext.getIOManager().deleteWorkspaceFiles();
//Reclaim storage for temporary datasets.
- String storageDirName = AsterixClusterProperties.INSTANCE.getStorageDirectoryName();
+ String storageDirName = ClusterProperties.INSTANCE.getStorageDirectoryName();
String[] ioDevices = ((PersistentLocalResourceRepository) runtimeContext.getLocalResourceRepository())
.getStorageMountingPoints();
for (String ioDevice : ioDevices) {
@@ -293,7 +293,7 @@
.getMetadataProperties();
if (!metadataProperties.getNodeNames().contains(nodeId)) {
metadataProperties.getNodeNames().add(nodeId);
- Cluster cluster = AsterixClusterProperties.INSTANCE.getCluster();
+ Cluster cluster = ClusterProperties.INSTANCE.getCluster();
if (cluster == null) {
throw new IllegalStateException("No cluster configuration found for this instance");
}
@@ -310,7 +310,7 @@
for (Node node : nodes) {
String ncId = asterixInstanceName + "_" + node.getId();
if (ncId.equalsIgnoreCase(nodeId)) {
- String storeDir = AsterixClusterProperties.INSTANCE.getStorageDirectoryName();
+ String storeDir = ClusterProperties.INSTANCE.getStorageDirectoryName();
String nodeIoDevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
String[] ioDevicePaths = nodeIoDevices.trim().split(",");
for (int i = 0; i < ioDevicePaths.length; i++) {
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/aql/translator/QueryTranslatorTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/aql/translator/QueryTranslatorTest.java
index 4e8875b..f3fd080 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/aql/translator/QueryTranslatorTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/aql/translator/QueryTranslatorTest.java
@@ -31,13 +31,13 @@
import org.apache.asterix.app.translator.DefaultStatementExecutorFactory;
import org.apache.asterix.common.app.SessionConfig;
import org.apache.asterix.common.config.AsterixExternalProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.compiler.provider.AqlCompilationProvider;
import org.apache.asterix.event.schema.cluster.Cluster;
import org.apache.asterix.event.schema.cluster.MasterNode;
import org.apache.asterix.lang.common.base.Statement;
import org.apache.asterix.lang.common.statement.RunStatement;
import org.apache.asterix.runtime.util.AsterixAppContextInfo;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
import org.apache.asterix.translator.IStatementExecutor;
import org.junit.Assert;
import org.junit.Test;
@@ -63,8 +63,8 @@
// Mocks AsterixClusterProperties.
Cluster mockCluster = mock(Cluster.class);
MasterNode mockMasterNode = mock(MasterNode.class);
- AsterixClusterProperties mockClusterProperties = mock(AsterixClusterProperties.class);
- setFinalStaticField(AsterixClusterProperties.class.getDeclaredField("INSTANCE"), mockClusterProperties);
+ ClusterProperties mockClusterProperties = mock(ClusterProperties.class);
+ setFinalStaticField(ClusterProperties.class.getDeclaredField("INSTANCE"), mockClusterProperties);
when(mockClusterProperties.getCluster()).thenReturn(mockCluster);
when(mockCluster.getMasterNode()).thenReturn(mockMasterNode);
when(mockMasterNode.getClientIp()).thenReturn("127.0.0.1");
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixReplicationProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixReplicationProperties.java
index 86ace28..0638091 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixReplicationProperties.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/AsterixReplicationProperties.java
@@ -63,9 +63,9 @@
private final String nodeNamePrefix;
private final Cluster cluster;
- public AsterixReplicationProperties(AsterixPropertiesAccessor accessor, Cluster cluster) {
+ public AsterixReplicationProperties(AsterixPropertiesAccessor accessor) {
super(accessor);
- this.cluster = cluster;
+ this.cluster = ClusterProperties.INSTANCE.getCluster();
if (cluster != null) {
nodeNamePrefix = cluster.getInstanceName() + "_";
@@ -76,21 +76,11 @@
@PropertyKey(REPLICATION_ENABLED_KEY)
public boolean isReplicationEnabled() {
- if (cluster != null && cluster.getDataReplication() != null) {
- if (getReplicationFactor() == 1) {
- return false;
- }
-
- return cluster.getDataReplication().isEnabled();
-
- } else {
- return false;
- }
+ return ClusterProperties.INSTANCE.isReplicationEnabled();
}
public String getReplicaIPAddress(String nodeId) {
if (cluster != null) {
-
for (int i = 0; i < cluster.getNode().size(); i++) {
Node node = cluster.getNode().get(i);
if (getRealCluserNodeID(node.getId()).equals(nodeId)) {
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ClusterProperties.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ClusterProperties.java
new file mode 100644
index 0000000..81c5a6d
--- /dev/null
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/config/ClusterProperties.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.common.config;
+
+import java.io.InputStream;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+
+import org.apache.asterix.event.schema.cluster.Cluster;
+
+public class ClusterProperties {
+
+ public static final ClusterProperties INSTANCE = new ClusterProperties();
+
+ private static final String CLUSTER_CONFIGURATION_FILE = "cluster.xml";
+ private static final String DEFAULT_STORAGE_DIR_NAME = "storage";
+
+ private final Cluster cluster;
+
+ private ClusterProperties() {
+ InputStream is = this.getClass().getClassLoader().getResourceAsStream(CLUSTER_CONFIGURATION_FILE);
+ if (is != null) {
+ try {
+ JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+ cluster = (Cluster) unmarshaller.unmarshal(is);
+ } catch (JAXBException e) {
+ throw new IllegalStateException("Failed to read configuration file " + CLUSTER_CONFIGURATION_FILE, e);
+ }
+ } else {
+ cluster = null;
+ }
+ }
+
+ public Cluster getCluster() {
+ return cluster;
+ }
+
+ public String getStorageDirectoryName() {
+ if (cluster != null) {
+ return cluster.getStore();
+ }
+ // virtual cluster without cluster config file
+ return DEFAULT_STORAGE_DIR_NAME;
+ }
+
+ public boolean isReplicationEnabled() {
+ if (cluster != null && cluster.getDataReplication() != null) {
+ return cluster.getDataReplication().isEnabled();
+ }
+ return false;
+ }
+
+ public boolean isAutoFailoverEnabled() {
+ return isReplicationEnabled() && cluster.getDataReplication().isAutoFailover();
+ }
+}
\ No newline at end of file
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IExternalDataSourceFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IExternalDataSourceFactory.java
index 6a237c6..edb79f2 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IExternalDataSourceFactory.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/api/IExternalDataSourceFactory.java
@@ -26,7 +26,7 @@
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.runtime.util.AsterixAppContextInfo;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -96,7 +96,7 @@
Iterator<String> storeIt = stores.iterator();
while (storeIt.hasNext()) {
String node = storeIt.next();
- int numIODevices = AsterixClusterProperties.INSTANCE.getIODevices(node).length;
+ int numIODevices = ClusterStateManager.INSTANCE.getIODevices(node).length;
for (int k = 0; k < numIODevices; k++) {
locs.add(node);
i++;
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/factory/TwitterFirehoseStreamFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/factory/TwitterFirehoseStreamFactory.java
index 5575d2c..abe67fd 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/factory/TwitterFirehoseStreamFactory.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/input/stream/factory/TwitterFirehoseStreamFactory.java
@@ -26,7 +26,7 @@
import org.apache.asterix.external.api.AsterixInputStream;
import org.apache.asterix.external.api.IInputStreamFactory;
import org.apache.asterix.external.input.stream.TwitterFirehoseInputStream;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -69,7 +69,7 @@
List<String> chosenLocations = new ArrayList<String>();
String[] availableLocations = locations != null ? locations
- : AsterixClusterProperties.INSTANCE.getParticipantNodes().toArray(new String[] {});
+ : ClusterStateManager.INSTANCE.getParticipantNodes().toArray(new String[] {});
for (int i = 0, k = 0; i < count; i++, k = (k + 1) % availableLocations.length) {
chosenLocations.add(availableLocations[k]);
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedUtils.java
index 44980c8..366534f 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/FeedUtils.java
@@ -25,9 +25,10 @@
import java.util.Map;
import org.apache.asterix.common.cluster.ClusterPartition;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.utils.StoragePathUtil;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint.PartitionConstraintType;
@@ -75,7 +76,7 @@
public static FileSplit splitsForAdapter(String dataverseName, String feedName, String nodeName,
ClusterPartition partition) {
File relPathFile = new File(prepareDataverseFeedName(dataverseName, feedName));
- String storageDirName = AsterixClusterProperties.INSTANCE.getStorageDirectoryName();
+ String storageDirName = ClusterProperties.INSTANCE.getStorageDirectoryName();
String storagePartitionPath =
StoragePathUtil.prepareStoragePartitionPath(storageDirName, partition.getPartitionId());
// Note: feed adapter instances in a single node share the feed logger
@@ -93,7 +94,7 @@
List<FileSplit> splits = new ArrayList<>();
for (String nd : locations) {
splits.add(splitsForAdapter(dataverseName, feedName, nd,
- AsterixClusterProperties.INSTANCE.getNodePartitions(nd)[0]));
+ ClusterStateManager.INSTANCE.getNodePartitions(nd)[0]));
}
return splits.toArray(new FileSplit[] {});
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
index 0848532..2ce0383 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/HDFSUtils.java
@@ -30,7 +30,7 @@
import org.apache.asterix.external.indexing.RecordId.RecordIdType;
import org.apache.asterix.external.input.stream.HDFSInputStream;
import org.apache.asterix.runtime.util.AsterixAppContextInfo;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hadoop.fs.BlockLocation;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
@@ -205,7 +205,7 @@
ArrayList<String> locs = new ArrayList<>();
Map<String, String[]> stores = AsterixAppContextInfo.INSTANCE.getMetadataProperties().getStores();
for (String node : stores.keySet()) {
- int numIODevices = AsterixClusterProperties.INSTANCE.getIODevices(node).length;
+ int numIODevices = ClusterStateManager.INSTANCE.getIODevices(node).length;
for (int k = 0; k < numIODevices; k++) {
locs.add(node);
}
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/input/record/reader/kv/KVTestReaderFactory.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/input/record/reader/kv/KVTestReaderFactory.java
index 61f5021..6841e6b 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/input/record/reader/kv/KVTestReaderFactory.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/input/record/reader/kv/KVTestReaderFactory.java
@@ -22,7 +22,7 @@
import org.apache.asterix.external.api.IRecordReader;
import org.apache.asterix.external.api.IRecordReaderFactory;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
import org.apache.hyracks.api.context.IHyracksTaskContext;
@@ -42,7 +42,7 @@
@Override
public AlgebricksAbsolutePartitionConstraint getPartitionConstraint() {
- clusterLocations = AsterixClusterProperties.INSTANCE.getClusterLocations();
+ clusterLocations = ClusterStateManager.INSTANCE.getClusterLocations();
numOfReaders = clusterLocations.getLocations().length;
return clusterLocations;
}
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 55b1045..c1dfd02 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
@@ -32,6 +32,7 @@
import org.apache.asterix.common.api.ILocalResourceMetadata;
import org.apache.asterix.common.cluster.ClusterPartition;
import org.apache.asterix.common.config.AsterixMetadataProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
import org.apache.asterix.common.config.GlobalConfig;
import org.apache.asterix.common.config.IAsterixPropertiesProvider;
@@ -68,7 +69,6 @@
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.formats.NonTaggedDataFormat;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
import org.apache.asterix.transaction.management.resource.LSMBTreeLocalResourceMetadata;
import org.apache.asterix.transaction.management.resource.PersistentLocalResourceFactoryProvider;
import org.apache.asterix.transaction.management.service.transaction.TransactionManagementConstants.LockManagerConstants.LockMode;
@@ -315,7 +315,7 @@
ClusterPartition metadataPartition = propertiesProvider.getMetadataProperties().getMetadataPartition();
int metadataDeviceId = metadataPartition.getIODeviceNum();
String metadataPartitionPath = StoragePathUtil.prepareStoragePartitionPath(
- AsterixClusterProperties.INSTANCE.getStorageDirectoryName(), metadataPartition.getPartitionId());
+ ClusterProperties.INSTANCE.getStorageDirectoryName(), metadataPartition.getPartitionId());
String resourceName = metadataPartitionPath + File.separator + index.getFileNameRelativePath();
FileReference file = ioManager.getAbsoluteFileRef(metadataDeviceId, resourceName);
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/cluster/ClusterManager.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/cluster/ClusterManager.java
index f076152..6371f3e 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/cluster/ClusterManager.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/cluster/ClusterManager.java
@@ -31,6 +31,7 @@
import org.apache.asterix.common.api.IClusterEventsSubscriber;
import org.apache.asterix.common.config.AsterixExternalProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.event.management.AsterixEventServiceClient;
import org.apache.asterix.event.model.AsterixInstance;
@@ -46,7 +47,6 @@
import org.apache.asterix.installer.schema.conf.Configuration;
import org.apache.asterix.metadata.api.IClusterManager;
import org.apache.asterix.runtime.util.AsterixAppContextInfo;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
public class ClusterManager implements IClusterManager {
@@ -61,7 +61,7 @@
private static final Set<IClusterEventsSubscriber> eventSubscribers = new HashSet<IClusterEventsSubscriber>();
private ClusterManager() {
- Cluster asterixCluster = AsterixClusterProperties.INSTANCE.getCluster();
+ Cluster asterixCluster = ClusterProperties.INSTANCE.getCluster();
String eventHome = asterixCluster == null ? null
: asterixCluster.getWorkingDir() == null ? null : asterixCluster.getWorkingDir().getDir();
@@ -75,8 +75,7 @@
Unmarshaller unmarshaller = configCtx.createUnmarshaller();
configuration = (Configuration) unmarshaller.unmarshal(configFile);
AsterixEventService.initialize(configuration, asterixDir, eventHome);
- client = AsterixEventService
- .getAsterixEventServiceClient(AsterixClusterProperties.INSTANCE.getCluster());
+ client = AsterixEventService.getAsterixEventServiceClient(ClusterProperties.INSTANCE.getCluster());
lookupService = ServiceProvider.INSTANCE.getLookupService();
if (!lookupService.isRunning(configuration)) {
@@ -99,11 +98,11 @@
@Override
public void addNode(Node node) throws AsterixException {
try {
- Cluster cluster = AsterixClusterProperties.INSTANCE.getCluster();
+ Cluster cluster = ClusterProperties.INSTANCE.getCluster();
List<Pattern> pattern = new ArrayList<Pattern>();
String asterixInstanceName = AsterixAppContextInfo.INSTANCE.getMetadataProperties().getInstanceName();
Patterns prepareNode = PatternCreator.INSTANCE.createPrepareNodePattern(asterixInstanceName,
- AsterixClusterProperties.INSTANCE.getCluster(), node);
+ ClusterProperties.INSTANCE.getCluster(), node);
cluster.getNode().add(node);
client.submit(prepareNode);
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
index d8ac7b9..41a843f 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/AqlMetadataProvider.java
@@ -92,7 +92,7 @@
import org.apache.asterix.runtime.operators.AsterixLSMInvertedIndexUpsertOperatorDescriptor;
import org.apache.asterix.runtime.operators.AsterixLSMTreeUpsertOperatorDescriptor;
import org.apache.asterix.runtime.util.AsterixAppContextInfo;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.asterix.runtime.util.AsterixRuntimeComponentsProvider;
import org.apache.asterix.transaction.management.opcallbacks.LockThenSearchOperationCallbackFactory;
import org.apache.asterix.transaction.management.opcallbacks.PrimaryIndexInstantSearchOperationCallbackFactory;
@@ -951,7 +951,7 @@
List<String> nodeGroup = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, dataset.getNodeGroupName())
.getNodeNames();
for (String nd : nodeGroup) {
- numPartitions += AsterixClusterProperties.INSTANCE.getNodePartitionsCount(nd);
+ numPartitions += ClusterStateManager.INSTANCE.getNodePartitionsCount(nd);
}
numElementsHint = numElementsHint / numPartitions;
return numElementsHint;
@@ -1027,7 +1027,7 @@
}
public AlgebricksAbsolutePartitionConstraint getClusterLocations() {
- return AsterixClusterProperties.INSTANCE.getClusterLocations();
+ return ClusterStateManager.INSTANCE.getClusterLocations();
}
public Pair<IFileSplitProvider, AlgebricksPartitionConstraint> splitProviderAndPartitionConstraintsForFilesIndex(
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/FeedDataSource.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/FeedDataSource.java
index 5853a39..d1d5df0 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/FeedDataSource.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/FeedDataSource.java
@@ -33,7 +33,7 @@
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.formats.NonTaggedDataFormat;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -76,7 +76,7 @@
this.locations = locations;
this.pkTypes = pkTypes;
this.keyAccessExpression = keyAccessExpression;
- this.computeCardinality = AsterixClusterProperties.INSTANCE.getParticipantNodes().size();
+ this.computeCardinality = ClusterStateManager.INSTANCE.getParticipantNodes().size();
initFeedDataSource();
}
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java
index 3dfa8a5..39ad1c6 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataManagerUtil.java
@@ -36,7 +36,7 @@
import org.apache.asterix.metadata.utils.MetadataConstants;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.properties.DefaultNodeGroupDomain;
import org.apache.hyracks.algebricks.core.algebra.properties.INodeDomain;
@@ -116,7 +116,7 @@
NodeGroup nodeGroup = MetadataManager.INSTANCE.getNodegroup(mdTxnCtx, nodeGroupName);
List<String> partitions = new ArrayList<>();
for (String location : nodeGroup.getNodeNames()) {
- int numPartitions = AsterixClusterProperties.INSTANCE.getNodePartitionsCount(location);
+ int numPartitions = ClusterStateManager.INSTANCE.getNodePartitionsCount(location);
for (int i = 0; i < numPartitions; i++) {
partitions.add(location);
}
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SplitsAndConstraintsUtil.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SplitsAndConstraintsUtil.java
index 85e4405..21e2150 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SplitsAndConstraintsUtil.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/SplitsAndConstraintsUtil.java
@@ -23,12 +23,13 @@
import java.util.List;
import org.apache.asterix.common.cluster.ClusterPartition;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.utils.StoragePathUtil;
import org.apache.asterix.metadata.MetadataException;
import org.apache.asterix.metadata.MetadataManager;
import org.apache.asterix.metadata.MetadataTransactionContext;
import org.apache.asterix.metadata.entities.Dataset;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.common.utils.Pair;
@@ -44,11 +45,11 @@
File relPathFile = new File(dataverseName);
List<FileSplit> splits = new ArrayList<>();
// get all partitions
- ClusterPartition[] clusterPartition = AsterixClusterProperties.INSTANCE.getClusterPartitons();
- String storageDirName = AsterixClusterProperties.INSTANCE.getStorageDirectoryName();
+ ClusterPartition[] clusterPartition = ClusterStateManager.INSTANCE.getClusterPartitons();
+ String storageDirName = ClusterProperties.INSTANCE.getStorageDirectoryName();
for (int j = 0; j < clusterPartition.length; j++) {
int nodePartitions =
- AsterixClusterProperties.INSTANCE.getNodePartitionsCount(clusterPartition[j].getNodeId());
+ ClusterStateManager.INSTANCE.getNodePartitionsCount(clusterPartition[j].getNodeId());
for (int i = 0; i < nodePartitions; i++) {
File f = new File(StoragePathUtil.prepareStoragePartitionPath(storageDirName,
clusterPartition[i].getPartitionId()) + File.separator + relPathFile);
@@ -70,11 +71,11 @@
throw new AlgebricksException("Couldn't find node group " + dataset.getNodeGroupName());
}
- String storageDirName = AsterixClusterProperties.INSTANCE.getStorageDirectoryName();
+ String storageDirName = ClusterProperties.INSTANCE.getStorageDirectoryName();
List<FileSplit> splits = new ArrayList<>();
for (String nd : nodeGroup) {
- int numPartitions = AsterixClusterProperties.INSTANCE.getNodePartitionsCount(nd);
- ClusterPartition[] nodePartitions = AsterixClusterProperties.INSTANCE.getNodePartitions(nd);
+ int numPartitions = ClusterStateManager.INSTANCE.getNodePartitionsCount(nd);
+ ClusterPartition[] nodePartitions = ClusterStateManager.INSTANCE.getNodePartitions(nd);
// currently this case is never executed since the metadata group doesn't exists
if (dataset.getNodeGroupName().compareTo(MetadataConstants.METADATA_NODEGROUP_NAME) == 0) {
numPartitions = 1;
@@ -110,8 +111,8 @@
List<FileSplit> splits = new ArrayList<>();
for (String nodeId : nodeGroup) {
// get node partitions
- ClusterPartition[] nodePartitions = AsterixClusterProperties.INSTANCE.getNodePartitions(nodeId);
- String storageDirName = AsterixClusterProperties.INSTANCE.getStorageDirectoryName();
+ ClusterPartition[] nodePartitions = ClusterStateManager.INSTANCE.getNodePartitions(nodeId);
+ String storageDirName = ClusterProperties.INSTANCE.getStorageDirectoryName();
int firstPartition = 0;
if (create) {
// Only the first partition when create
@@ -146,7 +147,7 @@
}
public static String getIndexPath(String partitionPath, int partition, String dataverse, String fullIndexName) {
- String storageDirName = AsterixClusterProperties.INSTANCE.getStorageDirectoryName();
+ String storageDirName = ClusterProperties.INSTANCE.getStorageDirectoryName();
return partitionPath + StoragePathUtil.prepareStoragePartitionPath(storageDirName, partition) + File.separator
+ StoragePathUtil.prepareDataverseIndexName(dataverse, fullIndexName);
}
diff --git a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/ReplicationManager.java b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/ReplicationManager.java
index 53bd164..87be768 100644
--- a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/ReplicationManager.java
+++ b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/management/ReplicationManager.java
@@ -53,6 +53,7 @@
import org.apache.asterix.common.cluster.ClusterPartition;
import org.apache.asterix.common.config.AsterixReplicationProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.config.IAsterixPropertiesProvider;
import org.apache.asterix.common.dataflow.AsterixLSMIndexUtil;
import org.apache.asterix.common.replication.AsterixReplicationJob;
@@ -65,7 +66,6 @@
import org.apache.asterix.common.transactions.ILogManager;
import org.apache.asterix.common.transactions.ILogRecord;
import org.apache.asterix.common.transactions.LogType;
-import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
import org.apache.asterix.event.schema.cluster.Node;
import org.apache.asterix.replication.functions.ReplicaFilesRequest;
import org.apache.asterix.replication.functions.ReplicaIndexFlushRequest;
@@ -76,6 +76,7 @@
import org.apache.asterix.replication.storage.LSMComponentProperties;
import org.apache.asterix.replication.storage.LSMIndexFileProperties;
import org.apache.asterix.replication.storage.ReplicaResourcesManager;
+import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
import org.apache.hyracks.api.application.IClusterLifecycleListener.ClusterEventType;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.replication.IReplicationJob;
@@ -441,7 +442,7 @@
@Override
public boolean isReplicationEnabled() {
- return replicationProperties.isReplicationEnabled();
+ return ClusterProperties.INSTANCE.isReplicationEnabled();
}
@Override
diff --git a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/recovery/RemoteRecoveryManager.java b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/recovery/RemoteRecoveryManager.java
index 46a2076..866831b 100644
--- a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/recovery/RemoteRecoveryManager.java
+++ b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/recovery/RemoteRecoveryManager.java
@@ -32,15 +32,15 @@
import org.apache.asterix.common.api.IDatasetLifecycleManager;
import org.apache.asterix.common.cluster.ClusterPartition;
import org.apache.asterix.common.config.AsterixReplicationProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.config.IAsterixPropertiesProvider;
import org.apache.asterix.common.exceptions.ACIDException;
import org.apache.asterix.common.replication.IRemoteRecoveryManager;
import org.apache.asterix.common.replication.IReplicationManager;
import org.apache.asterix.common.transactions.ILogManager;
import org.apache.asterix.common.transactions.IRecoveryManager;
-import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
import org.apache.asterix.replication.storage.ReplicaResourcesManager;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
public class RemoteRecoveryManager implements IRemoteRecoveryManager {
@@ -181,7 +181,7 @@
//3. remove any existing storage data and initialize storage metadata
resourceRepository.deleteStorageData(true);
- resourceRepository.initializeNewUniverse(AsterixClusterProperties.INSTANCE.getStorageDirectoryName());
+ resourceRepository.initializeNewUniverse(ClusterProperties.INSTANCE.getStorageDirectoryName());
//4. select remote replicas to recover from per lost replica data
failbackRecoveryReplicas = constructRemoteRecoveryPlan();
diff --git a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/storage/ReplicaResourcesManager.java b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/storage/ReplicaResourcesManager.java
index 01d6db7..6fc8fd5 100644
--- a/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/storage/ReplicaResourcesManager.java
+++ b/asterixdb/asterix-replication/src/main/java/org/apache/asterix/replication/storage/ReplicaResourcesManager.java
@@ -39,11 +39,11 @@
import org.apache.asterix.common.cluster.ClusterPartition;
import org.apache.asterix.common.config.AsterixMetadataProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.replication.IReplicaResourcesManager;
-import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
import org.apache.asterix.common.utils.StoragePathUtil;
import org.apache.asterix.metadata.utils.SplitsAndConstraintsUtil;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.transaction.management.resource.PersistentLocalResourceRepository;
import org.apache.commons.io.FileUtils;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.storage.common.file.ILocalResourceRepository;
@@ -245,7 +245,7 @@
*/
public Set<File> getPartitionIndexes(int partition) {
Set<File> partitionIndexes = new HashSet<File>();
- String storageDirName = AsterixClusterProperties.INSTANCE.getStorageDirectoryName();
+ String storageDirName = ClusterProperties.INSTANCE.getStorageDirectoryName();
String partitionStoragePath = localRepository.getPartitionPath(partition)
+ StoragePathUtil.prepareStoragePartitionPath(storageDirName, partition);
File partitionRoot = new File(partitionStoragePath);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/CompleteFailbackResponseMessage.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/CompleteFailbackResponseMessage.java
index 73e5fd2..4ae73ea 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/CompleteFailbackResponseMessage.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/CompleteFailbackResponseMessage.java
@@ -20,7 +20,7 @@
import java.util.Set;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.service.IControllerService;
@@ -49,6 +49,6 @@
@Override
public void handle(IControllerService cs) throws HyracksDataException {
- AsterixClusterProperties.INSTANCE.processCompleteFailbackResponse(this);
+ ClusterStateManager.INSTANCE.processCompleteFailbackResponse(this);
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/PreparePartitionsFailbackResponseMessage.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/PreparePartitionsFailbackResponseMessage.java
index 299121a..db89f7c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/PreparePartitionsFailbackResponseMessage.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/PreparePartitionsFailbackResponseMessage.java
@@ -20,7 +20,7 @@
import java.util.Set;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.service.IControllerService;
@@ -40,7 +40,7 @@
@Override
public void handle(IControllerService cs) throws HyracksDataException {
- AsterixClusterProperties.INSTANCE.processPreparePartitionsFailbackResponse(this);
+ ClusterStateManager.INSTANCE.processPreparePartitionsFailbackResponse(this);
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/ResourceIdRequestMessage.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/ResourceIdRequestMessage.java
index 32d3f64..afe2427 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/ResourceIdRequestMessage.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/ResourceIdRequestMessage.java
@@ -25,7 +25,7 @@
import org.apache.asterix.common.messaging.api.ICCMessageBroker;
import org.apache.asterix.common.transactions.IAsterixResourceIdManager;
import org.apache.asterix.runtime.util.AsterixAppContextInfo;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.service.IControllerService;
@@ -43,7 +43,7 @@
ICCMessageBroker broker =
(ICCMessageBroker) AsterixAppContextInfo.INSTANCE.getCCApplicationContext().getMessageBroker();
ResourceIdRequestResponseMessage reponse = new ResourceIdRequestResponseMessage();
- if (!AsterixClusterProperties.INSTANCE.isClusterActive()) {
+ if (!ClusterStateManager.INSTANCE.isClusterActive()) {
reponse.setResourceId(-1);
reponse.setException(new Exception("Cannot generate global resource id when cluster is not active."));
} else {
@@ -63,7 +63,7 @@
private void requestMaxResourceID(IAsterixResourceIdManager resourceIdManager, ICCMessageBroker broker)
throws Exception {
- Set<String> getParticipantNodes = AsterixClusterProperties.INSTANCE.getParticipantNodes();
+ Set<String> getParticipantNodes = ClusterStateManager.INSTANCE.getParticipantNodes();
ReportMaxResourceIdRequestMessage msg = new ReportMaxResourceIdRequestMessage();
for (String nodeId : getParticipantNodes) {
if (!resourceIdManager.reported(nodeId)) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/TakeoverMetadataNodeResponseMessage.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/TakeoverMetadataNodeResponseMessage.java
index e18fc8d..2466e2b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/TakeoverMetadataNodeResponseMessage.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/TakeoverMetadataNodeResponseMessage.java
@@ -19,7 +19,7 @@
package org.apache.asterix.runtime.message;
import org.apache.asterix.common.messaging.api.IApplicationMessage;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.service.IControllerService;
@@ -38,7 +38,7 @@
@Override
public void handle(IControllerService cs) throws HyracksDataException {
- AsterixClusterProperties.INSTANCE.processMetadataNodeTakeoverResponse(this);
+ ClusterStateManager.INSTANCE.processMetadataNodeTakeoverResponse(this);
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/TakeoverPartitionsResponseMessage.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/TakeoverPartitionsResponseMessage.java
index 1c57a2a..a4a5226 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/TakeoverPartitionsResponseMessage.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/message/TakeoverPartitionsResponseMessage.java
@@ -19,7 +19,7 @@
package org.apache.asterix.runtime.message;
import org.apache.asterix.common.messaging.api.IApplicationMessage;
-import org.apache.asterix.runtime.util.AsterixClusterProperties;
+import org.apache.asterix.runtime.util.ClusterStateManager;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.api.service.IControllerService;
@@ -50,7 +50,7 @@
@Override
public void handle(IControllerService cs) throws HyracksDataException {
- AsterixClusterProperties.INSTANCE.processPartitionTakeoverResponse(this);
+ ClusterStateManager.INSTANCE.processPartitionTakeoverResponse(this);
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/AsterixAppContextInfo.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/AsterixAppContextInfo.java
index 9fdeebb..471d3d3 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/AsterixAppContextInfo.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/AsterixAppContextInfo.java
@@ -103,8 +103,7 @@
INSTANCE.txnProperties = new AsterixTransactionProperties(propertiesAccessor);
INSTANCE.feedProperties = new AsterixFeedProperties(propertiesAccessor);
INSTANCE.extensionProperties = new AsterixExtensionProperties(propertiesAccessor);
- INSTANCE.replicationProperties = new AsterixReplicationProperties(propertiesAccessor,
- AsterixClusterProperties.INSTANCE.getCluster());
+ INSTANCE.replicationProperties = new AsterixReplicationProperties(propertiesAccessor);
INSTANCE.hcc = hcc;
INSTANCE.buildProperties = new AsterixBuildProperties(propertiesAccessor);
INSTANCE.messagingProperties = new MessagingProperties(propertiesAccessor);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/AsterixClusterProperties.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/ClusterStateManager.java
similarity index 91%
rename from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/AsterixClusterProperties.java
rename to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/ClusterStateManager.java
index d9a55ad..487b8fa 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/AsterixClusterProperties.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/util/ClusterStateManager.java
@@ -18,7 +18,6 @@
*/
package org.apache.asterix.runtime.util;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -32,13 +31,10 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-
import org.apache.asterix.common.api.IClusterManagementWork.ClusterState;
import org.apache.asterix.common.cluster.ClusterPartition;
import org.apache.asterix.common.config.AsterixReplicationProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.messaging.api.ICCMessageBroker;
import org.apache.asterix.event.schema.cluster.Cluster;
import org.apache.asterix.event.schema.cluster.Node;
@@ -62,20 +58,17 @@
* A holder class for properties related to the Asterix cluster.
*/
-public class AsterixClusterProperties {
+public class ClusterStateManager {
/*
* TODO: currently after instance restarts we require all nodes to join again,
* otherwise the cluster wont be ACTIVE. we may overcome this by storing the cluster state before the instance
* shutdown and using it on startup to identify the nodes that are expected the join.
*/
- private static final Logger LOGGER = Logger.getLogger(AsterixClusterProperties.class.getName());
- public static final AsterixClusterProperties INSTANCE = new AsterixClusterProperties();
- public static final String CLUSTER_CONFIGURATION_FILE = "cluster.xml";
-
+ private static final Logger LOGGER = Logger.getLogger(ClusterStateManager.class.getName());
+ public static final ClusterStateManager INSTANCE = new ClusterStateManager();
private static final String CLUSTER_NET_IP_ADDRESS_KEY = "cluster-net-ip-address";
private static final String IO_DEVICES = "iodevices";
- private static final String DEFAULT_STORAGE_DIR_NAME = "storage";
private Map<String, Map<String, String>> activeNcConfiguration = new HashMap<>();
private final Cluster cluster;
@@ -98,27 +91,16 @@
private LinkedList<NodeFailbackPlan> pendingProcessingFailbackPlans;
private Map<Long, NodeFailbackPlan> planId2FailbackPlanMap;
- private AsterixClusterProperties() {
- InputStream is = this.getClass().getClassLoader().getResourceAsStream(CLUSTER_CONFIGURATION_FILE);
- if (is != null) {
- try {
- JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
- Unmarshaller unmarshaller = ctx.createUnmarshaller();
- cluster = (Cluster) unmarshaller.unmarshal(is);
- } catch (JAXBException e) {
- throw new IllegalStateException("Failed to read configuration file " + CLUSTER_CONFIGURATION_FILE, e);
- }
- } else {
- cluster = null;
- }
+ private ClusterStateManager() {
+ cluster = ClusterProperties.INSTANCE.getCluster();
// if this is the CC process
if (AsterixAppContextInfo.INSTANCE.initialized()
&& AsterixAppContextInfo.INSTANCE.getCCApplicationContext() != null) {
node2PartitionsMap = AsterixAppContextInfo.INSTANCE.getMetadataProperties().getNodePartitions();
clusterPartitions = AsterixAppContextInfo.INSTANCE.getMetadataProperties().getClusterPartitions();
currentMetadataNode = AsterixAppContextInfo.INSTANCE.getMetadataProperties().getMetadataNodeName();
- replicationEnabled = isReplicationEnabled();
- autoFailover = isAutoFailoverEnabled();
+ replicationEnabled = ClusterProperties.INSTANCE.isReplicationEnabled();
+ autoFailover = ClusterProperties.INSTANCE.isAutoFailoverEnabled();
if (autoFailover) {
pendingTakeoverRequests = new HashMap<>();
pendingProcessingFailbackPlans = new LinkedList<>();
@@ -246,10 +228,6 @@
return state;
}
- public Cluster getCluster() {
- return cluster;
- }
-
public synchronized Node getAvailableSubstitutionNode() {
List<Node> subNodes = cluster.getSubstituteNodes() == null ? null : cluster.getSubstituteNodes().getNode();
return subNodes == null || subNodes.isEmpty() ? null : subNodes.get(0);
@@ -320,19 +298,10 @@
return partitons.toArray(new ClusterPartition[] {});
}
- public String getStorageDirectoryName() {
- if (cluster != null) {
- return cluster.getStore();
- }
- // virtual cluster without cluster config file
- return DEFAULT_STORAGE_DIR_NAME;
- }
-
private synchronized void requestPartitionsTakeover(String failedNodeId) {
//replica -> list of partitions to takeover
Map<String, List<Integer>> partitionRecoveryPlan = new HashMap<>();
- AsterixReplicationProperties replicationProperties = AsterixAppContextInfo.INSTANCE
- .getReplicationProperties();
+ AsterixReplicationProperties replicationProperties = AsterixAppContextInfo.INSTANCE.getReplicationProperties();
//collect the partitions of the failed NC
List<ClusterPartition> lostPartitions = getNodeAssignedPartitions(failedNodeId);
@@ -357,8 +326,8 @@
} else {
LOGGER.info("Partitions to recover: " + lostPartitions);
}
- ICCMessageBroker messageBroker = (ICCMessageBroker) AsterixAppContextInfo.INSTANCE
- .getCCApplicationContext().getMessageBroker();
+ ICCMessageBroker messageBroker = (ICCMessageBroker) AsterixAppContextInfo.INSTANCE.getCCApplicationContext()
+ .getMessageBroker();
//For each replica, send a request to takeover the assigned partitions
for (Entry<String, List<Integer>> entry : partitionRecoveryPlan.entrySet()) {
String replica = entry.getKey();
@@ -428,8 +397,8 @@
.getMetadataPartition();
//request the metadataPartition node to register itself as the metadata node
TakeoverMetadataNodeRequestMessage takeoverRequest = new TakeoverMetadataNodeRequestMessage();
- ICCMessageBroker messageBroker = (ICCMessageBroker) AsterixAppContextInfo.INSTANCE
- .getCCApplicationContext().getMessageBroker();
+ ICCMessageBroker messageBroker = (ICCMessageBroker) AsterixAppContextInfo.INSTANCE.getCCApplicationContext()
+ .getMessageBroker();
try {
messageBroker.sendApplicationMessageToNC(takeoverRequest, metadataPartiton.getActiveNodeId());
} catch (Exception e) {
@@ -467,8 +436,7 @@
planId2FailbackPlanMap.put(plan.getPlanId(), plan);
//get all partitions this node requires to resync
- AsterixReplicationProperties replicationProperties = AsterixAppContextInfo.INSTANCE
- .getReplicationProperties();
+ AsterixReplicationProperties replicationProperties = AsterixAppContextInfo.INSTANCE.getReplicationProperties();
Set<String> nodeReplicas = replicationProperties.getNodeReplicationClients(failingBackNodeId);
for (String replicaId : nodeReplicas) {
ClusterPartition[] nodePartitions = node2PartitionsMap.get(replicaId);
@@ -574,8 +542,8 @@
CompleteFailbackRequestMessage request = plan.getCompleteFailbackRequestMessage();
//send complete resync and takeover partitions to the failing back node
- ICCMessageBroker messageBroker = (ICCMessageBroker) AsterixAppContextInfo.INSTANCE
- .getCCApplicationContext().getMessageBroker();
+ ICCMessageBroker messageBroker = (ICCMessageBroker) AsterixAppContextInfo.INSTANCE.getCCApplicationContext()
+ .getMessageBroker();
try {
messageBroker.sendApplicationMessageToNC(request, request.getNodeId());
} catch (Exception e) {
@@ -605,8 +573,7 @@
}
private synchronized void notifyImpactedReplicas(String nodeId, ClusterEventType event) {
- AsterixReplicationProperties replicationProperties = AsterixAppContextInfo.INSTANCE
- .getReplicationProperties();
+ AsterixReplicationProperties replicationProperties = AsterixAppContextInfo.INSTANCE.getReplicationProperties();
Set<String> remoteReplicas = replicationProperties.getRemoteReplicasIds(nodeId);
String nodeIdAddress = "";
//in case the node joined with a new IP address, we need to send it to the other replicas
@@ -615,8 +582,8 @@
}
ReplicaEventMessage msg = new ReplicaEventMessage(nodeId, nodeIdAddress, event);
- ICCMessageBroker messageBroker = (ICCMessageBroker) AsterixAppContextInfo.INSTANCE
- .getCCApplicationContext().getMessageBroker();
+ ICCMessageBroker messageBroker = (ICCMessageBroker) AsterixAppContextInfo.INSTANCE.getCCApplicationContext()
+ .getMessageBroker();
for (String replica : remoteReplicas) {
//if the remote replica is alive, send the event
if (activeNcConfiguration.containsKey(replica)) {
@@ -655,17 +622,6 @@
return metadataNodeActive;
}
- public boolean isReplicationEnabled() {
- if (cluster != null && cluster.getDataReplication() != null) {
- return cluster.getDataReplication().isEnabled();
- }
- return false;
- }
-
- public boolean isAutoFailoverEnabled() {
- return isReplicationEnabled() && cluster.getDataReplication().isAutoFailover();
- }
-
public synchronized JSONObject getClusterStateDescription() throws JSONException {
JSONObject stateDescription = new JSONObject();
stateDescription.put("state", state.name());
@@ -682,4 +638,4 @@
}
return stateDescription;
}
-}
+}
\ No newline at end of file
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/recovery/RecoveryManager.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/recovery/RecoveryManager.java
index eb22c22..6eb758c 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/recovery/RecoveryManager.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/recovery/RecoveryManager.java
@@ -51,6 +51,7 @@
import org.apache.asterix.common.api.ILocalResourceMetadata;
import org.apache.asterix.common.cluster.ClusterPartition;
import org.apache.asterix.common.config.AsterixMetadataProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.config.IAsterixPropertiesProvider;
import org.apache.asterix.common.exceptions.ACIDException;
import org.apache.asterix.common.ioopcallbacks.AbstractLSMIOOperationCallback;
@@ -108,9 +109,7 @@
this.txnSubsystem = txnSubsystem;
logMgr = (LogManager) txnSubsystem.getLogManager();
checkpointHistory = txnSubsystem.getTransactionProperties().getCheckpointHistory();
- IAsterixPropertiesProvider propertiesProvider =
- (IAsterixPropertiesProvider) txnSubsystem.getAsterixAppRuntimeContextProvider().getAppContext();
- replicationEnabled = propertiesProvider.getReplicationProperties().isReplicationEnabled();
+ replicationEnabled = ClusterProperties.INSTANCE.isReplicationEnabled();
localResourceRepository = (PersistentLocalResourceRepository) txnSubsystem.getAsterixAppRuntimeContextProvider()
.getLocalResourceRepository();
cachedEntityCommitsPerJobSize = txnSubsystem.getTransactionProperties().getJobRecoveryMemorySize();
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionSubsystem.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionSubsystem.java
index 6b25542..5f06b8a 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionSubsystem.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/TransactionSubsystem.java
@@ -24,6 +24,7 @@
import org.apache.asterix.common.config.AsterixReplicationProperties;
import org.apache.asterix.common.config.AsterixTransactionProperties;
+import org.apache.asterix.common.config.ClusterProperties;
import org.apache.asterix.common.config.IAsterixPropertiesProvider;
import org.apache.asterix.common.exceptions.ACIDException;
import org.apache.asterix.common.transactions.IAsterixAppRuntimeContextProvider;
@@ -72,7 +73,7 @@
.getAppContext()).getReplicationProperties();
}
- if (asterixReplicationProperties != null && asterixReplicationProperties.isReplicationEnabled()) {
+ if (asterixReplicationProperties != null && ClusterProperties.INSTANCE.isReplicationEnabled()) {
this.logManager = new LogManagerWithReplication(this);
} else {
this.logManager = new LogManager(this);