Search in sources :

Example 1 with ConfigProperty

use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.

the class ConfigurationUtils method getConfiguration.

/**
 * Gets all configuration properties filtered by the specified scope.
 *
 * @param conf the configuration to use
 * @param scope the scope to filter by
 * @return the properties
 */
public static List<ConfigProperty> getConfiguration(AlluxioConfiguration conf, Scope scope) {
    ConfigurationValueOptions useRawDisplayValue = ConfigurationValueOptions.defaults().useDisplayValue(true);
    List<ConfigProperty> configs = new ArrayList<>();
    List<PropertyKey> selectedKeys = conf.keySet().stream().filter(key -> GrpcUtils.contains(key.getScope(), scope)).filter(key -> key.isValid(key.getName())).collect(toList());
    for (PropertyKey key : selectedKeys) {
        ConfigProperty.Builder configProp = ConfigProperty.newBuilder().setName(key.getName()).setSource(conf.getSource(key).toString());
        if (conf.isSet(key)) {
            configProp.setValue(String.valueOf(conf.get(key, useRawDisplayValue)));
        }
        configs.add(configProp.build());
    }
    return configs;
}
Also used : Arrays(java.util.Arrays) URL(java.net.URL) BiFunction(java.util.function.BiFunction) LoggerFactory(org.slf4j.LoggerFactory) PropertyKey(alluxio.conf.PropertyKey) MetaMasterConfigurationServiceGrpc(alluxio.grpc.MetaMasterConfigurationServiceGrpc) GrpcChannel(alluxio.grpc.GrpcChannel) Map(java.util.Map) Splitter(com.google.common.base.Splitter) ServiceType(alluxio.util.network.NetworkAddressUtils.ServiceType) UnauthenticatedException(alluxio.exception.status.UnauthenticatedException) GrpcServerAddress(alluxio.grpc.GrpcServerAddress) CommandUtils(alluxio.cli.CommandUtils) Set(java.util.Set) ConfigProperty(alluxio.grpc.ConfigProperty) GuardedBy(javax.annotation.concurrent.GuardedBy) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) AlluxioProperties(alluxio.conf.AlluxioProperties) Sets(com.google.common.collect.Sets) FileNotFoundException(java.io.FileNotFoundException) List(java.util.List) Source(alluxio.conf.Source) InstancedConfiguration(alluxio.conf.InstancedConfiguration) RuntimeConstants(alluxio.RuntimeConstants) UnavailableException(alluxio.exception.status.UnavailableException) GetConfigurationPOptions(alluxio.grpc.GetConfigurationPOptions) HashMap(java.util.HashMap) NetworkAddressUtils(alluxio.util.network.NetworkAddressUtils) Scope(alluxio.grpc.Scope) ArrayList(java.util.ArrayList) PathUtils(alluxio.util.io.PathUtils) GetConfigurationPResponse(alluxio.grpc.GetConfigurationPResponse) Lists(com.google.common.collect.Lists) Constants(alluxio.Constants) GrpcUtils(alluxio.grpc.GrpcUtils) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) Nullable(javax.annotation.Nullable) ConfigurationValueOptions(alluxio.conf.ConfigurationValueOptions) Logger(org.slf4j.Logger) Properties(java.util.Properties) PathConfiguration(alluxio.conf.path.PathConfiguration) ExceptionMessage(alluxio.exception.ExceptionMessage) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) Collectors.toList(java.util.stream.Collectors.toList) GrpcChannelBuilder(alluxio.grpc.GrpcChannelBuilder) Preconditions(com.google.common.base.Preconditions) InputStream(java.io.InputStream) ConfigurationValueOptions(alluxio.conf.ConfigurationValueOptions) ConfigProperty(alluxio.grpc.ConfigProperty) ArrayList(java.util.ArrayList) PropertyKey(alluxio.conf.PropertyKey)

Example 2 with ConfigProperty

use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.

the class AlluxioMasterRestServiceHandler method getWebUIConfiguration.

/**
 * Gets Web UI ServerConfiguration page data.
 *
 * @return the response object
 */
@GET
@Path(WEBUI_CONFIG)
public Response getWebUIConfiguration() {
    return RestUtils.call(() -> {
        MasterWebUIConfiguration response = new MasterWebUIConfiguration();
        response.setWhitelist(mFileSystemMaster.getWhiteList());
        TreeSet<Triple<String, String, String>> sortedProperties = new TreeSet<>();
        Set<String> alluxioConfExcludes = Sets.newHashSet(PropertyKey.MASTER_WHITELIST.toString());
        for (ConfigProperty configProperty : mMetaMaster.getConfiguration(GetConfigurationPOptions.newBuilder().setRawValue(true).build()).toProto().getClusterConfigsList()) {
            String confName = configProperty.getName();
            if (!alluxioConfExcludes.contains(confName)) {
                sortedProperties.add(new ImmutableTriple<>(confName, ConfigurationUtils.valueAsString(configProperty.getValue()), configProperty.getSource()));
            }
        }
        response.setConfiguration(sortedProperties);
        return response;
    }, ServerConfiguration.global());
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) TreeSet(java.util.TreeSet) ConfigProperty(alluxio.grpc.ConfigProperty) MasterWebUIConfiguration(alluxio.wire.MasterWebUIConfiguration) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 3 with ConfigProperty

use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.

the class AlluxioWorkerRestServiceHandler method getWebUIConfiguration.

/**
 * Gets Web UI ServerConfiguration page data.
 *
 * @return the response object
 */
@GET
@Path(WEBUI_CONFIG)
public Response getWebUIConfiguration() {
    return RestUtils.call(() -> {
        WorkerWebUIConfiguration response = new WorkerWebUIConfiguration();
        response.setWhitelist(mBlockWorker.getWhiteList());
        TreeSet<Triple<String, String, String>> sortedProperties = new TreeSet<>();
        Set<String> alluxioConfExcludes = Sets.newHashSet(PropertyKey.WORKER_WHITELIST.toString());
        for (ConfigProperty configProperty : mBlockWorker.getConfiguration(GetConfigurationPOptions.newBuilder().setRawValue(true).build()).toProto().getClusterConfigsList()) {
            String confName = configProperty.getName();
            if (!alluxioConfExcludes.contains(confName)) {
                sortedProperties.add(new ImmutableTriple<>(confName, ConfigurationUtils.valueAsString(configProperty.getValue()), configProperty.getSource()));
            }
        }
        response.setConfiguration(sortedProperties);
        return response;
    }, ServerConfiguration.global());
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) ImmutableTriple(org.apache.commons.lang3.tuple.ImmutableTriple) WorkerWebUIConfiguration(alluxio.wire.WorkerWebUIConfiguration) TreeSet(java.util.TreeSet) ConfigProperty(alluxio.grpc.ConfigProperty) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 4 with ConfigProperty

use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.

the class BlockMasterSync method registerWithMaster.

/**
 * Registers with the Alluxio master. This should be called before the
 * continuous heartbeat thread begins.
 */
private void registerWithMaster() throws IOException {
    BlockStoreMeta storeMeta = mBlockWorker.getStoreMetaFull();
    StorageTierAssoc storageTierAssoc = new WorkerStorageTierAssoc();
    List<ConfigProperty> configList = ConfigurationUtils.getConfiguration(ServerConfiguration.global(), Scope.WORKER);
    if (ACQUIRE_LEASE) {
        LOG.info("Acquiring a RegisterLease from the master before registering");
        try {
            mMasterClient.acquireRegisterLeaseWithBackoff(mWorkerId.get(), storeMeta.getNumberOfBlocks(), getDefaultAcquireLeaseRetryPolicy());
            LOG.info("Lease acquired");
        } catch (FailedToAcquireRegisterLeaseException e) {
            mMasterClient.disconnect();
            if (ServerConfiguration.getBoolean(PropertyKey.TEST_MODE)) {
                throw new RuntimeException(String.format("Master register lease timeout exceeded: %dms", ACQUIRE_LEASE_WAIT_MAX_DURATION));
            }
            ProcessUtils.fatalError(LOG, "Master register lease timeout exceeded: %dms", ACQUIRE_LEASE_WAIT_MAX_DURATION);
        }
    }
    if (mUseStreaming) {
        mMasterClient.registerWithStream(mWorkerId.get(), storageTierAssoc.getOrderedStorageAliases(), storeMeta.getCapacityBytesOnTiers(), storeMeta.getUsedBytesOnTiers(), storeMeta.getBlockListByStorageLocation(), storeMeta.getLostStorage(), configList);
    } else {
        mMasterClient.register(mWorkerId.get(), storageTierAssoc.getOrderedStorageAliases(), storeMeta.getCapacityBytesOnTiers(), storeMeta.getUsedBytesOnTiers(), storeMeta.getBlockListByStorageLocation(), storeMeta.getLostStorage(), configList);
    }
// If the worker registers with master successfully, the lease will be recycled on the
// master side. No need to manually request for recycle on the worker side.
}
Also used : StorageTierAssoc(alluxio.StorageTierAssoc) WorkerStorageTierAssoc(alluxio.WorkerStorageTierAssoc) ConfigProperty(alluxio.grpc.ConfigProperty) WorkerStorageTierAssoc(alluxio.WorkerStorageTierAssoc) FailedToAcquireRegisterLeaseException(alluxio.exception.FailedToAcquireRegisterLeaseException)

Example 5 with ConfigProperty

use of alluxio.grpc.ConfigProperty in project alluxio by Alluxio.

the class ServerConfigurationCheckerTest method checkConf.

@Test
public void checkConf() {
    // Prepare data
    PropertyKey keyMasterEnforce = new PropertyKey.Builder("TestKey1").setConsistencyCheckLevel(PropertyKey.ConsistencyCheckLevel.ENFORCE).setScope(Scope.MASTER).build();
    ConfigProperty masterEnforceProp = ConfigProperty.newBuilder().setName(keyMasterEnforce.getName()).setSource("Test").setValue("Value").build();
    PropertyKey keyWorkerWarn = new PropertyKey.Builder("TestKey2").setConsistencyCheckLevel(PropertyKey.ConsistencyCheckLevel.WARN).setScope(Scope.WORKER).build();
    ConfigProperty workerWarnProp = ConfigProperty.newBuilder().setName(keyWorkerWarn.getName()).setSource("Test").setValue("Value").build();
    PropertyKey keyServerEnforce = new PropertyKey.Builder("TestKey3").setConsistencyCheckLevel(PropertyKey.ConsistencyCheckLevel.ENFORCE).setScope(Scope.SERVER).build();
    ConfigProperty serverEnforceProp = ConfigProperty.newBuilder().setName(keyServerEnforce.getName()).setSource("Test").setValue("Value").build();
    Random random = new Random();
    Address addressOne = new Address(RandomStringUtils.randomAlphanumeric(10), random.nextInt());
    Address addressTwo = new Address(RandomStringUtils.randomAlphanumeric(10), random.nextInt());
    // When records have nothing different, no errors or warns will be found
    mRecordOne.registerNewConf(addressOne, Arrays.asList(masterEnforceProp, workerWarnProp));
    mRecordTwo.registerNewConf(addressTwo, Arrays.asList(masterEnforceProp, workerWarnProp));
    checkResults(0, 0, ConfigStatus.PASSED);
    // When records have a wrong warn property, checker should be able to find config warns
    ConfigProperty wrongWorkerWarnProp = ConfigProperty.newBuilder().setName(workerWarnProp.getName()).setSource(workerWarnProp.getSource()).setValue("WrongValue").build();
    mRecordOne.registerNewConf(addressOne, Arrays.asList(masterEnforceProp, wrongWorkerWarnProp));
    checkResults(0, 1, ConfigStatus.WARN);
    // When records have a wrong enforce property, checker should be able to find config errors
    ConfigProperty wrongMasterEnforceProp = ConfigProperty.newBuilder().setName(masterEnforceProp.getName()).setSource(masterEnforceProp.getSource()).setValue("WrongValue").build();
    mRecordTwo.registerNewConf(addressTwo, Arrays.asList(wrongMasterEnforceProp, workerWarnProp));
    checkResults(1, 1, ConfigStatus.FAILED);
    ConfigProperty wrongServerEnforceProp = ConfigProperty.newBuilder().setName(serverEnforceProp.getName()).setSource(serverEnforceProp.getSource()).setValue("WrongValue").build();
    mRecordOne.registerNewConf(addressOne, Arrays.asList(masterEnforceProp, workerWarnProp, serverEnforceProp));
    mRecordTwo.registerNewConf(addressTwo, Arrays.asList(masterEnforceProp, workerWarnProp, wrongServerEnforceProp));
    checkResults(1, 0, ConfigStatus.FAILED);
}
Also used : Random(java.util.Random) Address(alluxio.wire.Address) ConfigProperty(alluxio.grpc.ConfigProperty) PropertyKey(alluxio.conf.PropertyKey) Test(org.junit.Test)

Aggregations

ConfigProperty (alluxio.grpc.ConfigProperty)9 PropertyKey (alluxio.conf.PropertyKey)5 Constants (alluxio.Constants)2 AlluxioProperties (alluxio.conf.AlluxioProperties)2 FailedToAcquireRegisterLeaseException (alluxio.exception.FailedToAcquireRegisterLeaseException)2 GetConfigurationPResponse (alluxio.grpc.GetConfigurationPResponse)2 GrpcUtils (alluxio.grpc.GrpcUtils)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 TreeSet (java.util.TreeSet)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 ImmutableTriple (org.apache.commons.lang3.tuple.ImmutableTriple)2 Triple (org.apache.commons.lang3.tuple.Triple)2 AbstractMasterClient (alluxio.AbstractMasterClient)1 RuntimeConstants (alluxio.RuntimeConstants)1 StorageTierAssoc (alluxio.StorageTierAssoc)1 WorkerStorageTierAssoc (alluxio.WorkerStorageTierAssoc)1