private void commitPutsToOverflow() throws InterruptedException { overflowPutTx = getOverflowTx(); overflowPutTx.begin(); for (Event event : putList) { overflowPutTx.put(event); } commitPutsToOverflow_core(overflowPutTx); totalStored.release(putList.size()); overflowPutCount += putList.size(); channelCounter.addToEventPutSuccessCount(putList.size()); }
/** * <p> * Ensures that a transaction exists for this thread and then * delegates the <code>take</code> to the thread's {@link * BasicTransactionSemantics} instance. * </p> */ @Override public Event take() throws ChannelException { BasicTransactionSemantics transaction = currentTransaction.get(); Preconditions.checkState(transaction != null, "No transaction exists for this thread"); return transaction.take(); }
/** * <p> * Ensures that a transaction exists for this thread and then * delegates the <code>put</code> to the thread's {@link * BasicTransactionSemantics} instance. * </p> */ @Override public void put(Event event) throws ChannelException { BasicTransactionSemantics transaction = currentTransaction.get(); Preconditions.checkState(transaction != null, "No transaction exists for this thread"); transaction.put(event); }
@Override public void rollback() { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "rollback() called from different thread than getTransaction()!"); Preconditions.checkState(state.equals(State.OPEN), "rollback() called when transaction is %s!", state); state = State.COMPLETED; try { doRollback(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ChannelException(e.toString(), e); } }
@Override public void close() { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "close() called from different thread than getTransaction()!"); Preconditions.checkState( state.equals(State.NEW) || state.equals(State.COMPLETED), "close() called when transaction is %s" + " - you must either commit or rollback first", state); state = State.CLOSED; doClose(); }
@Override public void begin() { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "begin() called from different thread than getTransaction()!"); Preconditions.checkState(state.equals(State.NEW), "begin() called when transaction is " + state + "!"); try { doBegin(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ChannelException(e.toString(), e); } state = State.OPEN; }
@Override public void commit() { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "commit() called from different thread than getTransaction()!"); Preconditions.checkState(state.equals(State.OPEN), "commit() called when transaction is %s!", state); try { doCommit(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ChannelException(e.toString(), e); } state = State.COMPLETED; }
@Override public void begin() { super.begin(); }
/** * <p> * The method to which {@link BasicChannelSemantics} delegates calls * to <code>put</code>. * </p> */ protected void put(Event event) { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "put() called from different thread than getTransaction()!"); Preconditions.checkState(state.equals(State.OPEN), "put() called when transaction is %s!", state); Preconditions.checkArgument(event != null, "put() called with null event!"); try { doPut(event); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ChannelException(e.toString(), e); } }
private void takeCommit() { if (takeCount > largestTakeTxSize) { largestTakeTxSize = takeCount; } synchronized (queueLock) { if (overflowTakeTx != null) { overflowTakeTx.commit(); } double memoryPercentFree = (memoryCapacity == 0) ? 0 : (memoryCapacity - memQueue.size() + takeCount) / (double) memoryCapacity; if (overflowActivated && memoryPercentFree >= overflowDeactivationThreshold) { overflowActivated = false; LOGGER.info("Overflow Deactivated"); } channelCounter.setChannelSize(getTotalStored()); } if (!useOverflow) { memQueRemaining.release(takeCount); bytesRemaining.release(takeListByteCount); } channelCounter.addToEventTakeSuccessCount(takeCount); }
/** * <p> * Ensures that a transaction exists for this thread and then * delegates the <code>put</code> to the thread's {@link * BasicTransactionSemantics} instance. * </p> */ @Override public void put(Event event) throws ChannelException { BasicTransactionSemantics transaction = currentTransaction.get(); Preconditions.checkState(transaction != null, "No transaction exists for this thread"); transaction.put(event); }
@Override public void rollback() { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "rollback() called from different thread than getTransaction()!"); Preconditions.checkState(state.equals(State.OPEN), "rollback() called when transaction is %s!", state); state = State.COMPLETED; try { doRollback(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ChannelException(e.toString(), e); } }
@Override public void close() { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "close() called from different thread than getTransaction()!"); Preconditions.checkState( state.equals(State.NEW) || state.equals(State.COMPLETED), "close() called when transaction is %s" + " - you must either commit or rollback first", state); state = State.CLOSED; doClose(); }
@Override public void begin() { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "begin() called from different thread than getTransaction()!"); Preconditions.checkState(state.equals(State.NEW), "begin() called when transaction is " + state + "!"); try { doBegin(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ChannelException(e.toString(), e); } state = State.OPEN; }
@Override public void commit() { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "commit() called from different thread than getTransaction()!"); Preconditions.checkState(state.equals(State.OPEN), "commit() called when transaction is %s!", state); try { doCommit(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ChannelException(e.toString(), e); } state = State.COMPLETED; }
@Override public void begin() { super.begin(); }
/** * <p> * The method to which {@link BasicChannelSemantics} delegates calls * to <code>put</code>. * </p> */ protected void put(Event event) { Preconditions.checkState(Thread.currentThread().getId() == initialThreadId, "put() called from different thread than getTransaction()!"); Preconditions.checkState(state.equals(State.OPEN), "put() called when transaction is %s!", state); Preconditions.checkArgument(event != null, "put() called with null event!"); try { doPut(event); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new ChannelException(e.toString(), e); } }