Skip to content

SAMZA-1921: upgrade to use the latest java AdminClient. - #789

Closed
sborya wants to merge 70 commits into
apache:masterfrom
sborya:JavaAdminClient
Closed

sborya wants to merge 70 commits into
apache:masterfrom
sborya:JavaAdminClient

Conversation

@sborya

@sborya sborya commented Oct 31, 2018

Copy link
Copy Markdown
Contributor

In this PR, I've refactored create/clear streams methods.

Boris Shkolnik and others added 30 commits October 16, 2017 15:25
protected static final long DEFAULT_EXPONENTIAL_SLEEP_MAX_DELAY_MS = 10000;
protected static final int MAX_RETRIES_ON_EXCEPTION = 5;
protected static final int DEFAULT_REPL_FACTOR = 2;
private static final int KAFKA_ADMIN_OPS_TIMEOUT_MS = 50000;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Do we need to make this to be configurable by the user.
  2. Why do we need to hardcode this to 50 seconds? Isn't that too high?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think user need to configure it. But I think you are right - it is too high. I will change it to 10 seconds (in case brokers are loaded), to match today's max delay.

this.metadataConsumer = metadataConsumer;

Properties props = createAdminClientProperties();
LOG.info("New admin client with props:" + props);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to use two different adminClient?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because deleteMessages() is only provided by the old kafka.admin.AdminClient. We will get rid of it when we move to the new Kafka (1.0)

@Override
public boolean createStream(StreamSpec streamSpec) {
LOG.info("Creating Kafka topic: {} on system: {}", streamSpec.getPhysicalName(), streamSpec.getSystemName());
final String REPL_FACTOR = "replication.factor";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would be better to move these static final constants to beginning of the class.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually yes, but this is kind of unfortunate hack, and it should be used only in this method. So I'd prefer to keep it here.

Comment thread samza-kafka/src/main/java/org/apache/samza/system/kafka/KafkaSystemAdmin.java Outdated
Comment thread samza-kafka/src/main/java/org/apache/samza/system/kafka/KafkaSystemAdmin.java Outdated
String repl = streamConfig.get(REPL_FACTOR);
LOG.warn("replication.factor (topic={}, repl={}) is invalid config for AdminClient.createTopics. Removing it. Using kSpec repl factor {}",
kSpec.getPhysicalName(), repl, kSpec.getReplicationFactor());
streamConfig.remove(REPL_FACTOR);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should preserve the replicationFactor value defined in the configuration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pass it in the spec.
You cannot pass it to the configs - it will fail config validation.

Comment thread samza-kafka/src/main/java/org/apache/samza/system/kafka/KafkaSystemAdmin.java Outdated
Comment thread samza-kafka/src/main/java/org/apache/samza/system/kafka/KafkaSystemAdmin.java Outdated
@asfgit asfgit closed this in ad12c6d Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants