You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/01/22 08:36:26 UTC
svn commit: r1234456 [3/17] - in /incubator/isis/trunk/framework/runtimes:
dflt/bytecode/dflt/src/main/java/org/apache/isis/runtimes/dflt/bytecode/dflt/classsubstitutor/
dflt/bytecode/dflt/src/main/java/org/apache/isis/runtimes/dflt/bytecode/dflt/objec...
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/AesEncryption.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/AesEncryption.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/AesEncryption.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/AesEncryption.java Sun Jan 22 07:36:07 2012
@@ -32,37 +32,41 @@ public class AesEncryption implements Da
private static final String AES = "AES";
private final byte[] specKey;
-
+
public AesEncryption() {
- specKey = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
- 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 };
+ specKey = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 };
+ }
+
+ @Override
+ public void init(final IsisConfiguration configuration) {
}
- public void init(IsisConfiguration configuration) {}
-
+ @Override
public String getType() {
return AES;
}
- public String encrypt(String plainText) {
+ @Override
+ public String encrypt(final String plainText) {
try {
- SecretKeySpec key = new SecretKeySpec(specKey, AES);
- Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
+ final SecretKeySpec key = new SecretKeySpec(specKey, AES);
+ final Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
cipher.init(Cipher.ENCRYPT_MODE, key);
return new String(cipher.doFinal(plainText.getBytes()));
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new NoSqlStoreException(e);
}
}
- public String decrypt(String encryptedText) {
+ @Override
+ public String decrypt(final String encryptedText) {
try {
- SecretKeySpec key = new SecretKeySpec(specKey, AES);
- Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
+ final SecretKeySpec key = new SecretKeySpec(specKey, AES);
+ final Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
cipher.init(Cipher.DECRYPT_MODE, key);
- byte[] decrypted = cipher.doFinal(encryptedText.getBytes());
+ final byte[] decrypted = cipher.doFinal(encryptedText.getBytes());
return new String(decrypted);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new NoSqlStoreException(e);
}
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionAbstract.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionAbstract.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionAbstract.java Sun Jan 22 07:36:07 2012
@@ -25,41 +25,44 @@ import org.apache.isis.core.commons.conf
import org.apache.isis.runtimes.dflt.objectstores.nosql.DataEncryption;
import org.apache.isis.runtimes.dflt.objectstores.nosql.NoSqlStoreException;
-
public abstract class BlowfishEncryptionAbstract implements DataEncryption {
private static final String BLOWFISH = "Blowfish";
private byte[] specKey;
-
- public void init(IsisConfiguration configuration) {
+
+ @Override
+ public void init(final IsisConfiguration configuration) {
specKey = secretKey(configuration);
}
public abstract byte[] secretKey(IsisConfiguration configuration);
+ @Override
public String getType() {
return BLOWFISH;
}
+ @Override
public String encrypt(final String plainText) {
try {
- SecretKeySpec key = new SecretKeySpec(specKey, BLOWFISH);
- Cipher cipher = Cipher.getInstance(BLOWFISH);
+ final SecretKeySpec key = new SecretKeySpec(specKey, BLOWFISH);
+ final Cipher cipher = Cipher.getInstance(BLOWFISH);
cipher.init(Cipher.ENCRYPT_MODE, key);
return new String(cipher.doFinal(plainText.getBytes()));
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new NoSqlStoreException(e);
}
}
+ @Override
public String decrypt(final String encryptedText) {
try {
- SecretKeySpec key = new SecretKeySpec(specKey, BLOWFISH);
- Cipher cipher = Cipher.getInstance(BLOWFISH);
+ final SecretKeySpec key = new SecretKeySpec(specKey, BLOWFISH);
+ final Cipher cipher = Cipher.getInstance(BLOWFISH);
cipher.init(Cipher.DECRYPT_MODE, key);
- byte[] decrypted = cipher.doFinal(encryptedText.getBytes());
+ final byte[] decrypted = cipher.doFinal(encryptedText.getBytes());
return new String(decrypted);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new NoSqlStoreException(e);
}
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionUsingConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionUsingConfiguration.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionUsingConfiguration.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionUsingConfiguration.java Sun Jan 22 07:36:07 2012
@@ -22,13 +22,13 @@ import org.apache.isis.core.commons.conf
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.runtimes.dflt.objectstores.nosql.NoSqlStoreException;
-
public class BlowfishEncryptionUsingConfiguration extends BlowfishEncryptionAbstract {
- private static final String ENCRYPTION_KEY = ConfigurationConstants.ROOT + "nosql.encryption.blowfish-key";
+ private static final String ENCRYPTION_KEY = ConfigurationConstants.ROOT + "nosql.encryption.blowfish-key";
- public byte[] secretKey(IsisConfiguration configuration) {
- String key = configuration.getString(ENCRYPTION_KEY);
+ @Override
+ public byte[] secretKey(final IsisConfiguration configuration) {
+ final String key = configuration.getString(ENCRYPTION_KEY);
if (key == null) {
throw new NoSqlStoreException("No blowfish encryption key specified in the configuration file (key: " + ENCRYPTION_KEY + ")");
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionUsingKeyFile.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionUsingKeyFile.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionUsingKeyFile.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/BlowfishEncryptionUsingKeyFile.java Sun Jan 22 07:36:07 2012
@@ -27,23 +27,23 @@ import org.apache.isis.core.commons.conf
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.runtimes.dflt.objectstores.nosql.NoSqlStoreException;
-
public class BlowfishEncryptionUsingKeyFile extends BlowfishEncryptionAbstract {
private static final String ENCRYPTION_KEY_FILE = ConfigurationConstants.ROOT + "nosql.encryption.blowfish-key-file";
- public byte[] secretKey(IsisConfiguration configuration) {
- String fileName = configuration.getString(ENCRYPTION_KEY_FILE, "./blowfish.key");
- File file = new File(fileName);
+ @Override
+ public byte[] secretKey(final IsisConfiguration configuration) {
+ final String fileName = configuration.getString(ENCRYPTION_KEY_FILE, "./blowfish.key");
+ final File file = new File(fileName);
if (file.exists()) {
try {
- InputStream fileInput = new FileInputStream(file);
- byte[] buffer = new byte[1024];
- int length = fileInput.read(buffer);
- byte[] key = new byte[length];
+ final InputStream fileInput = new FileInputStream(file);
+ final byte[] buffer = new byte[1024];
+ final int length = fileInput.read(buffer);
+ final byte[] key = new byte[length];
System.arraycopy(buffer, 0, key, 0, length);
return key;
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new NoSqlStoreException("Failed to read in encryption file: " + file.getAbsolutePath(), e);
}
} else {
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/Rot13Encryption.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/Rot13Encryption.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/Rot13Encryption.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/encryption/Rot13Encryption.java Sun Jan 22 07:36:07 2012
@@ -23,21 +23,26 @@ import org.apache.isis.runtimes.dflt.obj
public class Rot13Encryption implements DataEncryption {
+ @Override
public String getType() {
return "rot13";
}
- public void init(IsisConfiguration configuration) {}
-
- public String encrypt(String plainText) {
+ @Override
+ public void init(final IsisConfiguration configuration) {
+ }
+
+ @Override
+ public String encrypt(final String plainText) {
return encode(plainText);
}
- public String decrypt(String encryptedText) {
+ @Override
+ public String decrypt(final String encryptedText) {
return encode(encryptedText);
}
- private String encode(String plainText) {
+ private String encode(final String plainText) {
if (plainText == null) {
return plainText;
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ClientConnection.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ClientConnection.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ClientConnection.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ClientConnection.java Sun Jan 22 07:36:07 2012
@@ -44,7 +44,6 @@ public class ClientConnection {
private String[] headers;
private int header;
-
public ClientConnection(final InputStream input, final OutputStream output) {
outputStream = Util.trace(output, true);
writer = new PrintWriter(new OutputStreamWriter(outputStream, Util.ENCODING));
@@ -89,7 +88,8 @@ public class ClientConnection {
throw new ObjectNotFoundException(message);
} else if (status.equals("concurrency")) {
final String data = getResponseData();
- // TODO create better exceptions (requires way to restore object/version)
+ // TODO create better exceptions (requires way to restore
+ // object/version)
if (data.startsWith("{")) {
throw new ConcurrencyException(data, (Throwable) null);
@@ -160,8 +160,7 @@ public class ClientConnection {
private String readNext() {
if (header >= headers.length) {
- throw new RemotingException("attempting to reader header property (index) " + header
- + " when there are only " + headers.length);
+ throw new RemotingException("attempting to reader header property (index) " + header + " when there are only " + headers.length);
}
return headers[header++];
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/FileClientCommandContext.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/FileClientCommandContext.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/FileClientCommandContext.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/FileClientCommandContext.java Sun Jan 22 07:36:07 2012
@@ -63,14 +63,14 @@ class FileClientCommandContext implement
private void write(final char command, final JsonStateWriter writer) {
connection.request(command, writer.getRequest());
- String data = writer.getData();
+ final String data = writer.getData();
- CRC32 inputChecksum = new CRC32();
+ final CRC32 inputChecksum = new CRC32();
inputChecksum.update(data.getBytes());
inputChecksum.update('\n');
- long checksum = inputChecksum.getValue();
- String code = Long.toHexString(checksum);
-
+ final long checksum = inputChecksum.getValue();
+ final String code = Long.toHexString(checksum);
+
connection.requestData("00000000".substring(0, 8 - code.length()) + code + data);
connection.endRequestSection();
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/FileServerDb.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/FileServerDb.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/FileServerDb.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/FileServerDb.java Sun Jan 22 07:36:07 2012
@@ -122,15 +122,15 @@ public class FileServerDb implements NoS
}
private String checkData(final String data) {
- String objectData = data.substring(8);
-
- CRC32 inputChecksum = new CRC32();
+ final String objectData = data.substring(8);
+
+ final CRC32 inputChecksum = new CRC32();
inputChecksum.update(objectData.getBytes());
- long actualChecksum = inputChecksum.getValue();
-
- String encodedChecksum = data.substring(0, 8);
- long expectedChecksum = Long.valueOf(encodedChecksum, 16);
-
+ final long actualChecksum = inputChecksum.getValue();
+
+ final String encodedChecksum = data.substring(0, 8);
+ final long expectedChecksum = Long.valueOf(encodedChecksum, 16);
+
if (actualChecksum != expectedChecksum) {
throw new NoSqlStoreException("Data integrity error; checksums different");
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/JsonStateReader.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/JsonStateReader.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/JsonStateReader.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/JsonStateReader.java Sun Jan 22 07:36:07 2012
@@ -29,7 +29,8 @@ import org.json.JSONException;
import org.json.JSONObject;
public class JsonStateReader implements StateReader {
- // private static final Logger LOG = Logger.getLogger(FileStateReader.class);
+ // private static final Logger LOG =
+ // Logger.getLogger(FileStateReader.class);
private JSONObject instance;
public JsonStateReader(final String data) {
@@ -112,7 +113,7 @@ public class JsonStateReader implements
throw new NoSqlStoreException("failed to read field _encrypt", e);
}
}
-
+
@Override
public String readUser() {
return readRequiredField("_user");
@@ -136,7 +137,7 @@ public class JsonStateReader implements
public List<StateReader> readCollection(final String id) {
final JSONArray array = instance.optJSONArray(id);
final List<StateReader> readers = new ArrayList<StateReader>();
- if (array !=null) {
+ if (array != null) {
final int size = array.length();
for (int i = 0; i < size; i++) {
readers.add(new JsonStateReader(array.optJSONObject(i)));
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/JsonStateWriter.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/JsonStateWriter.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/JsonStateWriter.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/JsonStateWriter.java Sun Jan 22 07:36:07 2012
@@ -29,7 +29,8 @@ import org.json.JSONObject;
public class JsonStateWriter implements StateWriter {
- // private static final Logger LOG = Logger.getLogger(FileStateWriter.class);
+ // private static final Logger LOG =
+ // Logger.getLogger(FileStateWriter.class);
private final JSONObject dbObject;
private String type;
@@ -65,10 +66,10 @@ public class JsonStateWriter implements
}
@Override
- public void writeEncryptionType(String type) {
+ public void writeEncryptionType(final String type) {
writeField("_encrypt", type);
}
-
+
@Override
public void writeVersion(final String currentVersion, final String newVersion) {
this.currentVersion = currentVersion;
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/DataFileReader.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/DataFileReader.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/DataFileReader.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/DataFileReader.java Sun Jan 22 07:36:07 2012
@@ -35,8 +35,8 @@ public class DataFileReader {
private final String version;
/**
- * Opens the file for the specified id. The top line contains: type id version newline The remainder contains the
- * data.
+ * Opens the file for the specified id. The top line contains: type id
+ * version newline The remainder contains the data.
*/
public DataFileReader(final String type, final String id) throws IOException {
final File file = Util.dataFile(type, id);
@@ -48,8 +48,7 @@ public class DataFileReader {
final String[] split = line.split(" ");
this.id = split[1];
if (!id.equals(id)) {
- throw new FileServerException("Id in file (" + this.id + ") not the same as the file name: "
- + file.getAbsolutePath());
+ throw new FileServerException("Id in file (" + this.id + ") not the same as the file name: " + file.getAbsolutePath());
}
version = split[2];
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileContent.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileContent.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileContent.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileContent.java Sun Jan 22 07:36:07 2012
@@ -33,8 +33,7 @@ class FileContent {
final String data;
final String type;
- public FileContent(final char command, final String id, final String currentVersion, final String newVersion,
- final String type, final String buf) {
+ public FileContent(final char command, final String id, final String currentVersion, final String newVersion, final String type, final String buf) {
this.command = command;
this.id = id;
this.currentVersion = currentVersion;
@@ -43,7 +42,7 @@ class FileContent {
this.data = buf;
}
- public void write(OutputStream output) throws IOException {
+ public void write(final OutputStream output) throws IOException {
output.write(type.getBytes(ENCODING));
output.write(' ');
output.write(id.getBytes(ENCODING));
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileServer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileServer.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileServer.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileServer.java Sun Jan 22 07:36:07 2012
@@ -61,7 +61,6 @@ import org.apache.isis.runtimes.dflt.obj
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
-
public class FileServer {
private static final Logger LOG = Logger.getLogger(FileServer.class);
@@ -79,15 +78,15 @@ public class FileServer {
options.addOption("h", "help", false, "Show this help");
options.addOption("m", "mode", true, "mode: normal | secondary | recovery | archive");
- CommandLineParser parser = new BasicParser();
- CommandLine cmd = parser.parse(options, args);
+ final CommandLineParser parser = new BasicParser();
+ final CommandLine cmd = parser.parse(options, args);
if (cmd.hasOption('h')) {
printHelp(options);
return;
}
- String mode = cmd.getOptionValue("m");
+ final String mode = cmd.getOptionValue("m");
if ("recovery".equals(mode)) {
final FileServer fileServer = new FileServer();
@@ -107,7 +106,7 @@ public class FileServer {
}
private static void printHelp(final Options options) {
- HelpFormatter help = new HelpFormatter();
+ final HelpFormatter help = new HelpFormatter();
help.printHelp("FileSever [OPTIONS] [FIRST RECOVERY FILES] [LAST RECOVERY FILES]", options);
}
@@ -142,22 +141,26 @@ public class FileServer {
private void startNormal() {
new Thread("control") {
+ @Override
public void run() {
startControl();
};
}.start();
new Thread("service") {
+ @Override
public void run() {
startService();
};
}.start();
new Thread("log-rolling") {
+ @Override
public void run() {
startLogRolling();
}
}.start();
if (config.getBoolean("fileserver.sync", false)) {
new Thread("sync") {
+ @Override
public void run() {
startSyncing();
};
@@ -169,10 +172,10 @@ public class FileServer {
}
private void startService() {
- String serviceHost = config.getString("fileserver.host", DEFAULT_HOST);
- int servicePort = config.getInt("fileserver.port", DEFAULT_SERVICE_PORT);
- int connectionTimeout = config.getInt("fileserver.connection.timeout", 5000);
- int readTimeout = config.getInt("fileserver.read.timeout", 5000);
+ final String serviceHost = config.getString("fileserver.host", DEFAULT_HOST);
+ final int servicePort = config.getInt("fileserver.port", DEFAULT_SERVICE_PORT);
+ final int connectionTimeout = config.getInt("fileserver.connection.timeout", 5000);
+ final int readTimeout = config.getInt("fileserver.read.timeout", 5000);
ServerSocket socket = null;
try {
@@ -182,10 +185,10 @@ public class FileServer {
socket.setSoTimeout(connectionTimeout);
LOG.info("listenting on " + socket.getInetAddress().getHostAddress() + " port " + socket.getLocalPort());
LOG.debug("listenting on " + socket);
- LogRange logFileRange = Util.logFileRange();
+ final LogRange logFileRange = Util.logFileRange();
if (!logFileRange.noLogFile()) {
- long lastRecoveryFile = logFileRange.getLast();
- File file = Util.logFile(lastRecoveryFile);
+ final long lastRecoveryFile = logFileRange.getLast();
+ final File file = Util.logFile(lastRecoveryFile);
LOG.info("replaying last recovery file: " + file.getAbsolutePath());
recover(file);
}
@@ -205,13 +208,15 @@ public class FileServer {
while (isQuiescent) {
try {
Thread.sleep(300);
- } catch (InterruptedException ignore) {}
+ } catch (final InterruptedException ignore) {
+ }
}
final Socket connection = socket.accept();
LOG.debug("connection from " + connection);
connection.setSoTimeout(readTimeout);
serviceConnection(connection, readTimeout);
- } catch (final SocketTimeoutException expected) {} catch (final IOException e) {
+ } catch (final SocketTimeoutException expected) {
+ } catch (final IOException e) {
LOG.error("networking problem", e);
}
} while (awaitConnections);
@@ -245,9 +250,9 @@ public class FileServer {
}
private void startSyncing() {
- String syncHost = config.getString("fileserver.sync-host", DEFAULT_HOST);
- int syncPort = config.getInt("fileserver.sync-port", DEFAULT_SYNC_PORT);
- int connectionTimeout = config.getInt("fileserver.connection.timeout", 5000);
+ final String syncHost = config.getString("fileserver.sync-host", DEFAULT_HOST);
+ final int syncPort = config.getInt("fileserver.sync-port", DEFAULT_SYNC_PORT);
+ final int connectionTimeout = config.getInt("fileserver.connection.timeout", 5000);
LOG.info("preparing to sync to secondary server on " + syncHost + " port " + syncPort);
@@ -266,14 +271,14 @@ public class FileServer {
socket = new Socket(address, syncPort);
LOG.info("sync connected to " + socket.getInetAddress().getHostAddress() + " port " + socket.getLocalPort());
- CRC32 crc32 = new CRC32();
- DataOutput output = new DataOutputStream(new CheckedOutputStream(socket.getOutputStream(), crc32));
- DataInput input = new DataInputStream(socket.getInputStream());
+ final CRC32 crc32 = new CRC32();
+ final DataOutput output = new DataOutputStream(new CheckedOutputStream(socket.getOutputStream(), crc32));
+ final DataInput input = new DataInputStream(socket.getInputStream());
output.writeByte(INIT);
long logId = input.readLong();
do {
- long nextLogId = logId + 1;
- File file = Util.logFile(nextLogId);
+ final long nextLogId = logId + 1;
+ final File file = Util.logFile(nextLogId);
if (file.exists() && server.getLogger().isWritten(nextLogId)) {
logId++;
@@ -282,9 +287,9 @@ public class FileServer {
output.writeLong(logId);
LOG.info("sending recovery file: " + file.getName());
- BufferedInputStream fileInput = new BufferedInputStream(new FileInputStream(file));
+ final BufferedInputStream fileInput = new BufferedInputStream(new FileInputStream(file));
- byte[] buffer = new byte[8092];
+ final byte[] buffer = new byte[8092];
int read;
while ((read = fileInput.read(buffer)) > 0) {
output.writeInt(read);
@@ -296,12 +301,14 @@ public class FileServer {
}
try {
Thread.sleep(300);
- } catch (InterruptedException ignore) {}
+ } catch (final InterruptedException ignore) {
+ }
while (isQuiescent) {
try {
Thread.sleep(300);
- } catch (InterruptedException ignore) {}
+ } catch (final InterruptedException ignore) {
+ }
}
} while (awaitConnections);
@@ -309,26 +316,29 @@ public class FileServer {
LOG.warn("not yet connected to secondary server at " + syncHost + " port " + syncPort);
try {
Thread.sleep(connectionTimeout);
- } catch (InterruptedException ignore) {}
+ } catch (final InterruptedException ignore) {
+ }
} catch (final IOException e) {
LOG.error("start failure - networking not set up for " + syncHost, e);
try {
Thread.sleep(300);
- } catch (InterruptedException ignore) {}
+ } catch (final InterruptedException ignore) {
+ }
} catch (final RuntimeException e) {
LOG.error("start failure", e);
try {
Thread.sleep(300);
- } catch (InterruptedException ignore) {}
+ } catch (final InterruptedException ignore) {
+ }
}
}
}
private void startControl() {
- String controlHost = config.getString("fileserver.control-host", DEFAULT_HOST);
- int controlPort = config.getInt("fileserver.control-port", DEFAULT_CONTROL_PORT);
- int connectionTimeout = config.getInt("fileserver.connection.timeout", 5000);
+ final String controlHost = config.getString("fileserver.control-host", DEFAULT_HOST);
+ final int controlPort = config.getInt("fileserver.control-port", DEFAULT_CONTROL_PORT);
+ final int connectionTimeout = config.getInt("fileserver.connection.timeout", 5000);
ServerSocket socket = null;
try {
@@ -353,7 +363,8 @@ public class FileServer {
final Socket connection = socket.accept();
LOG.info("control connection from " + connection);
controlConnection(connection);
- } catch (final SocketTimeoutException expected) {} catch (final IOException e) {
+ } catch (final SocketTimeoutException expected) {
+ } catch (final IOException e) {
LOG.error("networking problem", e);
}
} while (awaitConnections);
@@ -377,7 +388,7 @@ public class FileServer {
break;
} else if ("quiesce".equals(line)) {
isQuiescent = true;
- String message = "Placing server in a quiescent state";
+ final String message = "Placing server in a quiescent state";
LOG.info(message);
print.println(message);
print.print("> ");
@@ -385,7 +396,7 @@ public class FileServer {
} else if ("resume".equals(line)) {
if (isQuiescent) {
isQuiescent = false;
- String message = "Resuming from a quiescent state";
+ final String message = "Resuming from a quiescent state";
LOG.info(message);
print.println(message);
} else {
@@ -421,20 +432,20 @@ public class FileServer {
}
}
- private void startRecovery(List list) {
+ private void startRecovery(final List list) {
LOG.info("starting recovery");
final LogRange logFileRange = Util.logFileRange();
if (logFileRange.noLogFile()) {
System.err.println("No recovery files found");
System.exit(0);
}
- long lastId = logFileRange.getLast();
+ final long lastId = logFileRange.getLast();
LOG.info("last log file is " + Util.logFile(lastId).getName());
long startId = lastId;
long endId = lastId;
- int size = list.size();
+ final int size = list.size();
if (size > 0) {
startId = Long.valueOf((String) list.get(0));
if (size > 1) {
@@ -452,27 +463,26 @@ public class FileServer {
Util.ensureDirectoryExists();
for (long id = startId; id <= endId; id++) {
- File file = Util.logFile(id);
+ final File file = Util.logFile(id);
LOG.info("recovering data from " + file.getName());
recover(file);
}
LOG.info("recovery complete");
}
-
- private void startArchive(List list) {
+ private void startArchive(final List list) {
LOG.info("starting archiving");
final LogRange logFileRange = Util.logFileRange();
if (logFileRange.noLogFile()) {
System.err.println("No recovery files found");
System.exit(0);
}
- long lastId = logFileRange.getLast();
+ final long lastId = logFileRange.getLast();
LOG.info("last log file is " + Util.logFile(lastId).getName());
long endId = lastId - 1;
- int size = list.size();
+ final int size = list.size();
if (size > 0) {
endId = Long.valueOf((String) list.get(0));
}
@@ -480,20 +490,20 @@ public class FileServer {
System.err.println("File ID invalid: they must be less that " + lastId);
System.exit(0);
}
- long startId = logFileRange.getFirst();
+ final long startId = logFileRange.getFirst();
for (long id = startId; id <= endId; id++) {
- File file = Util.logFile(id);
+ final File file = Util.logFile(id);
LOG.info("moving " + file.getName());
- File destination = Util.archiveLogFile(id);
+ final File destination = Util.archiveLogFile(id);
file.renameTo(destination);
}
LOG.info("archive complete");
}
-
+
private void startSecondary() {
- String serviceHost = config.getString("fileserver.sync-host", DEFAULT_HOST);
- int servicePort = config.getInt("fileserver.sync-port", DEFAULT_SYNC_PORT);
+ final String serviceHost = config.getString("fileserver.sync-host", DEFAULT_HOST);
+ final int servicePort = config.getInt("fileserver.sync-port", DEFAULT_SYNC_PORT);
Util.ensureDirectoryExists();
ServerSocket socket = null;
@@ -528,20 +538,20 @@ public class FileServer {
return;
}
- LogRange logFileRange = Util.logFileRange();
- long lastId = logFileRange.noLogFile() ? -1 : logFileRange.getLast();
+ final LogRange logFileRange = Util.logFileRange();
+ final long lastId = logFileRange.noLogFile() ? -1 : logFileRange.getLast();
output.writeLong(lastId);
do {
if (input.readByte() != RECOVERY_LOG) {
return;
}
crc32.reset();
- long logId = input.readLong();
- File file = Util.tmpLogFile(logId);
+ final long logId = input.readLong();
+ final File file = Util.tmpLogFile(logId);
LOG.info("syncing recovery file: " + file.getName());
- BufferedOutputStream fileOutput = new BufferedOutputStream(new FileOutputStream(file));
+ final BufferedOutputStream fileOutput = new BufferedOutputStream(new FileOutputStream(file));
- byte[] buffer = new byte[8092];
+ final byte[] buffer = new byte[8092];
int length;
while ((length = input.readInt()) > 0) {
input.readFully(buffer, 0, length);
@@ -549,14 +559,14 @@ public class FileServer {
}
fileOutput.close();
- long calculatedChecksum = crc32.getValue();
- long sentChecksum = input.readLong();
+ final long calculatedChecksum = crc32.getValue();
+ final long sentChecksum = input.readLong();
if (calculatedChecksum != sentChecksum) {
throw new NoSqlStoreException("Checksum didn't match during download of " + file.getName());
}
recover(file);
- File renameTo = Util.logFile(logId);
+ final File renameTo = Util.logFile(logId);
file.renameTo(renameTo);
} while (true);
} catch (final NoSqlStoreException e) {
@@ -576,13 +586,13 @@ public class FileServer {
// TODO restart
}
- private void recover(File file) {
+ private void recover(final File file) {
LineNumberReader reader = null;
try {
reader = new LineNumberReader(new InputStreamReader(new FileInputStream(file), Util.ENCODING));
while (true) {
- String line = reader.readLine();
+ final String line = reader.readLine();
if (line == null) {
break;
}
@@ -591,13 +601,13 @@ public class FileServer {
}
readTransaction(reader);
}
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new NoSqlStoreException(e);
} finally {
if (reader != null) {
try {
reader.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new NoSqlStoreException(e);
}
}
@@ -633,12 +643,11 @@ public class FileServer {
files.add(elementData);
}
}
- LOG.warn("transaction has no ending marker so is incomplete and will not be restored (ending " + reader.getLineNumber()
- + ")");
+ LOG.warn("transaction has no ending marker so is incomplete and will not be restored (ending " + reader.getLineNumber() + ")");
}
private FileContent readElementData(final String header, final LineNumberReader reader) throws IOException {
- StringBuffer content = new StringBuffer();
+ final StringBuffer content = new StringBuffer();
String line;
while ((line = reader.readLine()) != null) {
if (line.length() == 0) {
@@ -657,17 +666,18 @@ public class FileServer {
}
private void startLogRolling() {
- int rollPeriod = config.getInt("fileserver.log-period", 5);
- long sleepTime = rollPeriod * 60 * 1000;
+ final int rollPeriod = config.getInt("fileserver.log-period", 5);
+ final long sleepTime = rollPeriod * 60 * 1000;
while (awaitConnections) {
- LogWriter logger = server.getLogger();
+ final LogWriter logger = server.getLogger();
if (logger != null) {
logger.startNewFile();
}
try {
Thread.sleep(sleepTime);
- } catch (InterruptedException ignore) {}
+ } catch (final InterruptedException ignore) {
+ }
}
}
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileServerProcessor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileServerProcessor.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileServerProcessor.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/FileServerProcessor.java Sun Jan 22 07:36:07 2012
@@ -54,7 +54,7 @@ public class FileServerProcessor {
locks.waitUntilAllRealeased();
logger.shutdown();
}
-
+
LogWriter getLogger() {
return logger;
}
@@ -65,41 +65,41 @@ public class FileServerProcessor {
connection.readCommand();
final char command = connection.getCommand();
switch (command) {
- case 'L':
- list(connection);
- break;
-
- case 'R':
- read(connection);
- break;
-
- case 'W':
- write(connection);
- break;
-
- case 'I':
- hasInstances(connection);
- break;
-
- case 'S':
- service(connection);
- break;
-
- case 'T':
- saveService(connection);
- break;
-
- case 'N':
- nextSerialBatch(connection);
- break;
-
- case 'X':
- status(connection);
- break;
-
- default:
- LOG.warn("Unrecognised command " + command);
- connection.error("Unrecognised command " + command);
+ case 'L':
+ list(connection);
+ break;
+
+ case 'R':
+ read(connection);
+ break;
+
+ case 'W':
+ write(connection);
+ break;
+
+ case 'I':
+ hasInstances(connection);
+ break;
+
+ case 'S':
+ service(connection);
+ break;
+
+ case 'T':
+ saveService(connection);
+ break;
+
+ case 'N':
+ nextSerialBatch(connection);
+ break;
+
+ case 'X':
+ status(connection);
+ break;
+
+ default:
+ LOG.warn("Unrecognised command " + command);
+ connection.error("Unrecognised command " + command);
}
} else {
connection.abort();
@@ -177,8 +177,7 @@ public class FileServerProcessor {
}
- private DataFileReader findInstance(final String type, final String id, final ServerConnection connection)
- throws IOException {
+ private DataFileReader findInstance(final String type, final String id, final ServerConnection connection) throws IOException {
LOG.debug("reading file " + id);
locks.acquireRead(id, getTransactionId());
try {
@@ -247,8 +246,7 @@ public class FileServerProcessor {
if (!version.equals(item.currentVersion)) {
// String data = dataReader.getData();
dataReader.close();
- return "mismatch between FileContent version (" + item.currentVersion
- + ") and DataReader version (" + version + ")";
+ return "mismatch between FileContent version (" + item.currentVersion + ") and DataReader version (" + version + ")";
}
dataReader.close();
}
@@ -317,8 +315,7 @@ public class FileServerProcessor {
connection.ok();
}
- void saveService(final String key, final String name) throws FileNotFoundException, IOException,
- UnsupportedEncodingException {
+ void saveService(final String key, final String name) throws FileNotFoundException, IOException, UnsupportedEncodingException {
FileOutputStream fileOut = null;
final File file = Util.serviceFile(name);
try {
@@ -350,8 +347,7 @@ public class FileServerProcessor {
nextId = 1;
LOG.info("Initial ID batch created at " + nextId);
} else {
- final BufferedReader reader =
- new BufferedReader(new InputStreamReader(new FileInputStream(file), Util.ENCODING));
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), Util.ENCODING));
nextId = Long.valueOf(reader.readLine()).longValue();
reader.close();
LOG.info("New ID batch allocated, from " + nextId);
@@ -359,7 +355,7 @@ public class FileServerProcessor {
final long newBatchAt = nextId + batchSize;
logger.logNextSerialBatch(name, newBatchAt);
-
+
saveNextBatch(file, newBatchAt);
// TODO remove lock
@@ -373,7 +369,7 @@ public class FileServerProcessor {
fileOutput.close();
}
- public void saveNextBatch(String name, long nextBatch) throws IOException {
+ public void saveNextBatch(final String name, final long nextBatch) throws IOException {
saveNextBatch(Util.serialNumberFile(name), nextBatch);
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/LogRange.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/LogRange.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/LogRange.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/LogRange.java Sun Jan 22 07:36:07 2012
@@ -21,11 +21,11 @@ package org.apache.isis.runtimes.dflt.ob
class LogRange {
private long first = Long.MAX_VALUE;
private long last = 0;
-
+
public long getFirst() {
return first;
}
-
+
public long getLast() {
return last;
}
@@ -34,9 +34,8 @@ class LogRange {
return first == Long.MAX_VALUE && last == 0;
}
- public void add(long sequence) {
+ public void add(final long sequence) {
last = Math.max(last, sequence);
first = Math.min(first, sequence);
}
}
-
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/LogWriter.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/LogWriter.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/LogWriter.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/LogWriter.java Sun Jan 22 07:36:07 2012
@@ -36,13 +36,13 @@ public class LogWriter {
public void startNewFile() {
// don't start new file if old one is empty
- File file = Util.logFile(nextLogIdToWrite);
+ final File file = Util.logFile(nextLogIdToWrite);
if (file.exists() && file.length() > 0) {
startNewFile = true;
}
}
- public synchronized void logNextSerialBatch(String name, long newBatchAt) {
+ public synchronized void logNextSerialBatch(final String name, final long newBatchAt) {
startNewFileIfNeeded();
try {
writer.write(("#transaction started - " + new Date().toString() + "\n").getBytes());
@@ -60,7 +60,7 @@ public class LogWriter {
}
- public synchronized void logServiceEntry(String key, String name) {
+ public synchronized void logServiceEntry(final String key, final String name) {
startNewFileIfNeeded();
try {
writer.write(("#transaction started - " + new Date().toString() + "\n").getBytes());
@@ -103,14 +103,14 @@ public class LogWriter {
private void openNewFile() {
nextLogIdToWrite++;
- File file = Util.logFile(nextLogIdToWrite);
+ final File file = Util.logFile(nextLogIdToWrite);
if (file.exists()) {
throw new NoSqlStoreException("Log file already exists");
}
openFile(file);
}
- private void openFile(File file) {
+ private void openFile(final File file) {
try {
writer = new DataOutputStream(new FileOutputStream(file));
startNewFile = false;
@@ -123,7 +123,7 @@ public class LogWriter {
nextLogIdToWrite = Util.logFileRange().getLast();
startNewFile();
if (!startNewFile) {
- File file = Util.logFile(nextLogIdToWrite);
+ final File file = Util.logFile(nextLogIdToWrite);
openFile(file);
} else {
openNewFile();
@@ -142,7 +142,7 @@ public class LogWriter {
}
}
- public synchronized boolean isWritten(long logId) {
+ public synchronized boolean isWritten(final long logId) {
startNewFileIfNeeded();
return logId < nextLogIdToWrite;
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/ServerConnection.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/ServerConnection.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/ServerConnection.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/ServerConnection.java Sun Jan 22 07:36:07 2012
@@ -151,9 +151,11 @@ public class ServerConnection {
}
/*
- * public void getTermination() { try { String line = reader.readLine(); if (line == null || !line.equals("***")) {
- * logFailure(); throw new RemotingException("stream ended abruptly while reading data, aborting request"); } }
- * catch (IOException e) { logFailure(); throw new RemotingException(e); }
+ * public void getTermination() { try { String line = reader.readLine(); if
+ * (line == null || !line.equals("***")) { logFailure(); throw new
+ * RemotingException
+ * ("stream ended abruptly while reading data, aborting request"); } } catch
+ * (IOException e) { logFailure(); throw new RemotingException(e); }
*
* }
*/
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/Util.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/Util.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/Util.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/server/Util.java Sun Jan 22 07:36:07 2012
@@ -30,7 +30,6 @@ import java.nio.charset.Charset;
import org.apache.isis.runtimes.dflt.objectstores.nosql.NoSqlStoreException;
import org.apache.log4j.Logger;
-
public class Util {
private static final Logger LOG = Logger.getLogger(Util.class);
@@ -171,21 +170,22 @@ public class Util {
return new File(logDirectory, "recovery" + id + ".log.tmp");
}
- public static File archiveLogFile(long id) {
+ public static File archiveLogFile(final long id) {
return new File(logArchiveDirectory, "recovery" + id + ".log");
}
static LogRange logFileRange() {
- LogRange logRange = new LogRange();
- File[] listFiles = logDirectory.listFiles();
+ final LogRange logRange = new LogRange();
+ final File[] listFiles = logDirectory.listFiles();
if (listFiles != null) {
- for (File file : listFiles) {
- String name = file.getName();
- String substring = name.substring(8, name.length() - 4);
+ for (final File file : listFiles) {
+ final String name = file.getName();
+ final String substring = name.substring(8, name.length() - 4);
try {
- long sequence = Long.parseLong(substring);
+ final long sequence = Long.parseLong(substring);
logRange.add(sequence);
- } catch (NumberFormatException ignore) {}
+ } catch (final NumberFormatException ignore) {
+ }
}
}
return logRange;
@@ -220,7 +220,8 @@ public class Util {
private void log(final int b) {
log.append(b < 32 ? ("<" + b + ">" + (char) b) : (char) b);
- // System.out.print(b < 32 ? ("<" + b + ">" + (char) b) : (char) b);
+ // System.out.print(b < 32 ? ("<" + b + ">" + (char) b) : (char)
+ // b);
}
@Override
@@ -276,7 +277,8 @@ public class Util {
private void log(final int b) {
log.append(b < 32 ? ("<" + b + ">" + (char) b) : (char) b);
- // System.out.print(b < 32 ? ("<" + b + ">" + (char) b) : (char) b);
+ // System.out.print(b < 32 ? ("<" + b + ">" + (char) b) : (char)
+ // b);
}
@Override
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/mongo/MongoStateReader.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/mongo/MongoStateReader.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/mongo/MongoStateReader.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/mongo/MongoStateReader.java Sun Jan 22 07:36:07 2012
@@ -72,7 +72,7 @@ public class MongoStateReader implements
public String readEncrytionType() {
return (String) instance.get("_encrypt");
}
-
+
@Override
public String readObjectType() {
return (String) instance.get("_type");
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/mongo/MongoStateWriter.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/mongo/MongoStateWriter.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/mongo/MongoStateWriter.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/main/java/org/apache/isis/runtimes/dflt/objectstores/nosql/mongo/MongoStateWriter.java Sun Jan 22 07:36:07 2012
@@ -64,8 +64,10 @@ public class MongoStateWriter implements
dbObject.put(id, Long.toString(l));
}
- public void writeEncryptionType(String type) {}
-
+ @Override
+ public void writeEncryptionType(final String type) {
+ }
+
@Override
public void writeVersion(final String currentVersion, final String newVersion) {
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/DestroyObjectCommandImplementationTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/DestroyObjectCommandImplementationTest.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/DestroyObjectCommandImplementationTest.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/DestroyObjectCommandImplementationTest.java Sun Jan 22 07:36:07 2012
@@ -45,8 +45,7 @@ public class DestroyObjectCommandImpleme
@Test
public void testname() throws Exception {
- final ObjectSpecification specification =
- IsisContext.getSpecificationLoader().loadSpecification(ExampleReferencePojo.class);
+ final ObjectSpecification specification = IsisContext.getSpecificationLoader().loadSpecification(ExampleReferencePojo.class);
final ObjectAdapter object = IsisContext.getPersistenceSession().createInstance(specification);
IsisContext.getPersistenceSession().makePersistent(object);
object.setOptimisticLock(new SerialNumberVersion(3, "username", new Date(1000)));
@@ -62,8 +61,7 @@ public class DestroyObjectCommandImpleme
}
});
- final NoSqlDestroyObjectCommand command =
- new NoSqlDestroyObjectCommand(new SerialKeyCreator(), new SerialNumberVersionCreator(), object);
+ final NoSqlDestroyObjectCommand command = new NoSqlDestroyObjectCommand(new SerialKeyCreator(), new SerialNumberVersionCreator(), object);
command.execute(commandContext);
}
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/NoSqlObjectStoreTest.java Sun Jan 22 07:36:07 2012
@@ -19,6 +19,10 @@
package org.apache.isis.runtimes.dflt.objectstores.nosql;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -41,10 +45,6 @@ import org.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
public class NoSqlObjectStoreTest {
private Mockery context;
@@ -78,26 +78,30 @@ public class NoSqlObjectStoreTest {
});
keyCreator = context.mock(KeyCreator.class);
versionCreator = context.mock(VersionCreator.class);
-
- Map<String, DataEncryption> dataEncrypter = new HashMap<String, DataEncryption>();
- DataEncryption dataEncrypter1 = new DataEncryption() {
+
+ final Map<String, DataEncryption> dataEncrypter = new HashMap<String, DataEncryption>();
+ final DataEncryption dataEncrypter1 = new DataEncryption() {
+ @Override
public String getType() {
return "etc";
}
- public void init(IsisConfiguration configuration) {}
-
- public String encrypt(String plainText) {
+ @Override
+ public void init(final IsisConfiguration configuration) {
+ }
+
+ @Override
+ public String encrypt(final String plainText) {
throw new UnexpectedCallException();
}
- public String decrypt(String encryptedText) {
+ @Override
+ public String decrypt(final String encryptedText) {
return encryptedText.substring(3);
}
};
dataEncrypter.put(dataEncrypter1.getType(), dataEncrypter1);
-
store = new NoSqlObjectStore(db, new NoSqlOidGenerator(db), keyCreator, versionCreator, null, dataEncrypter);
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReaderTest.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReaderTest.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/ObjectReaderTest.java Sun Jan 22 07:36:07 2012
@@ -19,6 +19,9 @@
package org.apache.isis.runtimes.dflt.objectstores.nosql;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -39,9 +42,6 @@ import org.jmock.Mockery;
import org.junit.Before;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
public class ObjectReaderTest {
private ObjectReader objectReader;
@@ -63,21 +63,25 @@ public class ObjectReaderTest {
objectReader = new ObjectReader();
keyCreator = context.mock(KeyCreator.class);
versionCreator = context.mock(VersionCreator.class);
-
-
+
dataEncrypter = new HashMap<String, DataEncryption>();
- DataEncryption dataEncrypter1 = new DataEncryption() {
+ final DataEncryption dataEncrypter1 = new DataEncryption() {
+ @Override
public String getType() {
return "etc1";
}
- public void init(IsisConfiguration configuration) {}
-
- public String encrypt(String plainText) {
+ @Override
+ public void init(final IsisConfiguration configuration) {
+ }
+
+ @Override
+ public String encrypt(final String plainText) {
throw new UnexpectedCallException();
}
- public String decrypt(String encryptedText) {
+ @Override
+ public String decrypt(final String encryptedText) {
return encryptedText.substring(3);
}
};
@@ -176,8 +180,7 @@ public class ObjectReaderTest {
@Test
public void testReadingCollection() throws Exception {
- final ObjectSpecification specification =
- IsisContext.getSpecificationLoader().loadSpecification(ExampleValuePojo.class);
+ final ObjectSpecification specification = IsisContext.getSpecificationLoader().loadSpecification(ExampleValuePojo.class);
reader2 = context.mock(StateReader.class, "reader 2");
context.checking(new Expectations() {
{
@@ -250,8 +253,7 @@ public class ObjectReaderTest {
});
final ObjectSpecification specification = IsisContext.getSpecificationLoader().loadSpecification(ExampleValuePojo.class);
- final ObjectAdapter readObject = IsisContext.getPersistenceSession().recreateAdapter(SerialOid.createPersistent(4),
- specification);
+ final ObjectAdapter readObject = IsisContext.getPersistenceSession().recreateAdapter(SerialOid.createPersistent(4), specification);
objectReader.update(reader1, keyCreator, versionCreator, dataEncrypter, readObject);
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/SystemTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/SystemTest.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/SystemTest.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/SystemTest.java Sun Jan 22 07:36:07 2012
@@ -42,8 +42,7 @@ public class SystemTest {
@Test
public void test() {
- final ObjectSpecification specification =
- IsisContext.getSpecificationLoader().loadSpecification(ExampleReferencePojo.class);
+ final ObjectSpecification specification = IsisContext.getSpecificationLoader().loadSpecification(ExampleReferencePojo.class);
final ObjectAdapter object = IsisContext.getPersistenceSession().createInstance(specification);
final DebugBuilder debug = new DebugString();
@@ -52,7 +51,8 @@ public class SystemTest {
/*
* System.out.println(debug);
*
- * System.out.println(Dump.adapter(object)); System.out.println(Dump.specification(object));
+ * System.out.println(Dump.adapter(object));
+ * System.out.println(Dump.specification(object));
*/
}
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/TrialObjects.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/TrialObjects.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/TrialObjects.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/TrialObjects.java Sun Jan 22 07:36:07 2012
@@ -65,8 +65,7 @@ public class TrialObjects {
}
@Override
- public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter,
- final IdentifiedHolder identifiedHolder) {
+ public ObjectAdapter adapterFor(final Object pojo, final ObjectAdapter ownerAdapter, final IdentifiedHolder identifiedHolder) {
if (adapters.get(pojo) != null) {
return adapters.get(pojo);
} else {
@@ -89,10 +88,7 @@ public class TrialObjects {
}
};
- reflector =
- new ObjectReflectorDefault(configuration, new TestClassSubstitutor(), new CollectionTypeRegistryDefault(),
- new SpecificationTraverserDefault(), new MemberLayoutArrangerDefault(),
- new ProgrammingModelFacetsJava5(), new HashSet<FacetDecorator>(), new MetaModelValidatorDefault());
+ reflector = new ObjectReflectorDefault(configuration, new TestClassSubstitutor(), new CollectionTypeRegistryDefault(), new SpecificationTraverserDefault(), new MemberLayoutArrangerDefault(), new ProgrammingModelFacetsJava5(), new HashSet<FacetDecorator>(), new MetaModelValidatorDefault());
reflector.setRuntimeContext(new RuntimeContextNoRuntime() {
@Override
@@ -106,8 +102,7 @@ public class TrialObjects {
@Override
public ObjectAdapter createAdapter(final Object pojo, final Oid oid) {
final ObjectSpecification specification = reflector.loadSpecification(pojo.getClass());
- final ResolveState state =
- oid == null ? ResolveState.VALUE : oid.isTransient() ? ResolveState.TRANSIENT : ResolveState.GHOST;
+ final ResolveState state = oid == null ? ResolveState.VALUE : oid.isTransient() ? ResolveState.TRANSIENT : ResolveState.GHOST;
final TestProxyAdapter objectAdapter = new TestProxyAdapter();
objectAdapter.setupResolveState(state);
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/WriteObjectCommandTest.java Sun Jan 22 07:36:07 2012
@@ -97,19 +97,24 @@ public class WriteObjectCommandTest {
will(returnValue("1057"));
}
});
-
+
dataEncrypter = new DataEncryption() {
+ @Override
public String getType() {
return "etc1";
}
-
- public void init(IsisConfiguration configuration) {}
-
- public String encrypt(String plainText) {
+
+ @Override
+ public void init(final IsisConfiguration configuration) {
+ }
+
+ @Override
+ public String encrypt(final String plainText) {
return "ENC" + plainText;
}
- public String decrypt(String encryptedText) {
+ @Override
+ public String decrypt(final String encryptedText) {
throw new UnexpectedCallException();
}
};
@@ -136,7 +141,7 @@ public class WriteObjectCommandTest {
one(writer).writeUser("username");
one(writer).writeTime("1057");
one(writer).writeEncryptionType("etc1");
-
+
one(commandContext).insert(writer);
}
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ChecksummingPerfomance.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ChecksummingPerfomance.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ChecksummingPerfomance.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ChecksummingPerfomance.java Sun Jan 22 07:36:07 2012
@@ -26,14 +26,13 @@ import java.util.zip.CheckedInputStream;
import org.apache.isis.runtimes.dflt.objectstores.nosql.file.server.Util;
-
public class ChecksummingPerfomance {
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
- CRC32 inputChecksum = new CRC32();
- CheckedInputStream in = new CheckedInputStream(new FileInputStream("test.data"), inputChecksum);
- BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));
+ final CRC32 inputChecksum = new CRC32();
+ final CheckedInputStream in = new CheckedInputStream(new FileInputStream("test.data"), inputChecksum);
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));
for (int i = 0; i < 30; i++) {
long time = System.currentTimeMillis();
@@ -80,36 +79,35 @@ public class ChecksummingPerfomance {
}
- private static void testArray(StringBuffer buf) {
- byte[] data = buf.toString().getBytes();
+ private static void testArray(final StringBuffer buf) {
+ final byte[] data = buf.toString().getBytes();
- CRC32 inputChecksum = new CRC32();
+ final CRC32 inputChecksum = new CRC32();
inputChecksum.reset();
inputChecksum.update(data);
// System.out.println(inputChecksum.getValue());
}
-
- private static byte[] extractArray(StringBuffer buf) {
- byte[] data = buf.toString().getBytes();
+ private static byte[] extractArray(final StringBuffer buf) {
+ final byte[] data = buf.toString().getBytes();
return data;
}
-
- private static void checksumArray(byte[] data) {
- CRC32 inputChecksum = new CRC32();
+
+ private static void checksumArray(final byte[] data) {
+ final CRC32 inputChecksum = new CRC32();
inputChecksum.reset();
inputChecksum.update(data);
// System.out.println(inputChecksum.getValue());
}
- private static StringBuffer readChecksummedFile(int i) throws Exception {
- CRC32 inputChecksum = new CRC32();
- CheckedInputStream in = new CheckedInputStream(new FileInputStream("test" + i % 3 + ".data"), inputChecksum);
- BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));
+ private static StringBuffer readChecksummedFile(final int i) throws Exception {
+ final CRC32 inputChecksum = new CRC32();
+ final CheckedInputStream in = new CheckedInputStream(new FileInputStream("test" + i % 3 + ".data"), inputChecksum);
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));
- StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = new StringBuffer();
String line;
while ((line = reader.readLine()) != null) {
buf.append(line);
@@ -123,10 +121,10 @@ public class ChecksummingPerfomance {
return buf;
}
- private static StringBuffer readFile(int i) throws Exception {
- BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("test" + i % 3 + ".data"), Util.ENCODING));
+ private static StringBuffer readFile(final int i) throws Exception {
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("test" + i % 3 + ".data"), Util.ENCODING));
- StringBuffer buf = new StringBuffer();
+ final StringBuffer buf = new StringBuffer();
String line;
while ((line = reader.readLine()) != null) {
buf.append(line);
Modified: incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ClientConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ClientConnectionTest.java?rev=1234456&r1=1234455&r2=1234456&view=diff
==============================================================================
--- incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ClientConnectionTest.java (original)
+++ incubator/isis/trunk/framework/runtimes/dflt/objectstores/nosql/src/test/java/org/apache/isis/runtimes/dflt/objectstores/nosql/file/ClientConnectionTest.java Sun Jan 22 07:36:07 2012
@@ -18,6 +18,11 @@
*/
package org.apache.isis.runtimes.dflt.objectstores.nosql.file;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -30,12 +35,6 @@ import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-
public class ClientConnectionTest {
private InputStream input;
@@ -45,12 +44,12 @@ public class ClientConnectionTest {
@Before
public void setup() throws Exception {
Logger.getRootLogger().setLevel(Level.OFF);
-
+
input = IoUtils.asUtf8ByteStream("org.domain.Class false true 1025\n{data...}\n\n102334");
output = new ByteArrayOutputStream();
connection = new ClientConnection(input, output);
}
-
+
@Ignore
@Test
public void testRequest() throws Exception {
@@ -58,14 +57,14 @@ public class ClientConnectionTest {
connection.close();
assertEquals("Dxxx yyy\n", output.toString());
}
-
+
@Test
public void testRequestData() throws Exception {
connection.requestData("{data...}");
connection.close();
- // assertEquals("{data...}\n\n5de98274", output.toString());
+ // assertEquals("{data...}\n\n5de98274", output.toString());
}
-
+
@Test
public void testResponseHeaders() throws Exception {
connection.getReponseHeader();
@@ -74,7 +73,7 @@ public class ClientConnectionTest {
assertEquals(true, connection.getResponseAsBoolean());
assertEquals(1025L, connection.getResponseAsLong());
}
-
+
@Test
public void tooManyResponseHeadersExpected() throws Exception {
connection.getReponseHeader();
@@ -85,46 +84,44 @@ public class ClientConnectionTest {
try {
connection.getResponse();
fail();
- }catch (RemotingException e) {
+ } catch (final RemotingException e) {
assertThat(e.getMessage(), containsString("are only 4"));
}
}
-
+
@Test
public void testResponseData() throws Exception {
connection.getReponseHeader();
- String data = connection.getResponseData();
+ final String data = connection.getResponseData();
assertEquals("{data...}\n", data);
}
-
+
@Test
public void validateResponseOk() throws Exception {
input = IoUtils.asUtf8ByteStream("ok xx xx\n{data...}");
connection = new ClientConnection(input, output);
connection.validateRequest();
}
-
- @Test(expected=RemotingException.class)
+
+ @Test(expected = RemotingException.class)
public void validateResponseError() throws Exception {
input = IoUtils.asUtf8ByteStream("error message about it\n");
connection = new ClientConnection(input, output);
connection.validateRequest();
}
-
- @Test(expected=ObjectNotFoundException.class)
+
+ @Test(expected = ObjectNotFoundException.class)
public void validateObjectNotFound() throws Exception {
input = IoUtils.asUtf8ByteStream("not-found message about it\n");
connection = new ClientConnection(input, output);
connection.validateRequest();
}
-
- @Test(expected=ConcurrencyException.class)
+
+ @Test(expected = ConcurrencyException.class)
public void validateConcurrencyException() throws Exception {
input = IoUtils.asUtf8ByteStream("concurrency message about it\n");
connection = new ClientConnection(input, output);
connection.validateRequest();
}
-
-
-}
+}