Package org.apache.pig.penny.impl.comm

Examples of org.apache.pig.penny.impl.comm.Message


           
        }

        @Override
        public void receiveMessage(Location source, Tuple tuple) {
            final Message message = new Message(source, PhysicalLocation.coordinatorLocation(), tuple);
            //System.out.println("Got: " + message);
            synchronized(messages) {
                messages.add(message);
            }
            try {
View Full Code Here


                return location;
            }

            @Override
            public void sendToCoordinator(Tuple message) {
                senderReceiver.sendAsync(new Message(location, PhysicalLocation
                        .coordinatorLocation(), message));
            }

            @Override
            public void sendDownstream(Tuple message)
                    throws NoSuchLocationException {
                if (withinTaskDownstreamNeighbors.isEmpty()
                        && crossTaskDownstreamNeighbors.isEmpty())
                    throw new NoSuchLocationException("Line "
                            + logicalLocation.logId()
                            + " has no downstream neighbor.");
                for (String neighbor : withinTaskDownstreamNeighbors) {
                    sendWithinTaskMessage(neighbor, new Message(location,
                            new LogicalLocation(neighbor), message));
                }
                for (String neighbor : crossTaskDownstreamNeighbors) {
                    senderReceiver
                            .sendAsync(new Message(location,
                                    new LogicalLocation(neighbor), message));
                }
            }

            @Override
            public void sendUpstream(Tuple message)
                    throws NoSuchLocationException {
                if (withinTaskUpstreamNeighbors.isEmpty())
                    throw new NoSuchLocationException("Line "
                            + logicalLocation.logId()
                            + " has no within-task upstream neighbor.");
                for (String neighbor : withinTaskUpstreamNeighbors) {
                    sendWithinTaskMessage(neighbor, new Message(location,
                            new LogicalLocation(neighbor), message));
                }
            }

            @Override
            public void sendToAgents(LogicalLocation destination, Tuple tuple)
                    throws NoSuchLocationException {
                if (!logicalIds.contains(destination.logId()))
                    throw new NoSuchLocationException("Logical location "
                            + destination + " does not exist.");
                senderReceiver.sendAsync(new Message(location, destination, tuple));
            }

        };

        this.messageReceiptCallback = new MessageReceiptCallback() {
View Full Code Here

    public void finish() {
        synchronized (monitorAgent) {
            monitorAgent.finish();
        }
        senderReceiver.sendAsync(new Message(Type.DEREG, location, PhysicalLocation.coordinatorLocation(), null));
        senderReceiver.shutdown();
    }
View Full Code Here

            body.append("cross");
            body.append(keys);
            for (String tag : tags) {
                body.append(tag);
            }
            senderReceiver.sendAsync(new Message(Message.Type.TAINT, location,
                    new LogicalLocation(neighbor), body));
        }
    }
View Full Code Here

            body.append("within");
            for (String tag : tags) {
                body.append(tag);
            }
            for (String neighbor : withinTaskDownstreamNeighbors) {
                sendWithinTaskMessage(neighbor, new Message(Message.Type.TAINT, location, new LogicalLocation(neighbor), body));
            }
            withinTaskDownstreamTaint = tags;
        }
    }
View Full Code Here

        return keys;
    }
   
    private Message createRegistrationMessage() {
        Tuple body = new DefaultTuple();
        return new Message(Message.Type.REG, logicalLocation, PhysicalLocation.coordinatorLocation(), body);
    }
View Full Code Here

        @Override
        public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
                throws Exception {
            final Channel channel = ctx.getChannel();
            Message m = (Message)e.getMessage();
            Tuple t = cb.receive(m);
            if (m.type() == Type.DEREG) {
                channel.close();
            }
            if (t != null) {
                if (m.type() == Type.REG) {
                    PhysicalLocation pl = new PhysicalLocation(m.source().logId(), (Integer)t.get(0));
                    plMap.put(pl, channel);
                    ctx.setAttachment(pl);
                }
                Message rsp = new Message(m.type(), m.getAck(), m.destination(), m.source(), t);
                channel.write(rsp);
            }
        }
View Full Code Here

        }
       
         @Override
        public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
                throws Exception {
            final Message message = (Message) e.getMessage();
            if (message.getAck() == Message.NO_ACK) {
                cb.receive(message);
            } else {
                SyncCallResult scr = outstandingAcks.remove(message.getAck());
                if (scr != null) {
                    synchronized(scr) {
                        scr.setTuple(message.body());
                        scr.notifyAll();
                    }
                }
            }
        }
View Full Code Here

            }

            @Override
            public void sendToAgents(LogicalLocation location, Tuple tuple)
                    throws NoSuchLocationException {
                handleSendRequest(false, new Message(PhysicalLocation.coordinatorLocation(), location, tuple));
            }

        };
       
        coordinator.initialize(communicator);
View Full Code Here

TOP

Related Classes of org.apache.pig.penny.impl.comm.Message

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.