[virtualcommons-svn] SF.net SVN: virtualcommons:[66] csidex/trunk/src/main/java/edu/asu/commons
Status: Beta
Brought to you by:
alllee
From: <al...@us...> - 2008-11-18 00:21:12
|
Revision: 66 http://virtualcommons.svn.sourceforge.net/virtualcommons/?rev=66&view=rev Author: alllee Date: 2008-11-18 00:21:04 +0000 (Tue, 18 Nov 2008) Log Message: ----------- patching restoration of savefiles Modified Paths: -------------- csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedRoundData.java csidex/trunk/src/main/java/edu/asu/commons/net/NioDispatcher.java Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2008-10-29 23:37:17 UTC (rev 65) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/Persister.java 2008-11-18 00:21:04 UTC (rev 66) @@ -1,6 +1,7 @@ package edu.asu.commons.experiment; import java.io.File; +import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -176,23 +177,31 @@ logger.warning("Tried to restore a non-directory: " + directory); return; } - for (File saveDirectory : directory.listFiles()) { - if (saveDirectory.isDirectory()) { - // we are doing the "right thing", this is a directory of directories. - processSaveDirectory(saveDirectory, processors); + File[] subdirectories = directory.listFiles(new FileFilter() { + public boolean accept(File pathname) { + return pathname.isDirectory(); } - else { - // check to see if we are already in a save file directory - processSaveDirectory(directory, processors); + }); + if (subdirectories.length == 0) { + processSaveDirectory(directory, processors); + } + else { + for (File subdirectory: subdirectories) { + // recur on the subdirectory. + processSaveFiles(subdirectory, processors); } } } - + /** + * Processes the actual directory containing the save files. + * @param directory + * @param processors + */ private static void processSaveDirectory(File directory, List<SaveFileProcessor> processors) { try { - ExperimentConfiguration experimentConfiguration = restoreExperimentConfiguration(directory, DEFAULT_EXPERIMENT_CONFIGURATION_FILE); - int numberOfRounds = experimentConfiguration.getAllParameters().size(); +// ExperimentConfiguration experimentConfiguration = restoreExperimentConfiguration(directory, DEFAULT_EXPERIMENT_CONFIGURATION_FILE); + int numberOfRounds = restoreExperimentConfiguration(directory).getAllParameters().size(); for (int roundNumber = 0; roundNumber < numberOfRounds; roundNumber++) { SavedRoundData savedRoundData = restoreSavedRoundData(directory, roundNumber); String roundSaveFilePath = savedRoundData.getSaveFilePath(); @@ -210,7 +219,11 @@ logger.log(Level.SEVERE, "Error while processing [save directory: " + directory + "] - ignoring.", e); } } - + @SuppressWarnings("unchecked") + public static ExperimentConfiguration restoreExperimentConfiguration(File saveDirectory) { + return restoreExperimentConfiguration(saveDirectory, DEFAULT_EXPERIMENT_CONFIGURATION_FILE); + } + @SuppressWarnings("unchecked") public static ExperimentConfiguration restoreExperimentConfiguration(File saveDirectory, String experimentConfigurationFilename) { if (experimentConfigurationFilename == null || "".equals(experimentConfigurationFilename)) { experimentConfigurationFilename = DEFAULT_EXPERIMENT_CONFIGURATION_FILE; Modified: csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedRoundData.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedRoundData.java 2008-10-29 23:37:17 UTC (rev 65) +++ csidex/trunk/src/main/java/edu/asu/commons/experiment/SavedRoundData.java 2008-11-18 00:21:04 UTC (rev 66) @@ -10,6 +10,7 @@ import com.thoughtworks.xstream.XStream; import edu.asu.commons.conf.ExperimentRoundParameters; +import edu.asu.commons.event.ChatRequest; import edu.asu.commons.event.PersistableEvent; /** @@ -24,6 +25,7 @@ * @author <a href='mailto:All...@as...'>Allen Lee</a> * @version $Revision$ */ +@SuppressWarnings("unchecked") public class SavedRoundData implements Serializable { private static final long serialVersionUID = -2136359143854670064L; @@ -33,6 +35,7 @@ private ExperimentRoundParameters roundParameters; private DataModel dataModel; private SortedSet<PersistableEvent> actions; + private SortedSet<ChatRequest> chatRequests; private final String saveFilePath; private long roundStartTime; @@ -107,6 +110,8 @@ savedRoundData.setDataModel(dataModel); SortedSet<PersistableEvent> actions = (SortedSet<PersistableEvent>) stream.readObject(); savedRoundData.setActions(actions); + SortedSet<ChatRequest> chatRequests = (SortedSet<ChatRequest>) stream.readObject(); + savedRoundData.setChatRequests(chatRequests); // SavedRoundData savedRoundData = new SavedRoundData(roundSaveFilePath, roundParameters, dataModel, actions); return savedRoundData; } @@ -187,4 +192,12 @@ this.actions = actions; } } + + public SortedSet<ChatRequest> getChatRequests() { + return chatRequests; + } + + public void setChatRequests(SortedSet<ChatRequest> chatRequests) { + this.chatRequests = chatRequests; + } } Modified: csidex/trunk/src/main/java/edu/asu/commons/net/NioDispatcher.java =================================================================== --- csidex/trunk/src/main/java/edu/asu/commons/net/NioDispatcher.java 2008-10-29 23:37:17 UTC (rev 65) +++ csidex/trunk/src/main/java/edu/asu/commons/net/NioDispatcher.java 2008-11-18 00:21:04 UTC (rev 66) @@ -31,6 +31,9 @@ * are used to uniformly refer to the individual connections across the network. * The NioDispatcher is both a client and a server dispatcher, allowing p2p * connections. + * + * FIXME: replace WorkerPool implementation with 1.5 concurrency constructs + * instead from java.util.concurrent. * * @author <a href='All...@as...'>Allen Lee</a> * @version $Revision$ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |