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