[NO ISSUE][CONF][TX] Make path to store atomic txn logs configurable

- user model changes: no
- storage format changes: no
- interface changes: no

Change-Id: I0579cc7630bc718e678234e1d7147fcdb679b3f6
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17653
Reviewed-by: Peeyush Gupta <peeyush.gupta@couchbase.com>
Reviewed-by: Murtadha Al Hubail <mhubail@apache.org>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Murtadha Al Hubail <mhubail@apache.org>
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/GlobalTxManager.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/GlobalTxManager.java
index 4dbf38b..d69376a 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/GlobalTxManager.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/cc/GlobalTxManager.java
@@ -30,7 +30,6 @@
 import org.apache.asterix.common.exceptions.ACIDException;
 import org.apache.asterix.common.messaging.api.ICCMessageBroker;
 import org.apache.asterix.common.transactions.IGlobalTransactionContext;
-import org.apache.asterix.common.utils.StorageConstants;
 import org.apache.asterix.transaction.management.service.transaction.GlobalTransactionContext;
 import org.apache.asterix.transaction.management.service.transaction.GlobalTxInfo;
 import org.apache.hyracks.api.application.ICCServiceContext;
@@ -178,7 +177,7 @@
 
     @Override
     public void rollback() throws Exception {
-        Set<FileReference> txnLogFileRefs = ioManager.list(ioManager.resolve(StorageConstants.CC_TX_LOG_DIR));
+        Set<FileReference> txnLogFileRefs = ioManager.list(ioManager.resolve("."));
         for (FileReference txnLogFileRef : txnLogFileRefs) {
             IGlobalTransactionContext context = new GlobalTransactionContext(txnLogFileRef, ioManager);
             txnContextRepository.put(context.getJobId(), context);
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
index 0e740f7..e64b72f 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/hyracks/bootstrap/CCApplication.java
@@ -82,7 +82,6 @@
 import org.apache.asterix.common.metadata.IMetadataLockUtil;
 import org.apache.asterix.common.replication.INcLifecycleCoordinator;
 import org.apache.asterix.common.utils.Servlets;
-import org.apache.asterix.common.utils.StorageConstants;
 import org.apache.asterix.external.adapter.factory.AdapterFactoryService;
 import org.apache.asterix.file.StorageComponentProvider;
 import org.apache.asterix.messaging.CCMessageBroker;
@@ -167,9 +166,10 @@
         componentProvider = new StorageComponentProvider();
         ccExtensionManager = new CCExtensionManager(new ArrayList<>(getExtensions()));
         IGlobalRecoveryManager globalRecoveryManager = createGlobalRecoveryManager();
+        final CCConfig ccConfig = controllerService.getCCConfig();
 
         List<IODeviceHandle> devices = new ArrayList<>();
-        devices.add(new IODeviceHandle(new File(StorageConstants.CC_STORAGE_ROOT_DIR), "."));
+        devices.add(new IODeviceHandle(new File(ccConfig.getGlobalTxLogDir()), "."));
         IOManager ioManager = new IOManager(devices, new DefaultDeviceResolver(), 1, 10);
         CloudProperties cloudProperties = null;
         if (ccServiceCtx.getAppConfig().getBoolean(CLOUD_DEPLOYMENT)) {
@@ -180,7 +180,6 @@
         appCtx = createApplicationContext(null, globalRecoveryManager, lifecycleCoordinator, Receptionist::new,
                 ConfigValidator::new, ccExtensionManager, new AdapterFactoryService(), globalTxManager, ioManager,
                 cloudProperties);
-        final CCConfig ccConfig = controllerService.getCCConfig();
         if (System.getProperty("java.rmi.server.hostname") == null) {
             System.setProperty("java.rmi.server.hostname", ccConfig.getClusterPublicAddress());
         }
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StorageConstants.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StorageConstants.java
index 7b6ed0d..1321c96 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StorageConstants.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/StorageConstants.java
@@ -18,7 +18,6 @@
  */
 package org.apache.asterix.common.utils;
 
-import java.nio.file.Paths;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
@@ -31,8 +30,6 @@
  */
 public class StorageConstants {
 
-    public static final String CC_STORAGE_ROOT_DIR = "/tmp/";
-    public static final String CC_TX_LOG_DIR = Paths.get("cc", "txnlogs").toString();
     public static final String STORAGE_ROOT_DIR_NAME = "storage";
     public static final String INGESTION_LOGS_DIR_NAME = "ingestion_logs";
     public static final String PARTITION_DIR_PREFIX = "partition_";
diff --git a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/GlobalTransactionContext.java b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/GlobalTransactionContext.java
index 9d1dd1d..4cac9d8 100644
--- a/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/GlobalTransactionContext.java
+++ b/asterixdb/asterix-transactions/src/main/java/org/apache/asterix/transaction/management/service/transaction/GlobalTransactionContext.java
@@ -27,7 +27,6 @@
 import org.apache.asterix.common.cluster.IGlobalTxManager.TransactionStatus;
 import org.apache.asterix.common.exceptions.ACIDException;
 import org.apache.asterix.common.transactions.IGlobalTransactionContext;
-import org.apache.asterix.common.utils.StorageConstants;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.io.FileReference;
 import org.apache.hyracks.api.job.JobId;
@@ -124,8 +123,7 @@
     @Override
     public void persist(IOManager ioManager) {
         try {
-            FileReference fref = ioManager
-                    .resolve(Paths.get(StorageConstants.CC_TX_LOG_DIR, String.format("%s.log", jobId)).toString());
+            FileReference fref = ioManager.resolve(Paths.get(String.format("%s.log", jobId)).toString());
             AtomicTransactionLog txnLog = new AtomicTransactionLog(jobId, datasetIds, nodeResourceMap.keySet(),
                     nodeResourceMap, numPartitions);
             ioManager.overwrite(fref,
@@ -138,8 +136,7 @@
     @Override
     public void delete(IOManager ioManager) {
         try {
-            FileReference fref = ioManager
-                    .resolve(Paths.get(StorageConstants.CC_TX_LOG_DIR, String.format("%s.log", jobId)).toString());
+            FileReference fref = ioManager.resolve(Paths.get(String.format("%s.log", jobId)).toString());
             ioManager.delete(fref);
         } catch (HyracksDataException e) {
             throw new RuntimeException(e);
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/CCConfig.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/CCConfig.java
index d148145..6904e3c 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/CCConfig.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/CCConfig.java
@@ -84,7 +84,12 @@
                 OptionTypes.STRING,
                 (Function<IApplicationConfig, String>) appConfig -> FileUtil
                         .joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR), "passwd"),
-                ControllerConfig.Option.DEFAULT_DIR.cmdline() + "/passwd");
+                ControllerConfig.Option.DEFAULT_DIR.cmdline() + "/passwd"),
+        GLOBAL_TXN_LOG_DIR(
+                STRING,
+                appConfig -> FileUtil.joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR),
+                        "global-txn-log"),
+                ControllerConfig.Option.DEFAULT_DIR.cmdline() + "/global-txn-log");
 
         private final IOptionType parser;
         private Object defaultValue;
@@ -206,6 +211,8 @@
                     return "The password to the provided key store";
                 case CREDENTIAL_FILE:
                     return "Path to HTTP basic credentials";
+                case GLOBAL_TXN_LOG_DIR:
+                    return "Directory to store global transaction logs";
                 default:
                     throw new IllegalStateException("NYI: " + this);
             }
@@ -481,4 +488,8 @@
         return getAppConfig().getString(Option.CREDENTIAL_FILE);
     }
 
+    public String getGlobalTxLogDir() {
+        return getAppConfig().getString(Option.GLOBAL_TXN_LOG_DIR);
+    }
+
 }