Package co.paralleluniverse.galaxy.core.Message

Examples of co.paralleluniverse.galaxy.core.Message.LineMessage


        if (hasServer())
            cache.receive(Message.INVACK(Message.INV(sh(0), 1234L, sh(10))));

        assertState(1234L, O, null);

        final LineMessage get1 = Message.GET(sh(50), 1234L);
        final LineMessage get2 = Message.GET(sh(60), 1234L);
        cache.receive(get1);
        cache.receive(get2);

        assertState(1234L, O, null);
        verify(comm).send(argThat(equalTo(Message.PUT(get1, 1234L, 2, toBuffer("hello")))));
        verify(comm).send(argThat(equalTo(Message.PUT(get2, 1234L, 2, toBuffer("hello")))));

        final LineMessage getx = Message.GETX(sh(50), 1234L);
        cache.receive(getx);

        assertOwner(1234L, sh(50));

        assertState(1234L, I, null);
View Full Code Here


     * When GET/X is received and not broadcast and line is not found, send CHNGD_OWNER
     */
    @Test
    public void whenGETAndNoLineThenCHNGD_OWNER() throws Exception {
        for (Message.Type getType : new Message.Type[]{Message.Type.GET, Message.Type.GETX}) {
            final LineMessage get = new Message.GET(getType, sh(50), 1234L);
            cache.receive(get);

            verify(comm).send(argThat(equalTo(Message.CHNGD_OWNR(get, 1234L, sh(-1), false))));

            reset();
View Full Code Here

     * When GET/X broadcast is received and line is not found, send ACK
     */
    @Test
    public void whenGETBcastAndNoLineThenACK() throws Exception {
        for (Message.Type getType : new Message.Type[]{Message.Type.GET, Message.Type.GETX}) {
            final LineMessage get = new Message.GET(getType, sh(-1), 1234L);
            cache.receive(get);

            verify(comm).send(argThat(equalTo(Message.ACK(get))));

            reset();
View Full Code Here

    public void whenGetAndCHNGD_OWNRThenGETAgain() throws Exception {
        cache.runOp(new Op(GET, 1234L, null));

        when(cluster.getMaster(sh(20))).thenReturn(makeNodeInfo(sh(20)));

        LineMessage msg = (LineMessage) captureMessage();
        cache.receive(Message.CHNGD_OWNR(msg, 1234L, sh(20), true));

        verify(comm).send(argThat(equalTo(Message.GET(sh(20), 1234L))));
    }
View Full Code Here

        cache.runOp(new Op(GET, 1234L, null));

        when(cluster.getMaster(sh(20))).thenReturn(null);

        LineMessage msg = (LineMessage) captureMessage();
        cache.receive(Message.CHNGD_OWNR(msg, 1234L, sh(20), true));

        verify(comm).send(argThat(equalTo(Message.GET(sh(10), 1234L))));
    }
View Full Code Here

        when(cluster.getMaster(sh(20))).thenReturn(makeNodeInfo(sh(20)));

        cache.runOp(new Op(GETX, 1234L, null));

        LineMessage msg = (LineMessage) captureMessage();
        cache.receive(Message.CHNGD_OWNR(msg, 1234L, sh(20), true));

        verify(comm).send(argThat(equalTo(Message.GETX(sh(20), 1234L))));
    }
View Full Code Here

    }

    @Test
    public void whenGetxAndCHNGD_OWNRToYou() throws Exception {
        ListenableFuture<Object> future = cache.doOpAsync(GETX, 1234L, null, null, null);
        LineMessage msg = (LineMessage) captureMessage();
        cache.receive(Message.CHNGD_OWNR(msg, 1234L, sh(10), true));
        assertThat(future.isDone(), is(false));
        cache.receive(Message.PUTX(msg, 1234L, null, 0, 1L, toBuffer("foo")));
        if (hasServer())
            INVACK(1234L, sh(0));
View Full Code Here

    /**
     * When MSG is received and not broadcast and line is not found, send CHNGD_OWNER
     */
    @Test
    public void whenMSGAndNoLineThenCHNGD_OWNER() throws Exception {
        final LineMessage msg = Message.MSG(sh(10), 1234L, true, serialize("foo"));
        cache.receive(msg);

        verify(comm).send(argThat(equalTo(Message.CHNGD_OWNR(msg, 1234L, sh(-1), false))));
    }
View Full Code Here

    /**
     * When MSG broadcast is received and line is not found, send ACK
     */
    @Test
    public void whenMSGBcastAndNoLineThenACK() throws Exception {
        final LineMessage msg = Message.MSG(sh(-1), 1234L, true, serialize("foo"));
        cache.receive(msg);

        verify(comm).send(argThat(equalTo(Message.ACK(msg))));
    }
View Full Code Here

    @Test
    public void whenGETAndNotOwnerThenCHNGD_OWNER() throws Exception {
        for (Message.Type getType : new Message.Type[]{Message.Type.GET, Message.Type.GETX}) {
            PUT(1234L, sh(10), 1L, "hello");

            final LineMessage get = new Message.GET(getType, sh(50), 1234L);
            cache.receive(get);

            verify(comm).send(argThat(equalTo(Message.CHNGD_OWNR(get, 1234L, sh(10), true))));

            reset();
View Full Code Here

TOP

Related Classes of co.paralleluniverse.galaxy.core.Message.LineMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.