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.
Add proxy plugin interface to support user defined additional servlet (…
…apache#8067) Motivation In order to facilitate users' flexible access in the broker, we provide plug-ins similar to broker protocol and broker interceptor. Similarly, in the proxy, sometimes users also need similar plug-in functions to facilitate customizing some data requests. Modifications Add protocol plugin for proxy * Add proxy metrics logic Signed-off-by: xiaolong.ran <[email protected]> * fix proxy interface Signed-off-by: xiaolong.ran <[email protected]> * rename interceptor to protocol Signed-off-by: xiaolong.ran <[email protected]> * add test case Signed-off-by: xiaolong.ran <[email protected]> * fix license header Signed-off-by: xiaolong.ran <[email protected]> * fix ci error Signed-off-by: xiaolong.ran <[email protected]> * 1. change some class name; 2. add mock additional servlet test * fix * fix * fix * 1. add authentication support for proxy additional servlet plugin; 2. fix java doc * fix test Co-authored-by: gaoran10 <[email protected]>
- Loading branch information
Showing
17 changed files
with
1,003 additions
and
5 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
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
54 changes: 54 additions & 0 deletions
54
...y/src/main/java/org/apache/pulsar/proxy/server/plugin/servlet/ProxyAdditionalServlet.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,54 @@ | ||
/** | ||
* 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.proxy.server.plugin.servlet; | ||
|
||
import com.google.common.annotations.Beta; | ||
import org.apache.pulsar.proxy.server.ProxyConfiguration; | ||
import org.eclipse.jetty.servlet.ServletHolder; | ||
|
||
/** | ||
* The additional servlet interface for support additional servlet on Pulsar proxy. | ||
*/ | ||
@Beta | ||
public interface ProxyAdditionalServlet extends AutoCloseable { | ||
|
||
/** | ||
* load plugin config | ||
* | ||
* @param proxyConfiguration | ||
*/ | ||
void loadConfig(ProxyConfiguration proxyConfiguration); | ||
|
||
/** | ||
* Get the base path of prometheus metrics | ||
* | ||
* @return the base path of prometheus metrics | ||
*/ | ||
String getBasePath(); | ||
|
||
/** | ||
* Get the servlet holder | ||
* | ||
* @return the servlet holder | ||
*/ | ||
ServletHolder getServletHolder(); | ||
|
||
@Override | ||
void close(); | ||
} |
44 changes: 44 additions & 0 deletions
44
.../java/org/apache/pulsar/proxy/server/plugin/servlet/ProxyAdditionalServletDefinition.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,44 @@ | ||
/** | ||
* 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.proxy.server.plugin.servlet; | ||
|
||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* Metadata information about a proxy additional servlet. | ||
*/ | ||
@Data | ||
@NoArgsConstructor | ||
public class ProxyAdditionalServletDefinition { | ||
/** | ||
* The name of the proxy additional servlet. | ||
*/ | ||
private String name; | ||
|
||
/** | ||
* The description of the proxy additional servlet to be used for user help. | ||
*/ | ||
private String description; | ||
|
||
/** | ||
* The class name for the additional servlet. | ||
*/ | ||
private String additionalServletClass; | ||
} |
34 changes: 34 additions & 0 deletions
34
...java/org/apache/pulsar/proxy/server/plugin/servlet/ProxyAdditionalServletDefinitions.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,34 @@ | ||
/** | ||
* 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.proxy.server.plugin.servlet; | ||
|
||
import java.util.Map; | ||
import java.util.TreeMap; | ||
import lombok.Data; | ||
import lombok.experimental.Accessors; | ||
|
||
/** | ||
* The collection of proxy additional servlet definition. | ||
*/ | ||
@Data | ||
@Accessors(fluent = true) | ||
public class ProxyAdditionalServletDefinitions { | ||
|
||
private final Map<String, ProxyAdditionalServletMetadata> servlets = new TreeMap<>(); | ||
} |
41 changes: 41 additions & 0 deletions
41
...in/java/org/apache/pulsar/proxy/server/plugin/servlet/ProxyAdditionalServletMetadata.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,41 @@ | ||
/** | ||
* 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.proxy.server.plugin.servlet; | ||
|
||
import java.nio.file.Path; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* The metadata of proxy additional servlet | ||
*/ | ||
@Data | ||
@NoArgsConstructor | ||
public class ProxyAdditionalServletMetadata { | ||
|
||
/** | ||
* The definition of the proxy additional servlet. | ||
*/ | ||
private ProxyAdditionalServletDefinition definition; | ||
|
||
/** | ||
* The path to the additional servlet package. | ||
*/ | ||
private Path archivePath; | ||
} |
Oops, something went wrong.