Search in sources :

Example 41 with URISyntaxException

use of java.net.URISyntaxException in project hadoop by apache.

the class FileName method anonymize.

private static String anonymize(StatePool statePool, Configuration conf, FileNameState fState, String fileName) {
    String ret = null;
    try {
        URI uri = new URI(fileName);
        // anonymize the path i.e without the authority & scheme
        ret = anonymizePath(uri.getPath(), fState.getDirectoryState(), fState.getFileNameState());
        // anonymize the authority and scheme
        String authority = uri.getAuthority();
        String scheme = uri.getScheme();
        if (scheme != null) {
            String anonymizedAuthority = "";
            if (authority != null) {
                // anonymize the authority
                NodeName hostName = new NodeName(null, uri.getHost());
                anonymizedAuthority = hostName.getAnonymizedValue(statePool, conf);
            }
            ret = scheme + "://" + anonymizedAuthority + ret;
        }
    } catch (URISyntaxException use) {
        throw new RuntimeException(use);
    }
    return ret;
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 42 with URISyntaxException

use of java.net.URISyntaxException in project hadoop by apache.

the class ContainerManagerImpl method localize.

@Override
@SuppressWarnings("unchecked")
public ResourceLocalizationResponse localize(ResourceLocalizationRequest request) throws YarnException, IOException {
    ContainerId containerId = request.getContainerId();
    Container container = preReInitializeOrLocalizeCheck(containerId, ReInitOp.LOCALIZE);
    try {
        Map<LocalResourceVisibility, Collection<LocalResourceRequest>> req = container.getResourceSet().addResources(request.getLocalResources());
        if (req != null && !req.isEmpty()) {
            dispatcher.getEventHandler().handle(new ContainerLocalizationRequestEvent(container, req));
        }
    } catch (URISyntaxException e) {
        LOG.info("Error when parsing local resource URI for " + containerId, e);
        throw new YarnException(e);
    }
    return ResourceLocalizationResponse.newInstance();
}
Also used : Container(org.apache.hadoop.yarn.server.nodemanager.containermanager.container.Container) ContainerLocalizationRequestEvent(org.apache.hadoop.yarn.server.nodemanager.containermanager.localizer.event.ContainerLocalizationRequestEvent) ContainerId(org.apache.hadoop.yarn.api.records.ContainerId) Collection(java.util.Collection) URISyntaxException(java.net.URISyntaxException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) LocalResourceVisibility(org.apache.hadoop.yarn.api.records.LocalResourceVisibility)

Example 43 with URISyntaxException

use of java.net.URISyntaxException in project hadoop by apache.

the class RMWebAppFilter method appendOrReplaceParamter.

private String appendOrReplaceParamter(String uri, String newQuery) {
    if (uri.contains(YarnWebParams.NEXT_REFRESH_INTERVAL + "=")) {
        return uri.replaceAll(YarnWebParams.NEXT_REFRESH_INTERVAL + "=[^&]+", newQuery);
    }
    try {
        URI oldUri = new URI(uri);
        String appendQuery = oldUri.getQuery();
        if (appendQuery == null) {
            appendQuery = newQuery;
        } else {
            appendQuery += "&" + newQuery;
        }
        URI newUri = new URI(oldUri.getScheme(), oldUri.getAuthority(), oldUri.getPath(), appendQuery, oldUri.getFragment());
        return newUri.toString();
    } catch (URISyntaxException e) {
        return null;
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 44 with URISyntaxException

use of java.net.URISyntaxException in project hadoop by apache.

the class Submitter method setupPipesJob.

private static void setupPipesJob(JobConf conf) throws IOException {
    // default map output types to Text
    if (!getIsJavaMapper(conf)) {
        conf.setMapRunnerClass(PipesMapRunner.class);
        // Save the user's partitioner and hook in our's.
        setJavaPartitioner(conf, conf.getPartitionerClass());
        conf.setPartitionerClass(PipesPartitioner.class);
    }
    if (!getIsJavaReducer(conf)) {
        conf.setReducerClass(PipesReducer.class);
        if (!getIsJavaRecordWriter(conf)) {
            conf.setOutputFormat(NullOutputFormat.class);
        }
    }
    String textClassname = Text.class.getName();
    setIfUnset(conf, MRJobConfig.MAP_OUTPUT_KEY_CLASS, textClassname);
    setIfUnset(conf, MRJobConfig.MAP_OUTPUT_VALUE_CLASS, textClassname);
    setIfUnset(conf, MRJobConfig.OUTPUT_KEY_CLASS, textClassname);
    setIfUnset(conf, MRJobConfig.OUTPUT_VALUE_CLASS, textClassname);
    // from C++ RecordReaders ...
    if (!getIsJavaRecordReader(conf) && !getIsJavaMapper(conf)) {
        conf.setClass(Submitter.INPUT_FORMAT, conf.getInputFormat().getClass(), InputFormat.class);
        conf.setInputFormat(PipesNonJavaInputFormat.class);
    }
    String exec = getExecutable(conf);
    if (exec == null) {
        throw new IllegalArgumentException("No application program defined.");
    }
    // <path>#<executable>
    if (exec.contains("#")) {
        // set default gdb commands for map and reduce task 
        String defScript = "$HADOOP_HOME/src/c++/pipes/debug/pipes-default-script";
        setIfUnset(conf, MRJobConfig.MAP_DEBUG_SCRIPT, defScript);
        setIfUnset(conf, MRJobConfig.REDUCE_DEBUG_SCRIPT, defScript);
    }
    URI[] fileCache = DistributedCache.getCacheFiles(conf);
    if (fileCache == null) {
        fileCache = new URI[1];
    } else {
        URI[] tmp = new URI[fileCache.length + 1];
        System.arraycopy(fileCache, 0, tmp, 1, fileCache.length);
        fileCache = tmp;
    }
    try {
        fileCache[0] = new URI(exec);
    } catch (URISyntaxException e) {
        IOException ie = new IOException("Problem parsing execable URI " + exec);
        ie.initCause(e);
        throw ie;
    }
    DistributedCache.setCacheFiles(fileCache, conf);
}
Also used : URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) URI(java.net.URI)

Example 45 with URISyntaxException

use of java.net.URISyntaxException in project hadoop by apache.

the class LocalSASKeyGeneratorImpl method getSASKeyBasedStorageAccountInstance.

/**
   * Helper method that creates a CloudStorageAccount instance based on
   *  SAS key for accountName
   *
   * @param accountName Storage Account Name
   * @return CloudStorageAccount instance created using SAS key for
   *   the Storage Account.
   * @throws SASKeyGenerationException
   */
private CloudStorageAccount getSASKeyBasedStorageAccountInstance(String accountName) throws SASKeyGenerationException {
    try {
        String accountNameWithoutDomain = getAccountNameWithoutDomain(accountName);
        CloudStorageAccount account = getStorageAccountInstance(accountNameWithoutDomain, AzureNativeFileSystemStore.getAccountKeyFromConfiguration(accountName, getConf()));
        return new CloudStorageAccount(new StorageCredentialsSharedAccessSignature(account.generateSharedAccessSignature(getDefaultAccountAccessPolicy())), false, account.getEndpointSuffix(), accountNameWithoutDomain);
    } catch (KeyProviderException keyProviderEx) {
        throw new SASKeyGenerationException("Encountered KeyProviderException" + " while retrieving Storage key from configuration for account " + accountName, keyProviderEx);
    } catch (InvalidKeyException invalidKeyEx) {
        throw new SASKeyGenerationException("Encoutered InvalidKeyException " + "while generating Account level SAS key for account" + accountName, invalidKeyEx);
    } catch (StorageException storeEx) {
        throw new SASKeyGenerationException("Encoutered StorageException while " + "generating Account level SAS key for account" + accountName, storeEx);
    } catch (URISyntaxException uriSyntaxEx) {
        throw new SASKeyGenerationException("Encountered URISyntaxException for" + " account " + accountName, uriSyntaxEx);
    }
}
Also used : StorageCredentialsSharedAccessSignature(com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature) CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) URISyntaxException(java.net.URISyntaxException) InvalidKeyException(java.security.InvalidKeyException) StorageException(com.microsoft.azure.storage.StorageException)

Aggregations

URISyntaxException (java.net.URISyntaxException)4043 URI (java.net.URI)2496 IOException (java.io.IOException)1273 File (java.io.File)716 URL (java.net.URL)702 ArrayList (java.util.ArrayList)407 Test (org.junit.Test)274 MalformedURLException (java.net.MalformedURLException)270 InputStream (java.io.InputStream)224 HashMap (java.util.HashMap)212 Response (javax.ws.rs.core.Response)194 Test (org.testng.annotations.Test)175 Parameters (org.testng.annotations.Parameters)166 Builder (javax.ws.rs.client.Invocation.Builder)165 ResteasyClientBuilder (org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder)165 Map (java.util.Map)162 StorageException (com.microsoft.azure.storage.StorageException)142 Path (java.nio.file.Path)141 URIBuilder (org.apache.http.client.utils.URIBuilder)140 List (java.util.List)125