Search in sources :

Example 1 with Authority

use of alluxio.uri.Authority 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)

Example 2 with Authority

use of alluxio.uri.Authority in project alluxio by Alluxio.

the class FileSystem method validateFsUri.

@Override
protected void validateFsUri(URI fsUri) throws IOException, IllegalArgumentException {
    Preconditions.checkArgument(fsUri.getScheme().equals(getScheme()), PreconditionMessage.URI_SCHEME_MISMATCH.toString(), fsUri.getScheme(), getScheme());
    Authority auth = Authority.fromString(fsUri.getAuthority());
    if (auth instanceof UnknownAuthority) {
        throw new IOException(String.format("Authority \"%s\" is unknown. The client can not be " + "configured with the authority from %s", auth, fsUri));
    }
}
Also used : Authority(alluxio.uri.Authority) ZookeeperLogicalAuthority(alluxio.uri.ZookeeperLogicalAuthority) MultiMasterAuthority(alluxio.uri.MultiMasterAuthority) UnknownAuthority(alluxio.uri.UnknownAuthority) EmbeddedLogicalAuthority(alluxio.uri.EmbeddedLogicalAuthority) ZookeeperAuthority(alluxio.uri.ZookeeperAuthority) SingleMasterAuthority(alluxio.uri.SingleMasterAuthority) UnknownAuthority(alluxio.uri.UnknownAuthority) IOException(java.io.IOException)

Aggregations

Authority (alluxio.uri.Authority)2 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 EmbeddedLogicalAuthority (alluxio.uri.EmbeddedLogicalAuthority)1 MultiMasterAuthority (alluxio.uri.MultiMasterAuthority)1 SingleMasterAuthority (alluxio.uri.SingleMasterAuthority)1 UnknownAuthority (alluxio.uri.UnknownAuthority)1 ZookeeperAuthority (alluxio.uri.ZookeeperAuthority)1 ZookeeperLogicalAuthority (alluxio.uri.ZookeeperLogicalAuthority)1 IOException (java.io.IOException)1