Package co.paralleluniverse.galaxy.core.Message

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


    @Test
    public void whenGETBcastAndKnownOwnerThenCHNGD_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(-1), 1234L);
            cache.receive(get);

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

            reset();
View Full Code Here


    @Test
    public void whenGETBcastAndUnknownOwnerThenACK() throws Exception {
        for (Message.Type getType : new Message.Type[]{Message.Type.GET, Message.Type.GETX}) {
            cache.runOp(new Op(GET, 1234L, null)); // create an I line with unknown owner

            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

        assertThat(res1, is(PENDING));
        assertThat(res2, is(PENDING));
        assertThat(res3, is(PENDING));
        assertThat(res4, is(PENDING));

        cache.receive(Message.TIMEOUT(new LineMessage(sh(1), Type.GET, 1L)));

        try {
            op1.getResult();
            fail("TimeoutException not thrown");
        } catch (Exception e) {
View Full Code Here

        for (int i = 0; i < n; i++) {
            final Iterator<LineMessage> it = pending.iterator();
            if (!it.hasNext())
                break;

            final LineMessage msg = it.next();
            it.remove();

            LOG.debug("Handling pending message {}", msg);
            change |= handleMessage1(msg, line);

            messageCount++;
            totalDelay += now - msg.getTimestamp();
        }

        if (messageCount > 0)
            monitor.addMessageHandlingDelay(messageCount, totalDelay, reason);
View Full Code Here

    private List<Message.MSG> getAndClearPendingMSGs(CacheLine line) {
        final List<Message.MSG> ms = new ArrayList<>();
        final Collection<LineMessage> msgs = getPendingMessages(line);
        for (Iterator<LineMessage> it = msgs.iterator(); it.hasNext();) {
            final LineMessage msg = it.next();
            if (msg.getType() == Message.Type.MSG) {
                ms.add((Message.MSG) msg);
                it.remove();
            }
        }
        return ms;
View Full Code Here

            processLines(new LinePredicate() {
                @Override
                public boolean processLine(CacheLine line) {
                    // remove pending messages from node
                    for (Iterator<LineMessage> it = getPendingMessages(line).iterator(); it.hasNext();) {
                        LineMessage message = it.next();
                        if (message.getNode() == node)
                            it.remove();
                    }
                    processLineOnNodeEvent(line, node, newOwner);
                    return true;
                }
View Full Code Here

        send(id, Streamables.toByteArray(msg));
    }

    @Override
    public void send(long id, byte[] msg) throws TimeoutException {
        final LineMessage message = Message.MSG((short) -1, id, false, msg);
        cache.doOp(Type.SEND, id, null, message, null);
    }
View Full Code Here

        return sendAsync(id, Streamables.toByteArray(msg));
    }

    @Override
    public ListenableFuture<Void> sendAsync(long id, byte[] msg) {
        final LineMessage message = Message.MSG((short) -1, id, false, msg);
        return (ListenableFuture<Void>) (Object) cache.doOpAsync(Type.SEND, id, null, message, null);
    }
View Full Code Here

    }

    private void sendToOwnerOf(long line, Msg msg) throws TimeoutException {
        if (LOG.isDebugEnabled())
            LOG.debug("Sending to owner of {}: {}", Long.toHexString(line), msg);
        final LineMessage message = Message.MSG((short) -1, line, true, Streamables.toByteArray(msg));
        cache.doOp(Type.SEND, line, null, message, null);
    }
View Full Code Here

    }

    private ListenableFuture<Void> sendToOwnerOfAsync(long line, Msg msg) {
        if (LOG.isDebugEnabled())
            LOG.debug("Sending to owner of {}: {}", Long.toHexString(line), msg);
        final LineMessage message = Message.MSG((short) -1, line, true, Streamables.toByteArray(msg));
        return (ListenableFuture<Void>) (Object) cache.doOpAsync(Type.SEND, line, null, message, null);
    }
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.