public void nextTuple() { Utils.sleep(100); }
public void nextTuple() { if (_serveTuples.size() > 0) { FixedTuple ft = _serveTuples.remove(0); String id = UUID.randomUUID().toString(); _pending.put(id, ft); _collector.emit(ft.stream, ft.values, id); } else { Utils.sleep(100); } }
@Override public void nextTuple() { Long now = System.currentTimeMillis(); List<Object> tuple = Collections.singletonList(now); collector.emit(tuple, now); Utils.sleep(sleepTimeMs); }
public void downloadResourcesAsSupervisorImpl(String key, String localFile, ClientBlobStore cb) throws AuthorizationException, KeyNotFoundException, IOException { final int MAX_RETRY_ATTEMPTS = 2; final int ATTEMPTS_INTERVAL_TIME = 100; for (int retryAttempts = 0; retryAttempts < MAX_RETRY_ATTEMPTS; retryAttempts++) { if (downloadResourcesAsSupervisorAttempt(cb, key, localFile)) { break; } Utils.sleep(ATTEMPTS_INTERVAL_TIME); } } }
@Override public void nextTuple() { Utils.sleep(5000); for (Values v : values.get(index)) { collector.emit(v); } index = (index + 1) % values.size(); }
@Override public boolean isReady(long txid) { if (!_waitToEmit) { return true; } List allBatches = (List) RegisteredGlobalState.getState(_id); if (allBatches.size() > _masterEmitted) { _masterEmitted++; return true; } else { Utils.sleep(2); return false; } } }
public void nextTuple() { Utils.sleep(100); final String[] words = new String[]{ "nathan", "mike", "jackson", "golda", "bertels" }; final Random rand = new Random(); final String word = words[rand.nextInt(words.length)]; _collector.emit(new Values(word)); }
@Override public void nextTuple() { Utils.sleep(100); collector.emit(new Values(rand.nextInt(1000), System.currentTimeMillis() - (24 * 60 * 60 * 1000), ++msgId), msgId); }
public void nextTuple() { String[] user = sentences[index].split(","); Values values = new Values(Integer.parseInt(user[0]),user[1],user[2],user[3],user[4],user[5]); UUID msgId = UUID.randomUUID(); this.pending.put(msgId, values); this.collector.emit(values, msgId); index++; if (index >= sentences.length) { index = 0; } count++; total++; if(count > 1000){ Utils.sleep(1000); count = 0; System.out.println("Pending count: " + this.pending.size() + ", total: " + this.total); } }
@Override public void nextTuple() { Utils.sleep(2000); for (String word : words) { collector.emit(new Values(word)); } }
@Override public void nextTuple() { Utils.sleep(100); _collector.emit(new Values(getRandomSentence())); }
public void waitTopologyScheduled(String topoName, ILocalCluster cluster, int retryAttempts) throws TException { for (int i = 0; i < retryAttempts; i++) { if (checkTopologyScheduled(topoName, cluster)) { //sleep to prevent race conditions Utils.sleep(SLEEP_TIME_BETWEEN_RETRY); return; } Utils.sleep(SLEEP_TIME_BETWEEN_RETRY); } throw new RuntimeException("Error: Wait for topology " + topoName + " to be ACTIVE has timed out!"); }
@Override public void nextTuple() { Utils.sleep(990); collector.emit(new Values(i, function.apply(i))); i++; }
public void nextTuple() { Utils.sleep(100); final String[] words = new String[]{ "nathan", "mike", "jackson", "golda", "bertels" }; final Random rand = new Random(); final String word = words[rand.nextInt(words.length)]; _collector.emit(new Values(word)); }
@Override public void nextTuple() { Utils.sleep(100); String[] sentences = new String[]{ sentence("the cow jumped over the moon"), sentence("an apple a day keeps the doctor away"), sentence("four score and seven years ago"), sentence("snow white and the seven dwarfs"), sentence("i am at two with nature") }; final String sentence = sentences[_rand.nextInt(sentences.length)]; LOG.debug("Emitting tuple: {}", sentence); _collector.emit(new Values(sentence)); }
@Override public void nextTuple() { Utils.sleep(10); String[] sentences = new String[]{ sentence("the cow jumped over the moon"), sentence("an apple a day keeps the doctor away"), sentence("four score and seven years ago"), sentence("snow white and the seven dwarfs"), sentence("i am at two with nature") }; final String sentence = sentences[random.nextInt(sentences.length)]; this.collector.emit(new Values(sentence), UUID.randomUUID()); }
public void nextTuple() { Utils.sleep(100); final String[] words = new String[]{"nathan", "mike", "jackson", "golda", "bertels"}; final Random rand = new Random(); final String word = words[rand.nextInt(words.length)]; _collector.emit(new Values(word)); }
@Override public void nextTuple() { if (shouldRecover()) { handleRecovery(); startProgress(); } else if (shouldCheckpoint()) { doCheckpoint(); startProgress(); } else { Utils.sleep(sleepInterval); } }
@Test(timeout = 10000) public void testConcurrentGet() throws Exception { List<Integer> loaded = new ArrayList<>(); SimpleWindowPartitionCache<Integer, Object> cache = SimpleWindowPartitionCache.<Integer, Object>newBuilder() .maximumSize(1) .build(key -> { Utils.sleep(1000); loaded.add(key); return new Object(); }); FutureTask<Object> ft1 = new FutureTask<>(() -> cache.pinAndGet(1)); FutureTask<Object> ft2 = new FutureTask<>(() -> cache.pinAndGet(1)); Thread t1 = new Thread(ft1); Thread t2 = new Thread(ft2); t1.start(); t2.start(); t1.join(); t2.join(); Assert.assertEquals(Collections.singletonList(1), loaded); Assert.assertEquals(ft1.get(), ft2.get()); }
/** * Create a new topology that writes random UUIDs to Kafka. * * @param brokerUrl Kafka broker URL * @param topicName Topic to which publish sentences * @return A Storm topology that produces random UUIDs using a {@link LambdaSpout} and uses a {@link KafkaBolt} to publish the UUIDs to * the kafka topic specified */ public static StormTopology newTopology(String brokerUrl, String topicName) { final TopologyBuilder builder = new TopologyBuilder(); builder.setSpout("spout", () -> { Utils.sleep(1000); //Throttle this spout a bit to avoid maxing out CPU return UUID.randomUUID().toString(); }); /* The output field of the spout ("lambda") is provided as the boltMessageField so that this gets written out as the message in the kafka topic. The tuples have no key field, so the messages are written to Kafka without a key.*/ final KafkaBolt<String, String> bolt = new KafkaBolt<String, String>() .withProducerProperties(newProps(brokerUrl, topicName)) .withTopicSelector(new DefaultTopicSelector(topicName)) .withTupleToKafkaMapper(new FieldNameBasedTupleToKafkaMapper<>("key", "lambda")); builder.setBolt("forwardToKafka", bolt, 1).shuffleGrouping("spout"); return builder.createTopology(); }