/** * Returns the current wavelet version. */ public HashedVersion getCurrentWaveletVersion(WaveletName waveletName) { PerWavelet waveletInfo = getWavelet(waveletName); synchronized (waveletInfo) { return waveletInfo.getCurrentVersion(); } }
@Override public void waveletCommitted(WaveletName waveletName, HashedVersion version) { for (ParticipantId participant : waveletInfo.getWaveletParticipants(waveletName)) { waveletInfo.getUserManager(participant).onCommit(waveletName, version); } }
/** * Tell the user manager that we have a submit request outstanding. While a * submit request is outstanding, all wavelet updates are queued. * * @param channelId the channel identifying the specific client * @param waveletName the name of the wavelet */ public void submitRequest(String channelId, WaveletName waveletName) { WaveViewSubscription subscription = findSubscription(waveletName, channelId); if (subscription != null) { subscription.submitRequest(waveletName); } }
/** * Tests that delta updates are held back while a submit is in flight. */ public void testDeltaHeldBackWhileOutstandingSubmit() { OpenListener listener = mock(OpenListener.class); m.subscribe(W1, IdFilters.ALL_IDS, "ch", listener); m.submitRequest("ch", W1A); m.onUpdate(W1A, DELTAS); verifyZeroInteractions(listener); m.submitResponse("ch", W1A, V3); // V3 not the same as update delta. verify(listener).onUpdate(W1A, null, DELTAS, null, null, "ch"); }
public void testCannotOpenWavesWhenNotLoggedIn() throws Exception { OpenListener listener = mock(OpenListener.class); clientFrontend.openRequest(null, WAVE_ID, IdFilters.ALL_IDS, NO_KNOWN_WAVELETS, listener); verify(listener).onFailure("Not logged in"); CommittedWaveletSnapshot snapshot = provideWavelet(WN1); clientFrontend.waveletUpdate(snapshot.snapshot, DELTAS); Mockito.verifyNoMoreInteractions(listener); }
/** * Tests that a single delta update is received by the listener. */ public void testSingleDeltaReceived() { OpenListener listener = mock(OpenListener.class); m.subscribe(W1, IdFilters.ALL_IDS, "ch", listener); m.onUpdate(W1A, DELTAS); verify(listener).onUpdate(W1A, null, DELTAS, null, null, "ch"); }
private static void initializeFrontend(Injector injector, ServerRpcProvider server, WaveBus waveBus) throws WaveServerException { HashedVersionFactory hashFactory = injector.getInstance(HashedVersionFactory.class); WaveletProvider provider = injector.getInstance(WaveletProvider.class); WaveletInfo waveletInfo = WaveletInfo.create(hashFactory, provider); ClientFrontend frontend = ClientFrontendImpl.create(provider, waveBus, waveletInfo); ProtocolWaveClientRpc.Interface rpcImpl = WaveClientRpcImpl.create(frontend, false); server.registerService(ProtocolWaveClientRpc.newReflectiveService(rpcImpl)); }
public void testOpenEmptyWaveReceivesChannelIdAndMarker() { OpenListener listener = openWave(IdFilters.ALL_IDS); verifyChannelId(listener); verifyMarker(listener, WAVE_ID); }
@Override public void onSuccess(int operationsApplied, HashedVersion hashedVersionAfterApplication, long applicationTimestamp) { listener.onSuccess(operationsApplied, hashedVersionAfterApplication, applicationTimestamp); waveletInfo.getUserManager(author).submitResponse(channelId, waveletName, hashedVersionAfterApplication); }
/** * Receives notification that the specified wavelet has been committed at the * specified version. */ public void onCommit(WaveletName waveletName, HashedVersion version) { Preconditions.checkNotNull(waveletName); Preconditions.checkNotNull(version); List<WaveViewSubscription> listeners = matchSubscriptions(waveletName); for (WaveViewSubscription listener : listeners) { listener.onCommit(waveletName, version); } }
@Override public UserManager load(ParticipantId from) { return new UserManager(); } });
/** * Sends an update to the client. */ private void sendUpdate(WaveletName waveletName, List<TransformedWaveletDelta> deltas, HashedVersion committedVersion) { // Channel id needs to be sent with every message until views can be // closed, see bug 128. openListener.onUpdate(waveletName, null, deltas, committedVersion, null, channelId); }
/** * Creates new instance of {@link WaveletInfo}. * * @param hashFactory the factory for hashed versions. * @param provider the {@link WaveletProvider}. * @return new {@link WaveletInfo} instance. */ public static WaveletInfo create(HashedVersionFactory hashFactory, WaveletProvider provider) { return new WaveletInfo(hashFactory, provider); }
@Override public WaveletChannelState load(WaveletId id) { return new WaveletChannelState(); } });
/** * Creates a new RPC interface to the front-end. * * @param frontend front-end to which to forward requests * @param handleAuthentication whether to handle authentication; it's * otherwise expected to be handled before this class */ public static WaveClientRpcImpl create(ClientFrontend frontend, boolean handleAuthentication) { return new WaveClientRpcImpl(frontend, handleAuthentication); }
/** * Tests that delta updates are held back while a submit is in flight. */ public void testDeltaHeldBackWhileOutstandingSubmit() { OpenListener listener = mock(OpenListener.class); m.subscribe(W1, IdFilters.ALL_IDS, "ch", listener); m.submitRequest("ch", W1A); m.onUpdate(W1A, DELTAS); verifyZeroInteractions(listener); m.submitResponse("ch", W1A, V3); // V3 not the same as update delta. verify(listener).onUpdate(W1A, null, DELTAS, null, null, "ch"); }
public void testCannotOpenWavesWhenNotLoggedIn() throws Exception { OpenListener listener = mock(OpenListener.class); clientFrontend.openRequest(null, WAVE_ID, IdFilters.ALL_IDS, NO_KNOWN_WAVELETS, listener); verify(listener).onFailure(new ChannelException(ResponseCode.NOT_LOGGED_IN, "Not Logged in", null, Recoverable.NOT_RECOVERABLE, WAVE_ID, null)); CommittedWaveletSnapshot snapshot = provideWavelet(WN1); clientFrontend.waveletUpdate(snapshot.snapshot, DELTAS); Mockito.verifyNoMoreInteractions(listener); }
/** * Tests that a single delta update is received by the listener. */ public void testSingleDeltaReceived() { OpenListener listener = mock(OpenListener.class); m.subscribe(W1, IdFilters.ALL_IDS, "ch", listener); m.onUpdate(W1A, DELTAS); verify(listener).onUpdate(W1A, null, DELTAS, null, null, "ch"); }
public void testOpenEmptyWaveReceivesChannelIdAndMarker() { OpenListener listener = openWave(IdFilters.ALL_IDS); verifyChannelId(listener); verifyMarker(listener, WAVE_ID); }
@Override public void onFailure(String error) { listener.onFailure(error); waveletInfo.getUserManager(author).submitResponse(channelId, waveletName, null); } });