Codota Logo
StreamValidationException
Code IndexAdd Codota to your IDE (free)

How to use
StreamValidationException
in
org.apache.samza.system

Best Java code snippets using org.apache.samza.system.StreamValidationException (Showing top 7 results out of 315)

  • Common ways to obtain StreamValidationException
private void myMethod () {
StreamValidationException s =
  • Codota IconObject[] args;new StreamValidationException(String.format("<changeme>", args, expectedPartitionCounter, actualPartitionCounter))
  • Smart code suggestions by Codota
}
origin: apache/samza

@Override
public void validateStream(StreamSpec streamSpec) throws StreamValidationException {
 LOG.info("About to validate stream = " + streamSpec);
 String streamName = streamSpec.getPhysicalName();
 SystemStreamMetadata systemStreamMetadata =
   getSystemStreamMetadata(Collections.singleton(streamName)).get(streamName);
 if (systemStreamMetadata == null) {
  throw new StreamValidationException(
    "Failed to obtain metadata for stream " + streamName + ". Validation failed.");
 }
 int actualPartitionCounter = systemStreamMetadata.getSystemStreamPartitionMetadata().size();
 int expectedPartitionCounter = streamSpec.getPartitionCount();
 LOG.info("actualCount=" + actualPartitionCounter + "; expectedCount=" + expectedPartitionCounter);
 if (actualPartitionCounter != expectedPartitionCounter) {
  throw new StreamValidationException(
    String.format("Mismatch of partitions for stream %s. Expected %d, got %d. Validation failed.", streamName,
      expectedPartitionCounter, actualPartitionCounter));
 }
}
origin: org.apache.samza/samza-kafka_2.11

@Override
public void validateStream(StreamSpec streamSpec) throws StreamValidationException {
 LOG.info("About to validate stream = " + streamSpec);
 String streamName = streamSpec.getPhysicalName();
 SystemStreamMetadata systemStreamMetadata =
   getSystemStreamMetadata(Collections.singleton(streamName)).get(streamName);
 if (systemStreamMetadata == null) {
  throw new StreamValidationException(
    "Failed to obtain metadata for stream " + streamName + ". Validation failed.");
 }
 int actualPartitionCounter = systemStreamMetadata.getSystemStreamPartitionMetadata().size();
 int expectedPartitionCounter = streamSpec.getPartitionCount();
 LOG.info("actualCount=" + actualPartitionCounter + "; expectedCount=" + expectedPartitionCounter);
 if (actualPartitionCounter != expectedPartitionCounter) {
  throw new StreamValidationException(
    String.format("Mismatch of partitions for stream %s. Expected %d, got %d. Validation failed.", streamName,
      expectedPartitionCounter, actualPartitionCounter));
 }
}
origin: org.apache.samza/samza-kafka

@Override
public void validateStream(StreamSpec streamSpec) throws StreamValidationException {
 LOG.info("About to validate stream = " + streamSpec);
 String streamName = streamSpec.getPhysicalName();
 SystemStreamMetadata systemStreamMetadata =
   getSystemStreamMetadata(Collections.singleton(streamName)).get(streamName);
 if (systemStreamMetadata == null) {
  throw new StreamValidationException(
    "Failed to obtain metadata for stream " + streamName + ". Validation failed.");
 }
 int actualPartitionCounter = systemStreamMetadata.getSystemStreamPartitionMetadata().size();
 int expectedPartitionCounter = streamSpec.getPartitionCount();
 LOG.info("actualCount=" + actualPartitionCounter + "; expectedCount=" + expectedPartitionCounter);
 if (actualPartitionCounter != expectedPartitionCounter) {
  throw new StreamValidationException(
    String.format("Mismatch of partitions for stream %s. Expected %d, got %d. Validation failed.", streamName,
      expectedPartitionCounter, actualPartitionCounter));
 }
}
origin: apache/samza

@Test(expected = StreamValidationException.class)
public void testStartFailsOnTopicValidationErrors() {
 KafkaStreamSpec checkpointSpec = new KafkaStreamSpec(CHECKPOINT_TOPIC, CHECKPOINT_TOPIC,
   CHECKPOINT_SYSTEM, 1);
 // create an admin that throws an exception during validateStream
 SystemAdmin mockAdmin = newAdmin("0", "10");
 doThrow(new StreamValidationException("invalid stream")).when(mockAdmin).validateStream(checkpointSpec);
 SystemFactory factory = newFactory(mock(SystemProducer.class), mock(SystemConsumer.class), mockAdmin);
 KafkaCheckpointManager checkpointManager = new KafkaCheckpointManager(checkpointSpec, factory,
   true, mock(Config.class), mock(MetricsRegistry.class), null, new KafkaCheckpointLogKeySerde());
 // expect an exception during startup
 checkpointManager.createResources();
 checkpointManager.start();
}
origin: apache/samza

/**
 * Converts a StreamSpec into a KafakStreamSpec. Special handling for coordinator and changelog stream.
 * @param spec a StreamSpec object
 * @return KafkaStreamSpec object
 */
public KafkaStreamSpec toKafkaSpec(StreamSpec spec) {
 KafkaStreamSpec kafkaSpec;
 if (spec.isChangeLogStream()) {
  String topicName = spec.getPhysicalName();
  ChangelogInfo topicMeta = changelogTopicMetaInformation.get(topicName);
  if (topicMeta == null) {
   throw new StreamValidationException("Unable to find topic information for topic " + topicName);
  }
  kafkaSpec = new KafkaStreamSpec(spec.getId(), topicName, systemName, spec.getPartitionCount(),
    topicMeta.replicationFactor(), topicMeta.kafkaProps());
 } else if (spec.isCoordinatorStream()) {
  kafkaSpec =
    new KafkaStreamSpec(spec.getId(), spec.getPhysicalName(), systemName, 1, coordinatorStreamReplicationFactor,
      coordinatorStreamProperties);
 } else if (intermediateStreamProperties.containsKey(spec.getId())) {
  kafkaSpec = KafkaStreamSpec.fromSpec(spec).copyWithProperties(intermediateStreamProperties.get(spec.getId()));
 } else {
  kafkaSpec = KafkaStreamSpec.fromSpec(spec);
 }
 return kafkaSpec;
}
origin: org.apache.samza/samza-kafka

/**
 * Converts a StreamSpec into a KafakStreamSpec. Special handling for coordinator and changelog stream.
 * @param spec a StreamSpec object
 * @return KafkaStreamSpec object
 */
public KafkaStreamSpec toKafkaSpec(StreamSpec spec) {
 KafkaStreamSpec kafkaSpec;
 if (spec.isChangeLogStream()) {
  String topicName = spec.getPhysicalName();
  ChangelogInfo topicMeta = changelogTopicMetaInformation.get(topicName);
  if (topicMeta == null) {
   throw new StreamValidationException("Unable to find topic information for topic " + topicName);
  }
  kafkaSpec = new KafkaStreamSpec(spec.getId(), topicName, systemName, spec.getPartitionCount(),
    topicMeta.replicationFactor(), topicMeta.kafkaProps());
 } else if (spec.isCoordinatorStream()) {
  kafkaSpec =
    new KafkaStreamSpec(spec.getId(), spec.getPhysicalName(), systemName, 1, coordinatorStreamReplicationFactor,
      coordinatorStreamProperties);
 } else if (intermediateStreamProperties.containsKey(spec.getId())) {
  kafkaSpec = KafkaStreamSpec.fromSpec(spec).copyWithProperties(intermediateStreamProperties.get(spec.getId()));
 } else {
  kafkaSpec = KafkaStreamSpec.fromSpec(spec);
 }
 return kafkaSpec;
}
origin: org.apache.samza/samza-kafka_2.11

/**
 * Converts a StreamSpec into a KafakStreamSpec. Special handling for coordinator and changelog stream.
 * @param spec a StreamSpec object
 * @return KafkaStreamSpec object
 */
public KafkaStreamSpec toKafkaSpec(StreamSpec spec) {
 KafkaStreamSpec kafkaSpec;
 if (spec.isChangeLogStream()) {
  String topicName = spec.getPhysicalName();
  ChangelogInfo topicMeta = changelogTopicMetaInformation.get(topicName);
  if (topicMeta == null) {
   throw new StreamValidationException("Unable to find topic information for topic " + topicName);
  }
  kafkaSpec = new KafkaStreamSpec(spec.getId(), topicName, systemName, spec.getPartitionCount(),
    topicMeta.replicationFactor(), topicMeta.kafkaProps());
 } else if (spec.isCoordinatorStream()) {
  kafkaSpec =
    new KafkaStreamSpec(spec.getId(), spec.getPhysicalName(), systemName, 1, coordinatorStreamReplicationFactor,
      coordinatorStreamProperties);
 } else if (intermediateStreamProperties.containsKey(spec.getId())) {
  kafkaSpec = KafkaStreamSpec.fromSpec(spec).copyWithProperties(intermediateStreamProperties.get(spec.getId()));
 } else {
  kafkaSpec = KafkaStreamSpec.fromSpec(spec);
 }
 return kafkaSpec;
}
org.apache.samza.systemStreamValidationException

Most used methods

  • <init>

Popular in Java

  • Making http post requests using okhttp
  • putExtra (Intent)
  • notifyDataSetChanged (ArrayAdapter)
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement.A servlet is a small Java program that runs within
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