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
Add first V3 cluster APIs (+ V3 plumbing). #624
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
kafka-rest/src/main/java/io/confluent/kafkarest/backends/BackendsModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2020 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* http://www.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.kafkarest.backends; | ||
|
||
import io.confluent.kafkarest.KafkaRestContext; | ||
import io.confluent.kafkarest.backends.kafka.KafkaModule; | ||
import java.util.Objects; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
|
||
/** | ||
* A module to configure access to external dependencies. | ||
*/ | ||
public final class BackendsModule extends AbstractBinder { | ||
|
||
private final KafkaRestContext context; | ||
|
||
public BackendsModule(KafkaRestContext context) { | ||
this.context = Objects.requireNonNull(context); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
install(new KafkaModule(context)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this registered via (note: i may well ask some stupid questions due to ignorance of the frameworks etc., this may well be one of them). |
||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
kafka-rest/src/main/java/io/confluent/kafkarest/backends/kafka/KafkaModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2020 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* http://www.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.kafkarest.backends.kafka; | ||
|
||
import io.confluent.kafkarest.KafkaRestContext; | ||
import java.util.Objects; | ||
import org.apache.kafka.clients.admin.Admin; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
|
||
/** | ||
* A module to configure access to Kafka. | ||
* | ||
* <p>Right now this module does little but delegate to {@link KafkaRestContext}, since access to | ||
* Kafka is currently being configured there. It's the author's intention to move such logic here, | ||
* and eliminate {@code KafkaRestContext}, once dependence injection is properly used elsewhere.</p> | ||
*/ | ||
public final class KafkaModule extends AbstractBinder { | ||
|
||
private final KafkaRestContext context; | ||
|
||
public KafkaModule(KafkaRestContext context) { | ||
this.context = Objects.requireNonNull(context); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
// Reuse the AdminClient being constructed in KafkaRestContext. | ||
bind(context.getAdmin()).to(Admin.class); | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
kafka-rest/src/main/java/io/confluent/kafkarest/config/ConfigModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Copyright 2020 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* http://www.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.kafkarest.config; | ||
|
||
import io.confluent.kafkarest.KafkaRestConfig; | ||
import io.confluent.rest.RestConfig; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import javax.inject.Qualifier; | ||
import org.glassfish.hk2.api.AnnotationLiteral; | ||
import org.glassfish.hk2.api.TypeLiteral; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
|
||
/** | ||
* A module to populate the injector with the configurations passed to this application. | ||
* | ||
* <p>In addition to {@link KafkaRestConfig}, which contains all configurations, individual | ||
* configurations are also exposed, on a need-to-know basis.</p> | ||
*/ | ||
public final class ConfigModule extends AbstractBinder { | ||
|
||
private final KafkaRestConfig config; | ||
|
||
public ConfigModule(KafkaRestConfig config) { | ||
this.config = Objects.requireNonNull(config); | ||
} | ||
|
||
@Override | ||
protected void configure() { | ||
bind(config).to(KafkaRestConfig.class); | ||
|
||
// Keep this list alphabetically sorted. | ||
bind(config.getList(KafkaRestConfig.ADVERTISED_LISTENERS_CONFIG)) | ||
.qualifiedBy(new AdvertisedListenersConfigImpl()) | ||
.to(new TypeLiteral<List<String>>() { }); | ||
|
||
bind(config.getString(KafkaRestConfig.HOST_NAME_CONFIG)) | ||
.qualifiedBy(new HostNameConfigImpl()) | ||
.to(String.class); | ||
|
||
bind(config.getList(RestConfig.LISTENERS_CONFIG)) | ||
.qualifiedBy(new ListenersConfigImpl()) | ||
.to(new TypeLiteral<List<String>>() { }); | ||
|
||
bind(config.getInt(RestConfig.PORT_CONFIG)) | ||
.qualifiedBy(new PortConfigImpl()) | ||
.to(Integer.class); | ||
} | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER }) | ||
public @interface AdvertisedListenersConfig { | ||
} | ||
|
||
private static final class AdvertisedListenersConfigImpl | ||
extends AnnotationLiteral<AdvertisedListenersConfig> implements AdvertisedListenersConfig { | ||
} | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER }) | ||
@Deprecated | ||
public @interface HostNameConfig { | ||
} | ||
|
||
private static final class HostNameConfigImpl | ||
extends AnnotationLiteral<HostNameConfig> implements HostNameConfig { | ||
} | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER }) | ||
public @interface ListenersConfig { | ||
} | ||
|
||
private static final class ListenersConfigImpl | ||
extends AnnotationLiteral<ListenersConfig> implements ListenersConfig { | ||
} | ||
|
||
@Qualifier | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER }) | ||
@Deprecated | ||
public @interface PortConfig { | ||
} | ||
|
||
private static final class PortConfigImpl | ||
extends AnnotationLiteral<PortConfig> implements PortConfig { | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
kafka-rest/src/main/java/io/confluent/kafkarest/controllers/ClusterManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2020 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* http://www.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.kafkarest.controllers; | ||
|
||
import io.confluent.kafkarest.entities.Cluster; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* A service to manage Kafka {@link Cluster Clusters}. | ||
*/ | ||
public interface ClusterManager { | ||
|
||
/** | ||
* Returns the list of Kafka {@link Cluster Clusters} known. | ||
* | ||
* <p>Right now only one cluster is known, namely, the cluster to which this application is | ||
* connected to. Therefore, this method will always return at most 1 cluster.</p> | ||
*/ | ||
CompletableFuture<List<Cluster>> listClusters(); | ||
|
||
/** | ||
* Returns the Kafka {@link Cluster} with the given {@code clusterId}, or empty if no such cluster | ||
* is known. | ||
* | ||
* <p>See {@link #listClusters()} for caveats about known clusters.</p> | ||
*/ | ||
CompletableFuture<Optional<Cluster>> getCluster(String clusterId); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not spent any time thinking about the advantages of including absolute URLs in responses, but for your consideration, want to note that requiring this additional config seems like a material downside.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration is not required. See UrlFactoryImpl for how the absolute URLs are generated. This configuration is to allow for generating URLs using a LB.