Search in sources :

Example 36 with PropertyKey

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

the class S3AUnderFileSystemTest method getPermissionsWithMapping.

@Test
public void getPermissionsWithMapping() throws Exception {
    Map<PropertyKey, Object> conf = new HashMap<>();
    conf.put(PropertyKey.UNDERFS_S3_OWNER_ID_TO_USERNAME_MAPPING, "111=altname");
    try (Closeable c = new ConfigurationRule(conf, sConf).toResource()) {
        UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(sConf);
        mS3UnderFileSystem = new S3AUnderFileSystem(new AlluxioURI("s3a://" + BUCKET_NAME), mClient, BUCKET_NAME, mExecutor, mManager, UnderFileSystemConfiguration.defaults(sConf), false);
    }
    Mockito.when(mClient.getS3AccountOwner()).thenReturn(new Owner("111", "test"));
    Mockito.when(mClient.getBucketAcl(Mockito.anyString())).thenReturn(new AccessControlList());
    ObjectUnderFileSystem.ObjectPermissions permissions = mS3UnderFileSystem.getPermissions();
    Assert.assertEquals("altname", permissions.getOwner());
    Assert.assertEquals("altname", permissions.getGroup());
    Assert.assertEquals(0, permissions.getMode());
}
Also used : AccessControlList(com.amazonaws.services.s3.model.AccessControlList) Owner(com.amazonaws.services.s3.model.Owner) HashMap(java.util.HashMap) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Closeable(java.io.Closeable) ObjectUnderFileSystem(alluxio.underfs.ObjectUnderFileSystem) ConfigurationRule(alluxio.ConfigurationRule) PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 37 with PropertyKey

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

the class S3AUnderFileSystemTest method getPermissionsNoMapping.

@Test
public void getPermissionsNoMapping() throws Exception {
    Map<PropertyKey, Object> conf = new HashMap<>();
    conf.put(PropertyKey.UNDERFS_S3_OWNER_ID_TO_USERNAME_MAPPING, "111=userid");
    try (Closeable c = new ConfigurationRule(conf, sConf).toResource()) {
        UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(sConf);
        mS3UnderFileSystem = new S3AUnderFileSystem(new AlluxioURI("s3a://" + BUCKET_NAME), mClient, BUCKET_NAME, mExecutor, mManager, UnderFileSystemConfiguration.defaults(sConf), false);
    }
    Mockito.when(mClient.getS3AccountOwner()).thenReturn(new Owner("0", "test"));
    Mockito.when(mClient.getBucketAcl(Mockito.anyString())).thenReturn(new AccessControlList());
    ObjectUnderFileSystem.ObjectPermissions permissions = mS3UnderFileSystem.getPermissions();
    Assert.assertEquals("test", permissions.getOwner());
    Assert.assertEquals("test", permissions.getGroup());
    Assert.assertEquals(0, permissions.getMode());
}
Also used : AccessControlList(com.amazonaws.services.s3.model.AccessControlList) Owner(com.amazonaws.services.s3.model.Owner) HashMap(java.util.HashMap) UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Closeable(java.io.Closeable) ObjectUnderFileSystem(alluxio.underfs.ObjectUnderFileSystem) ConfigurationRule(alluxio.ConfigurationRule) PropertyKey(alluxio.conf.PropertyKey) AlluxioURI(alluxio.AlluxioURI) Test(org.junit.Test)

Example 38 with PropertyKey

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

the class DefaultMetaMaster method getConfiguration.

@Override
public Configuration getConfiguration(GetConfigurationPOptions options) {
    // NOTE(cc): there is no guarantee that the returned cluster and path configurations are
    // consistent snapshot of the system's state at a certain time, the path configuration might
    // be in a newer state. But it's guaranteed that the hashes are respectively correspondent to
    // the properties.
    Configuration.Builder builder = Configuration.newBuilder();
    if (!options.getIgnoreClusterConf()) {
        for (PropertyKey key : ServerConfiguration.keySet()) {
            if (key.isBuiltIn()) {
                Source source = ServerConfiguration.getSource(key);
                Object value = ServerConfiguration.getOrDefault(key, null, ConfigurationValueOptions.defaults().useDisplayValue(true).useRawValue(options.getRawValue()));
                builder.addClusterProperty(key.getName(), value, source);
            }
        }
        // NOTE(cc): assumes that ServerConfiguration is read-only when master is running, otherwise,
        // the following hash might not correspond to the above cluster configuration.
        builder.setClusterConfHash(ServerConfiguration.hash());
    }
    if (!options.getIgnorePathConf()) {
        PathPropertiesView pathProperties = mPathProperties.snapshot();
        pathProperties.getProperties().forEach((path, properties) -> properties.forEach((key, value) -> builder.addPathProperty(path, key, value)));
        builder.setPathConfHash(pathProperties.getHash());
    }
    return builder.build();
}
Also used : Configuration(alluxio.wire.Configuration) SystemClock(alluxio.clock.SystemClock) CloseableIterator(alluxio.resource.CloseableIterator) LoggerFactory(org.slf4j.LoggerFactory) Server(alluxio.Server) PropertyKey(alluxio.conf.PropertyKey) MetaCommand(alluxio.grpc.MetaCommand) GrpcService(alluxio.grpc.GrpcService) HeartbeatThread(alluxio.heartbeat.HeartbeatThread) Map(java.util.Map) ClientContext(alluxio.ClientContext) IndexDefinition(alluxio.collections.IndexDefinition) BackupPRequest(alluxio.grpc.BackupPRequest) IndexedSet(alluxio.collections.IndexedSet) ImmutableSet(com.google.common.collect.ImmutableSet) ServerConfiguration(alluxio.conf.ServerConfiguration) Set(java.util.Set) AlluxioException(alluxio.exception.AlluxioException) CheckpointName(alluxio.master.journal.checkpoint.CheckpointName) InetSocketAddress(java.net.InetSocketAddress) Executors(java.util.concurrent.Executors) RegisterMasterPOptions(alluxio.grpc.RegisterMasterPOptions) BackupRole(alluxio.master.backup.BackupRole) List(java.util.List) Source(alluxio.conf.Source) ServiceType(alluxio.grpc.ServiceType) CoreMasterContext(alluxio.master.CoreMasterContext) Optional(java.util.Optional) Journal(alluxio.proto.journal.Journal) UfsManager(alluxio.underfs.UfsManager) JournalContext(alluxio.master.journal.JournalContext) UnavailableException(alluxio.exception.status.UnavailableException) GetConfigurationPOptions(alluxio.grpc.GetConfigurationPOptions) HashMap(java.util.HashMap) OSUtils(alluxio.util.OSUtils) NetworkAddressUtils(alluxio.util.network.NetworkAddressUtils) ConfigHash(alluxio.wire.ConfigHash) BlockMaster(alluxio.master.block.BlockMaster) Scope(alluxio.grpc.Scope) JournalType(alluxio.master.journal.JournalType) Constants(alluxio.Constants) Meta(alluxio.proto.journal.Meta) Nullable(javax.annotation.Nullable) ConfigurationValueOptions(alluxio.conf.ConfigurationValueOptions) CoreMaster(alluxio.master.CoreMaster) Logger(org.slf4j.Logger) HeartbeatContext(alluxio.heartbeat.HeartbeatContext) ServerConfigurationStore(alluxio.master.meta.checkconf.ServerConfigurationStore) IdUtils(alluxio.util.IdUtils) ExceptionMessage(alluxio.exception.ExceptionMessage) HeartbeatExecutor(alluxio.heartbeat.HeartbeatExecutor) IOException(java.io.IOException) ThreadFactoryUtils(alluxio.util.ThreadFactoryUtils) NotFoundException(alluxio.exception.status.NotFoundException) LockResource(alluxio.resource.LockResource) ConfigurationUtils(alluxio.util.ConfigurationUtils) ExecutorServiceFactory(alluxio.util.executor.ExecutorServiceFactory) MasterClientContext(alluxio.master.MasterClientContext) BackupLeaderRole(alluxio.master.backup.BackupLeaderRole) BackupStatusPRequest(alluxio.grpc.BackupStatusPRequest) Clock(java.time.Clock) BackupStatus(alluxio.wire.BackupStatus) StateLockOptions(alluxio.master.StateLockOptions) ServerConfigurationChecker(alluxio.master.meta.checkconf.ServerConfigurationChecker) ExecutorServiceFactories(alluxio.util.executor.ExecutorServiceFactories) Collections(java.util.Collections) BackupWorkerRole(alluxio.master.backup.BackupWorkerRole) Address(alluxio.wire.Address) ConfigCheckReport(alluxio.wire.ConfigCheckReport) NotThreadSafe(javax.annotation.concurrent.NotThreadSafe) Configuration(alluxio.wire.Configuration) ServerConfiguration(alluxio.conf.ServerConfiguration) PropertyKey(alluxio.conf.PropertyKey) Source(alluxio.conf.Source)

Example 39 with PropertyKey

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

the class ServerConfigurationChecker method regenerateReport.

/**
 * Checks the server-side configurations and records the check results.
 */
public synchronized void regenerateReport() {
    // Generate the configuration map from master and worker configuration records
    Map<PropertyKey, Map<Optional<String>, List<String>>> confMap = generateConfMap();
    // Update the errors and warnings configuration
    Map<Scope, List<InconsistentProperty>> confErrors = new HashMap<>();
    Map<Scope, List<InconsistentProperty>> confWarns = new HashMap<>();
    for (Map.Entry<PropertyKey, Map<Optional<String>, List<String>>> entry : confMap.entrySet()) {
        if (entry.getValue().size() >= 2) {
            PropertyKey key = entry.getKey();
            InconsistentProperty inconsistentProperty = new InconsistentProperty().setName(key.getName()).setValues(entry.getValue());
            Scope scope = key.getScope().equals(Scope.ALL) ? Scope.SERVER : key.getScope();
            if (entry.getKey().getConsistencyLevel().equals(ConsistencyCheckLevel.ENFORCE)) {
                confErrors.putIfAbsent(scope, new ArrayList<>());
                confErrors.get(scope).add(inconsistentProperty);
            } else {
                confWarns.putIfAbsent(scope, new ArrayList<>());
                confWarns.get(scope).add(inconsistentProperty);
            }
        }
    }
    // Update configuration status
    ConfigStatus status = confErrors.values().stream().anyMatch(a -> a.size() > 0) ? ConfigStatus.FAILED : confWarns.values().stream().anyMatch(a -> a.size() > 0) ? ConfigStatus.WARN : ConfigStatus.PASSED;
    if (!status.equals(mConfigCheckReport.getConfigStatus())) {
        logConfigReport();
    }
    mConfigCheckReport = new ConfigCheckReport(confErrors, confWarns, status);
}
Also used : Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) InconsistentProperty(alluxio.wire.InconsistentProperty) HashMap(java.util.HashMap) PropertyKey(alluxio.conf.PropertyKey) Collectors(java.util.stream.Collectors) Scope(alluxio.grpc.Scope) ArrayList(java.util.ArrayList) ConfigStatus(alluxio.grpc.ConfigStatus) List(java.util.List) Map(java.util.Map) Optional(java.util.Optional) ConsistencyCheckLevel(alluxio.conf.PropertyKey.ConsistencyCheckLevel) Address(alluxio.wire.Address) ConfigCheckReport(alluxio.wire.ConfigCheckReport) HashMap(java.util.HashMap) Scope(alluxio.grpc.Scope) ConfigCheckReport(alluxio.wire.ConfigCheckReport) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) PropertyKey(alluxio.conf.PropertyKey) InconsistentProperty(alluxio.wire.InconsistentProperty) ConfigStatus(alluxio.grpc.ConfigStatus)

Example 40 with PropertyKey

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

the class IntegrationTestUtils method reserveMasterPorts.

/**
 * Reserves ports for each master service and updates the server configuration.
 */
public static void reserveMasterPorts() {
    for (ServiceType service : Arrays.asList(ServiceType.MASTER_RPC, ServiceType.MASTER_WEB, ServiceType.MASTER_RAFT, ServiceType.JOB_MASTER_RPC, ServiceType.JOB_MASTER_WEB, ServiceType.JOB_MASTER_RAFT)) {
        PropertyKey key = service.getPortKey();
        ServerConfiguration.set(key, PortRegistry.reservePort());
    }
}
Also used : ServiceType(alluxio.util.network.NetworkAddressUtils.ServiceType) PropertyKey(alluxio.conf.PropertyKey)

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