"rel=[234].+move.+multichunk",
"rel=[234].+delete.+temp",
}
));
TestClient clientA = new TestClient("A", testConnection);
clientA.createNewFile("A-original", 5 * 1024 * 1024); // << larger than one multichunk!
boolean firstUpFailed = false;
try {
clientA.up();
}
catch (StorageException e) {
firstUpFailed = true;
logger.log(Level.INFO, e.getMessage());
}
assertTrue(firstUpFailed);
assertEquals(0, new File(testConnection.getPath() + "/databases/").listFiles().length);
assertEquals(1, new File(testConnection.getPath() + "/multichunks/").listFiles().length);
assertEquals(1, new File(testConnection.getPath() + "/actions/").listFiles().length);
assertEquals(1, new File(testConnection.getPath() + "/transactions/").listFiles().length);
File[] tempFiles = new File(testConnection.getPath() + "/temporary").listFiles();
assertEquals(2, tempFiles.length);
assertTrue(tempFiles[0].length() > 500 * 1024 || tempFiles[1].length() > 500 * 1024); // The second multichunk should be >500 KB
assertTrue(tempFiles[0].length() < 100 * 1024 || tempFiles[1].length() < 100 * 1024); // The database file should be <100 KB
File transactionFile = new File(testConnection.getPath() + "/transactions/").listFiles()[0];
TransactionTO transactionTO = new Persister().read(TransactionTO.class, transactionFile);
assertEquals(3, transactionTO.getActions().size());
assertTrue(transactionTO.getActions().get(0).getRemoteFile().getName().contains("multichunk-"));
assertTrue(transactionTO.getActions().get(1).getRemoteFile().getName().contains("multichunk-"));
assertTrue(transactionTO.getActions().get(2).getRemoteFile().getName().contains("database-"));
// 2. Double check if list() does not return the multichunk
TransferManager transferManager = new TransactionAwareTransferManager(
new UnreliableLocalTransferPlugin().createTransferManager(testConnection, null), null);
Map<String, MultichunkRemoteFile> multiChunkList = transferManager.list(MultichunkRemoteFile.class);
assertEquals(0, multiChunkList.size());
// 3. Second try fails in the beginning, to see if cleanTransactions was successful
boolean secondUpFailed = false;
try {
clientA.up();
}
catch (StorageException e) {
secondUpFailed = true;
logger.log(Level.INFO, e.getMessage());
}
assertTrue(secondUpFailed);
assertEquals(0, new File(testConnection.getPath() + "/databases/").listFiles().length);
assertEquals(0, new File(testConnection.getPath() + "/multichunks/").listFiles().length);
assertEquals(2, new File(testConnection.getPath() + "/actions/").listFiles().length); // left over, 2 failed ops
assertEquals(0, new File(testConnection.getPath() + "/transactions/").listFiles().length);
assertEquals(4, new File(testConnection.getPath() + "/temporary/").listFiles().length);
// 4. Third try; this should finally succeed
clientA.up();
assertEquals(1, new File(testConnection.getPath() + "/databases/").listFiles().length);
assertEquals(2, new File(testConnection.getPath() + "/multichunks/").listFiles().length);
assertEquals(0, new File(testConnection.getPath() + "/actions/").listFiles().length); // cleaned
assertEquals(0, new File(testConnection.getPath() + "/transactions/").listFiles().length);
assertEquals(4, new File(testConnection.getPath() + "/temporary/").listFiles().length); // cleaned
// Tear down
clientA.deleteTestData();
}