Search in sources :

Example 1 with GetConfigurationPResponse

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

the class ClientContext method loadConf.

/**
 * This method will load the cluster and path level configuration defaults and update
 * the configuration in one RPC.
 *
 * This method should be synchronized so that concurrent calls to it don't continually overwrite
 * the previous configuration.
 *
 * The cluster defaults are updated per connection establishment, or when cluster defaults
 * updates are detected on client side.
 *
 * @param address the address to load cluster defaults from
 * @param loadClusterConf whether to load cluster level configuration
 * @param loadPathConf whether to load path level configuration
 * @throws AlluxioStatusException
 */
public synchronized void loadConf(InetSocketAddress address, boolean loadClusterConf, boolean loadPathConf) throws AlluxioStatusException {
    AlluxioConfiguration conf = mClusterConf;
    if (!loadClusterConf && !loadPathConf) {
        return;
    }
    GetConfigurationPResponse response = ConfigurationUtils.loadConfiguration(address, conf, !loadClusterConf, !loadPathConf);
    if (loadClusterConf) {
        mClusterConf = ConfigurationUtils.getClusterConf(response, conf, Scope.CLIENT);
        mClusterConfHash = response.getClusterConfigHash();
    }
    if (loadPathConf) {
        mPathConf = ConfigurationUtils.getPathConf(response, conf);
        mPathConfHash = response.getPathConfigHash();
        mIsPathConfLoaded = true;
    }
}
Also used : GetConfigurationPResponse(alluxio.grpc.GetConfigurationPResponse) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Example 2 with GetConfigurationPResponse

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

the class ServerConfiguration method loadWorkerClusterDefaults.

/**
 * Loads cluster default values for workers from the meta master if it's not loaded yet.
 *
 * @param address the master address
 */
public static synchronized void loadWorkerClusterDefaults(InetSocketAddress address) throws AlluxioStatusException {
    if (sConf.getBoolean(PropertyKey.USER_CONF_CLUSTER_DEFAULT_ENABLED) && !sConf.clusterDefaultsLoaded()) {
        GetConfigurationPResponse response = ConfigurationUtils.loadConfiguration(address, sConf, false, true);
        AlluxioConfiguration conf = ConfigurationUtils.getClusterConf(response, sConf, Scope.WORKER);
        sConf = new InstancedConfiguration(conf.copyProperties(), conf.clusterDefaultsLoaded());
    }
}
Also used : GetConfigurationPResponse(alluxio.grpc.GetConfigurationPResponse)

Example 3 with GetConfigurationPResponse

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

the class ConfigurationUtils method loadConfiguration.

/**
 * Loads configuration from meta master in one RPC.
 *
 * @param address the meta master address
 * @param conf the existing configuration
 * @param ignoreClusterConf do not load cluster configuration related information
 * @param ignorePathConf do not load path configuration related information
 * @return the RPC response
 */
public static GetConfigurationPResponse loadConfiguration(InetSocketAddress address, AlluxioConfiguration conf, boolean ignoreClusterConf, boolean ignorePathConf) throws AlluxioStatusException {
    GrpcChannel channel = null;
    try {
        LOG.debug("Alluxio client (version {}) is trying to load configuration from meta master {}", RuntimeConstants.VERSION, address);
        channel = GrpcChannelBuilder.newBuilder(GrpcServerAddress.create(address), conf).setClientType("ConfigurationUtils").disableAuthentication().build();
        MetaMasterConfigurationServiceGrpc.MetaMasterConfigurationServiceBlockingStub client = MetaMasterConfigurationServiceGrpc.newBlockingStub(channel);
        GetConfigurationPResponse response = client.getConfiguration(GetConfigurationPOptions.newBuilder().setRawValue(true).setIgnoreClusterConf(ignoreClusterConf).setIgnorePathConf(ignorePathConf).build());
        LOG.debug("Alluxio client has loaded configuration from meta master {}", address);
        return response;
    } catch (io.grpc.StatusRuntimeException e) {
        throw new UnavailableException(String.format("Failed to handshake with master %s to load cluster default configuration values: %s", address, e.getMessage()), e);
    } catch (UnauthenticatedException e) {
        throw new RuntimeException(String.format("Received authentication exception during boot-strap connect with host:%s", address), e);
    } finally {
        if (channel != null) {
            channel.shutdown();
        }
    }
}
Also used : MetaMasterConfigurationServiceGrpc(alluxio.grpc.MetaMasterConfigurationServiceGrpc) UnauthenticatedException(alluxio.exception.status.UnauthenticatedException) UnavailableException(alluxio.exception.status.UnavailableException) GetConfigurationPResponse(alluxio.grpc.GetConfigurationPResponse) GrpcChannel(alluxio.grpc.GrpcChannel)

Example 4 with GetConfigurationPResponse

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

the class Configuration method toProto.

/**
 * @return the proto representation
 */
public GetConfigurationPResponse toProto() {
    GetConfigurationPResponse.Builder response = GetConfigurationPResponse.newBuilder();
    if (mClusterConf != null) {
        mClusterConf.forEach(property -> response.addClusterConfigs(property.toProto()));
    }
    if (mPathConf != null) {
        mPathConf.forEach((path, properties) -> {
            List<ConfigProperty> propertyList = properties.stream().map(Property::toProto).collect(Collectors.toList());
            ConfigProperties configProperties = ConfigProperties.newBuilder().addAllProperties(propertyList).build();
            response.putPathConfigs(path, configProperties);
        });
    }
    if (mClusterConfHash != null) {
        response.setClusterConfigHash(mClusterConfHash);
    }
    if (mPathConfHash != null) {
        response.setPathConfigHash(mPathConfHash);
    }
    return response.build();
}
Also used : ConfigProperties(alluxio.grpc.ConfigProperties) ConfigProperty(alluxio.grpc.ConfigProperty) GetConfigurationPResponse(alluxio.grpc.GetConfigurationPResponse)

Aggregations

GetConfigurationPResponse (alluxio.grpc.GetConfigurationPResponse)4 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 UnauthenticatedException (alluxio.exception.status.UnauthenticatedException)1 UnavailableException (alluxio.exception.status.UnavailableException)1 ConfigProperties (alluxio.grpc.ConfigProperties)1 ConfigProperty (alluxio.grpc.ConfigProperty)1 GrpcChannel (alluxio.grpc.GrpcChannel)1 MetaMasterConfigurationServiceGrpc (alluxio.grpc.MetaMasterConfigurationServiceGrpc)1