forked from phoedos/pmd
getting closer
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@814 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -11,6 +11,8 @@ import net.jini.core.event.RemoteEventListener;
|
||||
import net.jini.core.event.RemoteEvent;
|
||||
import net.jini.core.event.UnknownEventException;
|
||||
import net.jini.core.entry.Entry;
|
||||
import net.jini.core.entry.UnusableEntryException;
|
||||
import net.jini.core.transaction.TransactionException;
|
||||
import net.sourceforge.pmd.cpd.*;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
@ -22,7 +24,6 @@ public class DCPDWorker {
|
||||
private Job currentJob;
|
||||
private TokenSetsWrapper tsw;
|
||||
private JavaSpace space;
|
||||
private TileWrapper tileWrapper;
|
||||
|
||||
public DCPDWorker() {
|
||||
try {
|
||||
@ -47,27 +48,32 @@ public class DCPDWorker {
|
||||
tsw = (TokenSetsWrapper)space.read(new TokenSetsWrapper(null, job.id), null, 100);
|
||||
System.out.println("Read a TokenSetsWrapper with " + tsw.tokenSets.size() + " token lists");
|
||||
|
||||
Entry twQuery = space.snapshot(new TileWrapper(null, null, job.id, TileWrapper.NOT_DONE, null, null, null));
|
||||
TileWrapper tileWrapper = null;
|
||||
while ((tileWrapper = (TileWrapper)space.take(twQuery, null, 100)) != null) {
|
||||
Occurrences results = expand(tileWrapper);
|
||||
for (Iterator i = results.getTiles();i.hasNext();) {
|
||||
Tile tile = (Tile)i.next();
|
||||
List theseOccurrences = marshal(results.getOccurrences(tile));
|
||||
int offset = 0;
|
||||
for (int j=0; j<theseOccurrences.size(); j++) {
|
||||
offset++;
|
||||
TileWrapper newTW = new TileWrapper(tile, theseOccurrences, job.id, TileWrapper.DONE, tileWrapper.sequenceNumber, new Integer(offset), new Integer(theseOccurrences.size()));
|
||||
space.write(newTW, null, Lease.FOREVER);
|
||||
System.out.println("wrote " + newTW.tile.getImage() + "(" + newTW.sequenceNumber + ":" + newTW.expansionNumber + "/" + newTW.expansionTotal+ ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("In doExpansion()");
|
||||
doExpansion();
|
||||
System.out.println("Done doExpansion()");
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void doExpansion() throws RemoteException, UnusableEntryException, TransactionException, InterruptedException{
|
||||
Entry twQuery = space.snapshot(new TileWrapper(null, null, currentJob.id, TileWrapper.NOT_DONE, null, null, null));
|
||||
|
||||
TileWrapper tileWrapper = null;
|
||||
while ((tileWrapper = (TileWrapper)space.take(twQuery, null, 100)) != null) {
|
||||
Occurrences results = expand(tileWrapper);
|
||||
for (Iterator i = results.getTiles();i.hasNext();) {
|
||||
Tile tile = (Tile)i.next();
|
||||
List theseOccurrences = marshal(results.getOccurrences(tile));
|
||||
for (int j=0; j<=theseOccurrences.size(); j++) {
|
||||
TileWrapper newTW = new TileWrapper(tile, theseOccurrences, currentJob.id, TileWrapper.DONE, tileWrapper.originalTilePosition, new Integer(j), new Integer(theseOccurrences.size()));
|
||||
space.write(newTW, null, Lease.FOREVER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List marshal(Iterator i) {
|
||||
List list = new ArrayList();
|
||||
while (i.hasNext()) {
|
||||
|
@ -62,9 +62,9 @@ public class DGST {
|
||||
addTileWrapperToOccurrences(tw, occ);
|
||||
|
||||
// now get tiles x:2..n - i.e., (5:2/3 and 5:3/3)
|
||||
for (int j = tw.expansionNumber.intValue()+1; j<tw.expansionTotal.intValue()+1; j++) {
|
||||
tw = (TileWrapper)space.take(new TileWrapper(null, null, job.id, TileWrapper.DONE, new Integer(i), new Integer(j), null), null, 100);
|
||||
addTileWrapperToOccurrences(tw, occ);
|
||||
for (int j = tw.expansionIndex.intValue()+1; j<tw.totalExpansions.intValue()+1; j++) {
|
||||
TileWrapper tw2 = (TileWrapper)space.take(new TileWrapper(null, null, job.id, TileWrapper.DONE, new Integer(i), new Integer(j), null), null, 100);
|
||||
addTileWrapperToOccurrences(tw2, occ);
|
||||
}
|
||||
}
|
||||
System.out.println("DONE GATHERING");
|
||||
|
@ -19,19 +19,19 @@ public class TileWrapper implements Entry {
|
||||
public Integer jobID;
|
||||
public List occurrences;
|
||||
public Integer isDone;
|
||||
public Integer sequenceNumber;
|
||||
public Integer expansionNumber;
|
||||
public Integer expansionTotal;
|
||||
public Integer originalTilePosition;
|
||||
public Integer expansionIndex;
|
||||
public Integer totalExpansions;
|
||||
|
||||
public TileWrapper() {}
|
||||
|
||||
public TileWrapper(Tile tile, List occurrences, Integer jobID, Integer isDone, Integer sequenceNumber, Integer expansionNumber, Integer expansionTotal) {
|
||||
public TileWrapper(Tile tile, List occurrences, Integer jobID, Integer isDone, Integer originalTilePosition, Integer expansionIndex, Integer totalExpansions) {
|
||||
this.tile = tile;
|
||||
this.jobID = jobID;
|
||||
this.occurrences = occurrences;
|
||||
this.isDone = isDone;
|
||||
this.sequenceNumber = sequenceNumber;
|
||||
this.expansionNumber = expansionNumber;
|
||||
this.expansionTotal = expansionTotal;
|
||||
this.originalTilePosition = originalTilePosition;
|
||||
this.expansionIndex = expansionIndex;
|
||||
this.totalExpansions = totalExpansions;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user