Execute.sleep(1000);
config.set("pagedb.node.list", "127.0.0.1:1091, 127.0.0.1:1090");
new DBCreator(1,catchers[1]).start();
while (done < 2) Execute.sleep(100);
Page page00 = PageTest.randomPage();
Page page01 = PageTest.randomPage();
Page page10 = PageTest.randomPage();
Page page11 = PageTest.randomPage();
page00.setUrl("http://example-"+tst+".com/test0=0");
page01.setUrl("http://example-"+tst+".com/test0=1");
page10.setUrl("http://example-"+tst+".com/test1=0");
page11.setUrl("http://example-"+tst+".com/test1=1");
dbs[0].addPage(page00);
dbs[0].addPage(page01);
dbs[1].addPage(page10);
dbs[1].addPage(page11);
Execute.sleep(1000);
done = 0;
new DBCloser(0).start();
new DBCloser(1).start();
while (done < 2) Execute.sleep(100);
PageDB db = new PageDB(dbNames[0]);
db.open(DPageDB.READ);
Iterator<Page> pages = db.iterator();
assertTrue("The first distributed pagedb should have two pages, yet it has none.", pages.hasNext());
Page page1 = pages.next();
assertTrue("One of the pages in the first distributed pagedb is not expected: "+page1.getUrl(), page1.equals(page00) || page1.equals(page10));
assertTrue("The first distributed pagedb should have two pages, yet it has one.", pages.hasNext());
Page page2 = pages.next();
assertTrue("One of the pages in the first distributed pagedb is not expected: "+page2.getUrl(), page2.equals(page00) || page2.equals(page10));
assertFalse("One of the pages in the first distributed pagedb has been cloned:"+page1.getUrl(), page1.equals(page2));
assertFalse("The first distributed pagedb should have two pages, yet it has more.", pages.hasNext());
db.close();
db = new PageDB(dbNames[1]);
db.open(DPageDB.READ);
pages = db.iterator();
assertTrue("The second distributed pagedb should have two pages, yet it has none.", pages.hasNext());
page1 = pages.next();
assertTrue("One of the pages in the second distributed pagedb is not expected: "+page1.getUrl(), page1.equals(page01) || page1.equals(page11));
assertTrue("The second distributed pagedb should have two pages, yet it has one.", pages.hasNext());
page2 = pages.next();
assertTrue("One of the pages in the second distributed pagedb is not expected: "+page2.getUrl(), page2.equals(page01) || page2.equals(page11));
assertFalse("One of the pages in the second distributed pagedb has been cloned:"+page1.getUrl(), page1.equals(page2));
assertFalse("The second pagedb should have two pages, yet it has more.", pages.hasNext());
db.close();
}
}