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

Support remote zilla configuration with change detection #1071

Merged
merged 47 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
a370a7b
WIP reconfigure only changed namespaces
attilakreiner May 31, 2024
3757300
WIP watch resources
attilakreiner Jun 5, 2024
c02e5c4
WIP refactoring watch resources
attilakreiner Jun 5, 2024
8fcae70
WIP refactoring 2
attilakreiner Jun 5, 2024
96f070e
WIP fix
attilakreiner Jun 6, 2024
df0b998
WIP EngineConfigWatcher
attilakreiner Jun 6, 2024
c0a554f
WIP ResourceResolver
attilakreiner Jun 6, 2024
b726267
WIP fix ResourceResolver
attilakreiner Jun 6, 2024
9c2cbbe
fix indentation
attilakreiner Jun 10, 2024
abb923f
fix EngineManager method names
attilakreiner Jun 10, 2024
b9355c6
rm ResourceResolver
attilakreiner Jun 10, 2024
c58ebc9
WIP EngineManager addResources
attilakreiner Jun 10, 2024
2285123
Revert "WIP reconfigure only changed namespaces"
attilakreiner Jun 11, 2024
39f34d0
fix EngineConfigWatcher addResources
attilakreiner Jun 11, 2024
b482fac
Merge branch 'develop' into config-reload
attilakreiner Jun 11, 2024
fd17488
Merge branch 'develop' into config-reload
attilakreiner Jun 13, 2024
b6c2ff2
Merge branch 'develop' into config-reload
attilakreiner Jun 14, 2024
2da3603
WIP readPath resolvePath readLocation
attilakreiner Jun 11, 2024
c85bdc1
WIP filesystem-http
attilakreiner Jun 5, 2024
ab94dac
WIP
attilakreiner Jun 18, 2024
22a2d03
fix
attilakreiner Jun 18, 2024
dfe9610
Merge branch 'develop' into config-reload
attilakreiner Jun 18, 2024
e4cf407
fix
attilakreiner Jun 18, 2024
df172d8
fix EngineConfiguration configPath
attilakreiner Jun 19, 2024
bef04ad
WIP fix
attilakreiner Jun 19, 2024
3177c80
WIP hfs 1
attilakreiner Jun 20, 2024
2a217f8
WIP hfs uri
attilakreiner Jun 20, 2024
4f5737a
WIP hfs resolveSibling
attilakreiner Jun 20, 2024
6395780
WIP hfs rm timeout
attilakreiner Jun 20, 2024
54a2b87
WIP hfs revert send
attilakreiner Jun 20, 2024
a5d0a39
WIP hfs HP readBody resolveBody
attilakreiner Jun 20, 2024
f19e623
WIP hfs HP readBody etag
attilakreiner Jun 20, 2024
a8a4015
WIP hfs HP
attilakreiner Jun 20, 2024
c2efe21
WIP hfs ignore AppIT
attilakreiner Jun 20, 2024
873b5e1
WIP hfs fix AppIT
attilakreiner Jun 20, 2024
c166431
WIP hfs watchBody 1
attilakreiner Jun 20, 2024
0c0f7f4
WIP hfs watchBody 2
attilakreiner Jun 20, 2024
31b420c
WIP hfs watchBody 3
attilakreiner Jun 21, 2024
d3109f7
WIP hfs watchBody 4
attilakreiner Jun 21, 2024
3198b10
WIP hfs watchBody 5
attilakreiner Jun 21, 2024
ef2d377
WIP hfs watchBody 6
attilakreiner Jun 21, 2024
8f982fe
WIP hfs getPath
attilakreiner Jun 21, 2024
50c8792
WIP hfs watchBody 7
attilakreiner Jun 21, 2024
71231a9
WIP fix
attilakreiner Jun 21, 2024
7535666
Remove BindingConfig.readLocation
jfallows Jun 26, 2024
e7c6c56
No watch event needed for identical response body
jfallows Jun 26, 2024
5423718
Handle status 204 with null body and infer delay for optional prefer …
jfallows Jun 26, 2024
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
6 changes: 6 additions & 0 deletions cloud/docker-image/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,12 @@
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>filesystem-http</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>metrics-stream</artifactId>
Expand Down
1 change: 1 addition & 0 deletions cloud/docker-image/src/main/docker/assembly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<include>io/aklivity/zilla/binding-*/**</include>
<include>io/aklivity/zilla/catalog-*/**</include>
<include>io/aklivity/zilla/exporter-*/**</include>
<include>io/aklivity/zilla/filesystem-*/**</include>
<include>io/aklivity/zilla/guard-*/**</include>
<include>io/aklivity/zilla/metrics-*/**</include>
<include>io/aklivity/zilla/model-*/**</include>
Expand Down
1 change: 1 addition & 0 deletions cloud/docker-image/src/main/docker/zpm.json.template
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"io.aklivity.zilla:exporter-otlp",
"io.aklivity.zilla:exporter-prometheus",
"io.aklivity.zilla:exporter-stdout",
"io.aklivity.zilla:filesystem-http",
"io.aklivity.zilla:guard-jwt",
"io.aklivity.zilla:metrics-stream",
"io.aklivity.zilla:metrics-http",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ private void attachProxyBinding(
namespaceGenerator.init(binding);
final List<String> labels = configs.stream().map(c -> c.apiLabel).collect(toList());
final NamespaceConfig composite = namespaceGenerator.generateProxy(binding, asyncapis, schemaIdsByApiId::get, labels);
composite.readURL = binding.readURL;
attach.accept(composite);
updateNamespace(configs, composite, new ArrayList<>(asyncapis.values()));
}
Expand Down Expand Up @@ -349,7 +348,6 @@ private void attachServerClientBinding(
namespaceConfig.servers.forEach(s -> s.setAsyncapiProtocol(
namespaceGenerator.resolveProtocol(s.protocol(), options, namespaceConfig.asyncapis, namespaceConfig.servers)));
final NamespaceConfig composite = namespaceGenerator.generate(binding, namespaceConfig);
composite.readURL = binding.readURL;
attach.accept(composite);
updateNamespace(namespaceConfig.configs, composite, namespaceConfig.asyncapis);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package io.aklivity.zilla.runtime.binding.echo.internal.bench;

import java.net.InetAddress;
import java.net.URL;
import java.nio.channels.SelectableChannel;
import java.nio.file.Path;
import java.time.Clock;
import java.util.function.LongSupplier;

Expand Down Expand Up @@ -319,8 +319,8 @@ public ConverterHandler supplyWriteConverter(
}

@Override
public URL resolvePath(
String path)
public Path resolvePath(
String location)
{
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public final class GrpcOptionsConfigAdapter implements OptionsConfigAdapterSpi,

private final GrpcProtobufParser parser = new GrpcProtobufParser();

private Function<String, String> readURL;
private Function<String, String> readResource;

@Override
public Kind kind()
Expand Down Expand Up @@ -88,7 +88,7 @@ public OptionsConfig adaptFromJson(
public void adaptContext(
ConfigAdapterContext context)
{
this.readURL = context::readURL;
this.readResource = context::readResource;
}

private List<GrpcProtobufConfig> asListProtobufs(
Expand All @@ -103,7 +103,7 @@ private GrpcProtobufConfig asProtobuf(
JsonValue value)
{
final String location = ((JsonString) value).getString();
final String protobuf = readURL.apply(location);
final String protobuf = readResource.apply(location);

return parser.parse(location, protobuf);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void initJson() throws IOException
{
content = new String(resource.readAllBytes(), UTF_8);
}
Mockito.doReturn(content).when(context).readURL("protobuf/echo.proto");
Mockito.doReturn(content).when(context).readResource("protobuf/echo.proto");
adapter = new OptionsConfigAdapter(OptionsConfigAdapterSpi.Kind.BINDING, context);
adapter.adaptType("grpc");
JsonbConfig config = new JsonbConfig()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import io.aklivity.zilla.runtime.binding.http.internal.types.String16FW;
import io.aklivity.zilla.runtime.binding.http.internal.types.String8FW;
import io.aklivity.zilla.runtime.engine.config.ModelConfig;
import io.aklivity.zilla.runtime.engine.config.OptionsConfig;

public final class HttpOptionsConfig extends OptionsConfig
Expand Down Expand Up @@ -55,41 +56,46 @@ public static <T> HttpOptionsConfigBuilder<T> builder(
HttpAuthorizationConfig authorization,
List<HttpRequestConfig> requests)
{
super(requests != null && !requests.isEmpty()
? requests.stream()
.flatMap(request -> Stream.concat(
Stream.of(request.content),
Stream.concat(
request.headers != null
? request.headers.stream().flatMap(header -> Stream.of(header != null ? header.model : null))
: Stream.empty(),
Stream.concat(
request.pathParams != null
? request.pathParams.stream().flatMap(param -> Stream.of(param != null ? param.model : null))
: Stream.empty(),
Stream.concat(
request.queryParams != null
? request.queryParams.stream().flatMap(param -> Stream.of(param != null ? param.model : null))
: Stream.empty(),
Stream.concat(request.responses != null
? request.responses.stream().flatMap(param -> Stream.of(param != null
? param.content
: null))
: Stream.empty(), request.responses != null
? request.responses.stream()
.flatMap(response -> response.headers != null
? response.headers.stream()
.flatMap(param -> Stream.of(param != null ? param.model : null))
: Stream.empty())
: Stream.empty())
)))).filter(Objects::nonNull))
.collect(Collectors.toList())
: emptyList());

super(resolveModels(requests), List.of());
this.versions = versions;
this.overrides = overrides;
this.access = access;
this.authorization = authorization;
this.requests = requests;
}

private static List<ModelConfig> resolveModels(
List<HttpRequestConfig> requests)
{
return requests != null && !requests.isEmpty()
? requests.stream()
.flatMap(request -> Stream.concat(
Stream.of(request.content),
Stream.concat(
request.headers != null
? request.headers.stream().flatMap(header -> Stream.of(header != null ? header.model : null))
: Stream.empty(),
Stream.concat(
request.pathParams != null
? request.pathParams.stream().flatMap(param -> Stream.of(param != null ? param.model : null))
: Stream.empty(),
Stream.concat(
request.queryParams != null
? request.queryParams.stream().flatMap(param -> Stream.of(param != null ? param.model : null))
: Stream.empty(),
Stream.concat(request.responses != null
? request.responses.stream().flatMap(param -> Stream.of(param != null
? param.content
: null))
: Stream.empty(), request.responses != null
? request.responses.stream()
.flatMap(response -> response.headers != null
? response.headers.stream()
.flatMap(param -> Stream.of(param != null ? param.model : null))
: Stream.empty())
: Stream.empty())
)))).filter(Objects::nonNull))
.collect(Collectors.toList())
: emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.function.Function;
import java.util.stream.Stream;

import io.aklivity.zilla.runtime.engine.config.ModelConfig;
import io.aklivity.zilla.runtime.engine.config.OptionsConfig;

public final class KafkaOptionsConfig extends OptionsConfig
Expand All @@ -49,15 +50,21 @@ public static <T> KafkaOptionsConfigBuilder<T> builder(
List<KafkaServerConfig> servers,
KafkaSaslConfig sasl)
{
super(topics != null && !topics.isEmpty()
? topics.stream()
.flatMap(t -> Stream.of(t.key, t.value))
.filter(Objects::nonNull)
.collect(toList())
: emptyList());
super(resolveModels(topics), List.of());
this.bootstrap = bootstrap;
this.topics = topics;
this.servers = servers;
this.sasl = sasl;
}

private static List<ModelConfig> resolveModels(
List<KafkaTopicConfig> topics)
{
return topics != null && !topics.isEmpty()
? topics.stream()
.flatMap(t -> Stream.of(t.key, t.value))
.filter(Objects::nonNull)
.collect(toList())
: emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.stream.Stream;

import io.aklivity.zilla.runtime.binding.mqtt.internal.config.MqttVersion;
import io.aklivity.zilla.runtime.engine.config.ModelConfig;
import io.aklivity.zilla.runtime.engine.config.OptionsConfig;

public class MqttOptionsConfig extends OptionsConfig
Expand All @@ -50,18 +51,24 @@ public MqttOptionsConfig(
List<MqttTopicConfig> topics,
List<MqttVersion> versions)
{
super(topics != null && !topics.isEmpty()
super(resolveModels(topics), List.of());
this.authorization = authorization;
this.topics = topics;
this.versions = versions;
}

private static List<ModelConfig> resolveModels(
List<MqttTopicConfig> topics)
{
return topics != null && !topics.isEmpty()
? topics.stream()
.flatMap(topic -> Stream.concat(
Stream.of(topic.content),
Stream.of(topic.content),
Optional.ofNullable(topic.userProperties).orElseGet(Collections::emptyList).stream()
.flatMap(p -> Stream.of(p.value))
.filter(Objects::nonNull))
.flatMap(p -> Stream.of(p.value))
.filter(Objects::nonNull))
.filter(Objects::nonNull))
.collect(Collectors.toList())
: emptyList());
this.authorization = authorization;
this.topics = topics;
this.versions = versions;
: emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public void attach(
Object2ObjectHashMap::new));

this.composite = namespaceGenerator.generate(binding, openapis, asyncapis, openapiSchemaIdsByApiId::get);
this.composite.readURL = binding.readURL;
attach.accept(this.composite);

BindingConfig mappingBinding = composite.bindings.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ public void attach(
for (OpenapiNamespaceConfig namespaceConfig : namespaceConfigs.values())
{
final NamespaceConfig composite = namespaceGenerator.generate(binding, namespaceConfig);
composite.readURL = binding.readURL;
attach.accept(composite);
namespaceConfig.configs.forEach(c ->
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import io.aklivity.zilla.runtime.engine.config.ModelConfig;
import io.aklivity.zilla.runtime.engine.config.OptionsConfig;

public final class SseOptionsConfig extends OptionsConfig
Expand All @@ -46,14 +47,20 @@ public static <T> SseOptionsConfigBuilder<T> builder(
int retry,
List<SseRequestConfig> requests)
{
super(requests != null && !requests.isEmpty()
super(resolveModels(requests), List.of());
this.retry = retry;
this.requests = requests;
}

private static List<ModelConfig> resolveModels(
List<SseRequestConfig> requests)
{
return requests != null && !requests.isEmpty()
? requests.stream()
.flatMap(path ->
Stream.of(path.content)
.filter(Objects::nonNull))
.collect(Collectors.toList())
: emptyList());
this.retry = retry;
this.requests = requests;
: emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
import static io.aklivity.zilla.runtime.engine.internal.stream.StreamId.isInitial;
import static java.lang.ThreadLocal.withInitial;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.agrona.LangUtil.rethrowUnchecked;

import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.channels.SelectableChannel;
import java.nio.file.Path;
import java.time.Clock;
import java.util.function.IntConsumer;
import java.util.function.LongSupplier;
Expand Down Expand Up @@ -85,7 +83,7 @@ public class TlsWorker implements EngineContext
private final BindingFactory factory;
private final VaultFactory vaultFactory;
private final Configuration config;
private final URL configURL;
private final Path configPath;

private final TlsSignaler signaler;

Expand All @@ -105,7 +103,7 @@ public TlsWorker(
.readonly(false)
.build()
.bufferPool();
this.configURL = config.configURL();
this.configPath = Path.of(config.configURI());

this.signaler = new TlsSignaler();

Expand Down Expand Up @@ -387,19 +385,10 @@ public ConverterHandler supplyWriteConverter(
}

@Override
public URL resolvePath(
String path)
public Path resolvePath(
String location)
{
URL resolved = null;
try
{
resolved = new URL(configURL, path);
}
catch (MalformedURLException ex)
{
rethrowUnchecked(ex);
}
return resolved;
return configPath.resolveSibling(location);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
package io.aklivity.zilla.runtime.catalog.filesystem.internal;

import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -34,7 +35,7 @@ public class FilesystemCatalogHandler implements CatalogHandler
private final CRC32C crc32c;
private final FilesystemEventContext event;
private final long catalogId;
private final Function<String, URL> resolvePath;
private final Function<String, Path> resolvePath;

public FilesystemCatalogHandler(
FilesystemOptionsConfig config,
Expand Down Expand Up @@ -72,8 +73,8 @@ private void registerSchema(
{
try
{
URL storeURL = resolvePath.apply(config.path);
try (InputStream input = storeURL.openStream())
Path storePath = resolvePath.apply(config.path);
try (InputStream input = Files.newInputStream(storePath))
{
String schema = new String(input.readAllBytes());
int schemaId = generateCRC32C(schema);
Expand Down
Loading