/** * The Context of the associated Source is passed. * * @param context */ @Override public void configure(Context context) { configureInterceptors(context); }
@Override public synchronized void setName(String name) { channelNameDescriptor = "[channel=" + name + "]"; super.setName(name); }
public void putPrimary(Integer eventCount) { totalPuts += eventCount; if ((queue.peekLast() == null) || queue.getLast().intValue() < 0) { queue.addLast(new MutableInteger(eventCount)); } else { queue.getLast().add(eventCount); } }
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()); }
@Override protected void doCommit() throws InterruptedException { if (putCalled) { putCommit(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Put Committed. Drain Order Queue state : " + drainOrder.dump()); } } else if (takeCalled) { takeCommit(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Take Committed. Drain Order Queue state : " + drainOrder.dump()); } } }
@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(); }
public static Transaction sharedInstance() { if (sharedInstance == null) { sharedInstance = new NoOpTransaction(); } return sharedInstance; }
/** * <p> * A convenience method for single-event <code>put</code> transactions. * </p> * @see #transact(Channel,Callable) */ public static void put(final Channel channel, final Event event) throws ChannelException { transact(channel, new Runnable() { @Override public void run() { channel.put(event); } }); }
@Override public List<Channel> getRequiredChannels(Event event) { /* * Seems like there are lot of components within flume that do not call * configure method. It is conceiveable that custom component tests too * do that. So in that case, revert to old behavior. */ if (requiredChannels == null) { return getAllChannels(); } return requiredChannels; }
@Override public Transaction getTransaction() { return NoOpTransaction.sharedInstance(); }
@Override protected BasicTransactionSemantics createTransaction() { return new MemoryTransaction(transCapacity, channelCounter); }
@Override protected BasicTransactionSemantics createTransaction() { return new SpillableMemoryTransaction(channelCounter); }
@Override public void begin() { super.begin(); }
public String dump() { StringBuilder sb = new StringBuilder(); sb.append(" [ "); for (MutableInteger i : queue) { sb.append(i.intValue()); sb.append(" "); } sb.append("]"); return sb.toString(); }
public void putOverflow(Integer eventCount) { totalPuts += eventCount; if ((queue.peekLast() == null) || queue.getLast().intValue() > 0) { queue.addLast(new MutableInteger(-eventCount)); } else { queue.getLast().add(-eventCount); } overflowCounter += eventCount; }
/** * <p> * A convenience method for single-event <code>take</code> transactions. * </p> * @return a single event, or null if the channel has none available * @see #transact(Channel,Callable) */ public static Event take(final Channel channel) throws ChannelException { return transact(channel, new Callable<Event>() { @Override public Event call() { return channel.take(); } }); }
public void putFirstPrimary(Integer eventCount) { if ((queue.peekFirst() == null) || queue.getFirst().intValue() < 0) { queue.addFirst(new MutableInteger(eventCount)); } else { queue.getFirst().add(eventCount); } }
/** * <p> * A convenience method for multiple-event <code>put</code> transactions. * </p> * @see #transact(Channel,Callable) */ public static void put(final Channel channel, final Collection<Event> events) throws ChannelException { transact(channel, new Runnable() { @Override public void run() { for (Event event : events) { channel.put(event); } } }); }
public void putFirstOverflow(Integer eventCount) { if ((queue.peekFirst() == null) || queue.getFirst().intValue() > 0) { queue.addFirst(new MutableInteger(-eventCount)); } else { queue.getFirst().add(-eventCount); } overflowCounter += eventCount; }