forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…pache#9246) Fixes apache#8089 ### Motivation apache#8089 addressed that making pulsar admin client api calls is conflict with Jersey library. This PR expose `PulsarAdmin` client through `Function Context`, so the function implementers can use PulsarAdmin to do whatever they want to do. ### Modifications - add `getPulsarAdmin()` and `getPulsarAdmin(String clusterName)` in function `Context` - add implementation of above interface in `ContextImpl` - add passing `pulsarWebServiceUrl` to function runtimes - add passing `pulsarWebServiceUrl` to `LocalRunner` / `JavaInstanceStarter` - add `"--web-service-url"` parameter to `LocalRunner` admin command - add unit tests - add example function - add `exposeAdminClientEnabled` in `functions_worker.yml`
- Loading branch information
Showing
70 changed files
with
880 additions
and
87 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
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,73 @@ | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.pulsar</groupId> | ||
<artifactId>pulsar</artifactId> | ||
<version>2.8.0-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
|
||
<artifactId>pulsar-client-admin-api</artifactId> | ||
<name>Pulsar Client Admin :: API</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>pulsar-common</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>pulsar-client-original</artifactId> | ||
<version>${project.parent.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>pulsar-package-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>checkstyle</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
166 changes: 166 additions & 0 deletions
166
pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/PulsarAdmin.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,166 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.client.admin; | ||
|
||
import java.io.Closeable; | ||
import org.apache.pulsar.client.admin.utils.DefaultImplementation; | ||
import org.apache.pulsar.client.impl.conf.ClientConfigurationData; | ||
import org.apache.pulsar.common.classification.InterfaceAudience; | ||
import org.apache.pulsar.common.classification.InterfaceStability; | ||
|
||
@InterfaceAudience.Public | ||
@InterfaceStability.Stable | ||
public interface PulsarAdmin extends Closeable { | ||
|
||
/** | ||
* Get a new builder instance that can used to configure and build a {@link PulsarAdmin} instance. | ||
* | ||
* @return the {@link PulsarAdminBuilder} | ||
* | ||
*/ | ||
static PulsarAdminBuilder builder() { | ||
return DefaultImplementation.newAdminClientBuilder(); | ||
} | ||
|
||
/** | ||
* @return the clusters management object | ||
*/ | ||
Clusters clusters(); | ||
|
||
/** | ||
* @return the brokers management object | ||
*/ | ||
Brokers brokers(); | ||
|
||
/** | ||
* @return the tenants management object | ||
*/ | ||
Tenants tenants(); | ||
|
||
/** | ||
* | ||
* @deprecated since 2.0. See {@link #tenants()} | ||
*/ | ||
@Deprecated | ||
Properties properties(); | ||
|
||
/** | ||
* @return the namespaces management object | ||
*/ | ||
Namespaces namespaces(); | ||
|
||
/** | ||
* @return the topics management object | ||
*/ | ||
Topics topics(); | ||
|
||
/** | ||
* @return the bookies management object | ||
*/ | ||
Bookies bookies(); | ||
|
||
/** | ||
* @return the persistentTopics management object | ||
* @deprecated Since 2.0. See {@link #topics()} | ||
*/ | ||
@Deprecated | ||
NonPersistentTopics nonPersistentTopics(); | ||
|
||
/** | ||
* @return the resource quota management object | ||
*/ | ||
ResourceQuotas resourceQuotas(); | ||
|
||
/** | ||
* @return does a looks up for the broker serving the topic | ||
*/ | ||
Lookup lookups(); | ||
|
||
/** | ||
* | ||
* @return the functions management object | ||
*/ | ||
Functions functions(); | ||
|
||
/** | ||
* @return the sources management object | ||
* @deprecated in favor of {@link #sources()} | ||
*/ | ||
@Deprecated | ||
Source source(); | ||
|
||
/** | ||
* @return the sources management object | ||
*/ | ||
Sources sources(); | ||
|
||
/** | ||
* @return the sinks management object | ||
* @deprecated in favor of {@link #sinks} | ||
*/ | ||
@Deprecated | ||
Sink sink(); | ||
|
||
/** | ||
* @return the sinks management object | ||
*/ | ||
Sinks sinks(); | ||
|
||
/** | ||
* @return the Worker stats | ||
*/ | ||
Worker worker(); | ||
|
||
/** | ||
* @return the broker statics | ||
*/ | ||
BrokerStats brokerStats(); | ||
|
||
/** | ||
* @return the proxy statics | ||
*/ | ||
ProxyStats proxyStats(); | ||
|
||
/** | ||
* @return the service HTTP URL that is being used | ||
*/ | ||
String getServiceUrl(); | ||
|
||
/** | ||
* @return the client Configuration Data that is being used | ||
*/ | ||
ClientConfigurationData getClientConfigData(); | ||
|
||
/** | ||
* @return the schemas | ||
*/ | ||
Schemas schemas(); | ||
|
||
/** | ||
* @return the packages management object | ||
*/ | ||
Packages packages(); | ||
|
||
/** | ||
* Close the PulsarAdminClient and release all the resources. | ||
* | ||
*/ | ||
@Override | ||
void close(); | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/package-info.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,19 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.client.admin; |
36 changes: 36 additions & 0 deletions
36
...t-admin-api/src/main/java/org/apache/pulsar/client/admin/utils/DefaultImplementation.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,36 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.pulsar.client.admin.utils; | ||
|
||
import lombok.experimental.UtilityClass; | ||
import org.apache.pulsar.client.admin.PulsarAdminBuilder; | ||
|
||
/** | ||
* Helper class for class instantiations and it also contains methods to work with schemas. | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
@UtilityClass | ||
public class DefaultImplementation { | ||
private static final Class<PulsarAdminBuilder> ADMIN_CLIENT_BUILDER_IMPL = ReflectionUtils.newClassInstance( | ||
"org.apache.pulsar.client.admin.internal.PulsarAdminBuilderImpl"); | ||
|
||
public static PulsarAdminBuilder newAdminClientBuilder() { | ||
return ReflectionUtils.catchExceptions(() -> ADMIN_CLIENT_BUILDER_IMPL.newInstance()); | ||
} | ||
} |
Oops, something went wrong.