Skip to content

Commit

Permalink
prepare to generalize of
Browse files Browse the repository at this point in the history
  • Loading branch information
kgyrtkirk committed Apr 8, 2020
1 parent d9661f8 commit 2b8248e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/main/java/hu/rxd/toolbox/switcher/ApacheMirrors.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package hu.rxd.toolbox.switcher;

import java.util.Collection;
import java.util.Collections;

public class ApacheMirrors implements Mirrors {

@Override
Expand All @@ -12,4 +15,8 @@ public String decodeStackVersion(String version) {
return version;
}

@Override
public Collection<Mirror> of0(Version ver) {
return Collections.EMPTY_LIST;
}
}
7 changes: 7 additions & 0 deletions src/main/java/hu/rxd/toolbox/switcher/CDPMirrors.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ public String getComponentVersion(Version version, Component c) throws Exception
private static final List<String> MIRROR_ROOTS =
Lists.newArrayList(("http://cloudera-build-us-west-1.vpc.cloudera.com/s3/build"));

@Override
@Deprecated // pending renames
public Collection<Mirror> of0(Version ver) {
return of(ver);
}

//" centos7/3.x/updates/%s/artifacts.txt",stackVersion)"
@Deprecated
public static Collection<Mirror> of(Version ver) {
List<Mirror> ret = new ArrayList<>();
for (String root : MIRROR_ROOTS) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/hu/rxd/toolbox/switcher/DevMirrors.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package hu.rxd.toolbox.switcher;

import java.util.Collection;
import java.util.Collections;

public class DevMirrors implements Mirrors {

@Override
Expand All @@ -11,4 +14,10 @@ public String getComponentVersion(Version version, Component c) {
public String decodeStackVersion(String version) {
throw new RuntimeException("unimpl");
}

@Override
public Collection<Mirror> of0(Version ver) {
return Collections.EMPTY_LIST;
}

}
7 changes: 6 additions & 1 deletion src/main/java/hu/rxd/toolbox/switcher/GenericComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,15 @@ protected List<URL> getCandidateUrls(Version ver) throws Exception {
List<URL> 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());
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/hu/rxd/toolbox/switcher/HdpMirrors.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mirror> of0(Version ver) {
return of(ver);
}

@Deprecated
public static Collection<Mirror> of(Version ver) {
List<Mirror> ret = new ArrayList<>();
for (String root : MIRROR_ROOTS) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/hu/rxd/toolbox/switcher/Mirrors.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package hu.rxd.toolbox.switcher;

import java.util.Collection;

public interface Mirrors {

String getComponentVersion(Version version, Component c) throws Exception;
Expand All @@ -11,4 +13,6 @@ public interface Mirrors {
* for CDP this is by acquiring the build id
*/
public String decodeStackVersion(String version);

Collection<Mirror> of0(Version ver);
}

0 comments on commit 2b8248e

Please sign in to comment.