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

Implement JoinGroup request as first class stream #844

Merged
merged 6 commits into from
Mar 12, 2024
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 @@ -73,6 +73,7 @@ public class KafkaConfiguration extends Configuration
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 IntPropertyDef KAFKA_CLIENT_GROUP_INITIAL_REBALANCE_DELAY_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 @@ -105,6 +106,8 @@ public class KafkaConfiguration extends Configuration
(int) Duration.ofSeconds(6).toMillis());
KAFKA_CLIENT_GROUP_MAX_SESSION_TIMEOUT_DEFAULT = config.property("client.group.max.session.timeout.default",
(int) Duration.ofMinutes(5).toMillis());
KAFKA_CLIENT_GROUP_INITIAL_REBALANCE_DELAY_DEFAULT = config.property("client.group.initial.rebalance.delay.default",
0);
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 @@ -315,6 +318,11 @@ public int clientGroupMaxSessionTimeoutDefault()
return KAFKA_CLIENT_GROUP_MAX_SESSION_TIMEOUT_DEFAULT.get(this);
}

public int clientGroupInitialRebalanceDelayDefault()
{
return KAFKA_CLIENT_GROUP_INITIAL_REBALANCE_DELAY_DEFAULT.get(this);
}

private static boolean supplyVerbose(
Configuration config)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package io.aklivity.zilla.runtime.binding.kafka.internal.stream;

import java.util.function.IntFunction;
import java.util.function.LongFunction;
import java.util.function.UnaryOperator;

Expand Down Expand Up @@ -62,12 +63,20 @@ public KafkaClientFactory(
final BindingHandler streamFactory = config.clientConnectionPool() ? connectionPool.streamFactory() :
context.streamFactory();

final IntFunction<BindingHandler> streamFactorySupplier = d ->
d == 0 ? streamFactory : context.streamFactory();

final UnaryOperator<KafkaSaslConfig> resolveSasl = config.clientConnectionPool() ? c -> null :
UnaryOperator.identity();

final IntFunction<UnaryOperator<KafkaSaslConfig>> resolveSaslSupplier = d ->
d == 0 ? resolveSasl : UnaryOperator.identity();

final Signaler signaler = config.clientConnectionPool() ? connectionPool.signaler() :
context.signaler();

final IntFunction<Signaler> signalSupplier = d -> d == 0 ? signaler : context.signaler();

final KafkaClientMetaFactory clientMetaFactory = new KafkaClientMetaFactory(
config, context, bindings::get, accountant::supplyDebitor, supplyClientRoute,
signaler, streamFactory, resolveSasl);
Expand All @@ -76,8 +85,8 @@ public KafkaClientFactory(
config, context, bindings::get, accountant::supplyDebitor, signaler, streamFactory, resolveSasl);

final KafkaClientGroupFactory clientGroupFactory = new KafkaClientGroupFactory(
config, context, bindings::get, accountant::supplyDebitor, signaler, streamFactory,
resolveSasl, supplyClientRoute);
config, context, bindings::get, accountant::supplyDebitor, signalSupplier, streamFactorySupplier,
resolveSaslSupplier, supplyClientRoute);

final KafkaClientFetchFactory clientFetchFactory = new KafkaClientFetchFactory(
config, context, bindings::get, accountant::supplyDebitor, supplyClientRoute);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ public void shouldRebalanceProtocolHighlanderUnknownMemberId() throws Exception
k3po.finish();
}

@Test
@Configuration("client.yaml")
@Specification({
"${app}/leader.assignment/client",
"${net}/initial.delay.config/server"})
public void shouldCreateConnectionForJoinGroup() throws Exception
{
k3po.finish();
}


@Test
@Configuration("client.yaml")
@Specification({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,28 @@ connect await ROUTED_CLUSTER_SERVER

connected

write 87 # size
write 121 # size
32s # describe configs
0s # v0
${newRequestId}
5s "zilla" # client id
1 # resources
[0x04] # broker resource
1s "0" # "node" topic
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
28s "group.max.session.timeout.ms" # name
32s "group.initial.rebalance.delay.ms" # name

read 103 # size
read 143 # size
(int:newRequestId)
0
1 # resources
0s # no error
-1s # error message
[0x04] # broker resource
1s "0" # "0" nodeId
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
4s "6000" # value
[0x00] # not read only
Expand All @@ -89,6 +90,11 @@ read 103 # size
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive
32s "group.initial.rebalance.delay.ms" # name
1s "0" # value
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive

write 82 # size
11s # join group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,34 +48,40 @@ accepted

connected

read 87 # size
read 121 # size
32s # describe configs
0s # v0
(int:requestId)
5s "zilla" # client id
1 # resources
[0x04] # broker resource
1s "0" # "node" topic
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
28s "group.max.session.timeout.ms" # name
32s "group.initial.rebalance.delay.ms" # name

write 103 # size
write 143 # size
${requestId}
0
1 # resources
0s # no error
-1s # error message
[0x04] # broker resource
1s "0" # "0" nodeId
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
4s "6000" # value
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive
28s "group.max.session.timeout.ms" # name
5s "30000" # value
28s "group.max.session.timeout.ms" # name
5s "30000" # value
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive
32s "group.initial.rebalance.delay.ms" # name
1s "0" # value
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,28 @@ connect await ROUTED_CLUSTER_SERVER

connected

write 87 # size
write 121 # size
32s # describe configs
0s # v0
${newRequestId}
5s "zilla" # client id
1 # resources
[0x04] # broker resource
1s "0" # "node" topic
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
28s "group.max.session.timeout.ms" # name
32s "group.initial.rebalance.delay.ms" # name

read 103 # size
read 143 # size
(int:newRequestId)
0
1 # resources
0s # no error
-1s # error message
[0x04] # broker resource
1s "0" # "0" nodeId
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
4s "6000" # value
[0x00] # not read only
Expand All @@ -90,6 +91,11 @@ read 103 # size
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive
32s "group.initial.rebalance.delay.ms" # name
1s "0" # value
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive

write 82 # size
11s # join group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,40 @@ accepted

connected

read 87 # size
read 121 # size
32s # describe configs
0s # v0
(int:requestId)
5s "zilla" # client id
1 # resources
[0x04] # broker resource
1s "0" # "node" topic
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
28s "group.max.session.timeout.ms" # name
32s "group.initial.rebalance.delay.ms" # name

write 103 # size
write 143 # size
${requestId}
0
1 # resources
0s # no error
-1s # error message
[0x04] # broker resource
1s "0" # "0" nodeId
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
4s "6000" # value
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive
28s "group.max.session.timeout.ms" # name
5s "30000" # value
28s "group.max.session.timeout.ms" # name
5s "30000" # value
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive
32s "group.initial.rebalance.delay.ms" # name
1s "0" # value
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,28 @@ connect await ROUTED_DESCRIBE_SERVER

connected

write 87 # size
write 121 # size
32s # describe configs
0s # v0
${newRequestId}
5s "zilla" # client id
1 # resources
[0x04] # broker resource
1s "0" # "node" topic
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
28s "group.max.session.timeout.ms" # name
32s "group.initial.rebalance.delay.ms" # name

read 103 # size
read 143 # size
(int:newRequestId)
0
1 # resources
0s # no error
-1s # error message
[0x04] # broker resource
1s "0" # "0" nodeId
2 # configs
3 # configs
28s "group.min.session.timeout.ms" # name
4s "6000" # value
[0x00] # not read only
Expand All @@ -104,6 +105,11 @@ read 103 # size
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive
32s "group.initial.rebalance.delay.ms" # name
1s "0" # value
[0x00] # not read only
[0x00] # not default
[0x00] # not sensitive

write 82 # size
11s # join group
Expand Down
Loading