Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consumer group session timeout defaults #584

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -69,6 +69,8 @@ public class KafkaConfiguration extends Configuration
public static final IntPropertyDef KAFKA_CACHE_SERVER_RECONNECT_DELAY;
public static final PropertyDef<NonceSupplier> KAFKA_CLIENT_SASL_SCRAM_NONCE;
public static final PropertyDef<Duration> KAFKA_CLIENT_GROUP_REBALANCE_TIMEOUT;
public static final IntPropertyDef KAFKA_CLIENT_GROUP_MIN_SESSION_TIMEOUT_DEFAULT;
public static final IntPropertyDef KAFKA_CLIENT_GROUP_MAX_SESSION_TIMEOUT_DEFAULT;
public static final PropertyDef<String> KAFKA_CLIENT_ID;
public static final PropertyDef<InstanceIdSupplier> KAFKA_CLIENT_INSTANCE_ID;
public static final BooleanPropertyDef KAFKA_CLIENT_CONNECTION_POOL;
Expand Down Expand Up @@ -96,6 +98,9 @@ public class KafkaConfiguration extends Configuration
KafkaConfiguration::decodeNonceSupplier, KafkaConfiguration::defaultNonceSupplier);
KAFKA_CLIENT_GROUP_REBALANCE_TIMEOUT = config.property(Duration.class, "client.group.rebalance.timeout",
(c, v) -> Duration.parse(v), "PT4S");
KAFKA_CLIENT_GROUP_MIN_SESSION_TIMEOUT_DEFAULT = config.property("client.group.min.session.timeout.default", 0);
KAFKA_CLIENT_GROUP_MAX_SESSION_TIMEOUT_DEFAULT = config.property("client.group.max.session.timeout.default",
Integer.MAX_VALUE);
KAFKA_CACHE_DIRECTORY = config.property(Path.class, "cache.directory",
KafkaConfiguration::cacheDirectory, KafkaBinding.NAME);
KAFKA_CACHE_SERVER_BOOTSTRAP = config.property("cache.server.bootstrap", true);
Expand Down Expand Up @@ -290,6 +295,16 @@ public Duration clientGroupRebalanceTimeout()
return KAFKA_CLIENT_GROUP_REBALANCE_TIMEOUT.get(this);
}

public int clientGroupMinSessionTimeoutDefault()
{
return KAFKA_CLIENT_GROUP_MIN_SESSION_TIMEOUT_DEFAULT.get(this);
}

public int clientGroupMaxSessionTimeoutDefault()
{
return KAFKA_CLIENT_GROUP_MAX_SESSION_TIMEOUT_DEFAULT.get(this);
}

private static Path cacheDirectory(
Configuration config,
String cacheDirectory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ public final class KafkaClientGroupFactory extends KafkaClientSaslHandshaker imp
private final KafkaGroupCoordinatorClientDecoder decodeCoordinatorIgnoreAll = this::decodeIgnoreAll;
private final KafkaGroupCoordinatorClientDecoder decodeCoordinatorReject = this::decodeCoordinatorReject;

private final Map<String, String> configs = new LinkedHashMap<>();
private final int kafkaTypeId;
private final int proxyTypeId;
private final MutableDirectBuffer writeBuffer;
Expand All @@ -275,9 +274,11 @@ public final class KafkaClientGroupFactory extends KafkaClientSaslHandshaker imp
private final LongFunction<BudgetDebitor> supplyDebitor;
private final Long2ObjectHashMap<GroupMembership> instanceIds;
private final Object2ObjectHashMap<String, KafkaGroupStream> groupStreams;
private final Map<String, String> configs;
private final String clientId;
private final Duration rebalanceTimeout;

private final String groupMinSessionTimeoutDefault;
private final String groupMaxSessionTimeoutDefault;

public KafkaClientGroupFactory(
KafkaConfiguration config,
Expand All @@ -288,21 +289,24 @@ public KafkaClientGroupFactory(
BindingHandler streamFactory)
{
super(config, context);
this.rebalanceTimeout = config.clientGroupRebalanceTimeout();
this.clientId = config.clientId();
this.supplyInstanceId = config.clientInstanceIdSupplier();
this.kafkaTypeId = context.supplyTypeId(KafkaBinding.NAME);
this.proxyTypeId = context.supplyTypeId("proxy");
this.signaler = signaler;
this.streamFactory = streamFactory;
this.writeBuffer = new UnsafeBuffer(new byte[context.writeBuffer().capacity()]);
this.extBuffer = new UnsafeBuffer(new byte[context.writeBuffer().capacity()]);
this.decodePool = context.bufferPool();
this.encodePool = context.bufferPool();
this.supplyBinding = supplyBinding;
this.rebalanceTimeout = config.clientGroupRebalanceTimeout();
this.clientId = config.clientId();
this.supplyInstanceId = config.clientInstanceIdSupplier();
this.supplyDebitor = supplyDebitor;
this.signaler = signaler;
this.streamFactory = streamFactory;
this.instanceIds = new Long2ObjectHashMap<>();
this.groupStreams = new Object2ObjectHashMap<>();
this.configs = new LinkedHashMap<>();
this.groupMinSessionTimeoutDefault = String.valueOf(config.clientGroupMinSessionTimeoutDefault());
this.groupMaxSessionTimeoutDefault = String.valueOf(config.clientGroupMaxSessionTimeoutDefault());
}

@Override
Expand Down Expand Up @@ -3052,8 +3056,10 @@ private void onDecodeDescribeResponse(
{
nextResponseId++;

int timeoutMin = Integer.valueOf(newConfigs.get(GROUP_MIN_SESSION_TIMEOUT)).intValue();
int timeoutMax = Integer.valueOf(newConfigs.get(GROUP_MAX_SESSION_TIMEOUT)).intValue();
int timeoutMin =
Integer.valueOf(newConfigs.getOrDefault(GROUP_MIN_SESSION_TIMEOUT, groupMinSessionTimeoutDefault)).intValue();
int timeoutMax =
Integer.valueOf(newConfigs.getOrDefault(GROUP_MAX_SESSION_TIMEOUT, groupMaxSessionTimeoutDefault)).intValue();
if (delegate.timeout < timeoutMin)
{
delegate.timeout = timeoutMin;
Expand Down