From 4d4c7e2b7b7ca7cb2f34f0dbb0d0b00e049f6ba6 Mon Sep 17 00:00:00 2001 From: Bin Fan Date: Sat, 22 Jul 2023 10:45:08 -0700 Subject: [PATCH] Remove secondary master ### What changes are proposed in this pull request? Remove secondary master ### Why are the changes needed? Secondary Master is no longer used ### Does this PR introduce any user facing changes? - Property key `alluxio.secondary.master.metastore.dir` is removed pr-link: Alluxio/alluxio#17823 change-id: cid-6eabcd4e53d29aba7cea403ea8172a6af4a1328d --- bin/alluxio-masters.sh | 11 +- bin/alluxio-start.sh | 36 +----- bin/alluxio-stop.sh | 18 +-- bin/launch-process | 23 +--- conf/alluxio-env.sh.template | 4 - conf/log4j.properties | 8 -- docs/_data/table/en/env_vars.yml | 2 - .../main/java/alluxio/conf/PropertyKey.java | 16 +-- .../master/AlluxioSecondaryMaster.java | 120 ------------------ .../journal/ufs/UfsJournalReaderTest.java | 20 --- .../alluxio/master/LocalAlluxioCluster.java | 18 +-- .../alluxio/master/LocalAlluxioMaster.java | 56 +------- ...terEmbeddedJournalLocalAlluxioCluster.java | 2 +- .../MultiMasterLocalAlluxioCluster.java | 2 +- .../alluxio/client/cli/JournalToolTest.java | 1 - .../ft/journal/ufs/SecondaryMasterTest.java | 50 -------- .../LocalAlluxioClusterResource.java | 20 +-- libexec/alluxio-config.sh | 4 - 18 files changed, 24 insertions(+), 387 deletions(-) delete mode 100644 dora/core/server/master/src/main/java/alluxio/master/AlluxioSecondaryMaster.java delete mode 100644 dora/tests/src/test/java/alluxio/server/ft/journal/ufs/SecondaryMasterTest.java diff --git a/bin/alluxio-masters.sh b/bin/alluxio-masters.sh index e72cc693c820..966243cd701f 100755 --- a/bin/alluxio-masters.sh +++ b/bin/alluxio-masters.sh @@ -32,7 +32,6 @@ ALLUXIO_TASK_LOG="${ALLUXIO_LOGS_DIR}/task.log" echo "Executing the following command on all master nodes and logging to ${ALLUXIO_TASK_LOG}: $@" | tee -a ${ALLUXIO_TASK_LOG} -N=0 HA_ENABLED=$(${BIN}/alluxio getConf ${ALLUXIO_MASTER_JAVA_OPTS} alluxio.zookeeper.enabled) JOURNAL_TYPE=$(${BIN}/alluxio getConf ${ALLUXIO_MASTER_JAVA_OPTS} alluxio.master.journal.type | awk '{print toupper($0)}') if [[ ${JOURNAL_TYPE} == "EMBEDDED" ]]; then @@ -40,15 +39,9 @@ if [[ ${JOURNAL_TYPE} == "EMBEDDED" ]]; then fi for master in ${HOSTLIST[@]}; do echo "[${master}] Connecting as ${USER}..." >> ${ALLUXIO_TASK_LOG} - if [[ ${HA_ENABLED} == "true" || ${N} -eq 0 ]]; then - nohup $(ssh_command ${master}) ${LAUNCHER} \ - $"${@// /\\ }" 2>&1 | while read line; do echo "[$(date '+%F %T')][${master}] ${line}"; done >> ${ALLUXIO_TASK_LOG} & - else - nohup $(ssh_command ${master}) ${LAUNCHER} \ - $"export ALLUXIO_MASTER_SECONDARY=true; ${@// /\\ }" 2>&1 | while read line; do echo "[$(date '+%F %T')][${master}] ${line}"; done >> ${ALLUXIO_TASK_LOG} & - fi + nohup $(ssh_command ${master}) ${LAUNCHER} \ + $"${@// /\\ }" 2>&1 | while read line; do echo "[$(date '+%F %T')][${master}] ${line}"; done >> ${ALLUXIO_TASK_LOG} & pids[${#pids[@]}]=$! - N=$((N+1)) done # wait for all pids diff --git a/bin/alluxio-start.sh b/bin/alluxio-start.sh index 60586a03dee5..8186e3588d9f 100755 --- a/bin/alluxio-start.sh +++ b/bin/alluxio-start.sh @@ -23,7 +23,6 @@ Where ACTION is one of: job_workers \tStart job_workers on worker nodes. local [MOPT] [-c cache] \tStart all processes locally. master \tStart the local master on this node. - secondary_master \tStart the local secondary master on this node. masters \tStart masters on master nodes. proxy \tStart the proxy on this node. proxies \tStart proxies on master and worker nodes. @@ -134,10 +133,8 @@ start_job_master() { ${LAUNCHER} "${BIN}/alluxio" format fi - if [[ ${ALLUXIO_MASTER_SECONDARY} != "true" ]]; then - echo "Starting job master @ $(hostname -f). Logging to ${ALLUXIO_LOGS_DIR}" - (nohup ${BIN}/launch-process job_master > ${ALLUXIO_LOGS_DIR}/job_master.out 2>&1) & - fi + echo "Starting job master @ $(hostname -f). Logging to ${ALLUXIO_LOGS_DIR}" + (nohup ${BIN}/launch-process job_master > ${ALLUXIO_LOGS_DIR}/job_master.out 2>&1) & } start_job_masters() { @@ -172,17 +169,8 @@ start_master() { fi fi - if [[ ${ALLUXIO_MASTER_SECONDARY} == "true" ]]; then - if [[ `${LAUNCHER} ${BIN}/alluxio getConf ${ALLUXIO_MASTER_JAVA_OPTS} alluxio.master.journal.type` == "EMBEDDED" ]]; then - echo "Secondary master is not supported for journal type: EMBEDDED" - exit 1 - fi - echo "Starting secondary master @ $(hostname -f). Logging to ${ALLUXIO_LOGS_DIR}" - (nohup ${BIN}/launch-process secondary_master > ${ALLUXIO_LOGS_DIR}/secondary_master.out 2>&1) & - else - echo "Starting master @ $(hostname -f). Logging to ${ALLUXIO_LOGS_DIR}" - (JOURNAL_BACKUP="${journal_backup}" nohup ${BIN}/launch-process master > ${ALLUXIO_LOGS_DIR}/master.out 2>&1) & - fi + echo "Starting master @ $(hostname -f). Logging to ${ALLUXIO_LOGS_DIR}" + (JOURNAL_BACKUP="${journal_backup}" nohup ${BIN}/launch-process master > ${ALLUXIO_LOGS_DIR}/master.out 2>&1) & } start_masters() { @@ -445,7 +433,7 @@ main() { if [[ "${killonstart}" != "no" ]]; then case "${ACTION}" in - all | local | master | masters | secondary_master | job_master | job_masters | proxy | proxies | worker | workers | job_worker | job_workers ) + all | local | master | masters | job_master | job_masters | proxy | proxies | worker | workers | job_worker | job_workers ) stop ${ACTION} sleep 1 ;; @@ -488,14 +476,6 @@ main() { ${LAUNCHER} ${BIN}/alluxio formatWorker fi start_master - ALLUXIO_MASTER_SECONDARY=true - # We only start a secondary master when using a UFS journal. - local journal_type=$(${BIN}/alluxio getConf ${ALLUXIO_MASTER_JAVA_OPTS} \ - alluxio.master.journal.type | awk '{print toupper($0)}') - if [[ ${journal_type} == "UFS" ]]; then - start_master - fi - ALLUXIO_MASTER_SECONDARY=false start_job_master sleep 2 start_worker "${MOPT}" @@ -517,12 +497,6 @@ main() { master) start_master "${FORMAT}" ;; - secondary_master) - ALLUXIO_MASTER_SECONDARY=true - async=true # there does not exist a monitor process for secondary_master - start_master - ALLUXIO_MASTER_SECONDARY=false - ;; masters) start_masters ;; diff --git a/bin/alluxio-stop.sh b/bin/alluxio-stop.sh index d8f6811977c4..16bfa7ce6d27 100755 --- a/bin/alluxio-stop.sh +++ b/bin/alluxio-stop.sh @@ -21,7 +21,6 @@ Where component is one of: job_workers \tStop job workers on worker nodes. local [-c cache] \tStop all processes locally. master \tStop local primary master. - secondary_master \tStop local secondary master. masters \tStop masters on master nodes. proxy \tStop local proxy. proxies \tStop proxies on master and worker nodes. @@ -88,13 +87,8 @@ stop_job_workers() { } stop_master() { - if [[ ${ALLUXIO_MASTER_SECONDARY} == "true" ]]; then - generate_kill_command "alluxio.master.AlluxioSecondaryMaster" - ${LAUNCHER} "${KILL_COMMAND[@]}" - else - generate_kill_command "alluxio.master.AlluxioMaster" - ${LAUNCHER} "${KILL_COMMAND[@]}" - fi + generate_kill_command "alluxio.master.AlluxioMaster" + ${LAUNCHER} "${KILL_COMMAND[@]}" } stop_masters() { @@ -208,9 +202,6 @@ case "${WHAT}" in stop_job_worker stop_job_master stop_worker - ALLUXIO_MASTER_SECONDARY=true - stop_master - ALLUXIO_MASTER_SECONDARY=false stop_master ;; job_master) @@ -228,11 +219,6 @@ case "${WHAT}" in master) stop_master ;; - secondary_master) - ALLUXIO_MASTER_SECONDARY=true - stop_master - ALLUXIO_MASTER_SECONDARY=false - ;; masters) stop_masters ;; diff --git a/bin/launch-process b/bin/launch-process index b58280f4b77c..285f0fb44316 100755 --- a/bin/launch-process +++ b/bin/launch-process @@ -27,7 +27,7 @@ desired process in the foreground. It is recommended to use alluxio-start.sh unless you know what you are doing. " USAGE+=" - One of: master, secondary_master, job_master, worker, + One of: master, job_master, worker, job_worker, proxy" USAGE+=" @@ -60,7 +60,6 @@ contains() { # The variables that should be set after running this function: # - ALLUXIO_JAVA_OPTS # - ALLUXIO_MASTER_JAVA_OPTS -# - ALLUXIO_SECONDARY_MASTER_JAVA_OPTS # - ALLUXIO JOB_MASTER_JAVA_OPTS # - ALLUXIO_WORKER_JAVA_OPTS # - ALLUXIO_JOB_WORKER_JAVA_OPTS @@ -140,19 +139,6 @@ launch_master() { "alluxio.master.AlluxioMaster" } -# Launch a secondary master process -launch_secondary_master() { - # use a default Xmx value for the master - local contain_xmx="$(contains "${ALLUXIO_SECONDARY_MASTER_JAVA_OPTS}" "Xmx")" - local contain_max_percentage="$(contains "${ALLUXIO_SECONDARY_MASTER_JAVA_OPTS}" "MaxRAMPercentage")" - if [[ "${contain_xmx}" -eq "0" ]] && [[ "${contain_max_percentage}" -eq "0" ]]; then - ALLUXIO_SECONDARY_MASTER_JAVA_OPTS+=" -Xmx8g " - fi - launch_process "${ALLUXIO_SECONDARY_MASTER_ATTACH_OPTS}" \ - "${ALLUXIO_SECONDARY_MASTER_JAVA_OPTS}" \ - "alluxio.master.AlluxioSecondaryMaster" -} - # Launch a job master process launch_job_master() { launch_process "${ALLUXIO_JOB_MASTER_ATTACH_OPTS}" \ @@ -227,10 +213,6 @@ main() { logger_var_name="ALLUXIO_MASTER_LOGGER" logger_var_value="MASTER_LOGGER" ;; - secondary_master) - logger_var_name="ALLUXIO_SECONDARY_MASTER_LOGGER" - logger_var_value="SECONDARY_MASTER_LOGGER" - ;; job_master) logger_var_name="ALLUXIO_JOB_MASTER_LOGGER" logger_var_value="JOB_MASTER_LOGGER" @@ -268,9 +250,6 @@ main() { master) launch_master ;; - secondary_master) - launch_secondary_master - ;; job_master) launch_job_master ;; diff --git a/conf/alluxio-env.sh.template b/conf/alluxio-env.sh.template index d92f7cd043f3..c2e53d2686a9 100644 --- a/conf/alluxio-env.sh.template +++ b/conf/alluxio-env.sh.template @@ -69,10 +69,6 @@ # E.g. "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=60001" # ALLUXIO_MASTER_ATTACH_OPTS -# Configuring remote debugging for Alluxio secondary master process. (Default: "") -# E.g. "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=60010" -# ALLUXIO_SECONDARY_MASTER_ATTACH_OPTS - # Configuring remote debugging for Alluxio job master process. (Default: "") # E.g. "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=60002" # ALLUXIO_JOB_MASTER_ATTACH_OPTS diff --git a/conf/log4j.properties b/conf/log4j.properties index e20ba61f987b..68118926085e 100644 --- a/conf/log4j.properties +++ b/conf/log4j.properties @@ -59,14 +59,6 @@ log4j.appender.MASTER_LOGGER.MaxBackupIndex=100 log4j.appender.MASTER_LOGGER.layout=org.apache.log4j.PatternLayout log4j.appender.MASTER_LOGGER.layout.ConversionPattern=%d{ISO8601} %-5p [%t](%F:%L) - %m%n -# Appender for Master -log4j.appender.SECONDARY_MASTER_LOGGER=org.apache.log4j.RollingFileAppender -log4j.appender.SECONDARY_MASTER_LOGGER.File=${alluxio.logs.dir}/secondary_master.log -log4j.appender.SECONDARY_MASTER_LOGGER.MaxFileSize=10MB -log4j.appender.SECONDARY_MASTER_LOGGER.MaxBackupIndex=100 -log4j.appender.SECONDARY_MASTER_LOGGER.layout=org.apache.log4j.PatternLayout -log4j.appender.SECONDARY_MASTER_LOGGER.layout.ConversionPattern=%d{ISO8601} %-5p [%t](%F:%L) - %m%n - # Appender for Master audit log4j.appender.MASTER_AUDIT_LOGGER=org.apache.log4j.RollingFileAppender log4j.appender.MASTER_AUDIT_LOGGER.File=${alluxio.logs.dir}/master_audit.log diff --git a/docs/_data/table/en/env_vars.yml b/docs/_data/table/en/env_vars.yml index eb50d1863a11..2c63ff4945e6 100644 --- a/docs/_data/table/en/env_vars.yml +++ b/docs/_data/table/en/env_vars.yml @@ -43,8 +43,6 @@ description: Additional classpath entries for Alluxio processes. Empty by default. - name: ALLUXIO_MASTER_ATTACH_OPTS description: Additional Java VM options to apply when attaching a debugger to Alluxio master. -- name: ALLUXIO_SECONDARY_MASTER_ATTACH_OPTS - description: Additional Java VM options to apply when attaching a debugger to Alluxio secondary master. - name: ALLUXIO_JOB_MASTER_ATTACH_OPTS description: Additional Java VM options to apply when attaching a debugger to Alluxio job master. - name: ALLUXIO_WORKER_ATTACH_OPTS diff --git a/dora/core/common/src/main/java/alluxio/conf/PropertyKey.java b/dora/core/common/src/main/java/alluxio/conf/PropertyKey.java index d9cbee125fc2..79a10055d09d 100755 --- a/dora/core/common/src/main/java/alluxio/conf/PropertyKey.java +++ b/dora/core/common/src/main/java/alluxio/conf/PropertyKey.java @@ -4206,18 +4206,6 @@ public String toString() { .setDefaultValue(1000) .build(); - // - // Secondary master related properties - // - public static final PropertyKey SECONDARY_MASTER_METASTORE_DIR = - stringBuilder(Name.SECONDARY_MASTER_METASTORE_DIR) - .setDefaultValue(format("${%s}/secondary-metastore", Name.WORK_DIR)) - .setDescription( - "The secondary master metastore work directory. Only some metastores need disk.") - .setConsistencyCheckLevel(ConsistencyCheckLevel.WARN) - .setScope(Scope.SERVER) - .build(); - // // File system master related properties // @@ -8821,10 +8809,8 @@ public static final class Name { "alluxio.master.throttle.filesystem.rpc.queue.size.limit"; // - // Secondary master related properties + // Standby master related properties // - public static final String SECONDARY_MASTER_METASTORE_DIR = - "alluxio.secondary.master.metastore.dir"; public static final String STANDBY_MASTER_METRICS_SINK_ENABLED = "alluxio.standby.master.metrics.sink.enabled"; public static final String STANDBY_MASTER_WEB_ENABLED = diff --git a/dora/core/server/master/src/main/java/alluxio/master/AlluxioSecondaryMaster.java b/dora/core/server/master/src/main/java/alluxio/master/AlluxioSecondaryMaster.java deleted file mode 100644 index 760bca34cc49..000000000000 --- a/dora/core/server/master/src/main/java/alluxio/master/AlluxioSecondaryMaster.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 - * (the "License"). You may not use this work except in compliance with the License, which is - * available at www.apache.org/licenses/LICENSE-2.0 - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied, as more fully set forth in the License. - * - * See the NOTICE file distributed with this work for information regarding copyright ownership. - */ - -package alluxio.master; - -import alluxio.Process; -import alluxio.ProcessUtils; -import alluxio.RuntimeConstants; -import alluxio.conf.Configuration; -import alluxio.conf.PropertyKey; -import alluxio.master.journal.JournalSystem; -import alluxio.master.journal.JournalUtils; -import alluxio.underfs.MasterUfsManager; -import alluxio.util.CommonUtils; -import alluxio.util.CommonUtils.ProcessType; -import alluxio.util.WaitForOptions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeoutException; -import javax.annotation.concurrent.NotThreadSafe; - -/** - * The secondary Alluxio master that replays journal logs and writes checkpoints. - */ -@NotThreadSafe -public final class AlluxioSecondaryMaster implements Process { - private static final Logger LOG = LoggerFactory.getLogger(AlluxioSecondaryMaster.class); - private final MasterRegistry mRegistry = new MasterRegistry(); - private final JournalSystem mJournalSystem = new JournalSystem.Builder() - .setLocation(JournalUtils.getJournalLocation()).build(ProcessType.MASTER); - private final CountDownLatch mLatch = new CountDownLatch(1); - - private volatile boolean mRunning = false; - - /** - * Creates a {@link AlluxioSecondaryMaster}. - */ - AlluxioSecondaryMaster() { - String baseDir = Configuration.getString(PropertyKey.SECONDARY_MASTER_METASTORE_DIR); - // Create masters. - MasterUtils.createMasters(mRegistry, CoreMasterContext.newBuilder() - .setJournalSystem(mJournalSystem) - .setPrimarySelector(new AlwaysStandbyPrimarySelector()) - .setSafeModeManager(new DefaultSafeModeManager()) - .setBackupManager(new BackupManager(mRegistry)) - .setBlockStoreFactory(MasterUtils.getBlockStoreFactory(baseDir)) - .setInodeStoreFactory(MasterUtils.getInodeStoreFactory(baseDir)) - .setStartTimeMs(System.currentTimeMillis()) - .setPort(Configuration.getInt(PropertyKey.MASTER_RPC_PORT)) - .setUfsManager(new MasterUfsManager()) - .build()); - // Check that journals of each service have been formatted. - if (!mJournalSystem.isFormatted()) { - throw new RuntimeException( - String.format("Journal %s has not been formatted!", JournalUtils.getJournalLocation())); - } - } - - @Override - public void start() throws Exception { - mJournalSystem.start(); - mRunning = true; - mLatch.await(); - mJournalSystem.stop(); - mRegistry.close(); - mRunning = false; - } - - @Override - public void stop() throws Exception { - mLatch.countDown(); - } - - @Override - public boolean waitForReady(int timeoutMs) { - try { - CommonUtils.waitFor("Secondary master to start", () -> mRunning, - WaitForOptions.defaults().setTimeoutMs(timeoutMs)); - return true; - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - return false; - } catch (TimeoutException e) { - return false; - } - } - - @Override - public String toString() { - return "Alluxio secondary master"; - } - - /** - * Starts the secondary Alluxio master. - * - * @param args command line arguments, should be empty - */ - // TODO(peis): Move the non-static methods into AlluxioSecondaryMasterProcess for consistency. - public static void main(String[] args) { - if (args.length != 0) { - LOG.info("java -cp {} {}", RuntimeConstants.ALLUXIO_JAR, - AlluxioSecondaryMaster.class.getCanonicalName()); - System.exit(-1); - } - - AlluxioSecondaryMaster master = new AlluxioSecondaryMaster(); - ProcessUtils.run(master); - } -} diff --git a/dora/core/server/master/src/test/java/alluxio/master/journal/ufs/UfsJournalReaderTest.java b/dora/core/server/master/src/test/java/alluxio/master/journal/ufs/UfsJournalReaderTest.java index ed14f6eee536..9ccfd850980c 100644 --- a/dora/core/server/master/src/test/java/alluxio/master/journal/ufs/UfsJournalReaderTest.java +++ b/dora/core/server/master/src/test/java/alluxio/master/journal/ufs/UfsJournalReaderTest.java @@ -137,26 +137,6 @@ public void readIncompleteLogPrimary() throws Exception { } } - /** - * Secondary master cannot read incomplete logs. - */ - @Test - public void readIncompleteLogSecondary() throws Exception { - long endSN = 10; - buildCompletedLog(0, endSN); - buildIncompleteLog(endSN, endSN + 1); - try (JournalReader reader = mJournal.getReader(false)) { - int sn = 0; - while (reader.advance() != State.DONE) { - assertEquals(sn, reader.getEntry().getSequenceNumber()); - sn++; - } - - assertEquals(endSN, sn); - assertEquals(sn, reader.getNextSequenceNumber()); - } - } - /** * Reads logs created while reading the journal. */ diff --git a/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioCluster.java b/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioCluster.java index 0e7c012b2f53..00a9c1f0d836 100644 --- a/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioCluster.java +++ b/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioCluster.java @@ -39,8 +39,6 @@ */ @NotThreadSafe public final class LocalAlluxioCluster extends AbstractLocalAlluxioCluster { - private boolean mIncludeSecondary; - private boolean mIncludeProxy; private LocalAlluxioMaster mMaster; @@ -49,28 +47,18 @@ public final class LocalAlluxioCluster extends AbstractLocalAlluxioCluster { * Runs a test Alluxio cluster with a single Alluxio worker. */ public LocalAlluxioCluster() { - this(1, false, false); + this(1, false); } /** * @param numWorkers the number of workers to run - * @param includeSecondary weather to include the secondary master * @param includeProxy weather to include the proxy */ - public LocalAlluxioCluster(int numWorkers, boolean includeSecondary, boolean includeProxy) { + public LocalAlluxioCluster(int numWorkers, boolean includeProxy) { super(numWorkers); - mIncludeSecondary = includeSecondary; mIncludeProxy = includeProxy; } - /** - * @param numWorkers the number of workers to run - * @param includeSecondary weather to include the secondary master - */ - public LocalAlluxioCluster(int numWorkers, boolean includeSecondary) { - this(numWorkers, includeSecondary, false); - } - @Override public FileSystem getClient() throws IOException { return mMaster.getClient(); @@ -147,7 +135,7 @@ public void initConfiguration(String name) throws IOException { @Override public void startMasters() throws Exception { - mMaster = LocalAlluxioMaster.create(mWorkDirectory, mIncludeSecondary); + mMaster = LocalAlluxioMaster.create(mWorkDirectory); mMaster.start(); waitForMasterServing(); } diff --git a/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java b/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java index 49f70084cbfd..188a3ab6e4cb 100644 --- a/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java +++ b/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java @@ -17,7 +17,6 @@ import alluxio.client.file.FileSystemContext; import alluxio.conf.Configuration; import alluxio.conf.PropertyKey; -import alluxio.master.journal.JournalType; import alluxio.util.io.FileUtils; import alluxio.util.network.NetworkAddressUtils; import alluxio.util.network.NetworkAddressUtils.ServiceType; @@ -50,47 +49,39 @@ public final class LocalAlluxioMaster { private final ClientPool mClientPool = new ClientPool(mClientSupplier); - private final boolean mIncludeSecondary; - private AlluxioMasterProcess mMasterProcess; private Thread mMasterThread; - private AlluxioSecondaryMaster mSecondaryMaster; - private Thread mSecondaryMasterThread; - - private LocalAlluxioMaster(boolean includeSecondary) { + private LocalAlluxioMaster() { mHostname = NetworkAddressUtils.getConnectHost(ServiceType.MASTER_RPC, Configuration.global()); mJournalFolder = Configuration.getString(PropertyKey.MASTER_JOURNAL_FOLDER); - mIncludeSecondary = includeSecondary; } /** * Creates a new local Alluxio master with an isolated work directory and port. * - * @param includeSecondary whether to start a secondary master alongside the regular master * @return an instance of Alluxio master */ - public static LocalAlluxioMaster create(boolean includeSecondary) throws IOException { + public static LocalAlluxioMaster create() throws IOException { String workDirectory = uniquePath(); FileUtils.deletePathRecursively(workDirectory); Configuration.set(PropertyKey.WORK_DIR, workDirectory); - return create(workDirectory, includeSecondary); + return create(workDirectory); } /** * Creates a new local Alluxio master with a isolated port. * * @param workDirectory Alluxio work directory, this method will create it if it doesn't exist yet - * @param includeSecondary whether to start a secondary master alongside the regular master * @return the created Alluxio master */ - public static LocalAlluxioMaster create(String workDirectory, boolean includeSecondary) + public static LocalAlluxioMaster create(String workDirectory) throws IOException { if (!Files.isDirectory(Paths.get(workDirectory))) { Files.createDirectory(Paths.get(workDirectory)); } - return new LocalAlluxioMaster(includeSecondary); + return new LocalAlluxioMaster(); } /** @@ -116,35 +107,6 @@ public void run() { mMasterThread = new Thread(runMaster); mMasterThread.setName("MasterThread-" + System.identityHashCode(mMasterThread)); mMasterThread.start(); - // Don't start a secondary master when using the Raft journal. - if (Configuration.getEnum(PropertyKey.MASTER_JOURNAL_TYPE, - JournalType.class) == JournalType.EMBEDDED) { - return; - } - if (!mIncludeSecondary) { - return; - } - mSecondaryMaster = new AlluxioSecondaryMaster(); - Runnable runSecondaryMaster = new Runnable() { - @Override - public void run() { - try { - LOG.info("Starting secondary master {}.", mSecondaryMaster); - mSecondaryMaster.start(); - } catch (InterruptedException e) { - // this is expected - } catch (Exception e) { - // Log the exception as the RuntimeException will be caught and handled silently by JUnit - LOG.error("Start secondary master error", e); - throw new RuntimeException(e + " \n Start Secondary Master Error \n" + e.getMessage(), e); - } - } - }; - mSecondaryMasterThread = new Thread(runSecondaryMaster); - mSecondaryMasterThread - .setName("SecondaryMasterThread-" + System.identityHashCode(mSecondaryMasterThread)); - mSecondaryMasterThread.start(); - TestUtils.waitForReady(mSecondaryMaster); } /** @@ -158,14 +120,6 @@ public boolean isServing() { * Stops the master processes and cleans up client connections. */ public void stop() throws Exception { - if (mSecondaryMasterThread != null) { - mSecondaryMaster.stop(); - while (mSecondaryMasterThread.isAlive()) { - LOG.info("Stopping thread {}.", mSecondaryMasterThread.getName()); - mSecondaryMasterThread.join(1000); - } - mSecondaryMasterThread = null; - } if (mMasterThread != null) { mMasterProcess.stop(); while (mMasterThread.isAlive()) { diff --git a/dora/minicluster/src/main/java/alluxio/master/MultiMasterEmbeddedJournalLocalAlluxioCluster.java b/dora/minicluster/src/main/java/alluxio/master/MultiMasterEmbeddedJournalLocalAlluxioCluster.java index deec3910d405..6f2795800908 100644 --- a/dora/minicluster/src/main/java/alluxio/master/MultiMasterEmbeddedJournalLocalAlluxioCluster.java +++ b/dora/minicluster/src/main/java/alluxio/master/MultiMasterEmbeddedJournalLocalAlluxioCluster.java @@ -269,7 +269,7 @@ protected void startMasters() throws IOException { address.getEmbeddedJournalPort()); Configuration.set(PropertyKey.MASTER_JOURNAL_FOLDER, mJournalFolders.get(k)); - final LocalAlluxioMaster master = LocalAlluxioMaster.create(mWorkDirectory, false); + final LocalAlluxioMaster master = LocalAlluxioMaster.create(mWorkDirectory); master.start(); LOG.info("master NO.{} started, isServing: {}, address: {}", k, master.isServing(), master.getAddress()); diff --git a/dora/minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java b/dora/minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java index 72740fd58fbf..47914e584362 100644 --- a/dora/minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java +++ b/dora/minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java @@ -233,7 +233,7 @@ protected void startMasters() throws IOException { for (int k = 0; k < mNumOfMasters; k++) { Configuration.set(PropertyKey.MASTER_METASTORE_DIR, PathUtils.concatPath(mWorkDirectory, "metastore-" + k)); - final LocalAlluxioMaster master = LocalAlluxioMaster.create(mWorkDirectory, false); + final LocalAlluxioMaster master = LocalAlluxioMaster.create(mWorkDirectory); master.start(); LOG.info("master NO.{} started, isServing: {}, address: {}", k, master.isServing(), master.getAddress()); diff --git a/dora/tests/src/test/java/alluxio/client/cli/JournalToolTest.java b/dora/tests/src/test/java/alluxio/client/cli/JournalToolTest.java index bab59e4e7f10..3cda389f7cdd 100644 --- a/dora/tests/src/test/java/alluxio/client/cli/JournalToolTest.java +++ b/dora/tests/src/test/java/alluxio/client/cli/JournalToolTest.java @@ -80,7 +80,6 @@ public class JournalToolTest extends BaseIntegrationTest { @Rule public LocalAlluxioClusterResource mLocalAlluxioClusterResource = new LocalAlluxioClusterResource.Builder() - .setIncludeSecondary(true) .setProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) .setProperty(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, CHECKPOINT_SIZE) .setProperty(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, "100") diff --git a/dora/tests/src/test/java/alluxio/server/ft/journal/ufs/SecondaryMasterTest.java b/dora/tests/src/test/java/alluxio/server/ft/journal/ufs/SecondaryMasterTest.java deleted file mode 100644 index 8e2390261212..000000000000 --- a/dora/tests/src/test/java/alluxio/server/ft/journal/ufs/SecondaryMasterTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * The Alluxio Open Foundation licenses this work under the Apache License, version 2.0 - * (the "License"). You may not use this work except in compliance with the License, which is - * available at www.apache.org/licenses/LICENSE-2.0 - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied, as more fully set forth in the License. - * - * See the NOTICE file distributed with this work for information regarding copyright ownership. - */ - -package alluxio.server.ft.journal.ufs; - -import alluxio.AlluxioURI; -import alluxio.Constants; -import alluxio.annotation.dora.DoraTestTodoItem; -import alluxio.client.file.FileSystem; -import alluxio.conf.PropertyKey; -import alluxio.master.journal.JournalType; -import alluxio.testutils.BaseIntegrationTest; -import alluxio.testutils.IntegrationTestUtils; -import alluxio.testutils.LocalAlluxioClusterResource; - -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; - -@Ignore -@DoraTestTodoItem(action = DoraTestTodoItem.Action.REMOVE, owner = "jiacheng", - comment = "secondary master is deprecated") -public class SecondaryMasterTest extends BaseIntegrationTest { - @Rule - public LocalAlluxioClusterResource mClusterResource = - new LocalAlluxioClusterResource.Builder() - .setIncludeSecondary(true) - .setProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - .setProperty(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, 10) - .setProperty(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, 1) - .build(); - - @Test - public void secondaryShouldCreateCheckpoints() throws Exception { - FileSystem fs = mClusterResource.get().getClient(); - // Create a bunch of directories to trigger a checkpoint. - for (int i = 0; i < 10; i++) { - fs.createDirectory(new AlluxioURI("/dir" + i)); - } - IntegrationTestUtils.waitForUfsJournalCheckpoint(Constants.FILE_SYSTEM_MASTER_NAME); - } -} diff --git a/dora/tests/src/test/java/alluxio/testutils/LocalAlluxioClusterResource.java b/dora/tests/src/test/java/alluxio/testutils/LocalAlluxioClusterResource.java index 910b5f74702d..3990e9f01db0 100644 --- a/dora/tests/src/test/java/alluxio/testutils/LocalAlluxioClusterResource.java +++ b/dora/tests/src/test/java/alluxio/testutils/LocalAlluxioClusterResource.java @@ -82,9 +82,6 @@ public final class LocalAlluxioClusterResource implements TestRule { /** Number of Alluxio workers in the cluster. */ private final int mNumWorkers; - /** Weather to include the secondary master. */ - private final boolean mIncludeSecondary; - /** Weather to include the proxy. */ private final boolean mIncludeProxy; @@ -110,10 +107,9 @@ public final class LocalAlluxioClusterResource implements TestRule { * @param numWorkers the number of Alluxio workers to launch * @param configuration configuration for configuring the cluster */ - private LocalAlluxioClusterResource(boolean startCluster, boolean includeSecondary, + private LocalAlluxioClusterResource(boolean startCluster, boolean includeProxy, int numWorkers, Map configuration) { mStartCluster = startCluster; - mIncludeSecondary = includeSecondary; mIncludeProxy = includeProxy; mNumWorkers = numWorkers; mConfiguration.putAll(configuration); @@ -149,7 +145,7 @@ public LocalAlluxioClusterResource setProperty(PropertyKey key, Object value) { public void start() throws Exception { AuthenticatedClientUser.remove(); // Create a new cluster. - mLocalAlluxioCluster = new LocalAlluxioCluster(mNumWorkers, mIncludeSecondary, mIncludeProxy); + mLocalAlluxioCluster = new LocalAlluxioCluster(mNumWorkers, mIncludeProxy); // Init configuration for integration test mLocalAlluxioCluster.initConfiguration(mTestName); // Overwrite the test configuration with test specific parameters @@ -238,7 +234,6 @@ public TestRule getResetResource() { */ public static class Builder { private boolean mStartCluster; - private boolean mIncludeSecondary; private boolean mIncludeProxy; private int mNumWorkers; private Map mConfiguration; @@ -248,7 +243,6 @@ public static class Builder { */ public Builder() { mStartCluster = true; - mIncludeSecondary = false; mIncludeProxy = false; mNumWorkers = 1; mConfiguration = new HashMap<>(); @@ -262,14 +256,6 @@ public Builder setStartCluster(boolean startCluster) { return this; } - /** - * @param includeSecondary whether to include the secondary master - */ - public Builder setIncludeSecondary(boolean includeSecondary) { - mIncludeSecondary = includeSecondary; - return this; - } - /** * @param includeProxy whether to include the proxy */ @@ -299,7 +285,7 @@ public Builder setProperty(PropertyKey key, Object value) { * @return a {@link LocalAlluxioClusterResource} for the current builder values */ public LocalAlluxioClusterResource build() { - return new LocalAlluxioClusterResource(mStartCluster, mIncludeSecondary, mIncludeProxy, + return new LocalAlluxioClusterResource(mStartCluster, mIncludeProxy, mNumWorkers, mConfiguration); } } diff --git a/libexec/alluxio-config.sh b/libexec/alluxio-config.sh index 4d96e8b06b9e..f1f4282ae82d 100755 --- a/libexec/alluxio-config.sh +++ b/libexec/alluxio-config.sh @@ -132,10 +132,6 @@ ALLUXIO_MASTER_JAVA_OPTS_DEFAULT=" -Dalluxio.logger.type=${ALLUXIO_MASTER_LOGGER ALLUXIO_MASTER_JAVA_OPTS_DEFAULT+=" -Dalluxio.master.audit.logger.type=${ALLUXIO_MASTER_AUDIT_LOGGER:-MASTER_AUDIT_LOGGER}" ALLUXIO_MASTER_JAVA_OPTS="${ALLUXIO_MASTER_JAVA_OPTS_DEFAULT} ${ALLUXIO_JAVA_OPTS} ${ALLUXIO_MASTER_JAVA_OPTS}" -# Secondary master specific parameters based on ALLUXIO_JAVA_OPTS. -ALLUXIO_SECONDARY_MASTER_JAVA_OPTS_DEFAULT=" -Dalluxio.logger.type=${ALLUXIO_SECONDARY_MASTER_LOGGER:-SECONDARY_MASTER_LOGGER}" -ALLUXIO_SECONDARY_MASTER_JAVA_OPTS="${ALLUXIO_SECONDARY_MASTER_JAVA_OPTS_DEFAULT} ${ALLUXIO_JAVA_OPTS} ${ALLUXIO_SECONDARY_MASTER_JAVA_OPTS}" - # Proxy specific parameters that will be shared to all workers based on ALLUXIO_JAVA_OPTS. ALLUXIO_PROXY_JAVA_OPTS_DEFAULT=" -Dalluxio.logger.type=${ALLUXIO_PROXY_LOGGER:-PROXY_LOGGER}" ALLUXIO_PROXY_JAVA_OPTS_DEFAULT+=" -Dalluxio.proxy.audit.logger.type=${ALLUXIO_PROXY_AUDIT_LOGGER:-PROXY_AUDIT_LOGGER}"