Skip to content

Commit

Permalink
Merge branch 'nlnwa-issue141_fails_on_JDK8'
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger G. Coram committed Oct 16, 2014
2 parents eb79742 + 265d9fd commit caad6b6
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 41 deletions.
16 changes: 13 additions & 3 deletions src/site/xdoc/release_notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@
Full listing of changes and bug fixes are not available prior to release 1.2.0 and between release 1.6.0 and OpeWayback 2.0.0 BETA 1 release.
</p>
</section>

<section name="OpenWayback 2.0.0 Release">
<section name="OpenWayback 2.0.1 Release">
<subsection name="Features">
<ul>
</ul>
</subsection>
<subsection name="Bug Fixes">
<ul>
<li>Fixed building with JDK 8. <a href="https://github.com/iipc/openwayback/pull/141">#141</a></li>
</ul>
</subsection>
</section>
<section name="OpenWayback 2.0.0 Release">
<subsection name="Features">
<ul>
<li>Fixed URL resolution in ServerRelativeArchivalRedirect in non-ROOT context. <a href="https://github.com/iipc/openwayback/issues/92">#92</a>
Expand Down Expand Up @@ -48,7 +58,7 @@
<li>Fixed support for uncompressed ARCs files <a href="https://github.com/iipc/openwayback/issues/101">#101</a>
</li>
</ul>
</subsection>
</subsection>
</section>
<section name="OpenWayback 2.0.0 BETA 2 release">
<subsection name="Features">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,26 @@
import org.archive.wayback.util.url.AggressiveUrlCanonicalizer;

/**
*
*
* ResourceIndex which delegates queries to multiple partitioned remote indexes.
* <p>
* The remote index can be duplicated for failover and load balancing.
* Configuration is done with a map file which contains the range for each
* remote index partition and the urls to all instances of the partition.
* <p>
* <em>Format of mapfile:</em>
* <pre>
* &lt;partition name&gt; &lt;range start&gt; &lt;range end&gt; &lt;url to index partition&gt; [&lt;url to alternative index partition&gt; ...]
* </pre>
* <em>Example:</em>
* <pre>
* part_a apple.com/ http://part_a1.foo.com http://part_a2.foo.com
* part_b apple.com/ banana.com/ http://part_b1.foo.com http://part_b2.foo.com
* part_c banana.com/ cups.com/ http://part_c1.foo.com http://part_c2.foo.com
* part_d cups.com/ zorro.com/ http://part_d1.foo.com http://part_d2.foo.com
* </pre>
*
* @author brad
* @version $Date$, $Revision$
* @see org.archive.wayback.resourceindex.RemoteResourceIndex
*/
public class AlphaPartitionedIndex implements ResourceIndex {
private static final Logger LOGGER =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
public class RangeGroup implements ResourceIndex {

private HashMap<String,RangeMember> members = null;
HashMap<String,RangeMember> members = null;
private String name;
private String start;
private String end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,9 @@ public void setUrlBase(String urlBase) {
public void shutdown() throws IOException {
index.shutdown();
}

@Override
public String toString() {
return "RangeMember{urlBase=" + getUrlBase() + ", activeConnections=" + activeConnections + ", weight=" + getWeight() + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
*/
package org.archive.wayback.resourceindex.distributed;

import com.google.common.util.concurrent.Uninterruptibles;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import org.apache.commons.httpclient.URIException;
import org.archive.wayback.core.WaybackRequest;
Expand Down Expand Up @@ -87,87 +89,77 @@ public void testGroupBalance() throws Exception {
r.setRequestUrl(index.canonicalize("apple.com/"));
RangeGroup g = index.getRangeGroupForRequest(r);
assertEquals(g.getName(),"b");
RangeMember b1 = g.findBestMember();

RangeMember b1 = g.members.get("b1");
RangeMember b2 = g.members.get("b2");
assertEquals(b1.getUrlBase(),"b1");
assertEquals(b2.getUrlBase(),"b2");

b1.noteConnectionStart();
// b1 => 1
// b2 => 0
RangeMember b2 = g.findBestMember();
assertEquals(b2.getUrlBase(),"b2");
assertEquals(b2, g.findBestMember());
b2.noteConnectionStart();
// b1 => 1
// b2 => 1
b1.noteConnectionStart();
// b1 => 2
// b2 => 1
RangeMember b2_2 = g.findBestMember();
assertEquals(b2_2.getUrlBase(),"b2");
assertEquals(b2, g.findBestMember());
b1.noteConnectionSuccess();
// b1 => 1
// b2 => 1
RangeMember b1_2 = g.findBestMember();
assertEquals(b1_2.getUrlBase(),"b1");
b1.noteConnectionStart();
// b1 => 2
// b2 => 1
RangeMember b2_3 = g.findBestMember();
assertEquals(b2_3.getUrlBase(),"b2");
b2_3.noteConnectionStart();
assertEquals(b2, g.findBestMember());
b2.noteConnectionStart();
// b1 => 2
// b2 => 2
b1_2.noteConnectionSuccess();
b1.noteConnectionSuccess();
// b1 => 1
// b2 => 2
RangeMember b1_3 = g.findBestMember();
assertEquals(b1_3.getUrlBase(),"b1");
b1_3.noteConnectionStart();
assertEquals(b1, g.findBestMember());
b1.noteConnectionStart();
// b1 => 2
// b2 => 2
RangeMember b1_4 = g.findBestMember();
assertEquals(b1_4.getUrlBase(),"b1");
b1_4.noteConnectionStart();
b1.noteConnectionStart();
// b1 => 3
// b2 => 2
b2_3.noteConnectionSuccess();
b2.noteConnectionSuccess();
// b1 => 3
// b2 => 1
assertEquals(g.findBestMember().getUrlBase(),"b2");
assertEquals(b2, g.findBestMember());
g.findBestMember().noteConnectionStart();
// b1 => 3
// b2 => 2
assertEquals(g.findBestMember().getUrlBase(),"b2");
assertEquals(g.findBestMember().getUrlBase(),"b2");
assertEquals(b2, g.findBestMember());
assertEquals(b2, g.findBestMember());
g.findBestMember().noteConnectionStart();
// b1 => 3
// b2 => 3
assertEquals(g.findBestMember().getUrlBase(),"b1");
b1.noteConnectionSuccess();
// b1 => 2
// b2 => 3
assertEquals(g.findBestMember().getUrlBase(),"b1");
assertEquals(b1, g.findBestMember());
b1.noteConnectionFailure();
// b1 => 1-X
// b2 => 3
assertEquals(g.findBestMember().getUrlBase(),"b2");
assertEquals(b2, g.findBestMember());
b2.noteConnectionStart();
// b1 => 1-X
// b2 => 4
assertEquals(g.findBestMember().getUrlBase(),"b2");
assertEquals(b2, g.findBestMember());
b2.noteConnectionStart();
// b1 => 1-X
// b2 => 5

// HACKHACK: how to sleep for 1 ms?
long one = System.currentTimeMillis();
int two = 0;
while(System.currentTimeMillis() <= one) {
two++;
}
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.MILLISECONDS);

b1.noteConnectionSuccess();
// b1 => 0
// b2 => 5
assertEquals(g.findBestMember().getUrlBase(),"b1");
assertEquals(b1, g.findBestMember());
b1.noteConnectionStart();
// b1 => 1
// b2 => 5
Expand All @@ -178,11 +170,12 @@ public void testGroupBalance() throws Exception {
b1.noteConnectionStart();
// b1 => 6
// b2 => 5
assertEquals(g.findBestMember().getUrlBase(),"b2");
assertEquals(b2, g.findBestMember());
b2.noteConnectionStart();
// b1 => 6
// b2 => 6
assertEquals(g.findBestMember().getUrlBase(),"b1");
assertEquals(6, b1.getWeight());
assertEquals(6, b2.getWeight());
}

private void testFindRange(final AlphaPartitionedIndex apIndex,
Expand Down

0 comments on commit caad6b6

Please sign in to comment.