Search in sources :

Example 46 with PropertyKey

use of alluxio.conf.PropertyKey in project alluxio by Alluxio.

the class AddCommand method run.

@Override
public int run(CommandLine cl) throws IOException {
    AlluxioURI path = new AlluxioURI(cl.getArgs()[0]);
    Map<PropertyKey, String> propertyMap = new HashMap<>();
    if (cl.hasOption(PROPERTY_OPTION_NAME)) {
        Map<String, String> properties = Maps.fromProperties(cl.getOptionProperties(PROPERTY_OPTION_NAME));
        for (Map.Entry<String, String> property : properties.entrySet()) {
            PropertyKey key = PropertyKey.fromString(property.getKey());
            if (!GrpcUtils.contains(key.getScope(), Scope.CLIENT)) {
                throw new InvalidArgumentException(nonClientScopePropertyException(key));
            }
            propertyMap.put(key, property.getValue());
        }
    }
    mMetaConfigClient.setPathConfiguration(path, propertyMap);
    return 0;
}
Also used : InvalidArgumentException(alluxio.exception.status.InvalidArgumentException) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI)

Example 47 with PropertyKey

use of alluxio.conf.PropertyKey in project alluxio by Alluxio.

the class RemoveCommand method run.

@Override
public int run(CommandLine cl) throws IOException {
    AlluxioURI path = new AlluxioURI(cl.getArgs()[0]);
    if (cl.hasOption(KEYS_OPTION_NAME)) {
        String[] keys = cl.getOptionValue(KEYS_OPTION_NAME).split(",");
        Set<PropertyKey> propertyKeys = new HashSet<>();
        for (String key : keys) {
            propertyKeys.add(PropertyKey.fromString(key));
        }
        mMetaConfigClient.removePathConfiguration(path, propertyKeys);
    } else {
        mMetaConfigClient.removePathConfiguration(path);
    }
    return 0;
}
Also used : PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI) HashSet(java.util.HashSet)

Example 48 with PropertyKey

use of alluxio.conf.PropertyKey in project alluxio by Alluxio.

the class ConfigCheckerIntegrationTest method multiMastersEmbeddedHA.

@Test
public void multiMastersEmbeddedHA() throws Exception {
    PropertyKey key = PropertyKey.MASTER_JOURNAL_FLUSH_TIMEOUT_MS;
    Map<Integer, Map<PropertyKey, String>> masterProperties = generatePropertyWithDifferentValues(TEST_NUM_MASTERS, key);
    mCluster = MultiProcessCluster.newBuilder(PortCoordination.CONFIG_CHECKER_MULTI_MASTERS_EMBEDDED_HA).setClusterName("ConfigCheckerMultiMastersEmbeddedHATest").setNumMasters(TEST_NUM_MASTERS).setNumWorkers(0).addProperty(PropertyKey.MASTER_JOURNAL_TYPE, JournalType.EMBEDDED.toString()).setMasterProperties(masterProperties).build();
    mCluster.start();
    ConfigCheckReport report = getReport();
    // The master values of {@link PropertyKey#ALLUXIO_MASTER_JOURNAL_FOLDER} are different
    // when using embedded HA
    assertEquals(ConfigStatus.FAILED, report.getConfigStatus());
    assertThat(report.getConfigWarns().toString(), CoreMatchers.containsString(key.getName()));
    mCluster.notifySuccess();
}
Also used : ConfigCheckReport(alluxio.wire.ConfigCheckReport) HashMap(java.util.HashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) PropertyKey(alluxio.conf.PropertyKey) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Example 49 with PropertyKey

use of alluxio.conf.PropertyKey in project alluxio by Alluxio.

the class JournalBackupIntegrationTest method backupDelegationTest.

private void backupDelegationTest(MultiProcessCluster.Builder clusterBuilder) throws Exception {
    // Update configuration for each master to backup to a specific folder.
    Map<Integer, Map<PropertyKey, String>> masterProps = new HashMap<>();
    File backupsParent0 = AlluxioTestDirectory.createTemporaryDirectory("backups0");
    File backupsParent1 = AlluxioTestDirectory.createTemporaryDirectory("backups1");
    Map<PropertyKey, String> master0Props = new HashMap<>();
    master0Props.put(PropertyKey.MASTER_BACKUP_DIRECTORY, backupsParent0.getAbsolutePath());
    Map<PropertyKey, String> 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().setWriteType(WritePType.MUST_CACHE).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();
}
Also used : HashMap(java.util.HashMap) FileSystem(alluxio.client.file.FileSystem) Map(java.util.Map) HashMap(java.util.HashMap) File(java.io.File) PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI)

Aggregations

PropertyKey (alluxio.conf.PropertyKey)49 HashMap (java.util.HashMap)28 Test (org.junit.Test)16 Map (java.util.Map)15 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)10 AlluxioURI (alluxio.AlluxioURI)7 ConfigCheckReport (alluxio.wire.ConfigCheckReport)6 File (java.io.File)6 List (java.util.List)6 ConfigurationRule (alluxio.ConfigurationRule)5 Scope (alluxio.grpc.Scope)5 UnderFileSystemConfiguration (alluxio.underfs.UnderFileSystemConfiguration)5 Address (alluxio.wire.Address)5 ConfigProperty (alluxio.grpc.ConfigProperty)4 Closeable (java.io.Closeable)4 Optional (java.util.Optional)4 Constants (alluxio.Constants)3 AlluxioProperties (alluxio.conf.AlluxioProperties)3 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)3