diff --git a/dora/core/client/fs/src/test/java/alluxio/client/file/FileSystemFactoryTest.java b/dora/core/client/fs/src/test/java/alluxio/client/file/FileSystemFactoryTest.java index 8616b826c973..caa95e7ec109 100644 --- a/dora/core/client/fs/src/test/java/alluxio/client/file/FileSystemFactoryTest.java +++ b/dora/core/client/fs/src/test/java/alluxio/client/file/FileSystemFactoryTest.java @@ -27,7 +27,6 @@ import alluxio.master.MasterInquireClient; import alluxio.security.User; import alluxio.uri.MultiMasterAuthority; -import alluxio.uri.ZookeeperAuthority; import org.junit.After; import org.junit.Before; @@ -37,9 +36,7 @@ import java.io.Closeable; import java.io.IOException; import java.security.Principal; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Set; import javax.security.auth.Subject; @@ -88,26 +85,6 @@ public void multiMasterFileSystemCacheTest() { } } - @Test - public void zkFileSystemCacheTest() { - Map sysProps = new HashMap<>(); - sysProps.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), Boolean.toString(true)); - sysProps.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), "zk@192.168.0.5"); - sysProps.put(PropertyKey.ZOOKEEPER_ELECTION_PATH.getName(), "/alluxio/leader"); - - try (Closeable p = new SystemPropertyRule(sysProps).toResource()) { - Configuration.reloadProperties(); - AlluxioConfiguration conf = Configuration.global(); - MasterInquireClient.ConnectDetails connectDetails = - MasterInquireClient.Factory.getConnectDetails(conf); - // Make sure we have a Zookeeper authority - assertTrue(connectDetails.toAuthority() instanceof ZookeeperAuthority); - fileSystemCacheTest(); - } catch (IOException e) { - fail("Unable to set system properties"); - } - } - @Test public void nullSubjectTest() { assertThrows(NullPointerException.class, () -> FileSystem.Factory.get(null)); diff --git a/dora/core/client/hdfs/src/main/java/alluxio/hadoop/FileSystem.java b/dora/core/client/hdfs/src/main/java/alluxio/hadoop/FileSystem.java index 65cf0873e5b7..60c7a5db4c8e 100644 --- a/dora/core/client/hdfs/src/main/java/alluxio/hadoop/FileSystem.java +++ b/dora/core/client/hdfs/src/main/java/alluxio/hadoop/FileSystem.java @@ -20,8 +20,6 @@ import alluxio.uri.MultiMasterAuthority; import alluxio.uri.SingleMasterAuthority; import alluxio.uri.UnknownAuthority; -import alluxio.uri.ZookeeperAuthority; -import alluxio.uri.ZookeeperLogicalAuthority; import com.google.common.base.Preconditions; import org.apache.hadoop.conf.Configuration; @@ -66,7 +64,7 @@ public String getScheme() { @Override protected boolean isZookeeperMode() { - return mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED); + return false; } @Override @@ -74,17 +72,10 @@ protected Map getConfigurationFromUri(URI uri, Configuration con AlluxioURI alluxioUri = new AlluxioURI(uri.toString()); Map alluxioConfProperties = new HashMap<>(); - if (alluxioUri.getAuthority() instanceof ZookeeperAuthority) { - ZookeeperAuthority authority = (ZookeeperAuthority) alluxioUri.getAuthority(); - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), true); - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), - authority.getZookeeperAddress()); - } else if (alluxioUri.getAuthority() instanceof SingleMasterAuthority) { + if (alluxioUri.getAuthority() instanceof SingleMasterAuthority) { SingleMasterAuthority authority = (SingleMasterAuthority) alluxioUri.getAuthority(); alluxioConfProperties.put(PropertyKey.MASTER_HOSTNAME.getName(), authority.getHost()); alluxioConfProperties.put(PropertyKey.MASTER_RPC_PORT.getName(), authority.getPort()); - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), false); - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), null); // Unset the embedded journal related configuration // to support alluxio URI has the highest priority alluxioConfProperties.put(PropertyKey.MASTER_EMBEDDED_JOURNAL_ADDRESSES.getName(), null); @@ -93,9 +84,6 @@ protected Map getConfigurationFromUri(URI uri, Configuration con MultiMasterAuthority authority = (MultiMasterAuthority) alluxioUri.getAuthority(); alluxioConfProperties.put(PropertyKey.MASTER_RPC_ADDRESSES.getName(), authority.getMasterAddresses()); - // Unset the zookeeper configuration to support alluxio URI has the highest priority - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), false); - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), null); } else if (alluxioUri.getAuthority() instanceof EmbeddedLogicalAuthority) { EmbeddedLogicalAuthority authority = (EmbeddedLogicalAuthority) alluxioUri.getAuthority(); String masterNamesConfKey = PropertyKey.Template.MASTER_LOGICAL_NAMESERVICES @@ -115,27 +103,6 @@ protected Map getConfigurationFromUri(URI uri, Configuration con alluxioConfProperties.put(PropertyKey.MASTER_RPC_ADDRESSES.getName(), masterRpcAddress.toString()); - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), false); - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), null); - } else if (alluxioUri.getAuthority() instanceof ZookeeperLogicalAuthority) { - ZookeeperLogicalAuthority authority = (ZookeeperLogicalAuthority) alluxioUri.getAuthority(); - String zkNodesConfKey = PropertyKey.Template.MASTER_LOGICAL_ZOOKEEPER_NAMESERVICES - .format(authority.getLogicalName()).getName(); - String[] zkNodeNames = conf.getTrimmedStrings(zkNodesConfKey); - Preconditions.checkArgument(zkNodeNames.length != 0, - "Invalid uri. You must set %s to use the logical name", zkNodesConfKey); - - StringJoiner zkAddress = new StringJoiner(","); - for (String zkName : zkNodeNames) { - String name = PropertyKey.Template.MASTER_LOGICAL_ZOOKEEPER_ADDRESS - .format(authority.getLogicalName(), zkName).getName(); - String address = conf.get(name); - Preconditions.checkArgument(address != null, "You need to set %s", name); - zkAddress.add(address); - } - - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), true); - alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), zkAddress.toString()); } return alluxioConfProperties; } diff --git a/dora/core/client/hdfs/src/test/java/alluxio/hadoop/AbstractFileSystemApiTest.java b/dora/core/client/hdfs/src/test/java/alluxio/hadoop/AbstractFileSystemApiTest.java index 0e6287ba1b28..03b8e4e7f0e6 100644 --- a/dora/core/client/hdfs/src/test/java/alluxio/hadoop/AbstractFileSystemApiTest.java +++ b/dora/core/client/hdfs/src/test/java/alluxio/hadoop/AbstractFileSystemApiTest.java @@ -75,21 +75,6 @@ public void validAuthorityNoWarning() throws IOException { assertFalse(loggedAuthorityWarning()); } - @Test - @DoraTestTodoItem(action = DoraTestTodoItem.Action.FIX, owner = "Jiacheng", - comment = "fix test because the URI is general") - @Ignore - public void parseZkUriWithPlusDelimiters() throws Exception { - org.apache.hadoop.fs.FileSystem fs = FileSystem.get(URI.create("alluxio://zk@a:0+b:1+c:2/"), - new org.apache.hadoop.conf.Configuration()); - assertTrue(fs instanceof AbstractFileSystem); - AbstractFileSystem afs = (AbstractFileSystem) fs; - assertTrue(afs.mFileSystem.getConf() - .getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("a:0,b:1,c:2", afs.mFileSystem.getConf() - .get(PropertyKey.ZOOKEEPER_ADDRESS)); - } - private boolean loggedAuthorityWarning() { return mTestLogger.wasLogged("Authority .* is unknown"); } diff --git a/dora/core/client/hdfs/src/test/java/alluxio/hadoop/AbstractFileSystemTest.java b/dora/core/client/hdfs/src/test/java/alluxio/hadoop/AbstractFileSystemTest.java index f36c1680e358..5e06d5f67aa3 100644 --- a/dora/core/client/hdfs/src/test/java/alluxio/hadoop/AbstractFileSystemTest.java +++ b/dora/core/client/hdfs/src/test/java/alluxio/hadoop/AbstractFileSystemTest.java @@ -123,56 +123,6 @@ public void after() { HadoopClientTestUtils.disableMetrics(mConfiguration); } - @Test - public void hadoopShouldLoadFileSystemWithSingleZkUri() throws Exception { - org.apache.hadoop.conf.Configuration conf = getConf(); - URI uri = URI.create(Constants.HEADER + "zk@zkHost:2181/tmp/path.txt"); - - FileSystem hfs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, conf)); - assertTrue(hfs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("zkHost:2181", hfs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - } - - @Test - public void hadoopShouldLoadFileSystemWithMultipleZkUri() throws Exception { - org.apache.hadoop.conf.Configuration conf = getConf(); - URI uri = URI.create(Constants.HEADER + "zk@host1:2181,host2:2181,host3:2181/tmp/path.txt"); - org.apache.hadoop.fs.FileSystem fs = org.apache.hadoop.fs.FileSystem.get(uri, conf); - - FileSystem hfs = getHadoopFilesystem(fs); - assertTrue(hfs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("host1:2181,host2:2181,host3:2181", - hfs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - - uri = URI.create(Constants.HEADER + "zk@host1:2181;host2:2181;host3:2181/tmp/path.txt"); - fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, conf)); - assertTrue(hfs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("host1:2181,host2:2181,host3:2181", - hfs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - } - - @Test - public void fsShouldSetPropertyConfWithLogicalUriConfig() throws Exception { - URI uri = URI.create("alluxio://ebj@logical/path"); - Configuration conf = getConf(); - conf.set(PropertyKey.Template.MASTER_LOGICAL_NAMESERVICES.format("logical").getName(), - "master1,master2,master3"); - conf.set( - PropertyKey.Template.MASTER_LOGICAL_RPC_ADDRESS.format("logical", "master1").getName(), - "host1:19998"); - conf.set( - PropertyKey.Template.MASTER_LOGICAL_RPC_ADDRESS.format("logical", "master2").getName(), - "host2:19998"); - conf.set( - PropertyKey.Template.MASTER_LOGICAL_RPC_ADDRESS.format("logical", "master3").getName(), - "host3:19998"); - AbstractFileSystem afs = new alluxio.hadoop.FileSystem(); - afs.initialize(uri, conf); - assertEquals("host1:19998,host2:19998,host3:19998", - afs.mFileSystem.getConf().get(PropertyKey.MASTER_RPC_ADDRESSES)); - assertFalse(afs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - } - @Test public void fsShouldTriggersExceptionWithUnknownLogicalUriWith() throws Exception { URI uri = URI.create("alluxio://ebj@logical/path"); @@ -180,28 +130,6 @@ public void fsShouldTriggersExceptionWithUnknownLogicalUriWith() throws Exceptio assertThrows(Exception.class, () -> afs.initialize(uri, getConf())); } - @Test - public void fsShouldSetPropertyConfWithZkLogicalUriConfig() throws Exception { - URI uri = URI.create("alluxio://zk@logical/path"); - Configuration conf = getConf(); - conf.set(PropertyKey.Template.MASTER_LOGICAL_ZOOKEEPER_NAMESERVICES.format("logical").getName(), - "node1,node2,node3"); - conf.set( - PropertyKey.Template.MASTER_LOGICAL_ZOOKEEPER_ADDRESS.format("logical", "node1").getName(), - "host1:2181"); - conf.set( - PropertyKey.Template.MASTER_LOGICAL_ZOOKEEPER_ADDRESS.format("logical", "node2").getName(), - "host2:2181"); - conf.set( - PropertyKey.Template.MASTER_LOGICAL_ZOOKEEPER_ADDRESS.format("logical", "node3").getName(), - "host3:2181"); - AbstractFileSystem afs = new alluxio.hadoop.FileSystem(); - afs.initialize(uri, conf); - assertEquals("host1:2181,host2:2181,host3:2181", - afs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - assertTrue(afs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - } - @Test public void fsShouldTriggersExceptionWithUnknownZkLogicalUriWith() { URI uri = URI.create("alluxio://zk@logical/path"); @@ -214,8 +142,6 @@ public void fsShouldSetPropertyConfWithMultiMasterUri() throws Exception { URI uri = URI.create("alluxio://host1:19998,host2:19998,host3:19998/path"); AbstractFileSystem afs = new alluxio.hadoop.FileSystem(); afs.initialize(uri, getConf()); - assertFalse(afs.mFileSystem.getConf() - .getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); assertEquals("host1:19998,host2:19998,host3:19998", afs.mFileSystem.getConf().get(PropertyKey.MASTER_RPC_ADDRESSES)); @@ -223,8 +149,6 @@ public void fsShouldSetPropertyConfWithMultiMasterUri() throws Exception { afs = new FileSystem(); afs.initialize(uri, getConf()); - assertFalse(afs.mFileSystem.getConf() - .getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); assertEquals("host1:19998,host2:19998,host3:19998", afs.mFileSystem.getConf().get(PropertyKey.MASTER_RPC_ADDRESSES)); } @@ -249,76 +173,18 @@ public void hadoopShouldLoadFileSystemWhenConfigured() throws Exception { Map properties = new HashMap<>(); properties.put(PropertyKey.MASTER_HOSTNAME, uri.getHost()); properties.put(PropertyKey.MASTER_RPC_PORT, uri.getPort()); - properties.put(PropertyKey.ZOOKEEPER_ENABLED, false); - properties.put(PropertyKey.ZOOKEEPER_ADDRESS, null); try (Closeable c = new ConfigurationRule(properties, mConfiguration).toResource()) { final org.apache.hadoop.fs.FileSystem fs = org.apache.hadoop.fs.FileSystem.get(uri, conf); assertTrue(fs instanceof FileSystem); } } - @Test - public void resetContextUsingZookeeperUris() throws Exception { - // Change to signle zookeeper uri - URI uri = URI.create(Constants.HEADER + "zk@zkHost:2181/"); - FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - - assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("zkHost:2181", fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - - uri = URI.create(Constants.HEADER + "zk@host1:2181,host2:2181,host3:2181/tmp/path.txt"); - fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - - assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("host1:2181,host2:2181,host3:2181", - fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - - uri = URI.create(Constants.HEADER + "zk@host1:2181;host2:2181;host3:2181/tmp/path.txt"); - fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("host1:2181,host2:2181,host3:2181", - fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - } - - @Test - public void resetContextFromZkUriToNonZkUri() throws Exception { - org.apache.hadoop.conf.Configuration conf = getConf(); - URI uri = URI.create(Constants.HEADER + "zk@zkHost:2181/tmp/path.txt"); - FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, conf)); - assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("zkHost:2181", fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - - URI otherUri = URI.create(Constants.HEADER + "alluxioHost:19998/tmp/path.txt"); - fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(otherUri, conf)); - assertEquals("alluxioHost", fs.mFileSystem.getConf().get(PropertyKey.MASTER_HOSTNAME)); - assertEquals(19998, fs.mFileSystem.getConf().get(PropertyKey.MASTER_RPC_PORT)); - assertFalse(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertFalse(fs.mFileSystem.getConf().isSet(PropertyKey.ZOOKEEPER_ADDRESS)); - } @Test public void resetContextUsingMultiMasterUris() throws Exception { // Change to multi-master uri URI uri = URI.create(Constants.HEADER + "host1:19998,host2:19998,host3:19998/tmp/path.txt"); FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - assertFalse(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("host1:19998,host2:19998,host3:19998", - fs.mFileSystem.getConf().get(PropertyKey.MASTER_RPC_ADDRESSES)); - } - - @Test - public void resetContextFromZookeeperToMultiMaster() throws Exception { - URI uri = URI.create(Constants.HEADER + "zk@zkHost:2181/tmp/path.txt"); - FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("zkHost:2181", fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - - uri = URI.create(Constants.HEADER + "host1:19998,host2:19998,host3:19998/tmp/path.txt"); - fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - - assertFalse(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals(3, - ConfigurationUtils.getMasterRpcAddresses(fs.mFileSystem.getConf()).size()); assertEquals("host1:19998,host2:19998,host3:19998", fs.mFileSystem.getConf().get(PropertyKey.MASTER_RPC_ADDRESSES)); } @@ -328,7 +194,6 @@ public void resetContextFromMultiMasterToSingleMaster() throws Exception { URI uri = URI.create(Constants.HEADER + "host1:19998,host2:19998,host3:19998/tmp/path.txt"); FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - assertFalse(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); assertEquals(3, ConfigurationUtils.getMasterRpcAddresses(fs.mFileSystem.getConf()).size()); assertEquals("host1:19998,host2:19998,host3:19998", @@ -337,7 +202,6 @@ public void resetContextFromMultiMasterToSingleMaster() throws Exception { uri = URI.create(Constants.HEADER + "host:19998/tmp/path.txt"); fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - assertFalse(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); assertEquals(PropertyKey.MASTER_JOURNAL_TYPE.getDefaultValue(), fs.mFileSystem.getConf().get(PropertyKey.MASTER_JOURNAL_TYPE)); assertEquals(1, @@ -547,49 +411,6 @@ public void initializeWithFullPrincipalUgi() throws Exception { // FileSystem.create would have thrown an exception if the initialization failed. } - @Test - public void initializeWithZookeeperSystemProperties() throws Exception { - HashMap sysProps = new HashMap<>(); - sysProps.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), "true"); - sysProps.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), "zkHost:2181"); - try (Closeable p = new SystemPropertyRule(sysProps).toResource()) { - alluxio.conf.Configuration.reloadProperties(); - URI uri = URI.create("alluxio:///"); - FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - - assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("zkHost:2181", fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - } - } - - @Test - public void initializeWithZookeeperUriAndSystemProperty() throws Exception { - // When URI and system property both have Zookeeper configuration, - // those in the URI has the highest priority. - try (Closeable p = new SystemPropertyRule( - PropertyKey.ZOOKEEPER_ENABLED.getName(), "false").toResource()) { - alluxio.conf.Configuration.reloadProperties(); - URI uri = URI.create("alluxio://zk@zkHost:2181"); - FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("zkHost:2181", fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - fs.close(); - } - - HashMap sysProps = new HashMap<>(); - sysProps.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), "true"); - sysProps.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), "zkHost1:2181"); - try (Closeable p = new SystemPropertyRule(sysProps).toResource()) { - alluxio.conf.Configuration.reloadProperties(); - URI uri = URI.create("alluxio://zk@zkHost2:2181"); - FileSystem fs = getHadoopFilesystem(org.apache.hadoop.fs.FileSystem.get(uri, getConf())); - assertTrue(fs.mFileSystem.getConf().getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("zkHost2:2181", fs.mFileSystem.getConf().get(PropertyKey.ZOOKEEPER_ADDRESS)); - fs.close(); - } - alluxio.conf.Configuration.reloadProperties(); - } - @Test public void getBlockLocationsOnlyInAlluxio() throws Exception { WorkerNetAddress worker1 = new WorkerNetAddress().setHost("worker1").setDataPort(1234); diff --git a/dora/core/client/hdfs/src/test/java/alluxio/hadoop/HadoopConfigurationUtilsTest.java b/dora/core/client/hdfs/src/test/java/alluxio/hadoop/HadoopConfigurationUtilsTest.java index 56b1e87125f0..ede43c095b6a 100644 --- a/dora/core/client/hdfs/src/test/java/alluxio/hadoop/HadoopConfigurationUtilsTest.java +++ b/dora/core/client/hdfs/src/test/java/alluxio/hadoop/HadoopConfigurationUtilsTest.java @@ -41,7 +41,7 @@ public void mergeEmptyHadoopConfiguration() { org.apache.hadoop.conf.Configuration hadoopConfig = new org.apache.hadoop.conf.Configuration(); mConf.merge( HadoopConfigurationUtils.getConfigurationFromHadoop(hadoopConfig), Source.RUNTIME); - assertFalse(mConf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); + assertFalse(mConf.getBoolean(PropertyKey.MASTER_HOSTNAME)); } /** @@ -53,9 +53,6 @@ public void mergeHadoopConfiguration() { hadoopConfig.set(PropertyKey.S3A_ACCESS_KEY.toString(), TEST_S3_ACCCES_KEY); hadoopConfig.set(PropertyKey.S3A_SECRET_KEY.toString(), TEST_S3_SECRET_KEY); hadoopConfig.set(TEST_ALLUXIO_PROPERTY, TEST_ALLUXIO_VALUE); - hadoopConfig.setBoolean(PropertyKey.ZOOKEEPER_ENABLED.getName(), true); - hadoopConfig.set(PropertyKey.ZOOKEEPER_ADDRESS.getName(), - "host1:port1,host2:port2;host3:port3"); // This hadoop config will not be loaded into Alluxio configuration. hadoopConfig.set("hadoop.config.parameter", "hadoop config value"); @@ -65,8 +62,5 @@ public void mergeHadoopConfiguration() { assertEquals(TEST_S3_SECRET_KEY, mConf.get(PropertyKey.S3A_SECRET_KEY)); assertEquals(Source.RUNTIME, mConf.getSource(PropertyKey.S3A_ACCESS_KEY)); assertEquals(Source.RUNTIME, mConf.getSource(PropertyKey.S3A_SECRET_KEY)); - assertTrue(mConf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)); - assertEquals("host1:port1,host2:port2;host3:port3", - mConf.get(PropertyKey.ZOOKEEPER_ADDRESS)); } } diff --git a/dora/core/common/src/main/java/alluxio/check/UpdateCheck.java b/dora/core/common/src/main/java/alluxio/check/UpdateCheck.java index ba64aee2853d..aa8ee3ab2f8e 100644 --- a/dora/core/common/src/main/java/alluxio/check/UpdateCheck.java +++ b/dora/core/common/src/main/java/alluxio/check/UpdateCheck.java @@ -156,7 +156,6 @@ public static void addUserAgentFeatures(List info) { addIfTrue(FeatureUtils.isEmbeddedJournal(), info, EMBEDDED_KEY); addIfTrue(FeatureUtils.isInodeStoreRocks(), info, INODE_METASTORE_ROCKS_KEY); addIfTrue(FeatureUtils.isBlockStoreRocks(), info, BLOCK_METASTORE_ROCKS_KEY); - addIfTrue(FeatureUtils.isZookeeperEnabled(), info, ZOOKEEPER_KEY); addIfTrue(FeatureUtils.isBackupDelegationEnabled(), info, BACKUP_DELEGATION_KEY); addIfTrue(FeatureUtils.isDailyBackupEnabled(), info, DAILY_BACKUP_KEY); addIfTrue(!FeatureUtils.isPersistenceBlacklistEmpty(), info, PERSIST_BLACK_LIST_KEY); diff --git a/dora/core/common/src/main/java/alluxio/conf/InstancedConfiguration.java b/dora/core/common/src/main/java/alluxio/conf/InstancedConfiguration.java index 93abba156dd9..ff723d66cc4e 100644 --- a/dora/core/common/src/main/java/alluxio/conf/InstancedConfiguration.java +++ b/dora/core/common/src/main/java/alluxio/conf/InstancedConfiguration.java @@ -391,7 +391,6 @@ public void validate() { checkTimeouts(); checkUserFileBufferBytes(); - checkZkConfiguration(); checkCheckpointZipConfig(); } @@ -516,18 +515,6 @@ private void checkUserFileBufferBytes() { PropertyKey.Name.USER_FILE_BUFFER_BYTES, usrFileBufferBytes); } - /** - * Validates Zookeeper-related configuration and prints warnings for possible sources of error. - * - * @throws IllegalStateException if invalid Zookeeper configuration is encountered - */ - private void checkZkConfiguration() { - checkState( - isSet(PropertyKey.ZOOKEEPER_ADDRESS) == getBoolean(PropertyKey.ZOOKEEPER_ENABLED), - "Inconsistent Zookeeper configuration; %s should be set if and only if %s is true", - PropertyKey.Name.ZOOKEEPER_ADDRESS, PropertyKey.Name.ZOOKEEPER_ENABLED); - } - /** * @throws IllegalStateException if invalid checkpoint zip configuration parameters are found */ 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 ccf2910fc436..2343d8d4edbf 100755 --- a/dora/core/common/src/main/java/alluxio/conf/PropertyKey.java +++ b/dora/core/common/src/main/java/alluxio/conf/PropertyKey.java @@ -41,7 +41,6 @@ import alluxio.grpc.TtlAction; import alluxio.grpc.WritePType; import alluxio.master.GraceMode; -import alluxio.master.ZookeeperConnectionErrorPolicy; import alluxio.master.file.MetadataSyncTraversalOrder; import alluxio.master.journal.JournalType; import alluxio.master.metastore.MetastoreType; @@ -973,74 +972,7 @@ public String toString() { .setConsistencyCheckLevel(ConsistencyCheckLevel.WARN) .setScope(Scope.SERVER) .build(); - public static final PropertyKey ZOOKEEPER_ADDRESS = - stringBuilder(Name.ZOOKEEPER_ADDRESS) - .setDescription("Address of ZooKeeper.") - .setConsistencyCheckLevel(ConsistencyCheckLevel.ENFORCE) - .setScope(Scope.ALL) - .build(); - public static final PropertyKey ZOOKEEPER_CONNECTION_TIMEOUT = - durationBuilder(Name.ZOOKEEPER_CONNECTION_TIMEOUT) - .setDefaultValue("15s") // matches Zookeeper's default - .setDescription("Connection timeout for Alluxio (job) masters to select " - + "the leading (job) master when connecting to Zookeeper") - .setConsistencyCheckLevel(ConsistencyCheckLevel.WARN) - .setScope(Scope.MASTER) - .build(); - public static final PropertyKey ZOOKEEPER_ELECTION_PATH = - stringBuilder(Name.ZOOKEEPER_ELECTION_PATH) - .setDefaultValue("/alluxio/election") - .setDescription("Election directory in ZooKeeper.") - .setConsistencyCheckLevel(ConsistencyCheckLevel.ENFORCE) - .setScope(Scope.ALL) - .build(); - public static final PropertyKey ZOOKEEPER_ENABLED = - booleanBuilder(Name.ZOOKEEPER_ENABLED) - .setDefaultValue(false) - .setDescription("If true, setup master fault tolerant mode using ZooKeeper.") - .setConsistencyCheckLevel(ConsistencyCheckLevel.ENFORCE) - .setScope(Scope.ALL) - .build(); - public static final PropertyKey ZOOKEEPER_LEADER_INQUIRY_RETRY_COUNT = - intBuilder(Name.ZOOKEEPER_LEADER_INQUIRY_RETRY_COUNT) - .setDefaultValue(10) - .setDescription("The number of retries to inquire leader from ZooKeeper.") - .setConsistencyCheckLevel(ConsistencyCheckLevel.WARN) - .setScope(Scope.ALL) - .build(); - public static final PropertyKey ZOOKEEPER_LEADER_PATH = - stringBuilder(Name.ZOOKEEPER_LEADER_PATH) - .setDefaultValue("/alluxio/leader") - .setDescription("Leader directory in ZooKeeper.") - .setConsistencyCheckLevel(ConsistencyCheckLevel.ENFORCE) - .setScope(Scope.ALL) - .build(); - public static final PropertyKey ZOOKEEPER_SESSION_TIMEOUT = - durationBuilder(Name.ZOOKEEPER_SESSION_TIMEOUT) - .setDefaultValue("60s") // matches Zookeeper's default - .setDescription("Session timeout to use when connecting to Zookeeper") - .setConsistencyCheckLevel(ConsistencyCheckLevel.WARN) - .setScope(Scope.MASTER) - .build(); - public static final PropertyKey ZOOKEEPER_AUTH_ENABLED = - booleanBuilder(Name.ZOOKEEPER_AUTH_ENABLED) - .setDefaultValue(true) - .setDescription("If true, enable client-side Zookeeper authentication.") - .setConsistencyCheckLevel(ConsistencyCheckLevel.WARN) - .setScope(Scope.ALL) - .build(); - public static final PropertyKey ZOOKEEPER_LEADER_CONNECTION_ERROR_POLICY = - enumBuilder(Name.ZOOKEEPER_LEADER_CONNECTION_ERROR_POLICY, - ZookeeperConnectionErrorPolicy.class) - .setDefaultValue(ZookeeperConnectionErrorPolicy.SESSION) - .setDescription("Connection error policy defines how errors on zookeeper connections " - + "to be treated in leader election. " - + "STANDARD policy treats every connection event as failure." - + "SESSION policy relies on zookeeper sessions for judging failures, " - + "helping leader to retain its status, as long as its session is protected.") - .setConsistencyCheckLevel(ConsistencyCheckLevel.ENFORCE) - .setScope(Scope.MASTER) - .build(); + /** * UFS related properties. */ @@ -2610,9 +2542,7 @@ public String toString() { public static final PropertyKey MASTER_RPC_ADDRESSES = listBuilder(Name.MASTER_RPC_ADDRESSES) .setDescription("A list of comma-separated host:port RPC addresses where the client " - + "should look for masters when using multiple masters without Zookeeper. This " - + "property is not used when Zookeeper is enabled, since Zookeeper already stores " - + "the master addresses.") + + "should look for masters when using multiple masters.") .setScope(Scope.ALL) .build(); public static final PropertyKey MASTER_FAILOVER_COLLECT_INFO = @@ -6799,13 +6729,6 @@ public String toString() { .setScope(Scope.MASTER) .build(); - public static final PropertyKey ZOOKEEPER_JOB_ELECTION_PATH = - stringBuilder(Name.ZOOKEEPER_JOB_ELECTION_PATH) - .setDefaultValue("/alluxio/job_election").build(); - public static final PropertyKey ZOOKEEPER_JOB_LEADER_PATH = - stringBuilder(Name.ZOOKEEPER_JOB_LEADER_PATH) - .setDefaultValue("/alluxio/job_leader").build(); - // // Membership related properties // @@ -7180,18 +7103,7 @@ public static final class Name { public static final String WEB_THREAD_DUMP_TO_LOG = "alluxio.web.threaddump.log.enabled"; public static final String WEB_UI_ENABLED = "alluxio.web.ui.enabled"; public static final String WORK_DIR = "alluxio.work.dir"; - public static final String ZOOKEEPER_ADDRESS = "alluxio.zookeeper.address"; - public static final String ZOOKEEPER_CONNECTION_TIMEOUT = - "alluxio.zookeeper.connection.timeout"; - public static final String ZOOKEEPER_ELECTION_PATH = "alluxio.zookeeper.election.path"; - public static final String ZOOKEEPER_ENABLED = "alluxio.zookeeper.enabled"; - public static final String ZOOKEEPER_LEADER_INQUIRY_RETRY_COUNT = - "alluxio.zookeeper.leader.inquiry.retry"; - public static final String ZOOKEEPER_LEADER_PATH = "alluxio.zookeeper.leader.path"; - public static final String ZOOKEEPER_SESSION_TIMEOUT = "alluxio.zookeeper.session.timeout"; - public static final String ZOOKEEPER_AUTH_ENABLED = "alluxio.zookeeper.auth.enabled"; - public static final String ZOOKEEPER_LEADER_CONNECTION_ERROR_POLICY = - "alluxio.zookeeper.leader.connection.error.policy"; + // // UFS related properties // @@ -8485,9 +8397,6 @@ public static final class Name { public static final String JOB_WORKER_WEB_BIND_HOST = "alluxio.job.worker.web.bind.host"; public static final String JOB_WORKER_WEB_PORT = "alluxio.job.worker.web.port"; - public static final String ZOOKEEPER_JOB_ELECTION_PATH = "alluxio.zookeeper.job.election.path"; - public static final String ZOOKEEPER_JOB_LEADER_PATH = "alluxio.zookeeper.job.leader.path"; - // Membership related properties public static final String ALLUXIO_CLUSTER_NAME = "alluxio.cluster.name"; public static final String ETCD_ENDPOINTS = "alluxio.etcd.endpoints"; @@ -8585,7 +8494,6 @@ private Name() {} // prevent instantiation private static final String NAMESERVICE_PATTERN_STRING = "([a-zA-Z_\\-0-9.]+)"; private static final String ALLUXIO_MASTER_ID_PATTERN_STRING = "([a-zA-Z_\\-0-9.]+)"; - private static final String ZOOKEEPER_NODE_ID_PATTERN_STRING = "([a-zA-Z_\\-0-9.]+)"; /** * A set of templates to generate the names of parameterized properties given @@ -8613,12 +8521,6 @@ public enum Template { MASTER_LOGICAL_RPC_ADDRESS("alluxio.master.rpc.address.%s.%s", String.format("alluxio\\.master\\.rpc\\.address\\.%s\\.%s", NAMESERVICE_PATTERN_STRING, ALLUXIO_MASTER_ID_PATTERN_STRING)), - MASTER_LOGICAL_ZOOKEEPER_NAMESERVICES("alluxio.master.zookeeper.nameservices.%s", - String.format("alluxio\\.master\\.zookeeper\\.nameservices\\.%s", - NAMESERVICE_PATTERN_STRING)), - MASTER_LOGICAL_ZOOKEEPER_ADDRESS("alluxio.master.zookeeper.address.%s.%s", - String.format("alluxio\\.master\\.zookeeper\\.address\\.%s\\.%s", - NAMESERVICE_PATTERN_STRING, ZOOKEEPER_NODE_ID_PATTERN_STRING)), MASTER_MOUNT_TABLE_ALLUXIO("alluxio.master.mount.table.%s.alluxio", "alluxio\\.master\\.mount\\.table.(\\w+)\\.alluxio", PropertyType.STRING), diff --git a/dora/core/common/src/main/java/alluxio/exception/ExceptionMessage.java b/dora/core/common/src/main/java/alluxio/exception/ExceptionMessage.java index 89a57b6a05fa..ca022bc0d74c 100644 --- a/dora/core/common/src/main/java/alluxio/exception/ExceptionMessage.java +++ b/dora/core/common/src/main/java/alluxio/exception/ExceptionMessage.java @@ -162,8 +162,7 @@ public enum ExceptionMessage { // configuration UNABLE_TO_DETERMINE_MASTER_HOSTNAME("Cannot run {0}; Unable to determine {1} address. Please " - + "modify " + Constants.SITE_PROPERTIES + " to either set {2}, configure zookeeper with " - + "{3}=true and {4}=[comma-separated zookeeper master addresses], or utilize internal HA by " + + "modify " + Constants.SITE_PROPERTIES + " to utilize internal HA by " + "setting {5}=[comma-separated alluxio {1} addresses]"), DEFAULT_PROPERTIES_FILE_DOES_NOT_EXIST("The default Alluxio properties file does not exist"), INVALID_CONFIGURATION_KEY("Invalid property key {0}"), diff --git a/dora/core/common/src/main/java/alluxio/master/MasterInquireClient.java b/dora/core/common/src/main/java/alluxio/master/MasterInquireClient.java index daa7b95a90ea..2b336e3f7fd2 100644 --- a/dora/core/common/src/main/java/alluxio/master/MasterInquireClient.java +++ b/dora/core/common/src/main/java/alluxio/master/MasterInquireClient.java @@ -80,20 +80,12 @@ class Factory { * @return a master inquire client */ public static MasterInquireClient create(AlluxioConfiguration conf, UserState userState) { - if (conf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { - return ZkMasterInquireClient.getClient(conf.getString(PropertyKey.ZOOKEEPER_ADDRESS), - conf.getString(PropertyKey.ZOOKEEPER_ELECTION_PATH), - conf.getString(PropertyKey.ZOOKEEPER_LEADER_PATH), - conf.getInt(PropertyKey.ZOOKEEPER_LEADER_INQUIRY_RETRY_COUNT), - conf.getBoolean(PropertyKey.ZOOKEEPER_AUTH_ENABLED)); + List addresses = ConfigurationUtils.getMasterRpcAddresses(conf); + if (addresses.size() > 1) { + return new PollingMasterInquireClient(addresses, conf, userState, + alluxio.grpc.ServiceType.META_MASTER_CLIENT_SERVICE); } else { - List addresses = ConfigurationUtils.getMasterRpcAddresses(conf); - if (addresses.size() > 1) { - return new PollingMasterInquireClient(addresses, conf, userState, - alluxio.grpc.ServiceType.META_MASTER_CLIENT_SERVICE); - } else { - return new SingleMasterInquireClient(addresses.get(0)); - } + return new SingleMasterInquireClient(addresses.get(0)); } } @@ -120,20 +112,12 @@ public static MasterInquireClient createForAddresses( */ public static MasterInquireClient createForJobMaster(AlluxioConfiguration conf, UserState userState) { - if (conf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { - return ZkMasterInquireClient.getClient(conf.getString(PropertyKey.ZOOKEEPER_ADDRESS), - conf.getString(PropertyKey.ZOOKEEPER_JOB_ELECTION_PATH), - conf.getString(PropertyKey.ZOOKEEPER_JOB_LEADER_PATH), - conf.getInt(PropertyKey.ZOOKEEPER_LEADER_INQUIRY_RETRY_COUNT), - conf.getBoolean(PropertyKey.ZOOKEEPER_AUTH_ENABLED)); + List addresses = ConfigurationUtils.getJobMasterRpcAddresses(conf); + if (addresses.size() > 1) { + return new PollingMasterInquireClient(addresses, conf, userState, + alluxio.grpc.ServiceType.JOB_MASTER_CLIENT_SERVICE); } else { - List addresses = ConfigurationUtils.getJobMasterRpcAddresses(conf); - if (addresses.size() > 1) { - return new PollingMasterInquireClient(addresses, conf, userState, - alluxio.grpc.ServiceType.JOB_MASTER_CLIENT_SERVICE); - } else { - return new SingleMasterInquireClient(addresses.get(0)); - } + return new SingleMasterInquireClient(addresses.get(0)); } } @@ -142,10 +126,7 @@ public static MasterInquireClient createForJobMaster(AlluxioConfiguration conf, * @return the connect string represented by the configuration */ public static ConnectDetails getConnectDetails(AlluxioConfiguration conf) { - if (conf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { - return new ZkMasterConnectDetails(conf.getString(PropertyKey.ZOOKEEPER_ADDRESS), - conf.getString(PropertyKey.ZOOKEEPER_LEADER_PATH)); - } else if (ConfigurationUtils.getMasterRpcAddresses(conf).size() > 1) { + if (ConfigurationUtils.getMasterRpcAddresses(conf).size() > 1) { return new PollingMasterInquireClient.MultiMasterConnectDetails( ConfigurationUtils.getMasterRpcAddresses(conf)); } else { diff --git a/dora/core/common/src/main/java/alluxio/master/ZkMasterInquireClient.java b/dora/core/common/src/main/java/alluxio/master/ZkMasterInquireClient.java index 15c28e72d60c..cfa3479f3af6 100644 --- a/dora/core/common/src/main/java/alluxio/master/ZkMasterInquireClient.java +++ b/dora/core/common/src/main/java/alluxio/master/ZkMasterInquireClient.java @@ -14,7 +14,6 @@ import alluxio.Constants; import alluxio.exception.status.UnavailableException; import alluxio.uri.Authority; -import alluxio.uri.ZookeeperAuthority; import alluxio.util.CommonUtils; import alluxio.util.io.PathUtils; import alluxio.util.network.NetworkAddressUtils; @@ -270,7 +269,7 @@ public String getLeaderPath() { @Override public Authority toAuthority() { - return new ZookeeperAuthority(mZkAddress); + return null; } @Override diff --git a/dora/core/common/src/main/java/alluxio/uri/Authority.java b/dora/core/common/src/main/java/alluxio/uri/Authority.java index 7ce578de1ed3..c080caa693e1 100644 --- a/dora/core/common/src/main/java/alluxio/uri/Authority.java +++ b/dora/core/common/src/main/java/alluxio/uri/Authority.java @@ -40,11 +40,7 @@ static Authority fromString(String authority) { if (authority == null || authority.length() == 0) { return NoAuthority.INSTANCE; } - Matcher matcher = ZOOKEEPER_AUTH.matcher(authority); - if (matcher.matches()) { - return new ZookeeperAuthority(matcher.group(1).replaceAll("[;+]", ",")); - } - matcher = SINGLE_MASTER_AUTH.matcher(authority); + Matcher matcher = SINGLE_MASTER_AUTH.matcher(authority); if (matcher.matches()) { return new SingleMasterAuthority(matcher.group(1), Integer.parseInt(matcher.group(2))); } @@ -52,10 +48,6 @@ static Authority fromString(String authority) { if (matcher.matches()) { return new MultiMasterAuthority(authority.replaceAll("[;+]", ",")); } - matcher = LOGICAL_ZOOKEEPER_AUTH.matcher(authority); - if (matcher.matches()) { - return new ZookeeperLogicalAuthority(matcher.group(1)); - } matcher = LOGICAL_MASTER_AUTH.matcher(authority); if (matcher.matches()) { return new EmbeddedLogicalAuthority(matcher.group(1)); diff --git a/dora/core/common/src/main/java/alluxio/uri/ZookeeperAuthority.java b/dora/core/common/src/main/java/alluxio/uri/ZookeeperAuthority.java deleted file mode 100644 index 453bca19fe0d..000000000000 --- a/dora/core/common/src/main/java/alluxio/uri/ZookeeperAuthority.java +++ /dev/null @@ -1,59 +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.uri; - -import com.google.common.base.Objects; - -/** - * {@link ZookeeperAuthority} supports authority containing Zookeeper addresses. - */ -public final class ZookeeperAuthority implements Authority { - private static final long serialVersionUID = -3549197285125519688L; - - private final String mZkAddress; - - /** - * @param zkAddress the zookeeper address inside the uri - */ - public ZookeeperAuthority(String zkAddress) { - mZkAddress = zkAddress; - } - - /** - * @return the Zookeeper address in this authority - */ - public String getZookeeperAddress() { - return mZkAddress; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof ZookeeperAuthority)) { - return false; - } - ZookeeperAuthority that = (ZookeeperAuthority) o; - return toString().equals(that.toString()); - } - - @Override - public int hashCode() { - return Objects.hashCode(mZkAddress); - } - - @Override - public String toString() { - return "zk@" + mZkAddress; - } -} diff --git a/dora/core/common/src/main/java/alluxio/uri/ZookeeperLogicalAuthority.java b/dora/core/common/src/main/java/alluxio/uri/ZookeeperLogicalAuthority.java deleted file mode 100644 index 510635ff7f6d..000000000000 --- a/dora/core/common/src/main/java/alluxio/uri/ZookeeperLogicalAuthority.java +++ /dev/null @@ -1,67 +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.uri; - -import java.util.Objects; - -/** - * A zookeeper logical host authority implementation. - */ -public class ZookeeperLogicalAuthority implements Authority { - private static final long serialVersionUID = 8292537475920509321L; - - /** - * The zookeeper logical name. - */ - private final String mLogicalName; - - /** - * @param logicalName the zookeeper logical name - */ - public ZookeeperLogicalAuthority(String logicalName) { - mLogicalName = logicalName; - } - - /** - * @return the logical host from the authority - */ - public String getLogicalName() { - return mLogicalName; - } - - @Override - public int compareTo(Authority other) { - return toString().compareTo(other.toString()); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ZookeeperLogicalAuthority that = (ZookeeperLogicalAuthority) o; - return Objects.equals(mLogicalName, that.mLogicalName); - } - - @Override - public int hashCode() { - return Objects.hash(mLogicalName); - } - - @Override - public String toString() { - return "zk@" + mLogicalName; - } -} diff --git a/dora/core/common/src/main/java/alluxio/util/ConfigurationUtils.java b/dora/core/common/src/main/java/alluxio/util/ConfigurationUtils.java index a1784126c58d..9e67d4a466d4 100644 --- a/dora/core/common/src/main/java/alluxio/util/ConfigurationUtils.java +++ b/dora/core/common/src/main/java/alluxio/util/ConfigurationUtils.java @@ -175,9 +175,7 @@ public static List parseInetSocketAddresses(List addr * explicit configuration or through zookeeper */ public static boolean jobMasterHostConfigured(AlluxioConfiguration conf) { - boolean usingZk = conf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED) - && conf.isSet(PropertyKey.ZOOKEEPER_ADDRESS); - return conf.isSet(PropertyKey.JOB_MASTER_HOSTNAME) || usingZk + return conf.isSet(PropertyKey.JOB_MASTER_HOSTNAME) || getJobMasterRpcAddresses(conf).size() > 1; } @@ -208,8 +206,7 @@ public static String getJobMasterHostNotConfiguredMessage(String serviceName) { private static String getHostNotConfiguredMessage(String serviceName, String masterName, PropertyKey masterHostnameKey, PropertyKey embeddedJournalKey) { return ExceptionMessage.UNABLE_TO_DETERMINE_MASTER_HOSTNAME.getMessage(serviceName, masterName, - masterHostnameKey.getName(), PropertyKey.ZOOKEEPER_ENABLED.getName(), - PropertyKey.ZOOKEEPER_ADDRESS.getName(), embeddedJournalKey.getName()); + embeddedJournalKey.getName()); } /** @@ -235,9 +232,7 @@ public static float checkRatio(AlluxioConfiguration conf, PropertyKey key) { * explicit configuration or through zookeeper */ public static boolean masterHostConfigured(AlluxioConfiguration conf) { - boolean usingZk = conf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED) - && conf.isSet(PropertyKey.ZOOKEEPER_ADDRESS); - return conf.isSet(PropertyKey.MASTER_HOSTNAME) || usingZk + return conf.isSet(PropertyKey.MASTER_HOSTNAME) || getMasterRpcAddresses(conf).size() > 1; } @@ -246,7 +241,7 @@ public static boolean masterHostConfigured(AlluxioConfiguration conf) { * @return whether the configuration specifies to run in ha mode */ public static boolean isHaMode(AlluxioConfiguration conf) { - return conf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED) || getMasterRpcAddresses(conf).size() > 1; + return getMasterRpcAddresses(conf).size() > 1; } /** @@ -262,9 +257,6 @@ public static String valueAsString(String value) { * @return the alluxio scheme and authority determined by the configuration */ public static String getSchemeAuthority(AlluxioConfiguration conf) { - if (conf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { - return Constants.HEADER + "zk@" + conf.get(PropertyKey.ZOOKEEPER_ADDRESS); - } List addresses = getMasterRpcAddresses(conf); if (addresses.size() > 1) { diff --git a/dora/core/common/src/main/java/alluxio/util/FeatureUtils.java b/dora/core/common/src/main/java/alluxio/util/FeatureUtils.java index a5f3967bfa38..295a529f498b 100644 --- a/dora/core/common/src/main/java/alluxio/util/FeatureUtils.java +++ b/dora/core/common/src/main/java/alluxio/util/FeatureUtils.java @@ -54,15 +54,6 @@ public static boolean isBlockStoreRocks() { return Configuration.get(PropertyKey.MASTER_METASTORE) == MetastoreType.ROCKS; } - /** - * Utility to check Zookeeper is enabled. - * - * @return true, if Zookeeper is enabled - */ - public static boolean isZookeeperEnabled() { - return Configuration.getBoolean(PropertyKey.ZOOKEEPER_ENABLED); - } - /** * Utility to check back delegation is enabled. * diff --git a/dora/core/common/src/test/java/alluxio/AlluxioURITest.java b/dora/core/common/src/test/java/alluxio/AlluxioURITest.java index 07691a760e17..62ecbb2d0484 100644 --- a/dora/core/common/src/test/java/alluxio/AlluxioURITest.java +++ b/dora/core/common/src/test/java/alluxio/AlluxioURITest.java @@ -23,8 +23,6 @@ import alluxio.uri.NoAuthority; import alluxio.uri.SingleMasterAuthority; import alluxio.uri.UnknownAuthority; -import alluxio.uri.ZookeeperAuthority; -import alluxio.uri.ZookeeperLogicalAuthority; import alluxio.util.OSUtils; import com.google.common.testing.EqualsTester; @@ -171,49 +169,6 @@ public void plusMultiMasterUri() { assertEquals("host1:526,host2:54325,host3:624", authority.getMasterAddresses()); } - @Test - public void basicZookeeperUri() { - AlluxioURI uri = - new AlluxioURI("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c"); - assertEquals(uri, - new AlluxioURI("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c")); - assertEquals("alluxio", uri.getScheme()); - - assertEquals("zk@host1:2181,host2:2181,host3:2181", uri.getAuthority().toString()); - assertTrue(uri.getAuthority() instanceof ZookeeperAuthority); - ZookeeperAuthority zkAuthority = (ZookeeperAuthority) uri.getAuthority(); - assertEquals("host1:2181,host2:2181,host3:2181", zkAuthority.getZookeeperAddress()); - - assertEquals(2, uri.getDepth()); - assertEquals("a b c", uri.getName()); - assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z", - uri.getParent().toString()); - assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/", - uri.getParent().getParent().toString()); - assertEquals("/xy z/a b c", uri.getPath()); - assertTrue(uri.hasAuthority()); - assertTrue(uri.hasScheme()); - assertTrue(uri.isAbsolute()); - assertTrue(uri.isPathAbsolute()); - assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c/d", - uri.join("/d").toString()); - assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c/d", - uri.join(new AlluxioURI("/d")) - .toString()); - assertEquals("alluxio://zk@host1:2181,host2:2181,host3:2181/xy z/a b c", - uri.toString()); - } - - @Test - public void semicolonZookeeperUri() { - AlluxioURI uri = - new AlluxioURI("alluxio://zk@host1:2181;host2:2181;host3:2181/xy z/a b c"); - assertTrue(uri.hasAuthority()); - assertEquals("zk@host1:2181,host2:2181,host3:2181", uri.getAuthority().toString()); - assertTrue(uri.getAuthority() instanceof ZookeeperAuthority); - ZookeeperAuthority zkAuthority = (ZookeeperAuthority) uri.getAuthority(); - assertEquals("host1:2181,host2:2181,host3:2181", zkAuthority.getZookeeperAddress()); - } /** * Tests the {@link AlluxioURI#AlluxioURI(String)} constructor with query parameter. @@ -542,13 +497,6 @@ public void authorityTypeTests() { assertTrue(new AlluxioURI("file", Authority.fromString("localhost:8080"), "/b/c").getAuthority() instanceof SingleMasterAuthority); - assertTrue(new AlluxioURI("file", Authority.fromString("zk@host:2181"), "/b/c").getAuthority() - instanceof ZookeeperAuthority); - assertTrue(new AlluxioURI("alluxio://zk@host1:2181,host2:2181,host3:2181/b/c").getAuthority() - instanceof ZookeeperAuthority); - assertTrue(new AlluxioURI("alluxio://zk@host1:2181;host2:2181;host3:2181/b/c").getAuthority() - instanceof ZookeeperAuthority); - assertTrue(new AlluxioURI("file", Authority.fromString(""), "/b/c").getAuthority() instanceof NoAuthority); assertTrue(new AlluxioURI("file", null, "/b/c").getAuthority() @@ -561,9 +509,6 @@ public void authorityTypeTests() { assertTrue(new AlluxioURI("file", Authority.fromString("ebj@logical"), "/b/c").getAuthority() instanceof EmbeddedLogicalAuthority); - assertTrue(new AlluxioURI("file", Authority.fromString("zk@logical"), "/b/c").getAuthority() - instanceof ZookeeperLogicalAuthority); - assertTrue(new AlluxioURI("file", Authority.fromString("localhost"), "/b/c").getAuthority() instanceof UnknownAuthority); } diff --git a/dora/core/common/src/test/java/alluxio/check/UpdateCheckTest.java b/dora/core/common/src/test/java/alluxio/check/UpdateCheckTest.java index 2d47b28d758f..4e8d7ac4a156 100644 --- a/dora/core/common/src/test/java/alluxio/check/UpdateCheckTest.java +++ b/dora/core/common/src/test/java/alluxio/check/UpdateCheckTest.java @@ -194,18 +194,6 @@ public void featureStringBlockMetastoreRocks() { Assert.assertFalse(listContainsTarget(info, UpdateCheck.BLOCK_METASTORE_ROCKS_KEY)); } - @Test - public void featureStringZookeeper() { - List info = new ArrayList<>(); - Configuration.set(PropertyKey.ZOOKEEPER_ENABLED, true); - UpdateCheck.addUserAgentFeatures(info); - Assert.assertTrue(listContainsTarget(info, UpdateCheck.ZOOKEEPER_KEY)); - Configuration.set(PropertyKey.ZOOKEEPER_ENABLED, false); - info.clear(); - UpdateCheck.addUserAgentFeatures(info); - Assert.assertFalse(listContainsTarget(info, UpdateCheck.ZOOKEEPER_KEY)); - } - @Test public void featureStringBackupDelegation() { List info = new ArrayList<>(); diff --git a/dora/core/common/src/test/java/alluxio/conf/InstancedConfigurationTest.java b/dora/core/common/src/test/java/alluxio/conf/InstancedConfigurationTest.java index 83fbdc421d86..c9e3610548a4 100644 --- a/dora/core/common/src/test/java/alluxio/conf/InstancedConfigurationTest.java +++ b/dora/core/common/src/test/java/alluxio/conf/InstancedConfigurationTest.java @@ -214,9 +214,9 @@ public void alias() throws Exception { @Test public void isSet() { - assertFalse(mConfiguration.isSet(PropertyKey.ZOOKEEPER_ADDRESS)); - mConfiguration.set(PropertyKey.ZOOKEEPER_ADDRESS, "address"); - assertTrue(mConfiguration.isSet(PropertyKey.ZOOKEEPER_ADDRESS)); + assertFalse(mConfiguration.isSet(PropertyKey.MASTER_HOSTNAME)); + mConfiguration.set(PropertyKey.MASTER_HOSTNAME, "address"); + assertTrue(mConfiguration.isSet(PropertyKey.MASTER_HOSTNAME)); } @Test diff --git a/dora/core/common/src/test/java/alluxio/master/MasterInquireClientTest.java b/dora/core/common/src/test/java/alluxio/master/MasterInquireClientTest.java index f6e8bb7fd572..ae891989fa2b 100644 --- a/dora/core/common/src/test/java/alluxio/master/MasterInquireClientTest.java +++ b/dora/core/common/src/test/java/alluxio/master/MasterInquireClientTest.java @@ -69,30 +69,6 @@ public void singleMasterConnectString() throws Exception { } } - @Test - public void zkConnectString() throws Exception { - String zkAddr = "zkAddr:1234"; - String leaderPath = "/my/leader/path"; - try (Closeable c = new ConfigurationRule(new HashMap() { - { - put(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS); - put(PropertyKey.ZOOKEEPER_ADDRESS, zkAddr); - put(PropertyKey.ZOOKEEPER_LEADER_PATH, leaderPath); - } - }, mConfiguration).toResource()) { - ConnectDetails singleConnect = new SingleMasterConnectDetails( - NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, mConfiguration)); - assertCurrentConnectString(singleConnect); - try (Closeable c2 = - new ConfigurationRule(PropertyKey.ZOOKEEPER_ENABLED, true, mConfiguration) - .toResource()) { - ConnectDetails zkConnect = new ZkMasterConnectDetails(zkAddr, leaderPath); - assertCurrentConnectString(zkConnect); - assertEquals("zk@zkAddr:1234/my/leader/path", zkConnect.toString()); - } - } - } - private void assertCurrentConnectString(ConnectDetails cs) { assertEquals(cs, MasterInquireClient.Factory.getConnectDetails(mConfiguration)); } diff --git a/dora/core/common/src/test/java/alluxio/uri/AuthorityTest.java b/dora/core/common/src/test/java/alluxio/uri/AuthorityTest.java index be6727cb3cbc..b575a92b91a7 100644 --- a/dora/core/common/src/test/java/alluxio/uri/AuthorityTest.java +++ b/dora/core/common/src/test/java/alluxio/uri/AuthorityTest.java @@ -29,19 +29,11 @@ public void authorityFromStringTest() { assertTrue(Authority.fromString("localhost:19998") instanceof SingleMasterAuthority); assertTrue(Authority.fromString("127.0.0.1:19998") instanceof SingleMasterAuthority); - assertTrue(Authority.fromString("zk@host:2181") instanceof ZookeeperAuthority); - assertTrue(Authority.fromString("zk@host1:2181,127.0.0.2:2181,12.43.214.53:2181") - instanceof ZookeeperAuthority); - assertTrue(Authority.fromString("zk@host1:2181;host2:2181;host3:2181") - instanceof ZookeeperAuthority); - assertTrue(Authority.fromString("") instanceof NoAuthority); assertTrue(Authority.fromString(null) instanceof NoAuthority); assertTrue(Authority.fromString("ebj@logical") instanceof EmbeddedLogicalAuthority); - assertTrue(Authority.fromString("zk@logical") instanceof ZookeeperLogicalAuthority); - assertTrue(Authority.fromString("localhost") instanceof UnknownAuthority); assertTrue(Authority.fromString("f3,321:sad") instanceof UnknownAuthority); assertTrue(Authority.fromString("localhost:") instanceof UnknownAuthority); @@ -95,34 +87,6 @@ public void multiMasterAuthorityTest() { assertFalse(Authority.fromString("+++") instanceof MultiMasterAuthority); } - @Test - public void zookeeperAuthorityTest() { - ZookeeperAuthority authority = (ZookeeperAuthority) Authority.fromString("zk@host:2181"); - assertEquals("zk@host:2181", authority.toString()); - assertEquals("host:2181", authority.getZookeeperAddress()); - - authority = (ZookeeperAuthority) Authority - .fromString("zk@127.0.0.1:2181,127.0.0.2:2181,127.0.0.3:2181"); - assertEquals("zk@127.0.0.1:2181,127.0.0.2:2181,127.0.0.3:2181", authority.toString()); - assertEquals("127.0.0.1:2181,127.0.0.2:2181,127.0.0.3:2181", authority.getZookeeperAddress()); - - authority = (ZookeeperAuthority) Authority.fromString("zk@host1:2181;host2:2181;host3:2181"); - assertEquals("zk@host1:2181,host2:2181,host3:2181", authority.toString()); - assertEquals("host1:2181,host2:2181,host3:2181", authority.getZookeeperAddress()); - - authority = (ZookeeperAuthority) Authority.fromString("zk@host1:2181+host2:2181+host3:2181"); - assertEquals("zk@host1:2181,host2:2181,host3:2181", authority.toString()); - assertEquals("host1:2181,host2:2181,host3:2181", authority.getZookeeperAddress()); - } - - @Test - public void zookeeperLogicalAuthorityTest() { - ZookeeperLogicalAuthority authority = - (ZookeeperLogicalAuthority) Authority.fromString("zk@logical"); - assertEquals("zk@logical", authority.toString()); - assertEquals("logical", authority.getLogicalName()); - } - @Test public void embeddedLogicalAuthorityTest() { EmbeddedLogicalAuthority authority = @@ -131,16 +95,4 @@ public void embeddedLogicalAuthorityTest() { assertEquals("logical", authority.getLogicalName()); } - @Test - public void mixedDelimiters() { - String normalized = "a:0,b:0,c:0"; - for (String test : Arrays.asList( - "zk@a:0;b:0+c:0", - "zk@a:0,b:0;c:0", - "zk@a:0+b:0,c:0" - )) { - assertEquals(normalized, - ((ZookeeperAuthority) Authority.fromString(test)).getZookeeperAddress()); - } - } } diff --git a/dora/core/server/common/src/main/java/alluxio/master/PrimarySelector.java b/dora/core/server/common/src/main/java/alluxio/master/PrimarySelector.java index 6f7462936b46..d9118acf3751 100644 --- a/dora/core/server/common/src/main/java/alluxio/master/PrimarySelector.java +++ b/dora/core/server/common/src/main/java/alluxio/master/PrimarySelector.java @@ -24,34 +24,6 @@ * Interface for a class which can determine whether the local master is the primary. */ public interface PrimarySelector { - /** - * Factory for creating primary selectors. - */ - final class Factory { - /** - * @return a primary selector based on zookeeper configuration - */ - public static PrimarySelector createZkPrimarySelector() { - String zkAddress = Configuration.getString(PropertyKey.ZOOKEEPER_ADDRESS); - String zkElectionPath = Configuration.getString(PropertyKey.ZOOKEEPER_ELECTION_PATH); - String zkLeaderPath = Configuration.getString(PropertyKey.ZOOKEEPER_LEADER_PATH); - return new UfsJournalMultiMasterPrimarySelector(zkAddress, zkElectionPath, zkLeaderPath); - } - - /** - * @return a job master primary selector based on zookeeper configuration - */ - public static PrimarySelector createZkJobPrimarySelector() { - String zkAddress = Configuration.getString(PropertyKey.ZOOKEEPER_ADDRESS); - String zkElectionPath = Configuration.getString( - PropertyKey.ZOOKEEPER_JOB_ELECTION_PATH); - String zkLeaderPath = Configuration.getString(PropertyKey.ZOOKEEPER_JOB_LEADER_PATH); - return new UfsJournalMultiMasterPrimarySelector(zkAddress, zkElectionPath, zkLeaderPath); - } - - private Factory() {} // Not intended for instantiation. - } - /** * Starts the primary selector. * diff --git a/dora/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalMultiMasterPrimarySelector.java b/dora/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalMultiMasterPrimarySelector.java index 2b002b13217c..16ebeb5e7dce 100644 --- a/dora/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalMultiMasterPrimarySelector.java +++ b/dora/core/server/common/src/main/java/alluxio/master/journal/ufs/UfsJournalMultiMasterPrimarySelector.java @@ -79,8 +79,7 @@ public UfsJournalMultiMasterPrimarySelector(String zookeeperAddress, String elec } else { mLeaderFolder = leaderPath + AlluxioURI.SEPARATOR; } - mConnectionErrorPolicy = Configuration.getEnum( - PropertyKey.ZOOKEEPER_LEADER_CONNECTION_ERROR_POLICY, ZookeeperConnectionErrorPolicy.class); + mConnectionErrorPolicy = ZookeeperConnectionErrorPolicy.STANDARD; mLeaderZkSessionId = NOT_A_LEADER; @@ -228,10 +227,6 @@ private CuratorFramework getNewCuratorClient() { CuratorFrameworkFactory.Builder curatorBuilder = CuratorFrameworkFactory.builder(); curatorBuilder.connectString(mZookeeperAddress); curatorBuilder.retryPolicy(new ExponentialBackoffRetry(Constants.SECOND_MS, 3)); - curatorBuilder - .sessionTimeoutMs((int) Configuration.getMs(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT)); - curatorBuilder.connectionTimeoutMs( - (int) Configuration.getMs(PropertyKey.ZOOKEEPER_CONNECTION_TIMEOUT)); // Force compatibility mode to support writing to 3.4.x servers. curatorBuilder.zk34CompatibilityMode(true); // Prevent using container parents as it breaks compatibility with 3.4.x servers. diff --git a/dora/core/server/master/src/main/java/alluxio/master/AlluxioMasterProcess.java b/dora/core/server/master/src/main/java/alluxio/master/AlluxioMasterProcess.java index 442029b34af6..e1a86473ed1c 100644 --- a/dora/core/server/master/src/main/java/alluxio/master/AlluxioMasterProcess.java +++ b/dora/core/server/master/src/main/java/alluxio/master/AlluxioMasterProcess.java @@ -483,11 +483,7 @@ public static AlluxioMasterProcess create() { JournalSystem journalSystem = new JournalSystem.Builder() .setLocation(journalLocation).build(ProcessType.MASTER); final PrimarySelector primarySelector; - if (Configuration.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { - Preconditions.checkState(!(journalSystem instanceof RaftJournalSystem), - "Raft-based embedded journal and Zookeeper cannot be used at the same time."); - primarySelector = PrimarySelector.Factory.createZkPrimarySelector(); - } else if (journalSystem instanceof RaftJournalSystem) { + if (journalSystem instanceof RaftJournalSystem) { primarySelector = ((RaftJournalSystem) journalSystem).getPrimarySelector(); } else { primarySelector = new UfsJournalSingleMasterPrimarySelector(); diff --git a/dora/core/server/master/src/main/java/alluxio/master/meta/MetaMasterClientServiceHandler.java b/dora/core/server/master/src/main/java/alluxio/master/meta/MetaMasterClientServiceHandler.java index a6e4bbefe09b..dfae928ecc37 100644 --- a/dora/core/server/master/src/main/java/alluxio/master/meta/MetaMasterClientServiceHandler.java +++ b/dora/core/server/master/src/main/java/alluxio/master/meta/MetaMasterClientServiceHandler.java @@ -121,13 +121,6 @@ public void getMasterInfo(GetMasterInfoPOptions options, masterInfo.addAllWorkerAddresses(mMetaMaster.getWorkerAddresses().stream() .map(Address::toProto).collect(Collectors.toList())); break; - case ZOOKEEPER_ADDRESSES: - if (Configuration.isSet(PropertyKey.ZOOKEEPER_ADDRESS)) { - masterInfo.addAllZookeeperAddresses( - Arrays.asList(Configuration.getString(PropertyKey.ZOOKEEPER_ADDRESS) - .split(","))); - } - break; case RAFT_ADDRESSES: if (mMetaMaster.getMasterContext().getJournalSystem() instanceof RaftJournalSystem) { List raftAddresses = diff --git a/dora/core/server/master/src/test/java/alluxio/master/meta/checkconf/ConfigurationStoreTest.java b/dora/core/server/master/src/test/java/alluxio/master/meta/checkconf/ConfigurationStoreTest.java index b7ba119d62d5..9e8e22e0e7f7 100644 --- a/dora/core/server/master/src/test/java/alluxio/master/meta/checkconf/ConfigurationStoreTest.java +++ b/dora/core/server/master/src/test/java/alluxio/master/meta/checkconf/ConfigurationStoreTest.java @@ -40,7 +40,7 @@ public class ConfigurationStoreTest @Before public void before() { - PropertyKey keyEnforce = PropertyKey.ZOOKEEPER_ELECTION_PATH; + PropertyKey keyEnforce = PropertyKey.WORKER_KEYTAB_FILE; PropertyKey keyWarn = PropertyKey.WORKER_FREE_SPACE_TIMEOUT; mConfigListOne = Arrays.asList( ConfigProperty.newBuilder().setName(keyEnforce.getName()).setSource("Test") diff --git a/dora/job/server/src/main/java/alluxio/master/AlluxioJobMasterProcess.java b/dora/job/server/src/main/java/alluxio/master/AlluxioJobMasterProcess.java index ca35368f9ead..afad1bcbc450 100644 --- a/dora/job/server/src/main/java/alluxio/master/AlluxioJobMasterProcess.java +++ b/dora/job/server/src/main/java/alluxio/master/AlluxioJobMasterProcess.java @@ -117,11 +117,7 @@ public static AlluxioJobMasterProcess create() { .setLocation(URIUtils.appendPathOrDie(journalLocation, Constants.JOB_JOURNAL_NAME)) .build(ProcessType.JOB_MASTER); final PrimarySelector primarySelector; - if (Configuration.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { - Preconditions.checkState(!(journalSystem instanceof RaftJournalSystem), - "Raft journal cannot be used with Zookeeper enabled"); - primarySelector = PrimarySelector.Factory.createZkJobPrimarySelector(); - } else if (journalSystem instanceof RaftJournalSystem) { + if (journalSystem instanceof RaftJournalSystem) { primarySelector = ((RaftJournalSystem) journalSystem).getPrimarySelector(); } else { primarySelector = new UfsJournalSingleMasterPrimarySelector(); diff --git a/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java b/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java index 188a3ab6e4cb..ceae1f823eb4 100644 --- a/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java +++ b/dora/minicluster/src/main/java/alluxio/master/LocalAlluxioMaster.java @@ -33,7 +33,6 @@ /** * Constructs an isolated master. Primary users of this class are the {@link LocalAlluxioCluster} - * and {@link MultiMasterLocalAlluxioCluster}. * * Isolated is defined as having its own root directory, and port. */ diff --git a/dora/minicluster/src/main/java/alluxio/master/MultiMasterEmbeddedJournalLocalAlluxioCluster.java b/dora/minicluster/src/main/java/alluxio/master/MultiMasterEmbeddedJournalLocalAlluxioCluster.java index 6f2795800908..5534886a4aad 100644 --- a/dora/minicluster/src/main/java/alluxio/master/MultiMasterEmbeddedJournalLocalAlluxioCluster.java +++ b/dora/minicluster/src/main/java/alluxio/master/MultiMasterEmbeddedJournalLocalAlluxioCluster.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.net.InetSocketAddress; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.TimeoutException; @@ -220,6 +221,17 @@ public boolean stopLeader() { return true; } + /** + * Waits for the a new master to start until a timeout occurs. + * + * @param timeoutMs the number of milliseconds to wait before giving up and throwing an exception + */ + + public void waitForNewMaster(int timeoutMs) + throws TimeoutException, InterruptedException { + waitForPrimaryMasterServing(timeoutMs); + } + /** * Waits for the primary master to start until a timeout occurs. * diff --git a/dora/minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java b/dora/minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java deleted file mode 100644 index 47914e584362..000000000000 --- a/dora/minicluster/src/main/java/alluxio/master/MultiMasterLocalAlluxioCluster.java +++ /dev/null @@ -1,287 +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.AlluxioTestDirectory; -import alluxio.ConfigurationTestUtils; -import alluxio.Constants; -import alluxio.client.file.FileSystem; -import alluxio.client.file.FileSystemContext; -import alluxio.conf.Configuration; -import alluxio.conf.PropertyKey; -import alluxio.master.journal.JournalType; -import alluxio.underfs.UnderFileSystem; -import alluxio.underfs.options.DeleteOptions; -import alluxio.util.CommonUtils; -import alluxio.util.WaitForOptions; -import alluxio.util.io.PathUtils; -import alluxio.worker.WorkerProcess; - -import com.google.common.base.Throwables; -import org.apache.curator.test.TestingServer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.TimeoutException; -import javax.annotation.concurrent.NotThreadSafe; - -/** - * A local Alluxio cluster with multiple masters. - */ -@NotThreadSafe -public final class MultiMasterLocalAlluxioCluster extends AbstractLocalAlluxioCluster { - private static final Logger LOG = LoggerFactory.getLogger(MultiMasterLocalAlluxioCluster.class); - - private TestingServer mCuratorServer = null; - private int mNumOfMasters = 0; - - private final List mMasters = new ArrayList<>(); - - /** - * Runs a multi master local Alluxio cluster with a single worker. - * - * @param numMasters the number masters to run - */ - public MultiMasterLocalAlluxioCluster(int numMasters) { - this(numMasters, 1); - } - - /** - * @param numMasters the number of masters to run - * @param numWorkers the number of workers to run - */ - public MultiMasterLocalAlluxioCluster(int numMasters, int numWorkers) { - super(numWorkers); - mNumOfMasters = numMasters; - - try { - mCuratorServer = - new TestingServer(-1, AlluxioTestDirectory.createTemporaryDirectory("zk")); - LOG.info("Started testing zookeeper: {}", mCuratorServer.getConnectString()); - } catch (Exception e) { - throw Throwables.propagate(e); - } - } - - @Override - public void initConfiguration(String name) throws IOException { - setAlluxioWorkDirectory(name); - setHostname(); - for (Map.Entry entry : ConfigurationTestUtils - .testConfigurationDefaults(Configuration.global(), - mHostname, mWorkDirectory).entrySet()) { - Configuration.set(entry.getKey(), entry.getValue()); - } - Configuration.set(PropertyKey.MASTER_RPC_PORT, 0); - Configuration.set(PropertyKey.TEST_MODE, true); - Configuration.set(PropertyKey.JOB_WORKER_THROTTLING, false); - Configuration.set(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS); - Configuration.set(PropertyKey.MASTER_WEB_PORT, 0); - Configuration.set(PropertyKey.PROXY_WEB_PORT, 0); - Configuration.set(PropertyKey.WORKER_RPC_PORT, 0); - Configuration.set(PropertyKey.WORKER_WEB_PORT, 0); - } - - @Override - public synchronized FileSystem getClient() throws IOException { - return getLocalAlluxioMaster().getClient(); - } - - @Override - public FileSystem getClient(FileSystemContext context) throws IOException { - return getLocalAlluxioMaster().getClient(context); - } - - /** - * @return the URI of the master - */ - public String getUri() { - return Constants.HEADER + "zk@" + mCuratorServer.getConnectString(); - } - - @Override - public LocalAlluxioMaster getLocalAlluxioMaster() { - for (LocalAlluxioMaster master : mMasters) { - // Return the leader master, if possible. - if (master.isServing()) { - return master; - } - } - return mMasters.get(0); - } - - /** - * @param index the worker index - * @return the worker process - */ - public WorkerProcess getWorkerProcess(int index) { - return mWorkers.get(index); - } - - /** - * @return index of leader master in {@link #mMasters}, or -1 if there is no leader temporarily - */ - public int getLeaderIndex() { - for (int i = 0; i < mNumOfMasters; i++) { - if (mMasters.get(i).isServing()) { - return i; - } - } - return -1; - } - - /** - * @return the master addresses - */ - public List getMasterAddresses() { - List addrs = new ArrayList<>(); - for (int i = 0; i < mNumOfMasters; i++) { - addrs.add(mMasters.get(i).getAddress()); - } - return addrs; - } - - /** - * Iterates over the masters in the order of master creation, stops the first standby master. - * - * @return true if a standby master is successfully stopped, otherwise, false - */ - public boolean stopStandby() { - for (int k = 0; k < mNumOfMasters; k++) { - if (!mMasters.get(k).isServing()) { - try { - LOG.info("master {} is a standby. stopping it...", k); - mMasters.get(k).stop(); - LOG.info("master {} stopped.", k); - } catch (Exception e) { - LOG.error(e.getMessage(), e); - return false; - } - return true; - } - } - return false; - } - - /** - * Iterates over the masters in the order of master creation, stops the leader master. - * - * @return true if the leader master is successfully stopped, false otherwise - */ - public boolean stopLeader() { - for (int k = 0; k < mNumOfMasters; k++) { - if (mMasters.get(k).isServing()) { - try { - LOG.info("master {} is the leader. stopping it...", k); - mMasters.get(k).stop(); - LOG.info("master {} stopped.", k); - } catch (Exception e) { - LOG.error(e.getMessage(), e); - return false; - } - return true; - } - } - return false; - } - - /** - * Waits for a new master to start until a timeout occurs. - * - * @param timeoutMs the number of milliseconds to wait before giving up and throwing an exception - */ - public void waitForNewMaster(int timeoutMs) throws TimeoutException, InterruptedException { - CommonUtils.waitFor("the new leader master to start", () -> getLeaderIndex() != -1, - WaitForOptions.defaults().setTimeoutMs(timeoutMs)); - } - - /** - * Stops the cluster's Zookeeper service. - */ - public void stopZk() throws Exception { - mCuratorServer.stop(); - } - - /** - * Restarts the cluster's Zookeeper service. It must first be stopped with {@link #stopZk()}. - */ - public void restartZk() throws Exception { - mCuratorServer.restart(); - } - - @Override - protected void startMasters() throws IOException { - Configuration.set(PropertyKey.ZOOKEEPER_ENABLED, true); - Configuration.set(PropertyKey.ZOOKEEPER_ADDRESS, mCuratorServer.getConnectString()); - Configuration.set(PropertyKey.ZOOKEEPER_ELECTION_PATH, "/alluxio/election"); - Configuration.set(PropertyKey.ZOOKEEPER_LEADER_PATH, "/alluxio/leader"); - - for (int k = 0; k < mNumOfMasters; k++) { - Configuration.set(PropertyKey.MASTER_METASTORE_DIR, - PathUtils.concatPath(mWorkDirectory, "metastore-" + k)); - final LocalAlluxioMaster master = LocalAlluxioMaster.create(mWorkDirectory); - master.start(); - LOG.info("master NO.{} started, isServing: {}, address: {}", k, master.isServing(), - master.getAddress()); - mMasters.add(master); - // Each master should generate a new port for binding - Configuration.set(PropertyKey.MASTER_RPC_PORT, 0); - Configuration.set(PropertyKey.MASTER_WEB_PORT, 0); - } - - // Create the UFS directory after LocalAlluxioMaster construction, because LocalAlluxioMaster - // sets MASTER_MOUNT_TABLE_ROOT_UFS. - UnderFileSystem ufs = UnderFileSystem.Factory.createForRoot(Configuration.global()); - String path = Configuration.getString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS); - if (ufs.isDirectory(path)) { - ufs.deleteExistingDirectory(path, DeleteOptions.defaults().setRecursive(true)); - } - if (!ufs.mkdirs(path)) { - throw new IOException("Failed to make folder: " + path); - } - - LOG.info("all {} masters started.", mNumOfMasters); - LOG.info("waiting for a leader."); - try { - waitForMasterServing(); - } catch (Exception e) { - throw new IOException(e); - } - // Use first master port - Configuration.set(PropertyKey.MASTER_RPC_PORT, - getLocalAlluxioMaster().getRpcLocalPort()); - } - - @Override - public void startWorkers() throws Exception { - super.startWorkers(); - } - - @Override - public void stopFS() throws Exception { - super.stopFS(); - LOG.info("Stopping testing zookeeper: {}", mCuratorServer.getConnectString()); - mCuratorServer.close(); - } - - @Override - public void stopMasters() throws Exception { - for (int k = 0; k < mNumOfMasters; k++) { - mMasters.get(k).stop(); - } - } -} diff --git a/dora/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java b/dora/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java index 4672acd34b11..9bb1c068e73c 100644 --- a/dora/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java +++ b/dora/minicluster/src/main/java/alluxio/multi/process/MultiProcessCluster.java @@ -167,7 +167,7 @@ private MultiProcessCluster(Map properties, PropertyKey.MASTER_JOURNAL_TYPE, Configuration.getEnum(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.class)); mDeployMode = journalType == JournalType.EMBEDDED ? DeployMode.EMBEDDED - : numMasters > 1 ? DeployMode.ZOOKEEPER_HA : DeployMode.UFS_NON_HA; + : DeployMode.UFS_NON_HA; } /** @@ -238,13 +238,6 @@ public synchronized void startNewMasters(int count, boolean format) throws Excep mProperties.put(PropertyKey.MASTER_RPC_ADDRESSES, com.google.common.base.Joiner.on(",").join(rpcAddresses)); break; - case ZOOKEEPER_HA: - mCuratorServer = mCloser.register( - new TestingServer(-1, AlluxioTestDirectory.createTemporaryDirectory("zk"))); - mProperties.put(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS); - mProperties.put(PropertyKey.ZOOKEEPER_ENABLED, true); - mProperties.put(PropertyKey.ZOOKEEPER_ADDRESS, mCuratorServer.getConnectString()); - break; default: throw new IllegalStateException("Unknown deploy mode: " + mDeployMode); } @@ -571,8 +564,6 @@ public synchronized void stopAndRemoveMaster(int i) throws IOException { Configuration.set(PropertyKey.MASTER_EMBEDDED_JOURNAL_ADDRESSES, journalAddresses); Configuration.set(PropertyKey.MASTER_RPC_ADDRESSES, rpcAddresses); break; - case ZOOKEEPER_HA: // zk will take care of fault tolerance - break; default: // UFS_NON_HA: can't remove the only master in the cluster throw new IllegalStateException("Unimplemented deploy mode: " + mDeployMode); } @@ -798,12 +789,6 @@ public synchronized MasterInquireClient getMasterInquireClient() { return new SingleMasterInquireClient(InetSocketAddress.createUnresolved( mMasterAddresses.get(0).getHostname(), mMasterAddresses.get(0).getRpcPort())); } - case ZOOKEEPER_HA: - return ZkMasterInquireClient.getClient(mCuratorServer.getConnectString(), - Configuration.getString(PropertyKey.ZOOKEEPER_ELECTION_PATH), - Configuration.getString(PropertyKey.ZOOKEEPER_LEADER_PATH), - Configuration.getInt(PropertyKey.ZOOKEEPER_LEADER_INQUIRY_RETRY_COUNT), - Configuration.getBoolean(PropertyKey.ZOOKEEPER_AUTH_ENABLED)); default: throw new IllegalStateException("Unknown deploy mode: " + mDeployMode); } @@ -875,7 +860,7 @@ private enum State { */ public enum DeployMode { EMBEDDED, - UFS_NON_HA, ZOOKEEPER_HA + UFS_NON_HA } /** @@ -903,8 +888,6 @@ private Builder(List reservedPorts) { * @return the builder */ public Builder addProperty(PropertyKey key, Object value) { - Preconditions.checkState(!key.equals(PropertyKey.ZOOKEEPER_ENABLED), - "Enable Zookeeper via #setDeployMode instead of #addProperty"); mProperties.put(key, value); return this; } diff --git a/dora/minicluster/src/main/java/alluxio/multi/process/PortCoordination.java b/dora/minicluster/src/main/java/alluxio/multi/process/PortCoordination.java index 6ff1d23ed78f..4f99bc73ecf5 100644 --- a/dora/minicluster/src/main/java/alluxio/multi/process/PortCoordination.java +++ b/dora/minicluster/src/main/java/alluxio/multi/process/PortCoordination.java @@ -58,6 +58,7 @@ public class PortCoordination { public static final List EMBEDDED_JOURNAL_NEW_MEMBER = allocate(6, 0); public static final List EMBEDDED_JOURNAL_UNAVAILABLE_MASTER = allocate(5, 0); + public static final List FAULT_TOLERANCE = allocate(2, 1); public static final List JOURNAL_MIGRATION = allocate(3, 1); public static final List BACKUP_RESTORE_EMBEDDED = allocate(3, 1); @@ -73,6 +74,8 @@ public class PortCoordination { public static final List MULTI_PROCESS_SIMPLE_CLUSTER = allocate(1, 1); public static final List MULTI_PROCESS_ZOOKEEPER = allocate(3, 2); + public static final List JOBSERVICE_FAULT_TOLERANCE_SHELL = allocate(2, 1); + public static final List JOURNAL_STOP_SINGLE_MASTER = allocate(1, 0); public static final List JOURNAL_STOP_MULTI_MASTER = allocate(3, 0); diff --git a/dora/shell/src/test/java/alluxio/cli/LogLevelTest.java b/dora/shell/src/test/java/alluxio/cli/LogLevelTest.java index de87bb3a0399..9257d73d48b6 100644 --- a/dora/shell/src/test/java/alluxio/cli/LogLevelTest.java +++ b/dora/shell/src/test/java/alluxio/cli/LogLevelTest.java @@ -28,7 +28,6 @@ import alluxio.job.wire.JobWorkerHealth; import alluxio.master.MasterInquireClient; import alluxio.uri.MultiMasterAuthority; -import alluxio.uri.ZookeeperAuthority; import alluxio.wire.WorkerNetAddress; import org.apache.commons.cli.CommandLine; @@ -93,34 +92,6 @@ public void parseSingleJobMasterTarget() throws Exception { targets.get(0)); } - @Test - public void parseZooKeeperHAMasterTarget() throws Exception { - String masterAddress = "masters-1:2181"; - mConf.set(PropertyKey.ZOOKEEPER_ENABLED, true); - mConf.set(PropertyKey.ZOOKEEPER_ADDRESS, masterAddress); - - CommandLine mockCommandLine = mock(CommandLine.class); - String[] mockArgs = new String[]{"--target", "master"}; - when(mockCommandLine.getArgs()).thenReturn(mockArgs); - when(mockCommandLine.hasOption(LogLevel.TARGET_OPTION_NAME)).thenReturn(true); - when(mockCommandLine.getOptionValue(LogLevel.TARGET_OPTION_NAME)).thenReturn(mockArgs[1]); - try (MockedStatic mockFactory = - mockStatic(MasterInquireClient.Factory.class)) { - MasterInquireClient mockInquireClient = mock(MasterInquireClient.class); - when(mockInquireClient.getPrimaryRpcAddress()).thenReturn( - new InetSocketAddress("masters-1", mConf.getInt(PropertyKey.MASTER_RPC_PORT))); - when(mockInquireClient.getConnectDetails()) - .thenReturn(() -> new ZookeeperAuthority(masterAddress)); - mockFactory.when(() -> MasterInquireClient.Factory.create(any(), any())) - .thenReturn(mockInquireClient); - - List targets = LogLevel.parseOptTarget(mockCommandLine, mConf); - assertEquals(1, targets.size()); - assertEquals(new LogLevel.TargetInfo("masters-1", MASTER_WEB_PORT, "master"), - targets.get(0)); - } - } - @Test public void parseEmbeddedHAMasterTarget() throws Exception { String masterAddresses = "masters-1:19200,masters-2:19200"; @@ -148,31 +119,6 @@ public void parseEmbeddedHAMasterTarget() throws Exception { } } - @Test - public void parseZooKeeperHAJobMasterTarget() throws Exception { - mConf.set(PropertyKey.ZOOKEEPER_ENABLED, true); - mConf.set(PropertyKey.ZOOKEEPER_ADDRESS, "masters-1:2181"); - - CommandLine mockCommandLine = mock(CommandLine.class); - String[] mockArgs = new String[]{"--target", "job_master"}; - when(mockCommandLine.getArgs()).thenReturn(mockArgs); - when(mockCommandLine.hasOption(LogLevel.TARGET_OPTION_NAME)).thenReturn(true); - when(mockCommandLine.getOptionValue(LogLevel.TARGET_OPTION_NAME)).thenReturn(mockArgs[1]); - try (MockedStatic mockFactory = - mockStatic(JobMasterClient.Factory.class)) { - JobMasterClient mockJobClient = mock(JobMasterClient.class); - when(mockJobClient.getRemoteSockAddress()).thenReturn(new InetSocketAddress("masters-2", - mConf.getInt(PropertyKey.JOB_MASTER_RPC_PORT))); - when(mockJobClient.getRemoteHostName()).thenReturn("masters-2"); - mockFactory.when(() -> JobMasterClient.Factory.create(any())).thenReturn(mockJobClient); - - List targets = LogLevel.parseOptTarget(mockCommandLine, mConf); - assertEquals(1, targets.size()); - assertEquals(new LogLevel.TargetInfo("masters-2", JOB_MASTER_WEB_PORT, "job_master"), - targets.get(0)); - } - } - @Test public void parseEmbeddedHAJobMasterTarget() throws Exception { mConf.set(PropertyKey.JOB_MASTER_EMBEDDED_JOURNAL_ADDRESSES, "masters-1:19200,masters-2:19200"); diff --git a/dora/tests/integration/src/test/java/alluxio/client/cli/fs/GetConfTest.java b/dora/tests/integration/src/test/java/alluxio/client/cli/fs/GetConfTest.java index 24497bfe7fb1..4ee338a2d01a 100644 --- a/dora/tests/integration/src/test/java/alluxio/client/cli/fs/GetConfTest.java +++ b/dora/tests/integration/src/test/java/alluxio/client/cli/fs/GetConfTest.java @@ -131,11 +131,11 @@ public void getConfWithWrongUnit() throws Exception { public void getConfWithInvalidConf() throws Exception { try (Closeable p = new SystemPropertyRule(ImmutableMap.of( PropertyKey.CONF_VALIDATION_ENABLED.toString(), "false", - PropertyKey.ZOOKEEPER_ENABLED.toString(), "true")).toResource()) { + PropertyKey.MASTER_HOSTNAME.toString(), "host")).toResource()) { Configuration.reloadProperties(); ClientContext ctx = ClientContext.create(Configuration.global()); assertEquals(0, GetConf.getConf(ctx, - PropertyKey.ZOOKEEPER_ENABLED.toString())); + PropertyKey.MASTER_HOSTNAME.toString())); assertEquals("true\n", mOutputStream.toString()); } finally { Configuration.reloadProperties(); diff --git a/dora/tests/integration/src/test/java/alluxio/client/cli/fs/JobServiceFaultToleranceShellTest.java b/dora/tests/integration/src/test/java/alluxio/client/cli/fs/JobServiceFaultToleranceShellTest.java deleted file mode 100644 index e2b770b42f76..000000000000 --- a/dora/tests/integration/src/test/java/alluxio/client/cli/fs/JobServiceFaultToleranceShellTest.java +++ /dev/null @@ -1,89 +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.client.cli.fs; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import alluxio.AlluxioURI; -import alluxio.annotation.dora.DoraTestTodoItem; -import alluxio.cli.fs.FileSystemShell; -import alluxio.client.file.FileSystem; -import alluxio.conf.Configuration; -import alluxio.master.LocalAlluxioJobCluster; -import alluxio.master.MultiMasterLocalAlluxioCluster; -import alluxio.testutils.BaseIntegrationTest; -import alluxio.testutils.IntegrationTestUtils; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; - -import java.io.ByteArrayOutputStream; -import java.io.OutputStream; -import java.io.PrintStream; - -/** - * Tests that the job service is available to the shell when running in fault-tolerant mode. - */ -public final class JobServiceFaultToleranceShellTest extends BaseIntegrationTest { - private MultiMasterLocalAlluxioCluster mLocalAlluxioCluster; - private LocalAlluxioJobCluster mLocalAlluxioJobCluster; - private ByteArrayOutputStream mOutput; - - @Rule - public TestName mTestName = new TestName(); - - @Before - public void before() throws Exception { - mLocalAlluxioCluster = new MultiMasterLocalAlluxioCluster(2); - mLocalAlluxioCluster.initConfiguration( - IntegrationTestUtils.getTestName(getClass().getSimpleName(), mTestName.getMethodName())); - mLocalAlluxioCluster.start(); - mLocalAlluxioJobCluster = new LocalAlluxioJobCluster(); - mLocalAlluxioJobCluster.start(); - mOutput = new ByteArrayOutputStream(); - System.setOut(new PrintStream(mOutput)); - } - - @After - public void after() throws Exception { - if (mLocalAlluxioJobCluster != null) { - mLocalAlluxioJobCluster.stop(); - } - if (mLocalAlluxioCluster != null) { - mLocalAlluxioCluster.stop(); - } - System.setOut(System.out); - Configuration.reloadProperties(); - } - - @Test - @DoraTestTodoItem(action = DoraTestTodoItem.Action.REMOVE, owner = "bowen", - comment = "job master and job worker are deprecated") - @Ignore - public void distributedCp() throws Exception { - FileSystem fs = FileSystem.Factory.create(); - try (OutputStream out = fs.createFile(new AlluxioURI("/test"))) { - out.write("Hello".getBytes()); - } - - try (FileSystemShell shell = new FileSystemShell(Configuration.global())) { - int exitCode = shell.run("distributedCp", "/test", "/test2"); - assertEquals("Command failed, output: " + mOutput.toString(), 0, exitCode); - } - assertTrue(fs.exists(new AlluxioURI("/test2"))); - } -} diff --git a/dora/tests/integration/src/test/java/alluxio/server/configuration/ConfigCheckerIntegrationTest.java b/dora/tests/integration/src/test/java/alluxio/server/configuration/ConfigCheckerIntegrationTest.java index 99fd04917e54..1ab183d562d5 100644 --- a/dora/tests/integration/src/test/java/alluxio/server/configuration/ConfigCheckerIntegrationTest.java +++ b/dora/tests/integration/src/test/java/alluxio/server/configuration/ConfigCheckerIntegrationTest.java @@ -57,27 +57,6 @@ public void after() throws Exception { mCluster.destroy(); } - @Test - public void multiMasters() throws Exception { - PropertyKey key = PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS; - Map> masterProperties - = generatePropertyWithDifferentValues(TEST_NUM_MASTERS, key); - mCluster = MultiProcessCluster.newBuilder(PortCoordination.CONFIG_CHECKER_MULTI_MASTERS) - .setClusterName("ConfigCheckerMultiMastersTest") - .setNumMasters(TEST_NUM_MASTERS) - .setNumWorkers(0) - .setMasterProperties(masterProperties) - .build(); - mCluster.start(); - ConfigCheckReport report = getReport(); - // When using embedded journal, the journal paths are different - assertEquals(mCluster.getDeployMode().equals(DeployMode.ZOOKEEPER_HA) - ? ConfigStatus.WARN : ConfigStatus.FAILED, report.getConfigStatus()); - assertThat(report.getConfigWarns().toString(), - CoreMatchers.containsString(key.getName())); - mCluster.notifySuccess(); - } - @Test public void multiMastersEmbeddedHA() throws Exception { PropertyKey key = PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS; @@ -169,18 +148,10 @@ public void unsetVsSet() throws Exception { Map> errors = report.getConfigErrors(); assertTrue(errors.containsKey(Scope.MASTER)); - if (mCluster.getDeployMode().equals(DeployMode.ZOOKEEPER_HA)) { - assertEquals(1, errors.get(Scope.MASTER).size()); - InconsistentProperty property = errors.get(Scope.MASTER).get(0); - assertEquals(PropertyKey.MASTER_MOUNT_TABLE_ROOT_OPTION.getName(), property.getName()); - assertTrue(property.getValues().containsKey(Optional.of("option"))); - assertTrue(property.getValues().containsKey(Optional.empty())); - } else { - // When using embedded journal, the journal paths are different - assertEquals(2, errors.get(Scope.MASTER).size()); - assertThat(report.getConfigErrors().toString(), - CoreMatchers.containsString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_OPTION.getName())); - } + // When using embedded journal, the journal paths are different + assertEquals(2, errors.get(Scope.MASTER).size()); + assertThat(report.getConfigErrors().toString(), + CoreMatchers.containsString(PropertyKey.MASTER_MOUNT_TABLE_ROOT_OPTION.getName())); mCluster.notifySuccess(); } diff --git a/dora/tests/integration/src/test/java/alluxio/server/ft/FileSystemMasterFaultToleranceIntegrationTest.java b/dora/tests/integration/src/test/java/alluxio/server/ft/FileSystemMasterFaultToleranceIntegrationTest.java deleted file mode 100644 index fb0a68799646..000000000000 --- a/dora/tests/integration/src/test/java/alluxio/server/ft/FileSystemMasterFaultToleranceIntegrationTest.java +++ /dev/null @@ -1,433 +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; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThrows; - -import alluxio.AlluxioURI; -import alluxio.AuthenticatedUserRule; -import alluxio.Constants; -import alluxio.annotation.dora.DoraTestTodoItem; -import alluxio.client.file.FileSystem; -import alluxio.conf.Configuration; -import alluxio.conf.PropertyKey; -import alluxio.exception.FileAlreadyCompletedException; -import alluxio.exception.FileAlreadyExistsException; -import alluxio.exception.FileDoesNotExistException; -import alluxio.grpc.CompleteFilePOptions; -import alluxio.grpc.CreateFilePOptions; -import alluxio.grpc.DeletePOptions; -import alluxio.grpc.FileSystemMasterCommonPOptions; -import alluxio.grpc.MountPOptions; -import alluxio.grpc.RenamePOptions; -import alluxio.master.MultiMasterLocalAlluxioCluster; -import alluxio.master.file.FileSystemMaster; -import alluxio.master.file.contexts.CompleteFileContext; -import alluxio.master.file.contexts.CreateDirectoryContext; -import alluxio.master.file.contexts.CreateFileContext; -import alluxio.master.file.contexts.DeleteContext; -import alluxio.master.file.contexts.RenameContext; -import alluxio.testutils.BaseIntegrationTest; -import alluxio.testutils.IntegrationTestUtils; -import alluxio.util.io.PathUtils; -import alluxio.wire.FileInfo; -import alluxio.wire.OperationId; - -import com.google.common.collect.ImmutableMap; -import org.apache.commons.io.IOUtils; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import java.io.FileWriter; -import java.nio.charset.Charset; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.UUID; - -@RunWith(Parameterized.class) -@Ignore -@DoraTestTodoItem(action = DoraTestTodoItem.Action.FIX, owner = "jiacheng", - comment = "revisit HA") -public final class FileSystemMasterFaultToleranceIntegrationTest extends BaseIntegrationTest { - private static final int CLUSTER_WAIT_TIMEOUT_MS = 120 * Constants.SECOND_MS; - private static final String TEST_USER = "test"; - - private MultiMasterLocalAlluxioCluster mMultiMasterLocalAlluxioCluster; - - @Rule - public TemporaryFolder mFolder = new TemporaryFolder(); - - @Rule - public TestName mTestName = new TestName(); - - @Rule - public AuthenticatedUserRule mAuthenticatedUser = - new AuthenticatedUserRule(TEST_USER, Configuration.global()); - - @Parameterized.Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - {new ImmutableMap.Builder() - .put(PropertyKey.MASTER_FILE_SYSTEM_MERGE_INODE_JOURNALS, false) - .build()}, - {new ImmutableMap.Builder() - .put(PropertyKey.MASTER_FILE_SYSTEM_MERGE_INODE_JOURNALS, true) - .build()}, - }); - } - - @Parameterized.Parameter - public ImmutableMap mParameterizedConfigMap; - - @Before - public final void before() throws Exception { - mMultiMasterLocalAlluxioCluster = new MultiMasterLocalAlluxioCluster(2, 1); - mMultiMasterLocalAlluxioCluster.initConfiguration( - IntegrationTestUtils.getTestName(getClass().getSimpleName(), mTestName.getMethodName())); - Configuration.set(PropertyKey.USER_RPC_RETRY_MAX_DURATION, "60sec"); - Configuration.set(PropertyKey.USER_RPC_RETRY_MAX_SLEEP_MS, "1sec"); - Configuration.set(PropertyKey.NETWORK_CONNECTION_SERVER_SHUTDOWN_TIMEOUT, "30sec"); - Configuration.set(PropertyKey.MASTER_JOURNAL_TAILER_SHUTDOWN_QUIET_WAIT_TIME_MS, "0sec"); - Configuration.set(PropertyKey.SECURITY_LOGIN_USERNAME, TEST_USER); - Configuration.set(PropertyKey.MASTER_FILE_SYSTEM_MERGE_INODE_JOURNALS, false); - for (Map.Entry entry : mParameterizedConfigMap.entrySet()) { - Configuration.set(entry.getKey(), entry.getValue()); - } - mMultiMasterLocalAlluxioCluster.start(); - } - - @After - public final void after() throws Exception { - mMultiMasterLocalAlluxioCluster.stop(); - Configuration.reloadProperties(); - } - - @Test - public void syncMetadataUFSFailOver() throws Exception { - String ufsPath = mFolder.newFolder().getAbsoluteFile().toString(); - String ufsUri = "file://" + ufsPath; - MountPOptions options = MountPOptions.newBuilder().build(); - FileSystem client = mMultiMasterLocalAlluxioCluster.getClient(); - AlluxioURI mountPath = new AlluxioURI("/mnt1"); - client.mount(mountPath, new AlluxioURI(ufsUri), options); - - // create files outside alluxio - String fileName = "someFile"; - String contents = "contents"; - for (int i = 0; i < 100; i++) { - try (FileWriter fw = new FileWriter(Paths.get(PathUtils.concatPath( - ufsPath, fileName + i)).toString())) { - fw.write(contents + i); - } - } - for (int i = 0; i < 100; i++) { - // sync it with metadata sync - assertEquals(contents + i, IOUtils.toString(client.openFile( - mountPath.join(fileName + i)), Charset.defaultCharset())); - } - - // Promote standby to be a leader and reset test state. - mMultiMasterLocalAlluxioCluster.stopLeader(); - mMultiMasterLocalAlluxioCluster.waitForNewMaster(CLUSTER_WAIT_TIMEOUT_MS); - mMultiMasterLocalAlluxioCluster.waitForWorkersRegistered(CLUSTER_WAIT_TIMEOUT_MS); - - // read the files again - client = mMultiMasterLocalAlluxioCluster.getClient(); - for (int i = 0; i < 100; i++) { - assertEquals(contents + i, IOUtils.toString(client.openFile( - mountPath.join(fileName + i)), Charset.defaultCharset())); - } - } - - @Test - public void partitionTolerantCreateFile() throws Exception { - // Create paths for the test. - AlluxioURI testPath1 = new AlluxioURI("/testPath1"); - // Create context1 with unique operation id. - CreateFileContext context = CreateFileContext - .mergeFrom(CreateFilePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - // Create context2 with unique operation id. - CreateFileContext context2 = CreateFileContext - .mergeFrom(CreateFilePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - - // Run partition tolerance test on leading master. - { - // Acquire file-system-master of leading master. - final FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster - .getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class); - - // Create the path the first time. - leadingFsMaster.createFile(testPath1, context); - // Create the path the second time with the same context. - // It should just return successfully. - FileInfo fileInfo = leadingFsMaster.createFile(testPath1, context); - Assert.assertEquals(fileInfo.getFileId(), leadingFsMaster.getFileId(testPath1)); - - // Create the file again with a different context. - // It should fail with `FileAlreadyExistException`. - assertThrows(FileAlreadyExistsException.class, - () -> leadingFsMaster.createFile(testPath1, context2)); - } - - // Promote standby to be a leader and reset test state. - mMultiMasterLocalAlluxioCluster.stopLeader(); - mMultiMasterLocalAlluxioCluster.waitForNewMaster(CLUSTER_WAIT_TIMEOUT_MS); - mAuthenticatedUser.resetUser(); - - // Run partition tolerance test on the *new* leading master. - { - // Acquire file-system-master of leading master. - final FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster - .getLocalAlluxioMaster().getMasterProcess().getMaster(FileSystemMaster.class); - - // Creating on the new leader with the original operation-id should succeed. - FileInfo fileInfo = leadingFsMaster.createFile(testPath1, context); - Assert.assertEquals(fileInfo.getFileId(), leadingFsMaster.getFileId(testPath1)); - - // Creating on the new leader with a different operation-id should fail. - assertThrows(FileAlreadyExistsException.class, - () -> leadingFsMaster.createFile(testPath1, context2)); - } - } - - @Test - public void partitionTolerantCompleteFile() throws Exception { - // Create paths for the test. - AlluxioURI testPath1 = new AlluxioURI("/testPath1"); - // Create context1 with unique operation id. - CompleteFileContext context = CompleteFileContext - .mergeFrom(CompleteFilePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - // Create context2 with unique operation id. - CompleteFileContext context2 = CompleteFileContext - .mergeFrom(CompleteFilePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - - // Run partition tolerance test on leading master. - { - // Acquire file-system-master of leading master. - FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster() - .getMasterProcess().getMaster(FileSystemMaster.class); - - // Create the path to complete. - leadingFsMaster.createFile(testPath1, CreateFileContext.defaults()); - - // Complete the path the first time. - leadingFsMaster.completeFile(testPath1, context); - // Complete the path the second time with the same context. - // It should just return successfully. - leadingFsMaster.completeFile(testPath1, context); - - // Complete the file again with a different context. - // It should fail with `FileAlreadyCompletedException`. - assertThrows(FileAlreadyCompletedException.class, - () -> leadingFsMaster.completeFile(testPath1, context2)); - } - - // Promote standby to be a leader and reset test state. - mMultiMasterLocalAlluxioCluster.stopLeader(); - mMultiMasterLocalAlluxioCluster.waitForNewMaster(CLUSTER_WAIT_TIMEOUT_MS); - mAuthenticatedUser.resetUser(); - - // Run partition tolerance test on the *new* leading master. - { - // Acquire file-system-master of leading master. - FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster() - .getMasterProcess().getMaster(FileSystemMaster.class); - - // Completing the file on the new leader with the original operation-id should succeed. - leadingFsMaster.completeFile(testPath1, context); - - // Creating on the new leader with a different operation-id. - // It should fail with `FileAlreadyCompletedException`. - assertThrows(FileAlreadyCompletedException.class, - () -> leadingFsMaster.completeFile(testPath1, context2)); - } - } - - @Test - public void partitionTolerantDeleteFile() throws Exception { - // Create paths for the test. - AlluxioURI testPath1 = new AlluxioURI("/testPath1"); - // Create context1 with unique operation id. - DeleteContext context = DeleteContext - .mergeFrom(DeletePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - // Create context2 with unique operation id. - DeleteContext context2 = DeleteContext - .mergeFrom(DeletePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - { - // Acquire file-system-master of leading master. - FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster() - .getMasterProcess().getMaster(FileSystemMaster.class); - - // Create the path to delete. - leadingFsMaster.createFile(testPath1, CreateFileContext.defaults()); - leadingFsMaster.completeFile(testPath1, CompleteFileContext.defaults()); - - // Delete the path the first time. - leadingFsMaster.delete(testPath1, context); - // Delete the path the second time with the same context. - // It should just return successfully. - leadingFsMaster.delete(testPath1, context); - - // Delete the path again with a different context. - // It should fail with `FileDoesNotExistException`. - assertThrows(FileDoesNotExistException.class, - () -> leadingFsMaster.delete(testPath1, context2)); - } - - // Promote standby to be a leader and reset test state. - mMultiMasterLocalAlluxioCluster.stopLeader(); - mMultiMasterLocalAlluxioCluster.waitForNewMaster(CLUSTER_WAIT_TIMEOUT_MS); - mAuthenticatedUser.resetUser(); - - // Run partition tolerance test on the *new* leading master. - { - // Acquire file-system-master of leading master. - FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster() - .getMasterProcess().getMaster(FileSystemMaster.class); - // Deleting the file on the new leader with the original operation-id should succeed. - leadingFsMaster.delete(testPath1, context); - - // Deleting on the new leader with a different operation-id. - // It should fail with `FileDoesNotExistException`. - assertThrows(FileDoesNotExistException.class, - () -> leadingFsMaster.delete(testPath1, context2)); - } - } - - @Test - public void partitionTolerantDeleteDirectory() throws Exception { - // Create paths for the test. - AlluxioURI testPath1 = new AlluxioURI("/testPath1"); - // Create context1 with unique operation id. - DeleteContext context = DeleteContext - .mergeFrom(DeletePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - // Create context2 with unique operation id. - DeleteContext context2 = DeleteContext - .mergeFrom(DeletePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - - // Run partition tolerance test on leading master. - { - // Acquire file-system-master of leading master. - FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster() - .getMasterProcess().getMaster(FileSystemMaster.class); - - // Create the path to delete. - leadingFsMaster.createDirectory(testPath1, CreateDirectoryContext.defaults()); - - // Delete the path the first time. - leadingFsMaster.delete(testPath1, context); - // Delete the path the second time with the same context. - // It should just return successfully. - leadingFsMaster.delete(testPath1, context); - - // Delete the path again with a different context. - // It should fail with `FileDoesNotExistException`. - assertThrows(FileDoesNotExistException.class, - () -> leadingFsMaster.delete(testPath1, context2)); - } - - // Promote standby to be a leader and reset test state. - mMultiMasterLocalAlluxioCluster.stopLeader(); - mMultiMasterLocalAlluxioCluster.waitForNewMaster(CLUSTER_WAIT_TIMEOUT_MS); - mAuthenticatedUser.resetUser(); - - // Run partition tolerance test on the *new* leading master. - { - // Acquire file-system-master of leading master. - FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster() - .getMasterProcess().getMaster(FileSystemMaster.class); - - // Deleting the path on the new leader with the original operation-id should succeed. - leadingFsMaster.delete(testPath1, context); - - // Deleting on the new leader with a different operation-id. - // It should fail with `FileDoesNotExistException`. - assertThrows(FileDoesNotExistException.class, - () -> leadingFsMaster.delete(testPath1, context2)); - } - } - - @Test - public void partitionTolerantRename() throws Exception { - // Create paths for the test. - AlluxioURI testPath1 = new AlluxioURI("/testPath1"); - AlluxioURI testPath2 = new AlluxioURI("/testPath2"); - // Create context1 with unique operation id. - RenameContext context = RenameContext - .mergeFrom(RenamePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - // Create context2 with unique operation id. - RenameContext context2 = RenameContext - .mergeFrom(RenamePOptions.newBuilder().setCommonOptions(FileSystemMasterCommonPOptions - .newBuilder().setOperationId(new OperationId(UUID.randomUUID()).toFsProto()))); - - // Run partition tolerance test on leading master. - { - // Acquire file-system-master of leading master. - FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster() - .getMasterProcess().getMaster(FileSystemMaster.class); - - // Create the path to rename. - leadingFsMaster.createDirectory(testPath1, CreateDirectoryContext.defaults()); - - // Rename the path the first time. - leadingFsMaster.rename(testPath1, testPath2, context); - // Renaming the path the second time with the same context. - // It should just return successfully. - leadingFsMaster.rename(testPath1, testPath2, context); - - // Rename the path again with a different context. - // It should fail with `FileDoesNotExistException`. - assertThrows(FileDoesNotExistException.class, - () -> leadingFsMaster.rename(testPath1, testPath2, context2)); - } - - // Promote standby to be a leader and reset test state. - mMultiMasterLocalAlluxioCluster.stopLeader(); - mMultiMasterLocalAlluxioCluster.waitForNewMaster(CLUSTER_WAIT_TIMEOUT_MS); - mAuthenticatedUser.resetUser(); - - // Run partition tolerance test on the *new* leading master. - { - // Acquire file-system-master of leading master. - FileSystemMaster leadingFsMaster = mMultiMasterLocalAlluxioCluster.getLocalAlluxioMaster() - .getMasterProcess().getMaster(FileSystemMaster.class); - - // Renaming the path on the new leader with the original operation-id should succeed. - leadingFsMaster.rename(testPath1, testPath2, context); - - // Renaming on the new leader with a different operation-id. - // It should fail with `FileDoesNotExistException`. - assertThrows(FileDoesNotExistException.class, - () -> leadingFsMaster.rename(testPath1, testPath2, context2)); - } - } -} diff --git a/dora/tests/integration/src/test/java/alluxio/server/ft/MasterFailoverIntegrationTest.java b/dora/tests/integration/src/test/java/alluxio/server/ft/MasterFailoverIntegrationTest.java deleted file mode 100644 index fa70fa1e5e4b..000000000000 --- a/dora/tests/integration/src/test/java/alluxio/server/ft/MasterFailoverIntegrationTest.java +++ /dev/null @@ -1,144 +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; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -import alluxio.AlluxioURI; -import alluxio.Constants; -import alluxio.UnderFileSystemFactoryRegistryRule; -import alluxio.annotation.dora.DoraTestTodoItem; -import alluxio.client.file.FileSystem; -import alluxio.conf.Configuration; -import alluxio.conf.PropertyKey; -import alluxio.master.MultiMasterLocalAlluxioCluster; -import alluxio.testutils.BaseIntegrationTest; -import alluxio.testutils.IntegrationTestUtils; -import alluxio.testutils.underfs.delegating.DelegatingUnderFileSystem; -import alluxio.testutils.underfs.delegating.DelegatingUnderFileSystemFactory; -import alluxio.underfs.UnderFileSystem; -import alluxio.underfs.options.DeleteOptions; -import alluxio.util.CommonUtils; - -import com.google.common.io.Files; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; - -@Ignore -@DoraTestTodoItem(action = DoraTestTodoItem.Action.FIX, owner = "jiacheng", - comment = "revisit HA") -public final class MasterFailoverIntegrationTest extends BaseIntegrationTest { - private static final Logger LOG = LoggerFactory.getLogger(MasterFailoverIntegrationTest.class); - - private static final String LOCAL_UFS_PATH = Files.createTempDir().getAbsolutePath(); - private static final long DELETE_DELAY = 5 * Constants.SECOND_MS; - - private MultiMasterLocalAlluxioCluster mMultiMasterLocalAlluxioCluster; - private FileSystem mFileSystem; - - // An under file system which has slow directory deletion. - private static final UnderFileSystem UFS = - new DelegatingUnderFileSystem(UnderFileSystem.Factory.create(LOCAL_UFS_PATH, - Configuration.global())) { - @Override - public boolean deleteDirectory(String path) throws IOException { - CommonUtils.sleepMs(DELETE_DELAY); - return mUfs.deleteDirectory(path); - } - - @Override - public boolean deleteDirectory(String path, DeleteOptions options) throws IOException { - CommonUtils.sleepMs(DELETE_DELAY); - return mUfs.deleteDirectory(path, options); - } - }; - - @Rule - public TestName mTestName = new TestName(); - - @ClassRule - public static UnderFileSystemFactoryRegistryRule sUnderfilesystemfactoryregistry = - new UnderFileSystemFactoryRegistryRule(new DelegatingUnderFileSystemFactory(UFS)); - - @Before - public final void before() throws Exception { - mMultiMasterLocalAlluxioCluster = - new MultiMasterLocalAlluxioCluster(2); - mMultiMasterLocalAlluxioCluster.initConfiguration( - IntegrationTestUtils.getTestName(getClass().getSimpleName(), mTestName.getMethodName())); - Configuration.set(PropertyKey.USER_RPC_RETRY_MAX_DURATION, "60sec"); - Configuration.set(PropertyKey.USER_RPC_RETRY_MAX_SLEEP_MS, "1sec"); - Configuration.set(PropertyKey.NETWORK_CONNECTION_SERVER_SHUTDOWN_TIMEOUT, "30sec"); - Configuration.set(PropertyKey.MASTER_JOURNAL_TAILER_SHUTDOWN_QUIET_WAIT_TIME_MS, "0sec"); - Configuration.set(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS, - DelegatingUnderFileSystemFactory.DELEGATING_SCHEME + "://" + LOCAL_UFS_PATH); - mMultiMasterLocalAlluxioCluster.start(); - mFileSystem = mMultiMasterLocalAlluxioCluster.getClient(); - } - - @After - public final void after() throws Exception { - mMultiMasterLocalAlluxioCluster.stop(); - } - - @Test - public void failoverJournalFencingTest() throws Exception { - // This test verifies that when a master fails over due to Zookeeper disconnection, outstanding - // threads on the master are not allowed to write to the journal. - AlluxioURI dir = new AlluxioURI("/dir"); - mFileSystem.createDirectory(dir); - DeleteThread deleteThread = new DeleteThread(dir); - deleteThread.start(); - // Give the delete thread a chance to start. - Thread.sleep(500); - mMultiMasterLocalAlluxioCluster.stopZk(); - // Give master a chance to notice that ZK is dead and trigger failover. - Thread.sleep(10000); - mMultiMasterLocalAlluxioCluster.restartZk(); - deleteThread.join(); - // After failing on the original master, the delete should be retried on the new master. - assertFalse(mFileSystem.exists(dir)); - // Restart to make sure the journal is consistent (we didn't write two delete entries for /dir). - mMultiMasterLocalAlluxioCluster.restartMasters(); - mFileSystem = mMultiMasterLocalAlluxioCluster.getClient(); // need new client after restart - assertEquals(0, mFileSystem.listStatus(new AlluxioURI("/")).size()); - } - - private class DeleteThread extends Thread { - public final AlluxioURI mDir; - - public DeleteThread(AlluxioURI dir) { - mDir = dir; - } - - @Override - public void run() { - try { - LOG.info("Starting to delete {}", mDir); - mFileSystem.delete(mDir); - LOG.info("Deleted {}", mDir); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } -} diff --git a/dora/tests/integration/src/test/java/alluxio/server/ft/ZookeeperFailureIntegrationTest.java b/dora/tests/integration/src/test/java/alluxio/server/ft/ZookeeperFailureIntegrationTest.java deleted file mode 100644 index 77d938313b19..000000000000 --- a/dora/tests/integration/src/test/java/alluxio/server/ft/ZookeeperFailureIntegrationTest.java +++ /dev/null @@ -1,192 +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; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; - -import alluxio.ConfigurationRule; -import alluxio.conf.Configuration; -import alluxio.conf.PropertyKey; -import alluxio.grpc.FileSystemMasterClientServiceGrpc; -import alluxio.grpc.GrpcChannel; -import alluxio.grpc.GrpcChannelBuilder; -import alluxio.grpc.GrpcServerAddress; -import alluxio.grpc.ListStatusPRequest; -import alluxio.master.ZookeeperConnectionErrorPolicy; -import alluxio.master.journal.JournalType; -import alluxio.multi.process.MasterNetAddress; -import alluxio.multi.process.MultiProcessCluster; -import alluxio.multi.process.PortCoordination; -import alluxio.testutils.AlluxioOperationThread; -import alluxio.testutils.BaseIntegrationTest; -import alluxio.util.CommonUtils; - -import com.google.common.collect.ImmutableMap; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.net.InetSocketAddress; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicReference; - -/** - * Integration tests for Alluxio high availability when Zookeeper has failures. - */ -public class ZookeeperFailureIntegrationTest extends BaseIntegrationTest { - private static final Logger LOG = LoggerFactory.getLogger(ZookeeperFailureIntegrationTest.class); - - @Rule - public ConfigurationRule mConf = new ConfigurationRule(ImmutableMap.of( - PropertyKey.USER_BLOCK_SIZE_BYTES_DEFAULT, "1000", - PropertyKey.USER_RPC_RETRY_BASE_SLEEP_MS, "500", - PropertyKey.USER_RPC_RETRY_MAX_SLEEP_MS, "500", - PropertyKey.USER_RPC_RETRY_MAX_DURATION, "2500"), Configuration.modifiableGlobal()); - - public MultiProcessCluster mCluster; - - @After - public void after() throws Exception { - if (mCluster != null) { - mCluster.destroy(); - } - } - - /* - * This test starts alluxio in HA mode, kills Zookeeper, waits for Alluxio to fail, then restarts - * Zookeeper. Alluxio should recover when Zookeeper is restarted. - */ - @Ignore("In Dora, Client does not use Master/Journal services.") - @Test - public void zkFailure() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.ZOOKEEPER_FAILURE) - .setClusterName("ZookeeperFailure") - .setNumMasters(2) - .setNumWorkers(1) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - .build(); - mCluster.start(); - - AlluxioOperationThread thread = - new AlluxioOperationThread(mCluster.getFileSystemClient()); - thread.start(); - CommonUtils.waitFor("a successful operation to be performed", () -> thread.successes() > 0); - mCluster.stopZk(); - long zkStopTime = System.currentTimeMillis(); - // Wait until 3 different failures are encountered on the thread. - // PS: First failures could be related to worker capacity depending on process shutdown order, - // thus still leaving RPC server reachable. - AtomicInteger failureCounter = new AtomicInteger(3); - AtomicReference lastFailure = new AtomicReference<>(null); - CommonUtils.waitFor("operations to start failing", () -> failureCounter.getAndAdd( - (lastFailure.getAndSet(thread.getLatestFailure()) != lastFailure.get()) ? -1 : 0) <= 0); - - assertFalse(rpcServiceAvailable()); - LOG.info("First operation failed {}ms after stopping the Zookeeper cluster", - System.currentTimeMillis() - zkStopTime); - final long successes = thread.successes(); - mCluster.restartZk(); - long zkStartTime = System.currentTimeMillis(); - CommonUtils.waitFor("another successful operation to be performed", - () -> thread.successes() > successes); - thread.interrupt(); - thread.join(); - LOG.info("Recovered after {}ms", System.currentTimeMillis() - zkStartTime); - mCluster.notifySuccess(); - } - - @Ignore // cannot guarantee `assertNotEquals(leaderIdx, leaderIdx2);` - @Test - public void zkConnectionPolicy_Standard() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.ZOOKEEPER_CONNECTION_POLICY_STANDARD) - .setClusterName("ZookeeperConnectionPolicy_Standard") - .setNumMasters(2) - .setNumWorkers(0) - .addProperty(PropertyKey.ZOOKEEPER_LEADER_CONNECTION_ERROR_POLICY, - ZookeeperConnectionErrorPolicy.STANDARD) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - .build(); - mCluster.start(); - - int leaderIdx = getPrimaryMasterIndex(); - mCluster.restartZk(); - // Leader will step down under STANDARD connection error policy. - int leaderIdx2 = getPrimaryMasterIndex(); - assertNotEquals(leaderIdx, leaderIdx2); - - mCluster.notifySuccess(); - } - - @Test - public void zkConnectionPolicy_Session() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.ZOOKEEPER_CONNECTION_POLICY_SESSION) - .setClusterName("ZookeeperConnectionPolicy_Session") - .setNumMasters(2) - .setNumWorkers(0) - .addProperty(PropertyKey.ZOOKEEPER_LEADER_CONNECTION_ERROR_POLICY, - ZookeeperConnectionErrorPolicy.SESSION) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - .build(); - mCluster.start(); - - int leaderIdx = getPrimaryMasterIndex(); - mCluster.restartZk(); - // Leader will retain its status under SESSION connection error policy. - int leaderIdx2 = getPrimaryMasterIndex(); - assertEquals(leaderIdx, leaderIdx2); - - mCluster.notifySuccess(); - } - - /** - * Used to get primary master index with retries for when zk server is down. - */ - private int getPrimaryMasterIndex() throws Exception { - AtomicInteger primaryIndex = new AtomicInteger(); - CommonUtils.waitFor("Getting primary master index", () -> { - try { - primaryIndex.set(mCluster.getPrimaryMasterIndex(30000)); - return true; - } catch (Exception e) { - LOG.warn("Could not get primary master index.", e); - return false; - } - }); - - return primaryIndex.get(); - } - - /* - * This method uses a client with an explicit master address to ensure that the master has shut - * down its rpc service. - */ - private boolean rpcServiceAvailable() throws Exception { - MasterNetAddress netAddress = mCluster.getMasterAddresses().get(0); - InetSocketAddress address = - new InetSocketAddress(netAddress.getHostname(), netAddress.getRpcPort()); - try { - GrpcChannel channel = GrpcChannelBuilder - .newBuilder(GrpcServerAddress.create(address), Configuration.global()).build(); - FileSystemMasterClientServiceGrpc.FileSystemMasterClientServiceBlockingStub client = - FileSystemMasterClientServiceGrpc.newBlockingStub(channel); - client.listStatus(ListStatusPRequest.getDefaultInstance()); - } catch (Exception e) { - return false; - } - return true; - } -} diff --git a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/JournalBackupIntegrationTest.java b/dora/tests/integration/src/test/java/alluxio/server/ft/journal/JournalBackupIntegrationTest.java deleted file mode 100644 index b0810c2898c0..000000000000 --- a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/JournalBackupIntegrationTest.java +++ /dev/null @@ -1,832 +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; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import alluxio.AlluxioTestDirectory; -import alluxio.AlluxioURI; -import alluxio.ClientContext; -import alluxio.ConfigurationRule; -import alluxio.Constants; -import alluxio.client.WriteType; -import alluxio.client.block.BlockMasterClient; -import alluxio.client.block.RetryHandlingBlockMasterClient; -import alluxio.client.file.FileInStream; -import alluxio.client.file.FileOutStream; -import alluxio.client.file.FileSystem; -import alluxio.client.file.FileSystemTestUtils; -import alluxio.client.file.URIStatus; -import alluxio.client.meta.MetaMasterClient; -import alluxio.client.meta.RetryHandlingMetaMasterClient; -import alluxio.conf.Configuration; -import alluxio.conf.PropertyKey; -import alluxio.exception.BackupAbortedException; -import alluxio.exception.status.FailedPreconditionException; -import alluxio.grpc.BackupPOptions; -import alluxio.grpc.BackupPRequest; -import alluxio.grpc.BackupState; -import alluxio.grpc.CreateDirectoryPOptions; -import alluxio.grpc.CreateFilePOptions; -import alluxio.grpc.DeletePOptions; -import alluxio.grpc.ListStatusPOptions; -import alluxio.grpc.LoadMetadataPType; -import alluxio.grpc.WritePType; -import alluxio.master.MasterClientContext; -import alluxio.master.NoopMaster; -import alluxio.master.journal.JournalReader; -import alluxio.master.journal.JournalType; -import alluxio.master.journal.ufs.UfsJournal; -import alluxio.master.journal.ufs.UfsJournalLogWriter; -import alluxio.master.journal.ufs.UfsJournalReader; -import alluxio.master.metastore.MetastoreType; -import alluxio.multi.process.MultiProcessCluster; -import alluxio.multi.process.PortCoordination; -import alluxio.proto.journal.Journal; -import alluxio.testutils.AlluxioOperationThread; -import alluxio.testutils.BaseIntegrationTest; -import alluxio.util.CommonUtils; -import alluxio.util.URIUtils; -import alluxio.util.WaitForOptions; -import alluxio.wire.BackupStatus; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.UUID; -import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; - -/** - * Integration test for backing up and restoring alluxio master. - */ -@Ignore("In Dora, Client does not use Master/Journal services.") -public final class JournalBackupIntegrationTest extends BaseIntegrationTest { - public MultiProcessCluster mCluster; - private static final int GET_PRIMARY_INDEX_TIMEOUT_MS = 30000; - private static final int PRIMARY_KILL_TIMEOUT_MS = 30000; - private static final int WAIT_NODES_REGISTERED_MS = 30000; - - @Rule - public ConfigurationRule mConf = new ConfigurationRule(new HashMap() { - { - put(PropertyKey.USER_METRICS_COLLECTION_ENABLED, false); - } - }, Configuration.modifiableGlobal()); - - @After - public void after() throws Exception { - if (mCluster != null) { - mCluster.destroy(); - } - } - - // This test needs to stop and start master many times, so it can take up to a minute to complete. - @Test - public void backupRestoreZk() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_RESTORE_ZK) - .setClusterName("backupRestoreZk") - .setNumMasters(3) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Masters become primary faster - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "3sec") - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - backupRestoreTest(true); - } - - @Test - public void backupRestoreMetastore_Heap() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_RESTORE_METASSTORE_HEAP) - .setClusterName("backupRestoreMetastore_Heap") - .setNumMasters(1) - .setNumWorkers(1) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Masters become primary faster - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - .addProperty(PropertyKey.MASTER_METASTORE, MetastoreType.HEAP) - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - backupRestoreMetaStoreTest(); - } - - @Test - public void backupRestoreMetastore_Rocks() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_RESTORE_METASSTORE_ROCKS) - .setClusterName("backupRestoreMetastore_Rocks") - .setNumMasters(1) - .setNumWorkers(1) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Masters become primary faster - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - .addProperty(PropertyKey.MASTER_METASTORE, MetastoreType.ROCKS) - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - backupRestoreMetaStoreTest(); - } - - @Test - public void backupRestoreMetastore_InodeRocksBlockHeap() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_RESTORE_METASSTORE_ROCKS) - .setClusterName("backupRestoreMetastore_InodeRocksBlockHeap") - .setNumMasters(1) - .setNumWorkers(1) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Masters become primary faster - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - .addProperty(PropertyKey.MASTER_INODE_METASTORE, MetastoreType.ROCKS) - .addProperty(PropertyKey.MASTER_BLOCK_METASTORE, MetastoreType.HEAP) - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - backupRestoreMetaStoreTest(); - } - - @Test - public void backupRestoreMetastore_InodeHeapBlockRocks() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_RESTORE_METASSTORE_ROCKS) - .setClusterName("backupRestoreMetastore_InodeHeapBlockRocks") - .setNumMasters(1) - .setNumWorkers(1) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Masters become primary faster - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - .addProperty(PropertyKey.MASTER_INODE_METASTORE, MetastoreType.HEAP) - .addProperty(PropertyKey.MASTER_BLOCK_METASTORE, MetastoreType.ROCKS) - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - backupRestoreMetaStoreTest(); - } - - @Test - public void emergencyBackup() throws Exception { - emergencyBackupCore(1); - } - - @Test - public void emergencyBackupHA() throws Exception { - emergencyBackupCore(3); - } - - private void emergencyBackupCore(int numMasters) throws Exception { - TemporaryFolder backupFolder = new TemporaryFolder(); - backupFolder.create(); - List ports1 = numMasters > 1 - ? PortCoordination.BACKUP_EMERGENCY_HA_1 : PortCoordination.BACKUP_EMERGENCY_1; - String clusterName1 = numMasters > 1 ? "emergencyBackup_HA_1" : "emergencyBackup_1"; - mCluster = MultiProcessCluster.newBuilder(ports1) - .setClusterName(clusterName1) - .setNumMasters(numMasters) - .setNumWorkers(0) - // Masters become primary faster, will be ignored in non HA case - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - .addProperty(PropertyKey.MASTER_METASTORE, MetastoreType.ROCKS) - .addProperty(PropertyKey.MASTER_BACKUP_DIRECTORY, backupFolder.getRoot()) - .addProperty(PropertyKey.MASTER_JOURNAL_BACKUP_WHEN_CORRUPTED, true) - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - mCluster.start(); - final int numFiles = 10; - // create normal uncorrupted journal - for (int i = 0; i < numFiles; i++) { - mCluster.getFileSystemClient().createFile(new AlluxioURI("/normal-file-" + i)); - } - mCluster.stopMasters(); - // corrupt journal - URI journalLocation = new URI(mCluster.getJournalDir()); - UfsJournal fsMaster = - new UfsJournal(URIUtils.appendPathOrDie(journalLocation, "FileSystemMaster"), - new NoopMaster(), 0, Collections::emptySet); - fsMaster.start(); - fsMaster.gainPrimacy(); - long nextSN = 0; - try (UfsJournalReader reader = new UfsJournalReader(fsMaster, true)) { - while (reader.advance() != JournalReader.State.DONE) { - nextSN++; - } - } - try (UfsJournalLogWriter writer = new UfsJournalLogWriter(fsMaster, nextSN)) { - Journal.JournalEntry entry = Journal.JournalEntry.newBuilder() - .setSequenceNumber(nextSN) - .setDeleteFile(alluxio.proto.journal.File.DeleteFileEntry.newBuilder() - .setId(4563728) // random non-zero ID number (zero would delete the root) - .setPath("/nonexistant") - .build()) - .build(); - writer.write(entry); - writer.flush(); - } - // this should fail and create backup(s) - mCluster.startMasters(); - // wait for backup file(s) to be created - // successful backups leave behind one .gz file and one .gz.complete file - CommonUtils.waitFor("backup file(s) to be created automatically", - () -> 2 * numMasters == Objects.requireNonNull(backupFolder.getRoot().list()).length, - WaitForOptions.defaults().setInterval(500).setTimeoutMs(30_000)); - List backupFiles = Arrays.stream(Objects.requireNonNull(backupFolder.getRoot().list())) - .filter(s -> s.endsWith(".gz")).collect(Collectors.toList()); - assertEquals(numMasters, backupFiles.size()); - // create new cluster - List ports2 = numMasters > 1 - ? PortCoordination.BACKUP_EMERGENCY_HA_2 : PortCoordination.BACKUP_EMERGENCY_2; - String clusterName2 = numMasters > 1 ? "emergencyBackup_HA_2" : "emergencyBackup_2"; - // verify that every backup contains all the entries - for (String backupFile : backupFiles) { - mCluster = MultiProcessCluster.newBuilder(ports2) - .setClusterName(String.format("%s_%s", clusterName2, backupFile)) - .setNumMasters(numMasters) - .setNumWorkers(0) - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // change metastore type to ensure backup is independent of metastore type - .addProperty(PropertyKey.MASTER_METASTORE, MetastoreType.HEAP) - .addProperty(PropertyKey.MASTER_JOURNAL_INIT_FROM_BACKUP, - Paths.get(backupFolder.getRoot().toString(), backupFile)) - .build(); - mCluster.start(); - // test that the files were restored from the backup properly - for (int i = 0; i < numFiles; i++) { - boolean exists = mCluster.getFileSystemClient().exists(new AlluxioURI("/normal-file-" + i)); - assertTrue(exists); - } - mCluster.stopMasters(); - mCluster.notifySuccess(); - } - backupFolder.delete(); - } - - @Test - public void syncRootOnBackupRestore() throws Exception { - syncLsTestCore(true); - } - - @Test - public void doNotSyncRootOnBackupRestore() throws Exception { - syncLsTestCore(false); - } - - private void syncLsTestCore(boolean syncRootOnRestore) throws Exception { - TemporaryFolder temporaryFolder = new TemporaryFolder(); - temporaryFolder.create(); - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_SYNC_ON_RESTORE) - .setClusterName("syncRootOnBackupRestore") - .setNumMasters(1) - .setNumWorkers(1) - .addProperty(PropertyKey.MASTER_BACKUP_DIRECTORY, temporaryFolder.getRoot()) - .addProperty(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, WriteType.CACHE_THROUGH) - .addProperty(PropertyKey.MASTER_JOURNAL_SYNC_ROOT_AFTER_INIT_FROM_BACKUP, syncRootOnRestore) - // this test uses NEVER as the metadata load type to ensure that the UFS sync is - // performed due to the invalidation associated with restoring a backup, as opposed to - // performed automatically under some other metadata load types - .addProperty(PropertyKey.USER_FILE_METADATA_LOAD_TYPE, LoadMetadataPType.NEVER) - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - mCluster.start(); - - mCluster.getFileSystemClient().createDirectory(new AlluxioURI("/in_backup")); - BackupStatus backup = - mCluster.getMetaMasterClient().backup(BackupPRequest.getDefaultInstance()); - UUID id = backup.getBackupId(); - while (backup.getState() != BackupState.Completed) { - backup = mCluster.getMetaMasterClient().getBackupStatus(id); - } - mCluster.getFileSystemClient().createDirectory(new AlluxioURI("/NOT_in_backup")); - mCluster.stopMasters(); - // give it an empty journal and start from backup - mCluster.updateMasterConf(PropertyKey.MASTER_JOURNAL_FOLDER, - temporaryFolder.newFolder().getAbsolutePath()); - mCluster.updateMasterConf(PropertyKey.MASTER_METASTORE_DIR, - temporaryFolder.newFolder().getAbsolutePath()); - mCluster.updateMasterConf(PropertyKey.MASTER_JOURNAL_INIT_FROM_BACKUP, - backup.getBackupUri().getPath()); - mCluster.startMasters(); - List statuses = mCluster.getFileSystemClient().listStatus(new AlluxioURI("/")); - int expected = syncRootOnRestore ? 2 : 1; - assertEquals(expected, statuses.size()); - mCluster.notifySuccess(); - temporaryFolder.delete(); - } - - @Test - public void syncContentsOnBackupRestore() throws Exception { - syncContentsTestCore(true); - } - - @Test - public void doNotSyncContentsOnBackupRestore() throws Exception { - syncContentsTestCore(false); - } - - private void syncContentsTestCore(boolean syncRootOnRestore) throws Exception { - TemporaryFolder temporaryFolder = new TemporaryFolder(); - temporaryFolder.create(); - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_CONTENT_ON_RESTORE) - .setClusterName("syncContentOnBackupRestore") - .setNumMasters(1) - .setNumWorkers(1) - .addProperty(PropertyKey.MASTER_BACKUP_DIRECTORY, temporaryFolder.getRoot()) - .addProperty(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, WriteType.CACHE_THROUGH) - .addProperty(PropertyKey.MASTER_JOURNAL_SYNC_ROOT_AFTER_INIT_FROM_BACKUP, syncRootOnRestore) - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - mCluster.start(); - - AlluxioURI f = new AlluxioURI("/in_backup"); - String originalData = "data"; - try (FileOutStream inBackup = mCluster.getFileSystemClient().createFile(f)) { - inBackup.write(originalData.getBytes()); - } - - BackupStatus backup = - mCluster.getMetaMasterClient().backup(BackupPRequest.getDefaultInstance()); - UUID id = backup.getBackupId(); - while (backup.getState() != BackupState.Completed) { - backup = mCluster.getMetaMasterClient().getBackupStatus(id); - } - - mCluster.getFileSystemClient().delete(f); - String modifiedData = "modified data"; - try (FileOutStream overwriteInBackup = mCluster.getFileSystemClient().createFile(f)) { - overwriteInBackup.write(modifiedData.getBytes()); - } - mCluster.stopMasters(); - // give it an empty journal and start from backup - mCluster.updateMasterConf(PropertyKey.MASTER_JOURNAL_FOLDER, - temporaryFolder.newFolder().getAbsolutePath()); - mCluster.updateMasterConf(PropertyKey.MASTER_METASTORE_DIR, - temporaryFolder.newFolder().getAbsolutePath()); - mCluster.updateMasterConf(PropertyKey.MASTER_JOURNAL_INIT_FROM_BACKUP, - backup.getBackupUri().getPath()); - mCluster.startMasters(); - mCluster.waitForAllNodesRegistered(WAIT_NODES_REGISTERED_MS); - - try (FileInStream inStream = mCluster.getFileSystemClient().openFile(f)) { - byte[] bytes = new byte[modifiedData.length()]; - int read = inStream.read(bytes); - // if the invalidation is not set during the backup restore only the length of the old - // contents ("data") will be read (instead of reading the new contents "modified data") - int expectedLength = syncRootOnRestore ? modifiedData.length() : originalData.length(); - String expectedStart = syncRootOnRestore ? modifiedData : - modifiedData.substring(0, originalData.length()); - assertEquals(expectedLength, read); - assertTrue(new String(bytes).startsWith(expectedStart)); - } - mCluster.notifySuccess(); - temporaryFolder.delete(); - } - - // This test needs to stop and start master many times, so it can take up to a minute to complete. - @Test - public void backupRestoreEmbedded() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_RESTORE_EMBEDDED) - .setClusterName("backupRestoreEmbedded") - .setNumMasters(3) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED) - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - backupRestoreTest(true); - } - - @Test - public void backupRestoreSingleMaster() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_RESTORE_SINGLE) - .setClusterName("backupRestoreSingle") - .setNumMasters(1) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - backupRestoreTest(false); - } - - // Tests various protocols and configurations for backup delegation. - @Test - public void backupDelegationProtocol() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_DELEGATION_PROTOCOL) - .setClusterName("backupDelegationProtocol") - .setNumMasters(3) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Masters become primary faster - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - // For faster backup role handshake. - .addProperty(PropertyKey.MASTER_BACKUP_CONNECT_INTERVAL_MIN, "100ms") - .addProperty(PropertyKey.MASTER_BACKUP_CONNECT_INTERVAL_MAX, "100ms") - // Enable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, true) - .build(); - - File backups = AlluxioTestDirectory.createTemporaryDirectory("backups"); - mCluster.start(); - - // Validate backup works with delegation. - waitForBackup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()); - - // Kill the primary. - int primaryIdx = mCluster.getPrimaryMasterIndex(GET_PRIMARY_INDEX_TIMEOUT_MS); - mCluster.waitForAndKillPrimaryMaster(PRIMARY_KILL_TIMEOUT_MS); - - // Validate backup works again after leader fail-over. - waitForBackup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()); - - // Continue testing with 2 masters... - // Find standby master index. - int newPrimaryIdx = mCluster.getPrimaryMasterIndex(GET_PRIMARY_INDEX_TIMEOUT_MS); - int followerIdx = (newPrimaryIdx + 1) % 2; - if (followerIdx == primaryIdx) { - followerIdx = (followerIdx + 1) % 2; - } - - // Kill the follower. (only leader remains). - mCluster.stopMaster(followerIdx); - - // Wait for a second for process to terminate properly. - // This is so that backup request don't get delegated to follower before termination. - Thread.sleep(1000); - - // Validate backup delegation fails. - try { - mCluster.getMetaMasterClient() - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()); - Assert.fail("Cannot delegate backup with no followers."); - } catch (FailedPreconditionException e) { - // Expected to fail since there is only single master. - } - - // Should work with "AllowLeader" backup. - mCluster.getMetaMasterClient() - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false).setAllowLeader(true)) - .build()); - - // Restart the follower. (1 leader 1 follower remains). - mCluster.startMaster(followerIdx); - - // Validate backup works again. - waitForBackup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()); - - // Schedule async backup. - UUID backupId = mCluster.getMetaMasterClient() - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false).setRunAsync(true)) - .build()) - .getBackupId(); - // Wait until backup is complete. - CommonUtils.waitFor("Backup completed.", () -> { - try { - return mCluster.getMetaMasterClient().getBackupStatus(backupId).getState() - .equals(BackupState.Completed); - } catch (Exception e) { - throw new RuntimeException( - String.format("Unexpected error while getting backup status: %s", e)); - } - }); - - // Schedule a local backup to overwrite latest backup Id in the current leader. - mCluster.getMetaMasterClient() - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false).setAllowLeader(true)) - .build()); - - // Validate old backup can still be queried. - mCluster.getMetaMasterClient().getBackupStatus(backupId); - - mCluster.notifySuccess(); - } - - // Tests various protocols and configurations for backup delegation during fail-overs. - @Test - public void backupDelegationFailoverProtocol() throws Exception { - mCluster = MultiProcessCluster.newBuilder(PortCoordination.BACKUP_DELEGATION_FAILOVER_PROTOCOL) - .setClusterName("backupDelegationFailoverProtocol") - .setNumMasters(2) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Masters become primary faster - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - // For faster backup role handshake. - .addProperty(PropertyKey.MASTER_BACKUP_CONNECT_INTERVAL_MIN, "100ms") - .addProperty(PropertyKey.MASTER_BACKUP_CONNECT_INTERVAL_MAX, "100ms") - // Enable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, true) - // Set backup timeout to be shorter - .addProperty(PropertyKey.MASTER_BACKUP_ABANDON_TIMEOUT, "3sec") - .build(); - - File backups = AlluxioTestDirectory.createTemporaryDirectory("backups"); - mCluster.start(); - - // Validate backup works with delegation. - waitForBackup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()); - - // Find standby master index. - int primaryIdx = mCluster.getPrimaryMasterIndex(GET_PRIMARY_INDEX_TIMEOUT_MS); - int followerIdx = (primaryIdx + 1) % 2; - - // Schedule async backup. - UUID backupId = mCluster.getMetaMasterClient() - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false).setRunAsync(true)) - .build()) - .getBackupId(); - // Kill follower immediately before it sends the next heartbeat to leader. - mCluster.stopMaster(followerIdx); - // Wait until backup is abandoned. - CommonUtils.waitForResult("Backup abandoned.", () -> { - try { - return mCluster.getMetaMasterClient().getBackupStatus(backupId); - } catch (Exception e) { - throw new RuntimeException( - String.format("Unexpected error while getting backup status: %s", e)); - } - }, (backupStatus) -> backupStatus.getError() instanceof BackupAbortedException); - - // Restart follower to restore HA. - mCluster.startMaster(followerIdx); - - // Validate delegated backup works again. - waitForBackup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()); - - // Schedule async backup. - mCluster.getMetaMasterClient() - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false).setRunAsync(true)) - .build()) - .getBackupId(); - - // Kill leader immediately before it receives the next heartbeat from backup-worker. - mCluster.waitForAndKillPrimaryMaster(PRIMARY_KILL_TIMEOUT_MS); - // Wait until follower steps up. - assertEquals(mCluster.getPrimaryMasterIndex(GET_PRIMARY_INDEX_TIMEOUT_MS), followerIdx); - - // Follower should step-up without problem and accept backup requests. - mCluster.getMetaMasterClient() - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false).setAllowLeader(true)) - .build()); - - mCluster.notifySuccess(); - } - - @Test - public void backupDelegationZk() throws Exception { - MultiProcessCluster.Builder clusterBuilder = MultiProcessCluster - .newBuilder(PortCoordination.BACKUP_DELEGATION_ZK) - .setClusterName("backupDelegationZk") - .setNumMasters(2) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Masters become primary faster - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - // Enable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, true) - // For faster backup role handshake. - .addProperty(PropertyKey.MASTER_BACKUP_CONNECT_INTERVAL_MIN, "100ms") - .addProperty(PropertyKey.MASTER_BACKUP_CONNECT_INTERVAL_MAX, "100ms"); - backupDelegationTest(clusterBuilder); - } - - @Test - public void backupDelegationEmbedded() throws Exception { - MultiProcessCluster.Builder clusterBuilder = - MultiProcessCluster.newBuilder(PortCoordination.BACKUP_DELEGATION_EMBEDDED) - .setClusterName("backupDelegationEmbedded") - .setNumMasters(2) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED) - // Enable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, true) - // For faster backup role handshake. - .addProperty(PropertyKey.MASTER_BACKUP_CONNECT_INTERVAL_MIN, "100ms") - .addProperty(PropertyKey.MASTER_BACKUP_CONNECT_INTERVAL_MAX, "100ms"); - backupDelegationTest(clusterBuilder); - } - - /** - * Used to wait until successful backup. - * - * It tolerates {@link FailedPreconditionException} that could be thrown when backup-workers have - * not established connection with the backup-leader yet. - * - * @param backupRequest the backup request - * @return backup uri - */ - private AlluxioURI waitForBackup(BackupPRequest backupRequest) throws Exception { - AtomicReference backupUriRef = new AtomicReference<>(null); - CommonUtils.waitFor("Backup delegation to succeed.", () -> { - try { - backupUriRef.set(mCluster.getMetaMasterClient().backup(backupRequest).getBackupUri()); - return true; - } catch (FailedPreconditionException e1) { - // Expected to fail with this until backup-workers connect with backup-leader. - return false; - } catch (Exception e2) { - throw new RuntimeException( - String.format("Backup failed with unexpected error: %s", e2)); - } - }, WaitForOptions.defaults()); - return backupUriRef.get(); - } - - private void backupRestoreTest(boolean testFailover) throws Exception { - File backups = AlluxioTestDirectory.createTemporaryDirectory("backups"); - mCluster.start(); - List opThreads = new ArrayList<>(); - // Run background threads to perform metadata operations while the journal backups and restores - // are happening. - for (int i = 0; i < 10; i++) { - AlluxioOperationThread thread = new AlluxioOperationThread(mCluster.getFileSystemClient()); - thread.start(); - opThreads.add(thread); - } - try { - FileSystem fs = mCluster.getFileSystemClient(); - MetaMasterClient metaClient = getMetaClient(mCluster); - - AlluxioURI dir1 = new AlluxioURI("/dir1"); - fs.createDirectory(dir1, - CreateDirectoryPOptions.newBuilder().build()); - AlluxioURI backup1 = metaClient - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()) - .getBackupUri(); - AlluxioURI dir2 = new AlluxioURI("/dir2"); - fs.createDirectory(dir2, - CreateDirectoryPOptions.newBuilder().build()); - AlluxioURI backup2 = metaClient - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()) - .getBackupUri(); - - restartMastersFromBackup(backup2); - assertTrue(fs.exists(dir1)); - assertTrue(fs.exists(dir2)); - - restartMastersFromBackup(backup1); - assertTrue(fs.exists(dir1)); - assertFalse(fs.exists(dir2)); - - // Restart normally and make sure we remember the state from backup 1. - mCluster.stopMasters(); - mCluster.startMasters(); - assertTrue(fs.exists(dir1)); - assertFalse(fs.exists(dir2)); - - if (testFailover) { - // Verify that failover works correctly. - mCluster.waitForAndKillPrimaryMaster(30 * Constants.SECOND_MS); - assertTrue(fs.exists(dir1)); - assertFalse(fs.exists(dir2)); - } - - mCluster.notifySuccess(); - } finally { - opThreads.forEach(Thread::interrupt); - } - } - - private void backupDelegationTest(MultiProcessCluster.Builder clusterBuilder) throws Exception { - // Update configuration for each master to backup to a specific folder. - Map> masterProps = new HashMap<>(); - File backupsParent0 = AlluxioTestDirectory.createTemporaryDirectory("backups0"); - File backupsParent1 = AlluxioTestDirectory.createTemporaryDirectory("backups1"); - Map master0Props = new HashMap<>(); - master0Props.put(PropertyKey.MASTER_BACKUP_DIRECTORY, backupsParent0.getAbsolutePath()); - Map master1Props = new HashMap<>(); - master1Props.put(PropertyKey.MASTER_BACKUP_DIRECTORY, backupsParent1.getAbsolutePath()); - masterProps.put(0, master0Props); - masterProps.put(1, master1Props); - clusterBuilder.setMasterProperties(masterProps); - // Start cluster. - mCluster = clusterBuilder.build(); - mCluster.start(); - - // Delegation test can work with 2 masters only. - assertEquals(2, mCluster.getMasterAddresses().size()); - - FileSystem fs = mCluster.getFileSystemClient(); - - AlluxioURI dir1 = new AlluxioURI("/dir1"); - mCluster.getFileSystemClient().createDirectory(dir1, - CreateDirectoryPOptions.newBuilder().build()); - - AlluxioURI backupUri = waitForBackup(BackupPRequest.newBuilder() - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(true)).build()); - - int primaryIndex = mCluster.getPrimaryMasterIndex(GET_PRIMARY_INDEX_TIMEOUT_MS); - int followerIndex = (primaryIndex + 1) % 2; - - // Validate backup is taken on follower's local path. - assertTrue(backupUri.toString() - .contains(masterProps.get(followerIndex).get(PropertyKey.MASTER_BACKUP_DIRECTORY))); - - // Validate backup is valid. - restartMastersFromBackup(backupUri); - assertTrue(fs.exists(dir1)); - - mCluster.notifySuccess(); - } - - private void backupRestoreMetaStoreTest() throws Exception { - // Directory for backups. - File backups = AlluxioTestDirectory.createTemporaryDirectory("backups"); - mCluster.start(); - - // Needs workers to be up before the test. - mCluster.waitForAllNodesRegistered(WAIT_NODES_REGISTERED_MS); - - // Acquire clients. - FileSystem fs = mCluster.getFileSystemClient(); - MetaMasterClient metaClient = getMetaClient(mCluster); - BlockMasterClient blockClient = getBlockClient(mCluster); - - // Create single test file. - String testFilePath = "/file"; - AlluxioURI testFileUri = new AlluxioURI(testFilePath); - - // Create file THROUGH. - FileSystemTestUtils.createByteFile(fs, testFilePath, 100, - CreateFilePOptions.newBuilder().setWriteType(WritePType.THROUGH).build()); - // Delete it from Alluxio namespace. - fs.delete(testFileUri, DeletePOptions.newBuilder().setAlluxioOnly(true).build()); - // List status on root to bring the file's meta back. - fs.listStatus(new AlluxioURI("/"), ListStatusPOptions.newBuilder().setRecursive(true) - .setLoadMetadataType(LoadMetadataPType.ONCE).build()); - // Verify that file's meta is in Alluxio. - assertNotNull(fs.getStatus(testFileUri)); - - // Take a backup. - AlluxioURI backup1 = metaClient - .backup(BackupPRequest.newBuilder().setTargetDirectory(backups.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()) - .getBackupUri(); - // Restart with backup. - restartMastersFromBackup(backup1); - - // Verify that file and its blocks are in Alluxio after restore. - URIStatus fileStatus = fs.getStatus(testFileUri); - assertNotNull(fileStatus); - for (long blockId : fileStatus.getBlockIds()) { - assertNotNull(blockClient.getBlockInfo(blockId)); - } - } - - private void restartMastersFromBackup(AlluxioURI backup) throws IOException { - mCluster.stopMasters(); - mCluster.formatJournal(); - mCluster.updateMasterConf(PropertyKey.MASTER_JOURNAL_INIT_FROM_BACKUP, backup.toString()); - mCluster.startMasters(); - mCluster.updateMasterConf(PropertyKey.MASTER_JOURNAL_INIT_FROM_BACKUP, null); - } - - private MetaMasterClient getMetaClient(MultiProcessCluster cluster) { - return new RetryHandlingMetaMasterClient( - MasterClientContext.newBuilder(ClientContext.create(Configuration.global())) - .setMasterInquireClient(cluster.getMasterInquireClient()) - .build()); - } - - private BlockMasterClient getBlockClient(MultiProcessCluster cluster) { - return new RetryHandlingBlockMasterClient( - MasterClientContext.newBuilder(ClientContext.create(Configuration.global())) - .setMasterInquireClient(cluster.getMasterInquireClient()).build()); - } -} diff --git a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/JournalMigrationIntegrationTest.java b/dora/tests/integration/src/test/java/alluxio/server/ft/journal/JournalMigrationIntegrationTest.java deleted file mode 100644 index 8a1097565271..000000000000 --- a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/JournalMigrationIntegrationTest.java +++ /dev/null @@ -1,90 +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; - -import static org.junit.Assert.assertEquals; - -import alluxio.AlluxioTestDirectory; -import alluxio.AlluxioURI; -import alluxio.ClientContext; -import alluxio.client.file.FileSystem; -import alluxio.client.meta.MetaMasterClient; -import alluxio.client.meta.RetryHandlingMetaMasterClient; -import alluxio.conf.Configuration; -import alluxio.conf.PropertyKey; -import alluxio.grpc.BackupPOptions; -import alluxio.grpc.BackupPRequest; -import alluxio.master.MasterClientContext; -import alluxio.master.journal.JournalType; -import alluxio.multi.process.MultiProcessCluster; -import alluxio.multi.process.MultiProcessCluster.DeployMode; -import alluxio.multi.process.PortCoordination; -import alluxio.testutils.BaseIntegrationTest; - -import org.junit.Test; - -import java.io.File; - -/** - * Integration test for migrating between UFS and embedded journals. - */ -public final class JournalMigrationIntegrationTest extends BaseIntegrationTest { - private static final int NUM_DIRS = 10; - - @Test - public void migration() throws Exception { - MultiProcessCluster cluster = MultiProcessCluster.newBuilder(PortCoordination.JOURNAL_MIGRATION) - .setClusterName("journalMigration") - .setNumMasters(3) - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - // Masters become primary faster - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "1sec") - // Disable backup delegation - .addProperty(PropertyKey.MASTER_BACKUP_DELEGATION_ENABLED, false) - .build(); - try { - cluster.start(); - FileSystem fs = cluster.getFileSystemClient(); - MetaMasterClient metaClient = new RetryHandlingMetaMasterClient( - MasterClientContext.newBuilder(ClientContext.create(Configuration.global())) - .setMasterInquireClient(cluster.getMasterInquireClient()) - .build()); - for (int i = 0; i < NUM_DIRS; i++) { - fs.createDirectory(new AlluxioURI("/dir" + i)); - } - File backupsDir = AlluxioTestDirectory.createTemporaryDirectory("backups"); - AlluxioURI zkBackup = metaClient - .backup(BackupPRequest.newBuilder().setTargetDirectory(backupsDir.getAbsolutePath()) - .setOptions(BackupPOptions.newBuilder().setLocalFileSystem(false)).build()) - .getBackupUri(); - cluster.updateMasterConf(PropertyKey.MASTER_JOURNAL_INIT_FROM_BACKUP, zkBackup.toString()); - - // Migrate to embedded journal HA. - cluster.stopMasters(); - cluster.formatJournal(); - cluster.updateDeployMode(DeployMode.EMBEDDED); - cluster.startMasters(); - assertEquals(NUM_DIRS, fs.listStatus(new AlluxioURI("/")).size()); - - // Migrate back to Zookeeper HA. - cluster.stopMasters(); - cluster.formatJournal(); - cluster.updateDeployMode(DeployMode.ZOOKEEPER_HA); - cluster.startMasters(); - assertEquals(NUM_DIRS, fs.listStatus(new AlluxioURI("/")).size()); - - cluster.notifySuccess(); - } finally { - cluster.destroy(); - } - } -} diff --git a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/JournalShutdownIntegrationTest.java b/dora/tests/integration/src/test/java/alluxio/server/ft/journal/JournalShutdownIntegrationTest.java deleted file mode 100644 index 3edc56d8d624..000000000000 --- a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/JournalShutdownIntegrationTest.java +++ /dev/null @@ -1,333 +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; - -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.spy; - -import alluxio.AlluxioURI; -import alluxio.AuthenticatedUserRule; -import alluxio.ConfigurationRule; -import alluxio.Constants; -import alluxio.SystemPropertyRule; -import alluxio.client.WriteType; -import alluxio.client.file.FileSystem; -import alluxio.client.file.FileSystemContext; -import alluxio.conf.Configuration; -import alluxio.conf.PropertyKey; -import alluxio.master.LocalAlluxioCluster; -import alluxio.master.MultiMasterLocalAlluxioCluster; -import alluxio.multi.process.MultiProcessCluster; -import alluxio.multi.process.PortCoordination; -import alluxio.testutils.BaseIntegrationTest; -import alluxio.testutils.IntegrationTestUtils; -import alluxio.testutils.master.FsMasterResource; -import alluxio.testutils.master.MasterTestUtils; -import alluxio.testutils.underfs.sleeping.SleepingUnderFileSystem; -import alluxio.testutils.underfs.sleeping.SleepingUnderFileSystemFactory; -import alluxio.testutils.underfs.sleeping.SleepingUnderFileSystemOptions; -import alluxio.underfs.UnderFileSystemConfiguration; -import alluxio.underfs.UnderFileSystemFactory; -import alluxio.underfs.UnderFileSystemFactoryRegistry; -import alluxio.util.CommonUtils; - -import com.google.common.collect.ImmutableMap; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; - -import java.io.IOException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -/** - * Test master journal for cluster terminating. Assert that test can replay the log and reproduce - * the correct state. Test both the single master and multi masters. - */ -@Ignore -public class JournalShutdownIntegrationTest extends BaseIntegrationTest { - @ClassRule - public static SystemPropertyRule sDisableHdfsCacheRule = - new SystemPropertyRule("fs.hdfs.impl.disable.cache", "true"); - - @Rule - public AuthenticatedUserRule mAuthenticatedUser = new AuthenticatedUserRule("test", - Configuration.global()); - - @Rule - private TestName mTestName = new TestName(); - - @Rule - public ConfigurationRule mConfigRule = - new ConfigurationRule(new ImmutableMap.Builder() - .put(PropertyKey.MASTER_JOURNAL_TAILER_SHUTDOWN_QUIET_WAIT_TIME_MS, "100") - .put(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, 2) - .put(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, 128) - .put(PropertyKey.USER_RPC_RETRY_MAX_SLEEP_MS, "1sec").build(), - Configuration.modifiableGlobal()); - - private static final long SHUTDOWN_TIME_MS = 15 * Constants.SECOND_MS; - private static final String TEST_FILE_DIR = "/files/"; - private static final int TEST_NUM_MASTERS = 3; - private static final long TEST_TIME_MS = Constants.SECOND_MS; - - private ClientThread mCreateFileThread; - /** Executor for running client threads. */ - private ExecutorService mExecutorsForClient; - private FileSystemContext mFsContext; - - @Before - public final void before() throws Exception { - mExecutorsForClient = Executors.newFixedThreadPool(1); - mFsContext = FileSystemContext.create(Configuration.global()); - } - - @After - public final void after() throws Exception { - mExecutorsForClient.shutdown(); - mFsContext.close(); - Configuration.reloadProperties(); - Configuration.set(PropertyKey.USER_METRICS_COLLECTION_ENABLED, false); - } - - @Test - public void singleMasterJournalStopIntegration() throws Exception { - MultiProcessCluster cluster = - MultiProcessCluster.newBuilder(PortCoordination.JOURNAL_STOP_SINGLE_MASTER) - .setClusterName("singleMasterJournalStopIntegration") - .setNumWorkers(0) - .setNumMasters(1) - .build(); - try { - cluster.start(); - FileSystem fs = cluster.getFileSystemClient(); - runCreateFileThread(fs); - cluster.waitForAndKillPrimaryMaster(10 * Constants.SECOND_MS); - awaitClientTermination(); - cluster.startMaster(0); - int actualFiles = fs.listStatus(new AlluxioURI(TEST_FILE_DIR)).size(); - int successFiles = mCreateFileThread.getSuccessNum(); - assertTrue( - String.format("successFiles: %s, actualFiles: %s", successFiles, actualFiles), - (successFiles == actualFiles) || (successFiles + 1 == actualFiles)); - cluster.notifySuccess(); - } finally { - cluster.destroy(); - } - } - - /* - * We use the external cluster for this test due to flakiness issues when running in a single JVM. - */ - @Test - public void multiMasterJournalStopIntegration() throws Exception { - MultiProcessCluster cluster = - MultiProcessCluster.newBuilder(PortCoordination.JOURNAL_STOP_MULTI_MASTER) - .setClusterName("multiMasterJournalStopIntegration") - .setNumWorkers(0) - .setNumMasters(TEST_NUM_MASTERS) - // Cannot go lower than 2x the tick time. Curator testing cluster tick time is 3s and - // cannot be overridden until later versions of Curator. - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "6s") - .build(); - try { - cluster.start(); - FileSystem fs = cluster.getFileSystemClient(); - runCreateFileThread(fs); - for (int i = 0; i < TEST_NUM_MASTERS; i++) { - cluster.waitForAndKillPrimaryMaster(30 * Constants.SECOND_MS); - } - awaitClientTermination(); - cluster.startMaster(0); - int actualFiles = fs.listStatus(new AlluxioURI(TEST_FILE_DIR)).size(); - int successFiles = mCreateFileThread.getSuccessNum(); - assertTrue( - String.format("successFiles: %s, actualFiles: %s", successFiles, actualFiles), - (successFiles == actualFiles) || (successFiles + 1 == actualFiles)); - cluster.notifySuccess(); - } finally { - cluster.destroy(); - } - } - - @Test - public void singleMasterMountUnmountJournal() throws Exception { - LocalAlluxioCluster cluster = setupSingleMasterCluster(); - UnderFileSystemFactory factory = mountUnmount(cluster.getClient()); - // Shutdown the cluster - cluster.stopFS(); - CommonUtils.sleepMs(TEST_TIME_MS); - awaitClientTermination(); - // Fail the creation of UFS - doThrow(new RuntimeException()).when(factory).create(anyString(), - any(UnderFileSystemConfiguration.class)); - createFsMasterFromJournal().close(); - } - - @Test - public void multiMasterMountUnmountJournal() throws Exception { - MultiMasterLocalAlluxioCluster cluster = null; - UnderFileSystemFactory factory = null; - try { - cluster = new MultiMasterLocalAlluxioCluster(TEST_NUM_MASTERS); - cluster.initConfiguration( - IntegrationTestUtils.getTestName(getClass().getSimpleName(), mTestName.getMethodName())); - cluster.start(); - cluster.stopLeader(); - factory = mountUnmount(cluster.getClient()); - // Kill the leader one by one. - for (int kills = 0; kills < TEST_NUM_MASTERS; kills++) { - cluster.waitForNewMaster(120 * Constants.SECOND_MS); - assertTrue(cluster.stopLeader()); - } - } finally { - // Shutdown the cluster - if (cluster != null) { - cluster.stopFS(); - } - } - CommonUtils.sleepMs(TEST_TIME_MS); - awaitClientTermination(); - // Fail the creation of UFS - doThrow(new RuntimeException()).when(factory).create(anyString(), - any(UnderFileSystemConfiguration.class)); - createFsMasterFromJournal().close(); - } - - /** - * @param fs Filesystem client - * @return a spied UFS factory mounted to and then unmounted from fs - */ - private UnderFileSystemFactory mountUnmount(FileSystem fs) throws Exception { - SleepingUnderFileSystem sleepingUfs = new SleepingUnderFileSystem(new AlluxioURI("sleep:///"), - new SleepingUnderFileSystemOptions(), - UnderFileSystemConfiguration.defaults(Configuration.global())); - SleepingUnderFileSystemFactory sleepingUfsFactory = - new SleepingUnderFileSystemFactory(sleepingUfs); - UnderFileSystemFactoryRegistry.register(sleepingUfsFactory); - fs.mount(new AlluxioURI("/mnt"), new AlluxioURI("sleep:///")); - fs.unmount(new AlluxioURI("/mnt")); - return spy(sleepingUfsFactory); - } - - /** - * Waits for the client to terminate. - */ - private void awaitClientTermination() throws Exception { - // Ensure the client threads are stopped. - mExecutorsForClient.shutdownNow(); - if (!mExecutorsForClient.awaitTermination(SHUTDOWN_TIME_MS, TimeUnit.MILLISECONDS)) { - throw new Exception("Client thread did not terminate"); - } - } - - /** - * Creates file system master from journal. - */ - private FsMasterResource createFsMasterFromJournal() throws Exception { - return MasterTestUtils.createLeaderFileSystemMasterFromJournal(); - } - - /** - * Sets up and starts a single master cluster. - */ - private LocalAlluxioCluster setupSingleMasterCluster() throws Exception { - // Setup and start the local alluxio cluster. - LocalAlluxioCluster cluster = new LocalAlluxioCluster(); - cluster.initConfiguration( - IntegrationTestUtils.getTestName(getClass().getSimpleName(), mTestName.getMethodName())); - Configuration.set(PropertyKey.USER_FILE_WRITE_TYPE_DEFAULT, WriteType.CACHE_THROUGH); - cluster.start(); - return cluster; - } - - /** - * Starts a file-creating thread and runs it for some time, at least until it has created one - * file. - * - * @param fs a file system client to use for creating files - */ - private void runCreateFileThread(FileSystem fs) { - mCreateFileThread = new ClientThread(0, fs); - mExecutorsForClient.submit(mCreateFileThread); - CommonUtils.sleepMs(TEST_TIME_MS); - while (mCreateFileThread.getSuccessNum() == 0) { - CommonUtils.sleepMs(TEST_TIME_MS); - } - } - - /** - * Hold a client and keep creating files. - */ - class ClientThread implements Runnable { - /** The number of successfully created files. */ - private int mSuccessNum = 0; - - private final int mOpType; // 0: create file - private final FileSystem mFileSystem; - - /** - * Constructs the client thread. - * - * @param opType the create operation type - * @param fs a file system client to use for creating files - */ - public ClientThread(int opType, FileSystem fs) { - mOpType = opType; - mFileSystem = fs; - } - - /** - * Gets the number of files which are successfully created. - * - * @return the number of files successfully created - */ - public int getSuccessNum() { - return mSuccessNum; - } - - /** - * Keep creating files until something crashes or fail to create. Record how many files are - * created successfully. - */ - @Override - public void run() { - try { - // This infinity loop will be broken if something crashes or fail to create. This is - // expected since the master will shutdown at a certain time. - while (!Thread.interrupted()) { - if (mOpType == 0) { - try { - mFileSystem.createFile(new AlluxioURI(TEST_FILE_DIR + mSuccessNum)).close(); - } catch (IOException e) { - break; - } - } - // The create operation may succeed at the master side but still returns false due to the - // shutdown. So the mSuccessNum may be less than the actual success number. - mSuccessNum++; - CommonUtils.sleepMs(100); - } - } catch (Exception e) { - // Something crashed. Stop the thread. - } - } - } -} diff --git a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/MultiMasterJournalTest.java b/dora/tests/integration/src/test/java/alluxio/server/ft/journal/MultiMasterJournalTest.java deleted file mode 100644 index 03893e93c53d..000000000000 --- a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/MultiMasterJournalTest.java +++ /dev/null @@ -1,102 +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; - -import static org.junit.Assert.assertEquals; - -import alluxio.AlluxioURI; -import alluxio.Constants; -import alluxio.client.file.FileSystem; -import alluxio.conf.Configuration; -import alluxio.conf.PropertyKey; -import alluxio.grpc.FileSystemMasterCommonPOptions; -import alluxio.grpc.SetAttributePOptions; -import alluxio.grpc.TtlAction; -import alluxio.master.MultiMasterLocalAlluxioCluster; -import alluxio.master.file.meta.TtlIntervalRule; -import alluxio.testutils.BaseIntegrationTest; -import alluxio.testutils.IntegrationTestUtils; -import alluxio.util.CommonUtils; -import alluxio.util.WaitForOptions; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TestName; - -public class MultiMasterJournalTest extends BaseIntegrationTest { - private MultiMasterLocalAlluxioCluster mCluster; - - @Rule - public TtlIntervalRule mTtlRule = new TtlIntervalRule(200); - - @Rule - public TestName mTestName = new TestName(); - - @Before - public void before() throws Exception { - mCluster = new MultiMasterLocalAlluxioCluster(2, 0); - mCluster.initConfiguration( - IntegrationTestUtils.getTestName(getClass().getSimpleName(), mTestName.getMethodName())); - Configuration.set(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, 5); - Configuration.set(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, 100); - mCluster.start(); - } - - @After - public void after() throws Exception { - mCluster.stop(); - } - - @Deprecated - public void testCheckpointReplay() throws Exception { - // TODO(JiamingMai): AlluxioFileOutStream is deprecated. - // We need to implement it with DoraFileOutStream. - triggerAndWaitForCheckpoint(); - mCluster.restartMasters(); - assertEquals("The cluster should remember the 10 files", 10, - mCluster.getClient().listStatus(new AlluxioURI("/")).size()); - } - - @Deprecated - public void testTtl() throws Exception { - // TODO(JiamingMai): AlluxioFileOutStream is deprecated. - // We need to implement it with DoraFileOutStream. - // Test that ttls are still applied after restart. - AlluxioURI file = new AlluxioURI("/file"); - mCluster.getClient().createFile(file).close(); - int ttl = 5 * Constants.SECOND_MS; - mCluster.getClient().setAttribute(file, SetAttributePOptions.newBuilder() - .setCommonOptions(FileSystemMasterCommonPOptions.newBuilder() - .setTtl(ttl) - .setTtlAction(TtlAction.DELETE)) - .build()); - triggerAndWaitForCheckpoint(); - mCluster.restartMasters(); - FileSystem client = mCluster.getClient(); - CommonUtils.waitFor("file to be deleted", () -> { - try { - return !client.exists(file); - } catch (Exception e) { - throw new RuntimeException(e); - } - }, WaitForOptions.defaults().setTimeoutMs(30 * Constants.SECOND_MS)); - } - - private void triggerAndWaitForCheckpoint() throws Exception { - FileSystem client = mCluster.getClient(); - for (int i = 0; i < 10; i++) { - client.createFile(new AlluxioURI("/triggerCheckpoint" + i)).close(); - } - IntegrationTestUtils.waitForUfsJournalCheckpoint(Constants.FILE_SYSTEM_MASTER_NAME); - } -} diff --git a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/MultiProcessCheckpointTest.java b/dora/tests/integration/src/test/java/alluxio/server/ft/journal/MultiProcessCheckpointTest.java deleted file mode 100644 index a6eddbb71990..000000000000 --- a/dora/tests/integration/src/test/java/alluxio/server/ft/journal/MultiProcessCheckpointTest.java +++ /dev/null @@ -1,93 +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; - -import static org.junit.Assert.assertEquals; - -import alluxio.AlluxioURI; -import alluxio.Constants; -import alluxio.client.file.FileSystem; -import alluxio.client.metrics.MetricsMasterClient; -import alluxio.conf.PropertyKey; -import alluxio.master.journal.JournalType; -import alluxio.metrics.MetricKey; -import alluxio.multi.process.MultiProcessCluster; -import alluxio.multi.process.PortCoordination; -import alluxio.testutils.IntegrationTestUtils; - -import org.junit.Ignore; -import org.junit.Test; - -import java.net.URI; - -@Ignore("In Dora, Client does not use Master/Journal services.") -public class MultiProcessCheckpointTest { - - @Test - public void testDefault() throws Exception { - runTest(-1, false); - } - - @Test - public void testNoCompression() throws Exception { - runTest(0, false); - } - - @Test - public void testParallelCompression() throws Exception { - runTest(-1, true); - } - - void runTest(int compressionLevel, boolean parallelCompression) throws Exception { - MultiProcessCluster cluster = MultiProcessCluster.newBuilder(PortCoordination.CHECKPOINT) - .setClusterName("CheckpointTest") - .addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.UFS) - .addProperty(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT, "2sec") - .addProperty(PropertyKey.ZOOKEEPER_CONNECTION_TIMEOUT, "1sec") - .addProperty(PropertyKey.MASTER_METASTORE, "ROCKS") - .addProperty(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES, 100) - .addProperty(PropertyKey.MASTER_JOURNAL_LOG_SIZE_BYTES_MAX, "500") - .addProperty(PropertyKey.MASTER_JOURNAL_TAILER_SHUTDOWN_QUIET_WAIT_TIME_MS, "500") - .addProperty(PropertyKey.MASTER_EMBEDDED_JOURNAL_SNAPSHOT_REPLICATION_COMPRESSION_LEVEL, - compressionLevel) - .addProperty(PropertyKey.MASTER_METASTORE_ROCKS_PARALLEL_BACKUP, - parallelCompression) - .setNumMasters(2) - .setNumWorkers(0) - .build(); - try { - cluster.start(); - cluster.waitForAllNodesRegistered(20 * Constants.SECOND_MS); - String journal = cluster.getJournalDir(); - FileSystem fs = cluster.getFileSystemClient(); - int numFiles = 100; - for (int i = 0; i < numFiles; i++) { - fs.createFile(new AlluxioURI("/file" + i)).close(); - } - MetricsMasterClient metricsClient = cluster.getMetricsMasterClient(); - assertEquals(numFiles + 1, (long) metricsClient.getMetrics() - .get(MetricKey.MASTER_TOTAL_PATHS.getName()).getDoubleValue()); - IntegrationTestUtils.waitForUfsJournalCheckpoint(Constants.FILE_SYSTEM_MASTER_NAME, - new URI(journal)); - cluster.stopMasters(); - cluster.startMasters(); - cluster.waitForAllNodesRegistered(60 * Constants.SECOND_MS); - fs = cluster.getFileSystemClient(); - assertEquals(numFiles, fs.listStatus(new AlluxioURI("/")).size()); - assertEquals(numFiles + 1, (long) metricsClient.getMetrics() - .get(MetricKey.MASTER_TOTAL_PATHS.getName()).getDoubleValue()); - cluster.notifySuccess(); - } finally { - cluster.destroy(); - } - } -}