/** * calls Logger.mark(key, force) with <i> force </i> set to <b> true </b>. * <p>Caller is blocked until mark record is forced to disk. * @param key a log key returned by a previous call to put(). * @throws InvalidLogKeyException * @throws LogClosedException * @throws IOException * @throws InterruptedException * @see #mark(long, boolean) */ public void mark(long key) throws InvalidLogKeyException, LogClosedException, IOException, InterruptedException { mark(key, true); }
/** * add a USER record consisting of byte[] to the log. * * <p>wrap byte[] <i> data </i> in a new byte[][] * and delegates call to put(byte[][], boolean) * * @param data byte[] to be written to log * @param sync true if caller wishes to block waiting for the * record to force to disk. * @return log key for the record * @throws LogClosedException * @throws LogRecordSizeException * @throws LogFileOverflowException * @throws InterruptedException * @throws IOException */ public long put(byte[] data, boolean sync) throws LogClosedException, LogRecordSizeException, LogFileOverflowException, InterruptedException, IOException { return put(LogRecordType.USER, new byte[][]{data}, sync); }
public HowlJournal(Configuration configuration) throws InvalidFileSetException, LogConfigurationException, InvalidLogBufferException, ClassNotFoundException, IOException, InterruptedException { this.logger = new Logger(configuration); this.logger.open(); lastMark = new LongRecordLocation(logger.getActiveMark()); }
/** * @see org.apache.activeio.journal.Journal#setJournalEventListener(org.codehaus.activemq.journal.JournalEventListener) */ public void setJournalEventListener(final JournalEventListener eventListener) { logger.setLogEventListener(new LogEventListener() { public void logOverflowNotification(long key) { eventListener.overflowNotification(new LongRecordLocation(key)); } }); }
/** * @see org.apache.activeio.journal.Journal#close() */ public void close() throws IOException { try { logger.close(); } catch (IOException e) { throw e; } catch (InterruptedException e) { throw (InterruptedIOException) new InterruptedIOException() .initCause(e); } catch (Exception e) { throw (IOException) new IOException("Journal close failed: " + e) .initCause(e); } }
private void checkPutEnabled() throws LogClosedException { if (replayNeeded) throw new LogClosedException("replay() must be called prior to put(); activeMark [0x" + Long.toHexString(super.getActiveMark()) + "]"); }
/** * Wrapp Logger#replay(ReplayListener, long) so we can * intercept onRecord() notifications to process * XACOMMIT and XACOMMITMOVED records. */ public void replay(ReplayListener listener, long key) throws InvalidLogKeyException, LogConfigurationException { XAReplayListener replayListener = new XAReplayListener(listener); super.replay(replayListener, key, true); }
); stats.append(super.getStats());
/** * Common initialization for all constructors. */ private void init() { // allocate a table of active transaction objects activeTx = new XACommittingTx[50]; for (int i=0; i < activeTx.length; ++i) activeTx[i] = null; // allocate and initialize the table of indexes // for available entries in activeTx. // initially, all entries are available. availableTx = new XACommittingTx[activeTx.length]; for (int i=0; i < activeTx.length; ++i) availableTx[i] = new XACommittingTx(i); // register the event listener super.setLogEventListener(this); }
public void close() throws IOException, InterruptedException { if (isClosed) return; long newMark = Long.MAX_VALUE; XACommittingTx tx = null; // set new log mark at oldest activeTx entry synchronized(activeTxLock) { for (int i=0; i < activeTx.length; ++i) { tx = activeTx[i]; if (tx == null) continue; long key = tx.getLogKey(); if (key < newMark) newMark = key; } if (newMark < Long.MAX_VALUE) { try { this.mark(newMark, true); } catch (InvalidLogKeyException e) { // will not happen } catch (LogClosedException e) { // will not happen } } } super.close(); }
private void checkPutEnabled() throws LogClosedException { if (replayNeeded) throw new LogClosedException("replay() must be called prior to put(); activeMark [0x" + Long.toHexString(super.getActiveMark()) + "]"); }
/** * Wrapp Logger#replay(ReplayListener, long) so we can * intercept onRecord() notifications to process * XACOMMIT and XACOMMITMOVED records. */ public void replay(ReplayListener listener, long key) throws InvalidLogKeyException, LogConfigurationException { XAReplayListener replayListener = new XAReplayListener(listener); super.replay(replayListener, key, true); }
); stats.append(super.getStats());
/** * add a USER record consisting of byte[] to the log. * * <p>wrap byte[] <i> data </i> in a new byte[][] * and delegates call to put(byte[][], boolean) * * @param data byte[] to be written to log * @param sync true if caller wishes to block waiting for the * record to force to disk. * @return log key for the record * @throws LogClosedException * @throws LogRecordSizeException * @throws LogFileOverflowException * @throws InterruptedException * @throws IOException */ public long put(byte[] data, boolean sync) throws LogClosedException, LogRecordSizeException, LogFileOverflowException, InterruptedException, IOException { return put(LogRecordType.USER, new byte[][]{data}, sync); }
/** * calls Logger.mark(key, force) with <i> force </i> set to <b> true </b>. * <p>Caller is blocked until mark record is forced to disk. * @param key a log key returned by a previous call to put(). * @throws InvalidLogKeyException * @throws LogClosedException * @throws IOException * @throws InterruptedException * @see #mark(long, boolean) */ public void mark(long key) throws InvalidLogKeyException, LogClosedException, IOException, InterruptedException { mark(key, true); }
/** * Common initialization for all constructors. */ private void init() { // allocate a table of active transaction objects activeTx = new XACommittingTx[50]; for (int i=0; i < activeTx.length; ++i) activeTx[i] = null; // allocate and initialize the table of indexes // for available entries in activeTx. // initially, all entries are available. availableTx = new XACommittingTx[activeTx.length]; for (int i=0; i < activeTx.length; ++i) availableTx[i] = new XACommittingTx(i); // register the event listener super.setLogEventListener(this); }
public void close() throws IOException, InterruptedException { if (isClosed) return; long newMark = Long.MAX_VALUE; XACommittingTx tx = null; // set new log mark at oldest activeTx entry synchronized(activeTxLock) { for (int i=0; i < activeTx.length; ++i) { tx = activeTx[i]; if (tx == null) continue; long key = tx.getLogKey(); if (key < newMark) newMark = key; } if (newMark < Long.MAX_VALUE) { try { this.mark(newMark, true); } catch (InvalidLogKeyException e) { // will not happen } catch (LogClosedException e) { // will not happen } } } super.close(); }