Package backtype.storm.tuple

Examples of backtype.storm.tuple.Tuple


        Map<String, JuggaloaderStreamState> states = new HashMap<>();
        Values previousValues = null;
        for (int i = 0; iter.hasNext(); i++) {
            BasicDBObject dbObject = (BasicDBObject) iter.next();
            dbObject.put("testFunction", testFunction);
            Tuple tuple = createTuple(dbObject);
            Values values = JuggaloaderTimeBase.process(tuple, states, Constants.PERIOD_MINUTE, null);
            assertNotNull(values);

            if (i > JuggaloaderTimeBase.W) {
                if (dbObject.getString("isanomaly").equals("A") && !((Boolean)values.get(13))) {
View Full Code Here


    private Tuple createTuple(BasicDBObject dbObject) {
        Map<String,String> metricCriteria = new HashMap<>();
        metricCriteria.put("one", "1");
        metricCriteria.put("two", "2");

        Tuple tuple = mock(TupleImpl.class);
        when(tuple.getStringByField("metricAccount")).thenReturn("JuggaloaderTimeBaseTest-"+dbObject.getString("testFunction"));
        when(tuple.getStringByField("metricName")).thenReturn(MetricName.TEST_STREAM.toString());
        when(tuple.getStringByField("metricType")).thenReturn("ABSOLUTE");
        when(tuple.getLongByField("metricTimestamp")).thenReturn(getMetricTimestamp());
        when(tuple.getFloatByField("metricValue")).thenReturn(Float.parseFloat(dbObject.getString("y")));
        when(tuple.getValueByField("metaData")).thenReturn(new HashMap<String,Object>());
        when(tuple.getValueByField("metricCriteria")).thenReturn(metricCriteria);
        return tuple;
    }
View Full Code Here

        // Prepare the bolt so that it uses our mock output collector
        bolt.prepare(null, null, new OutputCollector(outputCollector));

        // Emit all events
        for (Map<String, Object> event : events) {
            Tuple tuple = Mockito.mock(Tuple.class);

            Mockito.when(tuple.getValue(0)).thenReturn(event);

            bolt.execute(tuple);
        }

        // Turn all emitted metrics into the metrics map
View Full Code Here

        List<BasicDBObject> connections = mongoClient.getConnections();

        for (BasicDBObject connection : connections) {
            InternalConnectionInventoryBolt bolt = new InternalConnectionInventoryBolt();
            MockOutputCollector outputCollector = new MockOutputCollector();
            Tuple tuple = mock(Tuple.class);
            List<BasicDBObject> expectedInventoryItems = new ArrayList<>();
            String connectionId = connection.getString("_id");
            final String connectionType = connection.getString("type");

            when(tuple.getValue(0)).thenReturn(connection);

            bolt.prepare(null, null, new OutputCollector(outputCollector));

            bolt.execute(tuple);
View Full Code Here

        // emit with or without anchors
        // before acking
        synchronized (emitQueue) {
            for (Object[] toemit : this.emitQueue) {
                String streamID = (String) toemit[0];
                Tuple anchor = (Tuple) toemit[1];
                Values vals = (Values) toemit[2];
                if (anchor == null)
                    _collector.emit(streamID, vals);
                else
                    _collector.emit(streamID, Arrays.asList(anchor), vals);
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

        _inputs.clear();
    }

    private void handleAck(Map action) {
        String id = (String) 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);
    }
View Full Code Here

        _collector.ack(acked);
    }

    private void handleFail(Map action) {
        String id = (String) 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);
    }
View Full Code Here

        if(anchorObj!=null) {
            if(anchorObj instanceof String) {
                anchorObj = Arrays.asList(anchorObj);
            }
            for(Object o: (List) anchorObj) {
                Tuple t = _inputs.get((String) o);
                if (t == null) {
                    throw new RuntimeException("Anchored onto " + o + " after ack/fail");
                }
                anchors.add(t);
            }
View Full Code Here

        Pair pair = (Pair) input.getValue(1);
       
        Pair trade = null;
        Pair customer = null;
       
        Tuple tradeTuple = null;
        Tuple customerTuple = null;
       
        if (input.getSourceComponent().equals(SequenceTopologyDef.CUSTOMER_BOLT_NAME) ) {
            customer = pair;
            customerTuple = input;
           
            tradeTuple = tradeMap.remove(tupleId);
            if (tradeTuple == null) {
                customerMap.put(tupleId, input);
                return;
            }
           
            trade = (Pair) tradeTuple.getValue(1);
           
        } else if (input.getSourceComponent().equals(SequenceTopologyDef.TRADE_BOLT_NAME)) {
            trade = pair;
            tradeTuple = input;
           
            customerTuple = customerMap.remove(tupleId);
            if (customerTuple == null) {
                tradeMap.put(tupleId, input);
                return;
            }
           
            customer = (Pair) customerTuple.getValue(1);
        } else {
            LOG.info("Unknow source component: " + input.getSourceComponent());
            collector.fail(input);
            return;
        }
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.