Repository: hadoop Updated Branches: refs/heads/trunk f66ad1fab -> 7da15eac7
HDFS-12579. JournalNodeSyncer should use fromUrl field of EditLogManifestResponse to construct servlet Url. Contributed by Hanisha Koneru. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7da15eac Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7da15eac Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7da15eac Branch: refs/heads/trunk Commit: 7da15eac7abe59f446b184aa1766bbfd3a19db4e Parents: f66ad1f Author: Arpit Agarwal <[email protected]> Authored: Wed Oct 25 14:24:22 2017 -0700 Committer: Arpit Agarwal <[email protected]> Committed: Wed Oct 25 14:24:22 2017 -0700 ---------------------------------------------------------------------- .../hdfs/qjournal/server/JournalNodeSyncer.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/7da15eac/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNodeSyncer.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNodeSyncer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNodeSyncer.java index b843aa8..cf5a9ec 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNodeSyncer.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JournalNodeSyncer.java @@ -309,14 +309,22 @@ public class JournalNodeSyncer { boolean success = false; try { if (remoteJNproxy.httpServerUrl == null) { - remoteJNproxy.httpServerUrl = getHttpServerURI("http", - remoteJNproxy.jnAddr.getHostName(), response.getHttpPort()); + if (response.hasFromURL()) { + remoteJNproxy.httpServerUrl = getHttpServerURI( + response.getFromURL(), remoteJNproxy.jnAddr.getHostName()); + } else { + LOG.error("EditLogManifest response does not have fromUrl " + + "field set. Aborting current sync attempt"); + break; + } } String urlPath = GetJournalEditServlet.buildPath(jid, missingLog .getStartTxId(), nsInfo, false); url = new URL(remoteJNproxy.httpServerUrl, urlPath); success = downloadMissingLogSegment(url, missingLog); + } catch (URISyntaxException e) { + LOG.error("EditLogManifest's fromUrl field syntax incorrect", e); } catch (MalformedURLException e) { LOG.error("MalformedURL when download missing log segment", e); } catch (Exception e) { @@ -374,9 +382,10 @@ public class JournalNodeSyncer { return missingEditLogs; } - private URL getHttpServerURI(String scheme, String hostname, int port) - throws MalformedURLException { - return new URL(scheme, hostname, port, ""); + private URL getHttpServerURI(String fromUrl, String hostAddr) + throws URISyntaxException, MalformedURLException { + URI uri = new URI(fromUrl); + return new URL(uri.getScheme(), hostAddr, uri.getPort(), ""); } /** --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
