[tranche] r291 committed - Made default store datablocks 'false' so there would be no confusion w...

3 views
Skip to first unread message

tra...@googlecode.com

unread,
Jun 9, 2011, 8:36:10 PM6/9/11
to tranche-d...@googlegroups.com
Revision: 291
Author: bryan...@gmail.com
Date: Thu Jun 9 17:35:38 2011
Log: Made default store datablocks 'false' so there would be no
confusion when deploying. Updated LocalDataServer so can set whether or not
to store datablocks on startup as well.
http://code.google.com/p/tranche/source/detail?r=291

Modified:
/src/org/tranche/LocalDataServer.java
/src/org/tranche/flatfile/DataBlockUtil.java

=======================================
--- /src/org/tranche/LocalDataServer.java Tue Apr 27 10:26:55 2010
+++ /src/org/tranche/LocalDataServer.java Thu Jun 9 17:35:38 2011
@@ -19,6 +19,9 @@
import java.io.IOException;
import org.tranche.clc.TrancheServerCommandLineClient;
import org.tranche.commons.DebugUtil;
+import org.tranche.configuration.ConfigKeys;
+import org.tranche.configuration.Configuration;
+import org.tranche.flatfile.DataBlockUtil;
import org.tranche.flatfile.FlatFileTrancheServer;
import org.tranche.server.Server;
import org.tranche.servers.ServerUtil;
@@ -28,6 +31,7 @@
/**
* <p>There can be only one local data server.</p>
* @author James "Augie" Hill - augm...@gmail.com
+ * @author Bryan Smith - bes...@umich.edu
*/
public class LocalDataServer {

@@ -209,6 +213,7 @@
System.out.println(" -p, --port Value: positive
integer. The port number to which the server will be bound.");
System.out.println(" -s, --ssl Value:
true/false. Whether the server should operate over SSL
connections.");
System.out.println(" -z, --userzipfile Values: two
strings. The file system location of the user zip file for the
server and the passphrase to unlock it.");
+ System.out.println(" -r, --datablockrefs Value:
true/false. Whether to store datablock refs.");
System.out.println();
System.out.println("RETURN CODES");
System.out.println(" 0: Exited normally");
@@ -232,6 +237,8 @@
return;
}
}
+
+ boolean isStoreDataBlockReferences =
DataBlockUtil.DEFAULT_STORE_DATA_BLOCK_REFERENCES;

// flags first
for (int i = 0; i < args.length; i++) {
@@ -340,6 +347,20 @@
} else {
return;
}
+ } finally {
+ i++;
+ }
+ } else if (args[i].equals("-r") ||
args[i].equals("--datablockrefs")) {
+ try {
+ isStoreDataBlockReferences =
Boolean.valueOf(args[i + 1]);
+ } catch (Exception e) {
+ System.err.println("ERROR: Invalid boolean value
(isStoreDataBlockReferences): " + args[i + 1]);
+ DebugUtil.debugErr(LocalDataServer.class, e);
+ if (!TestUtil.isTesting()) {
+ System.exit(2);
+ } else {
+ return;
+ }
} finally {
i++;
}
@@ -365,6 +386,7 @@
// set up the local server
try {
setUpFFTS();
+ setStoreDataBlockReferences(isStoreDataBlockReferences);

// interact using a client -- will also start a server
around the FFTS
client = new TrancheServerCommandLineClient(ffts,
System.in, System.out);
@@ -394,4 +416,15 @@
}
}
}
-}
+
+ /**
+ *
+ * @param isUsingDataBlockReferences
+ */
+ private static void setStoreDataBlockReferences(boolean
isUsingDataBlockReferences) {
+ Configuration config =
getFlatFileTrancheServer().getConfiguration();
+ config.setValue(ConfigKeys.DATABLOCK_STORE_DATABLOCK_REFERENCES,
String.valueOf(isUsingDataBlockReferences));
+ getFlatFileTrancheServer().saveConfiguration();
+ System.out.println("Using datablock references?........... " +
getFlatFileTrancheServer().getConfiguration().getValue(ConfigKeys.DATABLOCK_STORE_DATABLOCK_REFERENCES));
+ }
+}
=======================================
--- /src/org/tranche/flatfile/DataBlockUtil.java Tue Jun 7 17:30:36 2011
+++ /src/org/tranche/flatfile/DataBlockUtil.java Thu Jun 9 17:35:38 2011
@@ -55,7 +55,7 @@
@Fix(problem = "Corrupted DataBlock files, almost certainly due to server
process interrupted rudely. These represented dead ends in b-tree, as they
would always fail when adding or getting chunks.", solution = "Detect
corrupted datablock in DataBlock.fillBytes, and throw as
UnexpectedEndOfDataBlockException. Selectly catch and add to
DataBlockUtil.repairCorruptedDataBlock, which will salvage.", day = 8,
month = 8, year = 2008, author = "Bryan Smith")
public class DataBlockUtil {

- public static final boolean DEFAULT_STORE_DATA_BLOCK_REFERENCES = true;
+ public static final boolean DEFAULT_STORE_DATA_BLOCK_REFERENCES =
false;
/**
* <p>When moving, data block must have this much free space before a
move is considered.</p>
*/

Reply all
Reply to author
Forward
0 new messages