Search in sources :

Example 1 with AlluxioConfiguration

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

the class RoundRobinPolicyTest method equalsTest.

@Test
public void equalsTest() throws Exception {
    AlluxioConfiguration conf = ConfigurationTestUtils.defaults();
    CommonUtils.testEquals(RoundRobinPolicy.class, new Class[] { AlluxioConfiguration.class }, new Object[] { conf });
}
Also used : AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) Test(org.junit.Test)

Example 2 with AlluxioConfiguration

use of alluxio.conf.AlluxioConfiguration 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 3 with AlluxioConfiguration

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

the class UninstallCommand method run.

@Override
public int run(CommandLine cl) {
    String uri = cl.getArgs()[0];
    AlluxioConfiguration conf = ServerConfiguration.global();
    String extensionsDir = conf.getString(PropertyKey.EXTENSIONS_DIR);
    List<String> failedHosts = new ArrayList<>();
    for (String host : ConfigurationUtils.getServerHostnames(conf)) {
        try {
            LOG.info("Attempting to uninstall extension on host {}", host);
            String rmCmd = String.format("ssh %s %s rm %s", ShellUtils.COMMON_SSH_OPTS, host, PathUtils.concatPath(extensionsDir, uri));
            LOG.debug("Executing: {}", rmCmd);
            String output = ShellUtils.execCommand("bash", "-c", rmCmd);
            LOG.debug("Succeeded w/ output: {}", output);
        } catch (IOException e) {
            LOG.error("Error uninstalling extension on host {}.", host, e);
            failedHosts.add(host);
        }
    }
    if (failedHosts.size() != 0) {
        System.err.println("Failed to uninstall extension on hosts:");
        for (String failedHost : failedHosts) {
            System.err.println(failedHost);
        }
        return -1;
    }
    System.out.println("Extension uninstalled successfully.");
    return 0;
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Example 4 with AlluxioConfiguration

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

the class Format method main.

/**
 * Formats the Alluxio file system.
 *
 * @param args either {@code MASTER} or {@code WORKER}
 */
public static void main(String[] args) {
    if (args.length != 1) {
        LOG.info(USAGE);
        System.exit(-1);
    }
    AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
    // Set the process type as "MASTER" since format needs to access the journal like the master.
    CommonUtils.PROCESS_TYPE.set(CommonUtils.ProcessType.MASTER);
    Mode mode = null;
    try {
        mode = Mode.valueOf(args[0].toUpperCase());
    } catch (IllegalArgumentException e) {
        LOG.error("Unrecognized format mode: {}", args[0]);
        LOG.error("Usage: {}", USAGE);
        System.exit(-1);
    }
    try {
        format(mode, conf);
    } catch (Exception e) {
        LOG.error("Failed to format", e);
        System.exit(-1);
    }
    LOG.info("Formatting complete");
    System.exit(0);
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) IOException(java.io.IOException)

Example 5 with AlluxioConfiguration

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

the class BaseFileSystem method checkUri.

/**
 * Checks an {@link AlluxioURI} for scheme and authority information. Warn the user and throw an
 * exception if necessary.
 */
protected void checkUri(AlluxioURI uri) {
    Preconditions.checkNotNull(uri, "uri");
    if (!mFsContext.getUriValidationEnabled()) {
        return;
    }
    if (uri.hasScheme()) {
        String warnMsg = "The URI scheme \"{}\" is ignored and not required in URIs passed to" + " the Alluxio Filesystem client.";
        switch(uri.getScheme()) {
            case Constants.SCHEME:
                LOG.warn(warnMsg, Constants.SCHEME);
                break;
            default:
                throw new IllegalArgumentException(String.format("Scheme %s:// in AlluxioURI is invalid. Schemes in filesystem" + " operations are ignored. \"alluxio://\" or no scheme at all is valid.", uri.getScheme()));
        }
    }
    if (uri.hasAuthority()) {
        LOG.warn("The URI authority (hostname and port) is ignored and not required in URIs passed " + "to the Alluxio Filesystem client.");
        AlluxioConfiguration conf = mFsContext.getClusterConf();
        boolean skipAuthorityCheck = conf.isSet(PropertyKey.USER_SKIP_AUTHORITY_CHECK) && conf.getBoolean(PropertyKey.USER_SKIP_AUTHORITY_CHECK);
        if (!skipAuthorityCheck) {
            /* Even if we choose to log the warning, check if the Configuration host matches what the
         * user passes. If not, throw an exception letting the user know they don't match.
         */
            Authority configured = MasterInquireClient.Factory.create(mFsContext.getClusterConf(), mFsContext.getClientContext().getUserState()).getConnectDetails().toAuthority();
            if (!configured.equals(uri.getAuthority())) {
                throw new IllegalArgumentException(String.format("The URI authority %s does not match the configured value of %s.", uri.getAuthority(), configured));
            }
        }
    }
}
Also used : Authority(alluxio.uri.Authority) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Aggregations

AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)62 Test (org.junit.Test)20 InstancedConfiguration (alluxio.conf.InstancedConfiguration)17 IOException (java.io.IOException)11 AlluxioURI (alluxio.AlluxioURI)7 UnderFileSystemFactory (alluxio.underfs.UnderFileSystemFactory)7 ArrayList (java.util.ArrayList)7 AlluxioProperties (alluxio.conf.AlluxioProperties)5 PropertyKey (alluxio.conf.PropertyKey)5 OpenFilePOptions (alluxio.grpc.OpenFilePOptions)5 HealthCheckClient (alluxio.HealthCheckClient)4 FileSystemContext (alluxio.client.file.FileSystemContext)4 InStreamOptions (alluxio.client.file.options.InStreamOptions)4 InetSocketAddress (java.net.InetSocketAddress)4 Constants (alluxio.Constants)3 AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)3 FileSystem (alluxio.client.file.FileSystem)3 URIStatus (alluxio.client.file.URIStatus)3 ReadRequest (alluxio.grpc.ReadRequest)3 InputStream (java.io.InputStream)3