From 2b8248ea72590e3c380e34919be2e4a2e31bd1cf Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Wed, 8 Apr 2020 14:59:15 +0200 Subject: [PATCH] prepare to generalize of --- src/main/java/hu/rxd/toolbox/switcher/ApacheMirrors.java | 7 +++++++ src/main/java/hu/rxd/toolbox/switcher/CDPMirrors.java | 7 +++++++ src/main/java/hu/rxd/toolbox/switcher/DevMirrors.java | 9 +++++++++ .../java/hu/rxd/toolbox/switcher/GenericComponent.java | 7 ++++++- src/main/java/hu/rxd/toolbox/switcher/HdpMirrors.java | 7 +++++++ src/main/java/hu/rxd/toolbox/switcher/Mirrors.java | 4 ++++ 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/main/java/hu/rxd/toolbox/switcher/ApacheMirrors.java b/src/main/java/hu/rxd/toolbox/switcher/ApacheMirrors.java index d154100..f40403d 100644 --- a/src/main/java/hu/rxd/toolbox/switcher/ApacheMirrors.java +++ b/src/main/java/hu/rxd/toolbox/switcher/ApacheMirrors.java @@ -1,5 +1,8 @@ package hu.rxd.toolbox.switcher; +import java.util.Collection; +import java.util.Collections; + public class ApacheMirrors implements Mirrors { @Override @@ -12,4 +15,8 @@ public String decodeStackVersion(String version) { return version; } + @Override + public Collection of0(Version ver) { + return Collections.EMPTY_LIST; + } } diff --git a/src/main/java/hu/rxd/toolbox/switcher/CDPMirrors.java b/src/main/java/hu/rxd/toolbox/switcher/CDPMirrors.java index 692e45a..0af9823 100644 --- a/src/main/java/hu/rxd/toolbox/switcher/CDPMirrors.java +++ b/src/main/java/hu/rxd/toolbox/switcher/CDPMirrors.java @@ -38,7 +38,14 @@ public String getComponentVersion(Version version, Component c) throws Exception private static final List MIRROR_ROOTS = Lists.newArrayList(("http://cloudera-build-us-west-1.vpc.cloudera.com/s3/build")); + @Override + @Deprecated // pending renames + public Collection of0(Version ver) { + return of(ver); + } + //" centos7/3.x/updates/%s/artifacts.txt",stackVersion)" + @Deprecated public static Collection of(Version ver) { List ret = new ArrayList<>(); for (String root : MIRROR_ROOTS) { diff --git a/src/main/java/hu/rxd/toolbox/switcher/DevMirrors.java b/src/main/java/hu/rxd/toolbox/switcher/DevMirrors.java index 6d6a00a..05e3da0 100644 --- a/src/main/java/hu/rxd/toolbox/switcher/DevMirrors.java +++ b/src/main/java/hu/rxd/toolbox/switcher/DevMirrors.java @@ -1,5 +1,8 @@ package hu.rxd.toolbox.switcher; +import java.util.Collection; +import java.util.Collections; + public class DevMirrors implements Mirrors { @Override @@ -11,4 +14,10 @@ public String getComponentVersion(Version version, Component c) { public String decodeStackVersion(String version) { throw new RuntimeException("unimpl"); } + + @Override + public Collection of0(Version ver) { + return Collections.EMPTY_LIST; + } + } diff --git a/src/main/java/hu/rxd/toolbox/switcher/GenericComponent.java b/src/main/java/hu/rxd/toolbox/switcher/GenericComponent.java index 6089bf4..7c4b679 100644 --- a/src/main/java/hu/rxd/toolbox/switcher/GenericComponent.java +++ b/src/main/java/hu/rxd/toolbox/switcher/GenericComponent.java @@ -121,10 +121,15 @@ protected List getCandidateUrls(Version ver) throws Exception { List ret = new ArrayList<>(); switch (ver.type) { - case APACHE: + case APACHE: { + String componentVersion = ver.getComponentVersion(getComponentType()); + for (Mirror m : ver.type.getMirrors().of0(ver)) { + ret.add(m.getFor(getComponentType(), componentVersion)); + } ret.add(new URL(apache_mirror + getApacheMirrorPath(ver))); ret.add(new URL(archive_mirror + getApacheMirrorPath(ver))); break; + } case HDP: { // FIXME: can be moved?! String componentVersion = ver.getComponentVersion(getComponentType()); diff --git a/src/main/java/hu/rxd/toolbox/switcher/HdpMirrors.java b/src/main/java/hu/rxd/toolbox/switcher/HdpMirrors.java index 3180b37..a67f81d 100644 --- a/src/main/java/hu/rxd/toolbox/switcher/HdpMirrors.java +++ b/src/main/java/hu/rxd/toolbox/switcher/HdpMirrors.java @@ -73,6 +73,13 @@ public String getComponentVersion(Version version, Component c) throws Exception Lists.newArrayList("http://public-repo-1.hortonworks.com/HDP", "http://private-repo-1.hortonworks.com/HDP"); + @Override + @Deprecated // pending renames + public Collection of0(Version ver) { + return of(ver); + } + + @Deprecated public static Collection of(Version ver) { List ret = new ArrayList<>(); for (String root : MIRROR_ROOTS) { diff --git a/src/main/java/hu/rxd/toolbox/switcher/Mirrors.java b/src/main/java/hu/rxd/toolbox/switcher/Mirrors.java index 21a1406..5d800fd 100644 --- a/src/main/java/hu/rxd/toolbox/switcher/Mirrors.java +++ b/src/main/java/hu/rxd/toolbox/switcher/Mirrors.java @@ -1,5 +1,7 @@ package hu.rxd.toolbox.switcher; +import java.util.Collection; + public interface Mirrors { String getComponentVersion(Version version, Component c) throws Exception; @@ -11,4 +13,6 @@ public interface Mirrors { * for CDP this is by acquiring the build id */ public String decodeStackVersion(String version); + + Collection of0(Version ver); }