/** * 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)); }
private ConnectedChannel expectConnectedChannel(ObservableWaveletData knownSnapshot, Accessibility accessibility) { OperationChannel channel = muxListener.verifyOperationChannelCreated(knownSnapshot, accessibility); MockOperationChannelListener listener = new MockOperationChannelListener(); channel.setListener(listener); return new ConnectedChannel(channel, listener); }
private ConnectedChannel expectConnectedChannel(ObservableWaveletData knownSnapshot, Accessibility accessibility) { OperationChannel channel = muxListener.verifyOperationChannelCreated(knownSnapshot, accessibility); MockOperationChannelListener listener = new MockOperationChannelListener(); channel.setListener(listener); return new ConnectedChannel(channel, listener); }
public void testMuxCloseClosesAllUnsavedDataUpdaters() { mux.open(muxListener, IdFilters.ALL_IDS); MockOperationChannelListener listener1 = new MockOperationChannelListener(); MockOperationChannelListener listener2 = new MockOperationChannelListener(); OperationChannel ch1 = createOperationChannel(WAVELET_ID_1, USER_NAME); OperationChannel ch2 = createOperationChannel(WAVELET_ID_2, USER_NAME); ch1.setListener(listener1); ch2.setListener(listener2); mux.close(); assertEquals(2, fakeUnsavedDataListener.closeCalls); }
public void testMuxCloseClosesAllUnsavedDataUpdaters() { mux.open(muxListener, IdFilters.ALL_IDS); MockOperationChannelListener listener1 = new MockOperationChannelListener(); MockOperationChannelListener listener2 = new MockOperationChannelListener(); OperationChannel ch1 = createOperationChannel(WAVELET_ID_1, USER_NAME); OperationChannel ch2 = createOperationChannel(WAVELET_ID_2, USER_NAME); ch1.setListener(listener1); ch2.setListener(listener2); mux.close(); assertEquals(2, fakeUnsavedDataListener.closeCalls); }
private ConnectedChannel connectChannelSnapshot(ViewChannel.Listener viewListener, ObservableWaveletData snapshot, HashedVersion committed) throws ChannelException { viewListener.onSnapshot(snapshot.getWaveletId(), snapshot, committed, null); OperationChannel channel = muxListener.verifyOperationChannelCreated(snapshot, Accessibility.READ_WRITE); MockOperationChannelListener listener = new MockOperationChannelListener(); channel.setListener(listener); return new ConnectedChannel(channel, listener); }
private ConnectedChannel createOperationChannel(WaveletId waveletId, ParticipantId address) { mux.createOperationChannel(waveletId, address); OperationChannel channel = muxListener.verifyOperationChannelCreated(createSnapshot( WAVELET_ID_1, 0, NOSIG), Accessibility.READ_WRITE); MockOperationChannelListener channelListener = new MockOperationChannelListener(); channel.setListener(channelListener); return new ConnectedChannel(channel, channelListener); }
private ConnectedChannel createOperationChannel(WaveletId waveletId, ParticipantId address) { mux.createOperationChannel(waveletId, address); OperationChannel channel = muxListener.verifyOperationChannelCreated(createSnapshot( WAVELET_ID_1, 0, NOSIG), Accessibility.READ_WRITE); MockOperationChannelListener channelListener = new MockOperationChannelListener(); channel.setListener(channelListener); return new ConnectedChannel(channel, channelListener); }
private ConnectedChannel connectChannelSnapshot(ViewChannel.Listener viewListener, ObservableWaveletData snapshot, HashedVersion committed) throws ChannelException { viewListener.onSnapshot(snapshot.getWaveletId(), snapshot, committed, null); OperationChannel channel = muxListener.verifyOperationChannelCreated(snapshot, Accessibility.READ_WRITE); MockOperationChannelListener listener = new MockOperationChannelListener(); channel.setListener(listener); return new ConnectedChannel(channel, listener); }
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); }