Search in sources :

Example 11 with HOWLLog

use of org.apache.geronimo.transaction.log.HOWLLog in project aries by apache.

the class LogConversionTest method unknownExistingTransactionLogChangedLogDir.

@Test
@SuppressWarnings("unchecked")
public void unknownExistingTransactionLogChangedLogDir() throws Exception {
    File logDir = new File(BASE, "unknownExistingTransactionLogChangedLogDir");
    File newLogDir = new File(BASE, "unknownExistingTransactionLogChangedLogDir-new");
    FileUtils.deleteDirectory(logDir);
    FileUtils.deleteDirectory(newLogDir);
    logDir.mkdirs();
    Hashtable<String, Object> properties = new Hashtable<String, Object>();
    HOWLLog txLog = createLog("unknownExistingTransactionLogChangedLogDir", "transaction", 2, -1, 1, properties);
    txLog.doStart();
    transaction(txLog, 1, false);
    txLog.doStop();
    Hashtable<String, Object> newConfig = (Hashtable<String, Object>) properties.clone();
    newConfig.put("aries.transaction.howl.logFileDir", newLogDir.getAbsolutePath());
    assertFalse(TransactionLogUtils.copyActiveTransactions(null, newConfig));
    assertFalse("Transaction log should not exist", new File(newLogDir, "transaction_1.log").exists());
    assertTrue("Old transaction log should not be removed", logDir.exists());
    assertFalse("New transaction log should not be created (will be created on TX Manager startup)", newLogDir.exists());
}
Also used : HOWLLog(org.apache.geronimo.transaction.log.HOWLLog) Hashtable(java.util.Hashtable) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 12 with HOWLLog

use of org.apache.geronimo.transaction.log.HOWLLog in project aries by apache.

the class LogConversionTest method changed3ParametersAndLogDir.

@Test
@SuppressWarnings("unchecked")
public void changed3ParametersAndLogDir() throws Exception {
    File logDir = new File(BASE, "changed3ParametersAndLogDir");
    File newLogDir = new File(BASE, "changed3ParametersAndLogDir-new");
    FileUtils.deleteDirectory(logDir);
    FileUtils.deleteDirectory(newLogDir);
    logDir.mkdirs();
    Hashtable<String, Object> properties = new Hashtable<String, Object>();
    HOWLLog txLog = createLog("changed3ParametersAndLogDir", "transaction", 3, -1, 1, properties);
    txLog.doStart();
    transaction(txLog, 1, false);
    txLog.doStop();
    Hashtable<String, Object> newConfig = (Hashtable<String, Object>) properties.clone();
    newConfig.put("aries.transaction.howl.maxLogFiles", "4");
    newConfig.put("aries.transaction.howl.maxBlocksPerFile", "4");
    newConfig.put("aries.transaction.howl.bufferSize", "4");
    newConfig.put("aries.transaction.howl.logFileDir", newLogDir.getAbsolutePath());
    long lm = earlierLastModified(new File(logDir, "transaction_1.log"));
    assertTrue(TransactionLogUtils.copyActiveTransactions(properties, newConfig));
    assertTrue("Old transaction log should exist", new File(logDir, "transaction_1.log").exists());
    assertTrue("New transaction log should exist", new File(newLogDir, "transaction_1.log").exists());
    assertThat("Old transaction log should be touched (HOWL Log opened)", new File(logDir, "transaction_1.log").lastModified(), not(equalTo(lm)));
}
Also used : HOWLLog(org.apache.geronimo.transaction.log.HOWLLog) Hashtable(java.util.Hashtable) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 13 with HOWLLog

use of org.apache.geronimo.transaction.log.HOWLLog in project aries by apache.

the class LogConversionTest method changedBlockSize.

@Test
@SuppressWarnings("unchecked")
public void changedBlockSize() throws Exception {
    File logDir = new File(BASE, "changedBlockSize");
    FileUtils.deleteDirectory(logDir);
    logDir.mkdirs();
    Hashtable<String, Object> properties = new Hashtable<String, Object>();
    HOWLLog txLog = createLog("changedBlockSize", "transaction", 3, -1, 1, properties);
    txLog.doStart();
    transaction(txLog, 1, false);
    txLog.doStop();
    Hashtable<String, Object> newConfig = (Hashtable<String, Object>) properties.clone();
    newConfig.put("aries.transaction.howl.bufferSize", "32");
    long lm = earlierLastModified(new File(logDir, "transaction_1.log"));
    assertTrue(TransactionLogUtils.copyActiveTransactions(properties, newConfig));
    assertTrue("Transaction log should exist", new File(logDir, "transaction_1.log").exists());
    assertThat("Transaction log should be processed", new File(logDir, "transaction_1.log").lastModified(), not(equalTo(lm)));
}
Also used : HOWLLog(org.apache.geronimo.transaction.log.HOWLLog) Hashtable(java.util.Hashtable) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 14 with HOWLLog

use of org.apache.geronimo.transaction.log.HOWLLog in project aries by apache.

the class LogConversionTest method existingTransactionLogChangedLogFileNameAndLogDir.

@Test
@SuppressWarnings("unchecked")
public void existingTransactionLogChangedLogFileNameAndLogDir() throws Exception {
    File logDir = new File(BASE, "existingTransactionLogChangedLogFileNameAndLogDir");
    File newLogDir = new File(BASE, "existingTransactionLogChangedLogFileNameAndLogDir-new");
    FileUtils.deleteDirectory(logDir);
    logDir.mkdirs();
    Hashtable<String, Object> properties = new Hashtable<String, Object>();
    HOWLLog txLog = createLog("existingTransactionLogChangedLogFileNameAndLogDir", "transaction", 2, -1, 1, properties);
    txLog.doStart();
    transaction(txLog, 1, false);
    txLog.doStop();
    earlierLastModified(new File(logDir, "transaction_1.log"));
    Hashtable<String, Object> newConfig = (Hashtable<String, Object>) properties.clone();
    newConfig.put("aries.transaction.howl.logFileName", "megatransaction");
    newConfig.put("aries.transaction.howl.logFileDir", newLogDir.getAbsolutePath());
    assertTrue(TransactionLogUtils.copyActiveTransactions(properties, newConfig));
    assertFalse("Old transaction log should not exist", new File(logDir, "transaction_1.log").exists());
    assertTrue("New transaction log should exist", new File(newLogDir, "megatransaction_1.log").exists());
}
Also used : HOWLLog(org.apache.geronimo.transaction.log.HOWLLog) Hashtable(java.util.Hashtable) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Example 15 with HOWLLog

use of org.apache.geronimo.transaction.log.HOWLLog in project aries by apache.

the class LogConversionTest method changedMaxBlocksPerFile.

@Test
@SuppressWarnings("unchecked")
public void changedMaxBlocksPerFile() throws Exception {
    File logDir = new File(BASE, "changedMaxBlocksPerFile");
    FileUtils.deleteDirectory(logDir);
    logDir.mkdirs();
    Hashtable<String, Object> properties = new Hashtable<String, Object>();
    HOWLLog txLog = createLog("changedMaxBlocksPerFile", "transaction", 3, -1, 1, properties);
    txLog.doStart();
    transaction(txLog, 1, false);
    txLog.doStop();
    Hashtable<String, Object> newConfig = (Hashtable<String, Object>) properties.clone();
    newConfig.put("aries.transaction.howl.maxBlocksPerFile", "20");
    long lm = earlierLastModified(new File(logDir, "transaction_1.log"));
    assertTrue(TransactionLogUtils.copyActiveTransactions(properties, newConfig));
    assertTrue("Transaction log should exist", new File(logDir, "transaction_1.log").exists());
    assertFalse("There should be 3 transaction log files", new File(logDir, "transaction_4.log").exists());
    assertThat("Transaction log should be processed", new File(logDir, "transaction_1.log").lastModified(), not(equalTo(lm)));
}
Also used : HOWLLog(org.apache.geronimo.transaction.log.HOWLLog) Hashtable(java.util.Hashtable) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) Test(org.junit.Test)

Aggregations

HOWLLog (org.apache.geronimo.transaction.log.HOWLLog)16 File (java.io.File)14 RandomAccessFile (java.io.RandomAccessFile)11 Test (org.junit.Test)11 Hashtable (java.util.Hashtable)10 XidFactory (org.apache.geronimo.transaction.manager.XidFactory)3 GeronimoTransactionManager (org.apache.geronimo.transaction.manager.GeronimoTransactionManager)2 TransactionLog (org.apache.geronimo.transaction.manager.TransactionLog)2 ConfigurationException (org.osgi.service.cm.ConfigurationException)2 FilenameFilter (java.io.FilenameFilter)1 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 HashMap (java.util.HashMap)1 Matcher (java.util.regex.Matcher)1 XAException (javax.transaction.xa.XAException)1 XAResource (javax.transaction.xa.XAResource)1 UnrecoverableLog (org.apache.geronimo.transaction.log.UnrecoverableLog)1 NamedXAResource (org.apache.geronimo.transaction.manager.NamedXAResource)1 Recovery (org.apache.geronimo.transaction.manager.Recovery)1 TransactionBranchInfo (org.apache.geronimo.transaction.manager.TransactionBranchInfo)1