Search in sources :

Example 1 with UnrecoverableLog

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

the class TransactionManagerService method createTransactionLog.

static TransactionLog createTransactionLog(Dictionary properties, XidFactory xidFactory) throws ConfigurationException {
    TransactionLog result = null;
    if (getBool(properties, RECOVERABLE, DEFAULT_RECOVERABLE)) {
        String bufferClassName = getString(properties, HOWL_BUFFER_CLASS_NAME, "org.objectweb.howl.log.BlockLogBuffer");
        int bufferSizeKBytes = getInt(properties, HOWL_BUFFER_SIZE, 4);
        if (bufferSizeKBytes < 1 || bufferSizeKBytes > 32) {
            throw new ConfigurationException(HOWL_BUFFER_SIZE, "The buffer size must be between one and thirty-two.");
        }
        boolean checksumEnabled = getBool(properties, HOWL_CHECKSUM_ENABLED, true);
        boolean adler32Checksum = getBool(properties, HOWL_ADLER32_CHECKSUM, true);
        int flushSleepTimeMilliseconds = getInt(properties, HOWL_FLUSH_SLEEP_TIME, 50);
        String logFileExt = getString(properties, HOWL_LOG_FILE_EXT, "log");
        String logFileName = getString(properties, HOWL_LOG_FILE_NAME, "transaction");
        int maxBlocksPerFile = getInt(properties, HOWL_MAX_BLOCKS_PER_FILE, -1);
        int maxLogFiles = getInt(properties, HOWL_MAX_LOG_FILES, 2);
        int minBuffers = getInt(properties, HOWL_MIN_BUFFERS, 4);
        if (minBuffers < 0) {
            throw new ConfigurationException(HOWL_MIN_BUFFERS, "The minimum number of buffers must be greater than zero.");
        }
        int maxBuffers = getInt(properties, HOWL_MAX_BUFFERS, 0);
        if (maxBuffers > 0 && minBuffers < maxBuffers) {
            throw new ConfigurationException(HOWL_MAX_BUFFERS, "The maximum number of buffers must be greater than the minimum number of buffers.");
        }
        int threadsWaitingForceThreshold = getInt(properties, HOWL_THREADS_WAITING_FORCE_THRESHOLD, -1);
        boolean flushPartialBuffers = getBool(properties, HOWL_FLUSH_PARTIAL_BUFFERS, true);
        String logFileDir = getString(properties, HOWL_LOG_FILE_DIR, null);
        if (logFileDir == null || logFileDir.length() == 0 || !new File(logFileDir).isAbsolute()) {
            throw new ConfigurationException(HOWL_LOG_FILE_DIR, "The log file directory must be set to an absolute directory.");
        }
        try {
            result = new HOWLLog(bufferClassName, bufferSizeKBytes, checksumEnabled, adler32Checksum, flushSleepTimeMilliseconds, logFileDir, logFileExt, logFileName, maxBlocksPerFile, maxBuffers, maxLogFiles, minBuffers, threadsWaitingForceThreshold, flushPartialBuffers, xidFactory, null);
            ((HOWLLog) result).doStart();
        } catch (Exception e) {
            // This should not really happen as we've checked properties earlier
            throw new ConfigurationException(null, e.getMessage(), e);
        }
    } else {
        result = new UnrecoverableLog();
    }
    return result;
}
Also used : TransactionLog(org.apache.geronimo.transaction.manager.TransactionLog) ConfigurationException(org.osgi.service.cm.ConfigurationException) HOWLLog(org.apache.geronimo.transaction.log.HOWLLog) File(java.io.File) ConfigurationException(org.osgi.service.cm.ConfigurationException) XAException(javax.transaction.xa.XAException) UnrecoverableLog(org.apache.geronimo.transaction.log.UnrecoverableLog)

Aggregations

File (java.io.File)1 XAException (javax.transaction.xa.XAException)1 HOWLLog (org.apache.geronimo.transaction.log.HOWLLog)1 UnrecoverableLog (org.apache.geronimo.transaction.log.UnrecoverableLog)1 TransactionLog (org.apache.geronimo.transaction.manager.TransactionLog)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1