Codota Logo
PubSubMessage.getSequence
Code IndexAdd Codota to your IDE (free)

How to use
getSequence
method
in
com.yahoo.bullet.pubsub.PubSubMessage

Best Java code snippets using com.yahoo.bullet.pubsub.PubSubMessage.getSequence (Showing top 7 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
origin: com.yahoo.bullet/bullet-core

@Override
public boolean equals(Object other) {
  if (other == null || other.getClass() != PubSubMessage.class) {
    return false;
  }
  PubSubMessage otherMessage = (PubSubMessage) other;
  return id.equals(otherMessage.getId()) && sequence == otherMessage.getSequence();
}
origin: com.yahoo.bullet/bullet-core

@Override
public PubSubMessage receive() throws PubSubException {
  if (uncommittedMessages.size() >= maxUncommittedMessages) {
    log.warn("Reached limit of max uncommitted messages: {}. Waiting for commits to proceed.", maxUncommittedMessages);
    return null;
  }
  if (!haveMessages()) {
    return null;
  }
  PubSubMessage message = receivedMessages.remove(0);
  uncommittedMessages.put(ImmutablePair.of(message.getId(), message.getSequence()), message);
  return message;
}
origin: com.yahoo.bullet/bullet-storm

@Override
public List<PubSubMessage> getMessages() throws PubSubException {
  // Try and read from DRPC. The DRPCSpout does a sleep for 1 ms if there are no tuples, so we don't have to do it.
  spout.nextTuple();
  if (!collector.haveOutput()) {
    return null;
  }
  // The DRPCSpout only should have emitted one tuple
  List<List<Object>> tuples = collector.reset();
  log.debug("Have a message through DRPC {}", tuples);
  List<Object> tupleAndID = tuples.get(0);
  // The first object is the actual DRPCSpout tuple and the second is the DRPC messageID.
  List<Object> tuple = (List<Object>) tupleAndID.get(0);
  Object drpcID = tupleAndID.get(1);
  // The first object in the tuple is our PubSubMessage as JSON
  String pubSubMessageJSON = (String) tuple.get(0);
  // The second object in the tuple is the serialized returnInfo added by the DRPCSpout
  String returnInfo = (String) tuple.get(1);
  log.debug("Read message\n{}\nfrom DRPC with return information {}", pubSubMessageJSON, returnInfo);
  PubSubMessage pubSubMessage = PubSubMessage.fromJSON(pubSubMessageJSON);
  // Add returnInfo as metadata. Cannot add it to pubSubMessage
  String id = pubSubMessage.getId();
  String content = pubSubMessage.getContent();
  int sequence = pubSubMessage.getSequence();
  PubSubMessage message = new PubSubMessage(id, content, new Metadata(null, returnInfo), sequence);
  emittedIDs.put(ImmutablePair.of(id, sequence), drpcID);
  return Collections.singletonList(message);
}
origin: bullet-db/bullet-storm

@Override
public List<PubSubMessage> getMessages() throws PubSubException {
  // Try and read from DRPC. The DRPCSpout does a sleep for 1 ms if there are no tuples, so we don't have to do it.
  spout.nextTuple();
  if (!collector.haveOutput()) {
    return null;
  }
  // The DRPCSpout only should have emitted one tuple
  List<List<Object>> tuples = collector.reset();
  log.debug("Have a message through DRPC {}", tuples);
  List<Object> tupleAndID = tuples.get(0);
  // The first object is the actual DRPCSpout tuple and the second is the DRPC messageID.
  List<Object> tuple = (List<Object>) tupleAndID.get(0);
  Object drpcID = tupleAndID.get(1);
  // The first object in the tuple is our PubSubMessage as JSON
  String pubSubMessageJSON = (String) tuple.get(0);
  // The second object in the tuple is the serialized returnInfo added by the DRPCSpout
  String returnInfo = (String) tuple.get(1);
  log.debug("Read message\n{}\nfrom DRPC with return information {}", pubSubMessageJSON, returnInfo);
  PubSubMessage pubSubMessage = PubSubMessage.fromJSON(pubSubMessageJSON);
  // Add returnInfo as metadata. Cannot add it to pubSubMessage
  String id = pubSubMessage.getId();
  String content = pubSubMessage.getContent();
  int sequence = pubSubMessage.getSequence();
  PubSubMessage message = new PubSubMessage(id, content, new Metadata(null, returnInfo), sequence);
  emittedIDs.put(ImmutablePair.of(id, sequence), drpcID);
  return Collections.singletonList(message);
}
origin: com.yahoo.bullet/bullet-storm

@Override
public void send(PubSubMessage message) throws PubSubException {
  Metadata metadata = message.getMetadata();
  // Remove the content
  String content = metadata.getContent().toString();
  log.debug("Removing metadata {} for result {}@{}: {}", content, message.getId(), message.getSequence(), message.getContent());
  metadata.setContent(null);
  String serializedMessage = message.asJSON();
  Tuple tuple = new DRPCTuple(new Values(serializedMessage, content));
  // This sends the message through DRPC and not to the collector but it acks or fails accordingly.
  bolt.execute(tuple);
  if (!collector.isAcked()) {
    throw new PubSubException("Message not acked. Unable to send message through DRPC:\n " + serializedMessage);
  }
  // Otherwise, we're good to proceed
  collector.reset();
}
origin: bullet-db/bullet-storm

@Override
public void send(PubSubMessage message) throws PubSubException {
  Metadata metadata = message.getMetadata();
  // Remove the content
  String content = metadata.getContent().toString();
  log.debug("Removing metadata {} for result {}@{}: {}", content, message.getId(), message.getSequence(), message.getContent());
  metadata.setContent(null);
  String serializedMessage = message.asJSON();
  Tuple tuple = new DRPCTuple(new Values(serializedMessage, content));
  // This sends the message through DRPC and not to the collector but it acks or fails accordingly.
  bolt.execute(tuple);
  if (!collector.isAcked()) {
    throw new PubSubException("Message not acked. Unable to send message through DRPC:\n " + serializedMessage);
  }
  // Otherwise, we're good to proceed
  collector.reset();
}
origin: bullet-db/bullet-storm

Assert.assertEquals(actual.getSequence(), 0);
Assert.assertEquals(actual.getContent(), "{}");
Assert.assertFalse(actual.hasSignal());
Assert.assertEquals(actual.getSequence(), 1);
Assert.assertEquals(actual.getContent(), "{'duration': 2000}");
Assert.assertFalse(actual.hasSignal());
Assert.assertEquals(actual.getSequence(), 0);
Assert.assertEquals(actual.getContent(), "{}");
Assert.assertFalse(actual.hasSignal());
com.yahoo.bullet.pubsubPubSubMessagegetSequence

Popular methods of PubSubMessage

  • <init>
    Constructor for a message having content, Metadata and a sequence number.
  • asJSON
  • getId
  • getMetadata
  • fromJSON
    Converts a json representation back to an instance.
  • getContent
  • hasMetadata
    Check if message has Metadata.
  • hasSignal
    Check if message has a given Signal.
  • setMetadata

Popular in Java

  • Running tasks concurrently on multiple threads
  • onRequestPermissionsResult (Fragment)
  • getContentResolver (Context)
  • onCreateOptionsMenu (Activity)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • List (java.util)
    A List is a collection which maintains an ordering for its elements. Every element in the List has a
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now