/** * Registers a listener on an operation channel that sucks out operations as * soon as they appear, sending them to a target sink. * * @param channel channel from which operations are to be pulled * @param sink sink to which operations are to be pushed */ public static void start(OperationChannel channel, FlushingOperationSink<WaveletOperation> sink) { channel.setListener(new OperationSucker(channel, sink)); }
@Override protected void setUp() throws Exception { super.setUp(); channel = new MockOperationChannel(); sink = new MockFlushingOperationSink(); sucker = new OperationSucker(channel, sink); }
@Override protected void setUp() throws Exception { super.setUp(); channel = new MockOperationChannel(); sink = new MockFlushingOperationSink(); sucker = new OperationSucker(channel, sink); }
CcBasedWavelet(WaveId waveId, WaveletOperationContext.Factory contextFactory, ParticipationHelper participationHelper, OperationChannel channel, ObservableWaveletData target, CcDocumentFactory<?> docFactory, FailureHandler failureHandler, DuplexOpSinkFactory opTaps) { this.docFactory = docFactory; this.channel = channel; this.failureHandler = failureHandler; Preconditions.checkNotNull(opTaps, "OpTaps cannot be null"); // Sink through which all operations are sent to remote state remote = new ChannelAdapter(channel); // Sink through which all operations are applied to local state applier = new OperationApplier(target, target.getWaveletId()); opTap = opTaps.create(target.getWaveletId(), applier, remote); // Create operation adapter, which translates semantic methods into // operations, applying them to the target as well as sending them down // the operation channel. Local operation failure fails this wavelet // permanently. wavelet = new OpBasedWavelet(waveId, target, contextFactory, participationHelper, opTap.incoming(), opTap.outgoing()); // Create operation sucker, which sucks operations out of the channel and // applies them to the CC target. driver = new OperationSucker(channel, opTap.incoming()); channel.setListener(driver); }