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));
}
}
}
}
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));
}
}
Aggregations