[ASTERIXDB-2036] Make MetadataProvider Config final
- user model changes: no
- storage format changes: no
- interface changes: no
details:
- Make config map final to avoid NullPointerExceptions
Change-Id: I25ed6433a4e1a267deeedbf22d09c119704e8d7d
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1937
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Xikui Wang <xkkwww@gmail.com>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
index acb1614..e30272c 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveEntityEventsListener.java
@@ -21,7 +21,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ExecutorService;
@@ -112,7 +111,6 @@
this.appCtx = appCtx;
this.clusterStateManager = appCtx.getClusterStateManager();
this.metadataProvider = new MetadataProvider(appCtx, null);
- metadataProvider.setConfig(new HashMap<>());
this.hcc = hcc;
this.entityId = entityId;
this.datasets = datasets;
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 027fbbe..b97c014 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
@@ -261,13 +261,13 @@
FileSplit outputFile = null;
IAWriterFactory writerFactory = PrinterBasedWriterFactory.INSTANCE;
IResultSerializerFactoryProvider resultSerializerFactoryProvider = ResultSerializerFactoryProvider.INSTANCE;
- Map<String, String> config = new HashMap<>();
/* Since the system runs a large number of threads, when HTTP requests don't return, it becomes difficult to
* find the thread running the request to determine where it has stopped.
* Setting the thread name helps make that easier
*/
String threadName = Thread.currentThread().getName();
Thread.currentThread().setName(QueryTranslator.class.getSimpleName());
+ Map<String, String> config = new HashMap<>();
try {
for (Statement stmt : statements) {
if (sessionConfig.is(SessionConfig.FORMAT_HTML)) {
@@ -276,10 +276,10 @@
validateOperation(appCtx, activeDataverse, stmt);
rewriteStatement(stmt); // Rewrite the statement's AST.
MetadataProvider metadataProvider = new MetadataProvider(appCtx, activeDataverse);
+ metadataProvider.getConfig().putAll(config);
metadataProvider.setWriterFactory(writerFactory);
metadataProvider.setResultSerializerFactoryProvider(resultSerializerFactoryProvider);
metadataProvider.setOutputFile(outputFile);
- metadataProvider.setConfig(config);
switch (stmt.getKind()) {
case Statement.Kind.SET:
handleSetStatement(stmt, config);
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/active/ActiveEventsListenerTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/active/ActiveEventsListenerTest.java
index 0a7b444..a256bcf 100644
--- a/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/active/ActiveEventsListenerTest.java
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/test/active/ActiveEventsListenerTest.java
@@ -21,7 +21,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -117,7 +116,6 @@
Mockito.when(ccService.getExecutor()).thenReturn(executor);
locations = new AlgebricksAbsolutePartitionConstraint(nodes);
metadataProvider = new MetadataProvider(appCtx, null);
- metadataProvider.setConfig(new HashMap<>());
clusterController = new TestClusterControllerActor("CC", handler, allDatasets);
nodeControllers = new TestNodeControllerActor[2];
nodeControllers[0] = new TestNodeControllerActor(nodes[0], clusterController);
@@ -133,7 +131,6 @@
TestUserActor newUser(String name, CcApplicationContext appCtx) {
MetadataProvider actorMdProvider = new MetadataProvider(appCtx, null);
- actorMdProvider.setConfig(new HashMap<>());
return new TestUserActor("User: " + name, actorMdProvider, clusterController);
}
@@ -1387,8 +1384,6 @@
Mockito.when(ccService.getExecutor()).thenReturn(executor);
Mockito.when(ccAppCtx.getStorageComponentProvider()).thenReturn(componentProvider);
AlgebricksAbsolutePartitionConstraint locations = new AlgebricksAbsolutePartitionConstraint(nodes);
- MetadataProvider metadataProvider = new MetadataProvider(ccAppCtx, null);
- metadataProvider.setConfig(new HashMap<>());
additionalListeners[i] = listener = new TestEventsListener(clusterController, nodeControllers, jobIdFactory,
entityId, new ArrayList<>(allDatasets), statementExecutor, ccAppCtx, hcc, locations,
new InfiniteRetryPolicyFactory());
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
index 7d28a06..8971a90 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/declared/MetadataProvider.java
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -143,10 +144,10 @@
private final StorageProperties storageProperties;
private final Dataverse defaultDataverse;
private final LockList locks;
+ private final Map<String, String> config;
private MetadataTransactionContext mdTxnCtx;
private boolean isWriteTransaction;
- private Map<String, String> config;
private IAWriterFactory writerFactory;
private FileSplit outputFile;
private boolean asyncResults;
@@ -163,16 +164,13 @@
this.storageComponentProvider = appCtx.getStorageComponentProvider();
storageProperties = appCtx.getStorageProperties();
locks = new LockList();
+ config = new HashMap<>();
}
public String getPropertyValue(String propertyName) {
return config.get(propertyName);
}
- public void setConfig(Map<String, String> config) {
- this.config = config;
- }
-
public void disableBlockingOperator() {
blockingOperatorDisabled = true;
}