Tabnine Logo
KafkaCheckpointLogKey.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.apache.samza.checkpoint.kafka.KafkaCheckpointLogKey
constructor

Best Java code snippets using org.apache.samza.checkpoint.kafka.KafkaCheckpointLogKey.<init> (Showing top 6 results out of 315)

origin: apache/samza

 @Override
 public KafkaCheckpointLogKey fromBytes(byte[] bytes) {
  try {
   LinkedHashMap<String, String> deserializedKey = mapper.readValue(bytes, LinkedHashMap.class);

   if (!KafkaCheckpointLogKey.CHECKPOINT_KEY_TYPE.equals(deserializedKey.get(TYPE_FIELD))) {
    throw new IllegalArgumentException(String.format("Invalid key detected. Type of the key is %s", deserializedKey.get(TYPE_FIELD)));
   }

   return new KafkaCheckpointLogKey(deserializedKey.get(TYPE_FIELD), new TaskName(deserializedKey.get(TASK_NAME_FIELD)), deserializedKey.get(SSP_GROUPER_FACTORY_FIELD)
   );
  } catch (Exception e) {
   throw new SamzaException(String.format("Exception in de-serializing checkpoint bytes: %s",
     Arrays.toString(bytes)), e);
  }
 }
}
origin: org.apache.samza/samza-kafka

 @Override
 public KafkaCheckpointLogKey fromBytes(byte[] bytes) {
  try {
   LinkedHashMap<String, String> deserializedKey = mapper.readValue(bytes, LinkedHashMap.class);

   if (!KafkaCheckpointLogKey.CHECKPOINT_KEY_TYPE.equals(deserializedKey.get(TYPE_FIELD))) {
    throw new IllegalArgumentException(String.format("Invalid key detected. Type of the key is %s", deserializedKey.get(TYPE_FIELD)));
   }

   return new KafkaCheckpointLogKey(deserializedKey.get(TYPE_FIELD), new TaskName(deserializedKey.get(TASK_NAME_FIELD)), deserializedKey.get(SSP_GROUPER_FACTORY_FIELD)
   );
  } catch (Exception e) {
   throw new SamzaException(String.format("Exception in de-serializing checkpoint bytes: %s",
     Arrays.toString(bytes)), e);
  }
 }
}
origin: org.apache.samza/samza-kafka_2.11

 @Override
 public KafkaCheckpointLogKey fromBytes(byte[] bytes) {
  try {
   LinkedHashMap<String, String> deserializedKey = mapper.readValue(bytes, LinkedHashMap.class);

   if (!KafkaCheckpointLogKey.CHECKPOINT_KEY_TYPE.equals(deserializedKey.get(TYPE_FIELD))) {
    throw new IllegalArgumentException(String.format("Invalid key detected. Type of the key is %s", deserializedKey.get(TYPE_FIELD)));
   }

   return new KafkaCheckpointLogKey(deserializedKey.get(TYPE_FIELD), new TaskName(deserializedKey.get(TASK_NAME_FIELD)), deserializedKey.get(SSP_GROUPER_FACTORY_FIELD)
   );
  } catch (Exception e) {
   throw new SamzaException(String.format("Exception in de-serializing checkpoint bytes: %s",
     Arrays.toString(bytes)), e);
  }
 }
}
origin: apache/samza

@Test
public void testBinaryCompatibility() {
 KafkaCheckpointLogKey logKey1 = new KafkaCheckpointLogKey(KafkaCheckpointLogKey.CHECKPOINT_KEY_TYPE,
   new TaskName("Partition 0"), GroupByPartitionFactory.class.getCanonicalName());
 KafkaCheckpointLogKeySerde checkpointSerde = new KafkaCheckpointLogKeySerde();
 byte[] bytes = ("{\"systemstreampartition-grouper-factory\"" +
   ":\"org.apache.samza.container.grouper.stream.GroupByPartitionFactory\",\"taskName\":\"Partition 0\"," +
   "\"type\":\"checkpoint\"}").getBytes();
 // test that the checkpoints returned by the Serde are byte-wise identical to an actual checkpoint in Kafka
 Assert.assertEquals(true, Arrays.equals(bytes, checkpointSerde.toBytes(logKey1)));
}
origin: apache/samza

/**
 * Creates a new checkpoint envelope for the provided task, ssp and offset
 */
private IncomingMessageEnvelope newCheckpointEnvelope(TaskName taskName, SystemStreamPartition ssp, String offset) {
 KafkaCheckpointLogKey checkpointKey =
   new KafkaCheckpointLogKey("checkpoint", taskName, GROUPER_FACTORY_CLASS);
 KafkaCheckpointLogKeySerde checkpointKeySerde = new KafkaCheckpointLogKeySerde();
 Checkpoint checkpointMsg = new Checkpoint(ImmutableMap.of(ssp, offset));
 CheckpointSerde checkpointMsgSerde = new CheckpointSerde();
 return new IncomingMessageEnvelope(CHECKPOINT_SSP, offset, checkpointKeySerde.toBytes(checkpointKey),
   checkpointMsgSerde.toBytes(checkpointMsg));
}
origin: apache/samza

 @Test
 public void testSerde() {
  KafkaCheckpointLogKey key = new KafkaCheckpointLogKey(KafkaCheckpointLogKey.CHECKPOINT_KEY_TYPE,
    new TaskName("Partition 0"), GroupByPartitionFactory.class.getCanonicalName());
  KafkaCheckpointLogKeySerde checkpointSerde = new KafkaCheckpointLogKeySerde();

  // test that deserialize(serialize(k)) == k
  Assert.assertEquals(key, checkpointSerde.fromBytes(checkpointSerde.toBytes(key)));
 }
}
org.apache.samza.checkpoint.kafkaKafkaCheckpointLogKey<init>

Popular methods of KafkaCheckpointLogKey

  • getGrouperFactoryClassName
  • getTaskName
  • getType

Popular in Java

  • Start an intent from android
  • compareTo (BigDecimal)
  • onRequestPermissionsResult (Fragment)
  • onCreateOptionsMenu (Activity)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now