Search in sources :

Example 6 with MalformedURLException

use of java.net.MalformedURLException in project flink by apache.

the class ScalaShellRemoteStreamEnvironment method executeRemotely.

/**
	 * Executes the remote job.
	 *
	 * @param streamGraph
	 *            Stream Graph to execute
	 * @param jarFiles
	 * 			  List of jar file URLs to ship to the cluster
	 * @return The result of the job execution, containing elapsed time and accumulators.
	 */
@Override
protected JobExecutionResult executeRemotely(StreamGraph streamGraph, List<URL> jarFiles) throws ProgramInvocationException {
    URL jarUrl;
    try {
        jarUrl = flinkILoop.writeFilesToDisk().getAbsoluteFile().toURI().toURL();
    } catch (MalformedURLException e) {
        throw new ProgramInvocationException("Could not write the user code classes to disk.", e);
    }
    List<URL> allJarFiles = new ArrayList<>(jarFiles.size() + 1);
    allJarFiles.addAll(jarFiles);
    allJarFiles.add(jarUrl);
    return super.executeRemotely(streamGraph, allJarFiles);
}
Also used : MalformedURLException(java.net.MalformedURLException) ArrayList(java.util.ArrayList) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) URL(java.net.URL)

Example 7 with MalformedURLException

use of java.net.MalformedURLException in project groovy by apache.

the class AbstractHttpServlet method generateNamePrefixOnce.

protected void generateNamePrefixOnce() {
    URI uri = null;
    String realPath = servletContext.getRealPath("/");
    //prevent NPE if in .war
    if (realPath != null) {
        uri = new File(realPath).toURI();
    }
    try {
        URL res = servletContext.getResource("/");
        if (res != null) {
            uri = res.toURI();
        }
    } catch (MalformedURLException ignore) {
    } catch (URISyntaxException ignore) {
    }
    if (uri != null) {
        try {
            namePrefix = uri.toURL().toExternalForm();
            return;
        } catch (MalformedURLException e) {
            log("generateNamePrefixOnce [ERROR] Malformed URL for base path / == '" + uri + '\'', e);
        }
    }
    namePrefix = "";
}
Also used : MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) File(java.io.File) URL(java.net.URL)

Example 8 with MalformedURLException

use of java.net.MalformedURLException in project groovy by apache.

the class GroovyScriptEngine method getResourceConnection.

/**
     * Get a resource connection as a <code>URLConnection</code> to retrieve a script
     * from the <code>ResourceConnector</code>.
     *
     * @param resourceName name of the resource to be retrieved
     * @return a URLConnection to the resource
     * @throws ResourceException
     */
public URLConnection getResourceConnection(String resourceName) throws ResourceException {
    // Get the URLConnection
    URLConnection groovyScriptConn = null;
    ResourceException se = null;
    for (URL root : roots) {
        URL scriptURL = null;
        try {
            scriptURL = new URL(root, resourceName);
            groovyScriptConn = openConnection(scriptURL);
            // Now this is a bit unusual
            break;
        } catch (MalformedURLException e) {
            String message = "Malformed URL: " + root + ", " + resourceName;
            if (se == null) {
                se = new ResourceException(message);
            } else {
                se = new ResourceException(message, se);
            }
        } catch (IOException e1) {
            String message = "Cannot open URL: " + root + resourceName;
            groovyScriptConn = null;
            if (se == null) {
                se = new ResourceException(message);
            } else {
                se = new ResourceException(message, se);
            }
        }
    }
    if (se == null)
        se = new ResourceException("No resource for " + resourceName + " was found");
    // If we didn't find anything, report on all the exceptions that occurred.
    if (groovyScriptConn == null)
        throw se;
    return groovyScriptConn;
}
Also used : MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) URLConnection(java.net.URLConnection) URL(java.net.URL)

Example 9 with MalformedURLException

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

the class Checkpointer method getImageListenAddress.

private URL getImageListenAddress() {
    InetSocketAddress httpSocAddr = backupNode.getHttpAddress();
    int httpPort = httpSocAddr.getPort();
    try {
        return new URL(DFSUtil.getHttpClientScheme(conf) + "://" + infoBindAddress + ":" + httpPort);
    } catch (MalformedURLException e) {
        // Unreachable
        throw new RuntimeException(e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) InetSocketAddress(java.net.InetSocketAddress) URL(java.net.URL)

Example 10 with MalformedURLException

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

the class JournalNodeSyncer method getMissingLogSegments.

private void getMissingLogSegments(List<RemoteEditLog> thisJournalEditLogs, GetEditLogManifestResponseProto response, JournalNodeProxy remoteJNproxy) {
    List<RemoteEditLog> otherJournalEditLogs = PBHelper.convert(response.getManifest()).getLogs();
    if (otherJournalEditLogs == null || otherJournalEditLogs.isEmpty()) {
        LOG.warn("Journal at " + remoteJNproxy.jnAddr + " has no edit logs");
        return;
    }
    List<RemoteEditLog> missingLogs = getMissingLogList(thisJournalEditLogs, otherJournalEditLogs);
    if (!missingLogs.isEmpty()) {
        NamespaceInfo nsInfo = jnStorage.getNamespaceInfo();
        for (RemoteEditLog missingLog : missingLogs) {
            URL url = null;
            boolean success = false;
            try {
                if (remoteJNproxy.httpServerUrl == null) {
                    if (response.hasFromURL()) {
                        URI uri = URI.create(response.getFromURL());
                        remoteJNproxy.httpServerUrl = getHttpServerURI(uri.getScheme(), uri.getHost(), uri.getPort());
                    } else {
                        remoteJNproxy.httpServerUrl = getHttpServerURI("http", remoteJNproxy.jnAddr.getHostName(), response.getHttpPort());
                    }
                }
                String urlPath = GetJournalEditServlet.buildPath(jid, missingLog.getStartTxId(), nsInfo);
                url = new URL(remoteJNproxy.httpServerUrl, urlPath);
                success = downloadMissingLogSegment(url, missingLog);
            } catch (MalformedURLException e) {
                LOG.error("MalformedURL when download missing log segment", e);
            } catch (Exception e) {
                LOG.error("Exception in downloading missing log segment from url " + url, e);
            }
            if (!success) {
                LOG.error("Aborting current sync attempt.");
                break;
            }
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) RemoteEditLog(org.apache.hadoop.hdfs.server.protocol.RemoteEditLog) NamespaceInfo(org.apache.hadoop.hdfs.server.protocol.NamespaceInfo) URI(java.net.URI) URL(java.net.URL) ServiceException(com.google.protobuf.ServiceException) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException)

Aggregations

MalformedURLException (java.net.MalformedURLException)1319 URL (java.net.URL)984 IOException (java.io.IOException)397 File (java.io.File)324 ArrayList (java.util.ArrayList)132 HttpURLConnection (java.net.HttpURLConnection)108 InputStream (java.io.InputStream)106 HashMap (java.util.HashMap)89 URISyntaxException (java.net.URISyntaxException)78 URI (java.net.URI)76 Map (java.util.Map)69 URLClassLoader (java.net.URLClassLoader)65 InputStreamReader (java.io.InputStreamReader)61 BufferedReader (java.io.BufferedReader)58 FileNotFoundException (java.io.FileNotFoundException)53 URLConnection (java.net.URLConnection)52 HashSet (java.util.HashSet)50 Test (org.junit.Test)45 JSONException (org.json.JSONException)38 FileInputStream (java.io.FileInputStream)33