Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static com.linkedin.venice.ConfigKeys.KAFKA_PRODUCER_REQUEST_TIMEOUT_MS;
import static com.linkedin.venice.ConfigKeys.KAFKA_PRODUCER_RETRIES_CONFIG;
import static com.linkedin.venice.ConfigKeys.MULTI_REGION;
import static com.linkedin.venice.ConfigKeys.PUBSUB_BROKER_ADDRESS;
import static com.linkedin.venice.ConfigKeys.VENICE_PARTITIONERS;
import static com.linkedin.venice.VeniceConstants.DEFAULT_SSL_FACTORY_CLASS_NAME;
import static com.linkedin.venice.status.BatchJobHeartbeatConfigs.HEARTBEAT_ENABLED_CONFIG;
Expand Down Expand Up @@ -866,13 +867,8 @@ public void run() {
if (pushJobSetting.isSourceKafka) {
if (pushJobSetting.sourceVersionCompressionStrategy == CompressionStrategy.ZSTD_WITH_DICT) {
LOGGER.info("Source version uses ZSTD_WITH_DICT. Fetching source dictionary.");
Properties kafkaConsumerProperties = new Properties();
if (pushJobSetting.enableSSL) {
kafkaConsumerProperties.putAll(this.sslProperties.get());
}
kafkaConsumerProperties.setProperty(KAFKA_BOOTSTRAP_SERVERS, pushJobSetting.repushSourcePubsubBroker);
ByteBuffer sourceDict = DictionaryUtils
.readDictionaryFromKafka(pushJobSetting.kafkaInputTopic, new VeniceProperties(kafkaConsumerProperties));
.readDictionaryFromKafka(pushJobSetting.kafkaInputTopic, getSourceDictionaryConsumerProperties());
if (sourceDict != null) {
pushJobSetting.sourceDictionary = ByteUtils.extractByteArray(sourceDict);
}
Expand Down Expand Up @@ -1666,6 +1662,25 @@ private Optional<ByteBuffer> getCompressionDictionary() throws VeniceException {
return Optional.of(emptyPushZstdDictionary.get());
}

private VeniceProperties getSourceDictionaryConsumerProperties() {
return buildSourceDictionaryConsumerProperties(
props,
pushJobSetting.enableSSL ? sslProperties.get() : new Properties(),
pushJobSetting.repushSourcePubsubBroker);
}

@VisibleForTesting
static VeniceProperties buildSourceDictionaryConsumerProperties(
VeniceProperties jobProperties,
Properties sslProperties,
String sourcePubsubBroker) {
Properties consumerProperties = jobProperties.toProperties();
consumerProperties.putAll(sslProperties);
consumerProperties.setProperty(PUBSUB_BROKER_ADDRESS, sourcePubsubBroker);
consumerProperties.setProperty(KAFKA_BOOTSTRAP_SERVERS, sourcePubsubBroker);
return new VeniceProperties(consumerProperties);
}

private ByteBuffer fetchOrBuildCompressionDictionary() throws VeniceException {
// Prepare the param builder, which can be used by different scenarios.
KafkaInputDictTrainer.ParamBuilder paramBuilder = new KafkaInputDictTrainer.ParamBuilder()
Expand All @@ -1691,14 +1706,8 @@ private ByteBuffer fetchOrBuildCompressionDictionary() throws VeniceException {
return ByteBuffer.wrap(dictTrainer.trainDict());
} else {
LOGGER.info("Reading Zstd dictionary from input topic: {}", pushJobSetting.kafkaInputTopic);
// set up ssl properties and kafka consumer properties
Properties kafkaConsumerProperties = new Properties();
if (pushJobSetting.enableSSL) {
kafkaConsumerProperties.putAll(this.sslProperties.get());
}
kafkaConsumerProperties.setProperty(KAFKA_BOOTSTRAP_SERVERS, pushJobSetting.repushSourcePubsubBroker);
return DictionaryUtils
.readDictionaryFromKafka(pushJobSetting.kafkaInputTopic, new VeniceProperties(kafkaConsumerProperties));
.readDictionaryFromKafka(pushJobSetting.kafkaInputTopic, getSourceDictionaryConsumerProperties());
}
}
LOGGER.info(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.linkedin.venice.hadoop;

import static com.linkedin.venice.ConfigKeys.KAFKA_BOOTSTRAP_SERVERS;
import static com.linkedin.venice.ConfigKeys.PUBSUB_BROKER_ADDRESS;
import static com.linkedin.venice.ConfigKeys.PUBSUB_CONSUMER_ADAPTER_FACTORY_CLASS;
import static com.linkedin.venice.ConfigKeys.PUBSUB_SECURITY_PROTOCOL;
import static com.linkedin.venice.ConfigKeys.PUBSUB_TYPE_ID_TO_POSITION_CLASS_NAME_MAP;
import static com.linkedin.venice.vpj.VenicePushJobConstants.ALLOW_REGULAR_PUSH_WITH_TTL_REPUSH;
import static com.linkedin.venice.vpj.VenicePushJobConstants.COMPLIANCE_PUSH;
import static com.linkedin.venice.vpj.VenicePushJobConstants.KAFKA_INPUT_MAX_RECORDS_PER_MAPPER;
Expand All @@ -26,6 +31,7 @@
import com.linkedin.venice.meta.StoreInfo;
import com.linkedin.venice.meta.Version;
import com.linkedin.venice.utils.Time;
import com.linkedin.venice.utils.VeniceProperties;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand All @@ -42,6 +48,58 @@
*/

public class VenicePushJobRepushTest extends VenicePushJobTestBase {
@Test
public void testSourceDictionaryConsumerPropertiesRetainPubSubConfigAndOverrideBrokers() {
Properties jobProperties = new Properties();
jobProperties.setProperty(
PUBSUB_CONSUMER_ADAPTER_FACTORY_CLASS,
"com.linkedin.venice.pubsub.adapter.xinfra.consumer.XcConsumerAdapterFactory");
jobProperties.setProperty(
PUBSUB_TYPE_ID_TO_POSITION_CLASS_NAME_MAP,
"1:com.linkedin.venice.pubsub.adapter.xinfra.XinfraPosition");
jobProperties.setProperty("xc.pubsub.broker.url.to.region.name.map", "northguard:ei4");
jobProperties.setProperty(PUBSUB_BROKER_ADDRESS, "destination-broker");
jobProperties.setProperty(KAFKA_BOOTSTRAP_SERVERS, "legacy-broker");

VeniceProperties consumerProperties = VenicePushJob.buildSourceDictionaryConsumerProperties(
new VeniceProperties(jobProperties),
new Properties(),
"source-broker");

assertEquals(
consumerProperties.getString(PUBSUB_CONSUMER_ADAPTER_FACTORY_CLASS),
"com.linkedin.venice.pubsub.adapter.xinfra.consumer.XcConsumerAdapterFactory");
assertEquals(
consumerProperties.getString(PUBSUB_TYPE_ID_TO_POSITION_CLASS_NAME_MAP),
"1:com.linkedin.venice.pubsub.adapter.xinfra.XinfraPosition");
assertEquals(consumerProperties.getString("xc.pubsub.broker.url.to.region.name.map"), "northguard:ei4");
assertEquals(consumerProperties.getString(PUBSUB_BROKER_ADDRESS), "source-broker");
assertEquals(consumerProperties.getString(KAFKA_BOOTSTRAP_SERVERS), "source-broker");
assertEquals(
jobProperties.getProperty(PUBSUB_BROKER_ADDRESS),
"destination-broker",
"Building consumer properties must not mutate the job properties");
}

@Test
public void testSourceDictionaryConsumerPropertiesApplySslOverrides() {
Properties jobProperties = new Properties();
jobProperties.setProperty(PUBSUB_SECURITY_PROTOCOL, "PLAINTEXT");
jobProperties.setProperty("ssl.keystore.location", "stale-keystore");
jobProperties.setProperty("xc.tls.key.store.type", "PKCS12");

Properties sslProperties = new Properties();
sslProperties.setProperty(PUBSUB_SECURITY_PROTOCOL, "SSL");
sslProperties.setProperty("ssl.keystore.location", "credential-keystore");

VeniceProperties consumerProperties = VenicePushJob
.buildSourceDictionaryConsumerProperties(new VeniceProperties(jobProperties), sslProperties, "source-broker");

assertEquals(consumerProperties.getString(PUBSUB_SECURITY_PROTOCOL), "SSL");
assertEquals(consumerProperties.getString("ssl.keystore.location"), "credential-keystore");
assertEquals(consumerProperties.getString("xc.tls.key.store.type"), "PKCS12");
}

@Test(expectedExceptions = VeniceException.class, expectedExceptionsMessageRegExp = ".*Repush with TTL is only supported while using Kafka Input Format.*")
public void testRepushTTLJobWithNonKafkaInput() {
Properties repushProps = new Properties();
Expand Down
Loading