Package backtype.storm.tuple

Examples of backtype.storm.tuple.Tuple


  public static Tuple mockTickTuple() {
    return mockTuple(Constants.SYSTEM_COMPONENT_ID, Constants.SYSTEM_TICK_STREAM_ID);
  }

  public static Tuple mockTuple(String componentId, String streamId) {
    Tuple tuple = mock(Tuple.class);
    when(tuple.getSourceComponent()).thenReturn(componentId);
    when(tuple.getSourceStreamId()).thenReturn(streamId);
    return tuple;
  }
View Full Code Here


          TasksCommon.put_xor(anchors_to_ids, root_id, edge_id);
      }
        }
    }
    MessageId msgid=MessageId.makeId(anchors_to_ids);
    workerTransfer.transfer(t,new Tuple(topologyContext, values, task_id,out_stream_id, msgid));

      }
      return StormUtils.mk_list(out_tasks);
  } catch (Exception e) {
      LOG.error("bolt emit", e);
View Full Code Here

    msgid = MessageId.makeRootId(root_id, t);
      } else {
    msgid = MessageId.makeUnanchored();
      }

      Tuple tp = new Tuple(topology_context, values, task_id,out_stream_id, msgid);
      transfer_fn.transfer(t, tp);

  }

  TupleInfo info = new TupleInfo(out_stream_id,values);
View Full Code Here

              } else {
                  Map action = (Map) JSONValue.parse(line);
                  String command = (String) action.get("command");
                  if(command.equals("ack")) {
                    Long id = (Long) action.get("id");
                    Tuple acked = _inputs.remove(id);
                    if(acked==null) {
                        throw new RuntimeException("Acked a non-existent or already acked/failed id: " + id);
                    }
                    _collector.ack(acked);
                  } else if (command.equals("fail")) {
                    Long id = (Long) action.get("id");
                    Tuple failed = _inputs.remove(id);
                    if(failed==null) {
                        throw new RuntimeException("Failed a non-existent or already acked/failed id: " + id);
                    }
                    _collector.fail(failed);
                  } else if (command.equals("log")) {
View Full Code Here

    byte[] ser_msg = puller.recv();

    if (ser_msg != null && ser_msg.length > 0) {
      LOG.debug("Processing message");
      Tuple tuple = deserializer.deserialize(ser_msg);

      if (sampler.getResult()) {
        tuple_start_times.put(tuple, System.currentTimeMillis());
      }
View Full Code Here

  while (true) {

      byte[] ser_msg = puller.recv();

      if (ser_msg != null && ser_msg.length > 0) {
    Tuple tuple = deserializer.deserialize(ser_msg);
    Object id = tuple.getValue(0);
    Object olist = pending.remove(id);

    if (olist == null) {
        continue;
    }

    List list = (List) olist;

    Object start_time_ms = list.get(2);
    Long time_delta = null;
    if (start_time_ms != null) {
        time_delta = TimeUtils.time_delta_ms((Long) start_time_ms);
    }

    Object msgId = list.get(0);
    Object tupleInfo =  list.get(1);

    if (msgId == null||tupleInfo==null) {
        continue;
    }

    String stream_id = tuple.getSourceStreamId();
    if (stream_id.equals(Acker.ACKER_ACK_STREAM_ID)) {
        event_queue.add(new AckSpoutMsg(spout, storm_conf,
          msgId, (TupleInfo)tupleInfo, time_delta, task_stats));
    } else if (stream_id.equals(Acker.ACKER_FAIL_STREAM_ID)) {
        event_queue.add(new FailSpoutMsg(spout, storm_conf,
View Full Code Here

                int streamId = WritableUtils.readVInt(in);
                String componentName = _context.getComponentId(taskId);
                String streamName = _ids.getStreamName(componentName, streamId);
                MessageId id = MessageId.deserialize(in);
                List<Object> values = _kryo.deserializeFrom(bin);
                return new Tuple(_context, values, taskId, streamName, id);
            } catch(IOException e) {
                throw new RuntimeException(e);
            }
        }
View Full Code Here

    public static void send(TopologyContext topologyContext,
      TaskSendTargets taskTargets, WorkerTransfer transfer_fn,
      String stream, List<Object> values) {
  java.util.Set<Integer> tasks = taskTargets.get(stream, values);
  Integer taskId = topologyContext.getThisTaskId();
  Tuple tup = new Tuple(topologyContext, values, taskId, stream);
  for (Integer task : tasks) {
      transfer_fn.transfer(task, tup);
  }
    }
View Full Code Here

        } else {
            results.put(requestId, tuple);
        }

        if(returns.containsKey(requestId) && results.containsKey(requestId)) {
            Tuple result = results.remove(requestId);
            Tuple returner = returns.remove(requestId);
            LOG.debug(result.getValue(1).toString());
            List<Tuple> anchors = new ArrayList<Tuple>();
            anchors.add(result);
            anchors.add(returner);           
            _collector.emit(anchors, new Values(""+result.getValue(1), returner.getValue(1)));
            _collector.ack(result);
            _collector.ack(returner);
        }
    }
View Full Code Here

        public void run() {
            while (!stopRequested) {
                try {
                    ArrayList<Tuple> batch = new ArrayList<Tuple>();
                    // drainTo() does not block, take() does.
                    Tuple t = queue.take();
                    batch.add(t);
                    if (batchMaxSize > 0) {
                        queue.drainTo(batch, batchMaxSize);
                    } else {
                        queue.drainTo(batch);
View Full Code Here

TOP

Related Classes of backtype.storm.tuple.Tuple

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.