Package backtype.storm.messaging

Examples of backtype.storm.messaging.TaskMessage


        }

        // Read the length field.
        int length = buf.readInt();
        if (length<=0) {
            return new TaskMessage(task, null);
        }
       
        // Make sure if there's enough bytes in the buffer.
        if (buf.readableBytes() < length) {
            // The whole bytes were not received yet - return null.
            buf.resetReaderIndex();
            return null;
        }

        // There's enough bytes in the buffer. Read it.
        ChannelBuffer payload = buf.readBytes(length);

        // Successfully decoded a frame.
        // Return a TaskMessage object
        return new TaskMessage(task,payload.array());
    }
View Full Code Here


   
    private ArrayList<TaskMessage>[] groupMessages(List<TaskMessage> msgs) {
      ArrayList<TaskMessage> messageGroups[] = new ArrayList[queueCount];
     
      for (int i = 0; i < msgs.size(); i++) {
        TaskMessage message = msgs.get(i);
        int task = message.task();
       
        if (task == -1) {
          closing = true;
          return null;
        }
View Full Code Here

            connect();
            channel = channelRef.get();
        }

        while (msgs.hasNext()) {
            TaskMessage message = msgs.next();
            if (null == messageBatch) {
                messageBatch = new MessageBatch(messageBatchSize);
            }

            messageBatch.add(message);
View Full Code Here

        throw new RuntimeException("Client connection should not receive any messages");
    }

    @Override
    public void send(int taskId, byte[] payload) {
        TaskMessage msg = new TaskMessage(taskId, payload);
        List<TaskMessage> wrapper = new ArrayList<TaskMessage>(1);
        wrapper.add(msg);
        send(wrapper.iterator());
    }
View Full Code Here

        if ((flags & 0x01) == 0x01) {
            //non-blocking
            return message_queue.poll();
        } else {
            try {
                TaskMessage request = message_queue.take();
                LOG.debug("request to be processed: {}", request);
                return request;
            } catch (InterruptedException e) {
                LOG.info("exception within msg receiving", e);
                return null;
View Full Code Here

    void add(Object obj) {
        if (obj == null)
            throw new RuntimeException("null object forbidded in message batch");

        if (obj instanceof TaskMessage) {
            TaskMessage msg = (TaskMessage)obj;
            msgs.add(msg);
            encoded_length += msgEncodeLength(msg);
            return;
        }

        if (obj instanceof ControlMessage) {
            ControlMessage msg = (ControlMessage)obj;
            msgs.add(msg);
            encoded_length += msg.encodeLength();
            return;
        }

        throw new RuntimeException("Unsuppoted object type "+obj.getClass().getName());
    }
View Full Code Here

    void remove(Object obj) {
        if (obj == null) return;

        if (obj instanceof TaskMessage) {
            TaskMessage msg = (TaskMessage)obj;
            msgs.remove(msg);
            encoded_length -= msgEncodeLength(msg);
            return;
        }

        if (obj instanceof ControlMessage) {
            ControlMessage msg = (ControlMessage)obj;
            msgs.remove(msg);
            encoded_length -= msg.encodeLength();
            return;
        }
    }
View Full Code Here

        if (being_closed.get()) {
            throw new RuntimeException("Client is being closed, and does not take requests any more");
        }

        try {
            message_queue.put(new TaskMessage(task, message));
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        }

        // Read the length field.
        int length = buf.readInt();
        if (length<=0) {
            return new TaskMessage(task, null);
        }
       
        // Make sure if there's enough bytes in the buffer.
        if (buf.readableBytes() < length) {
            // The whole bytes were not received yet - return null.
            buf.resetReaderIndex();
            return null;
        }

        // There's enough bytes in the buffer. Read it.
        ChannelBuffer payload = buf.readBytes(length);

        // Successfully decoded a frame.
        // Return a TaskMessage object
        return new TaskMessage(task,payload.array());
    }
View Full Code Here

      try {
        TupleExt tuple = (TupleExt) event;
        int taskid = tuple.getTargetTaskId();
        byte[] tupleMessage = serializer.serialize(tuple);
        TaskMessage taskMessage = new TaskMessage(taskid, tupleMessage);
        transferQueue.publish(taskMessage);
      }finally {
        timer.stop();
      }
     
View Full Code Here

TOP

Related Classes of backtype.storm.messaging.TaskMessage

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.