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.
Added Submit Function capability to the pulsar-functions cli (apache#33)
* Create pulsar-functions module (#1) * Create pulsar-functions module * rename `sdk` package to `api` * Added the first cut of the Java interface for Pulsar functions (#2) * Added the first cut of the pulsar submit * Working
- Loading branch information
Showing
11 changed files
with
364 additions
and
18 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
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
135 changes: 135 additions & 0 deletions
135
pulsar-functions/runtime/src/main/java/org/apache/pulsar/client/admin/Functions.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,135 @@ | ||
/** | ||
* 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 org.apache.pulsar.client.admin.PulsarAdminException.ConflictException; | ||
import org.apache.pulsar.client.admin.PulsarAdminException.NotAuthorizedException; | ||
import org.apache.pulsar.client.admin.PulsarAdminException.NotFoundException; | ||
import org.apache.pulsar.client.admin.PulsarAdminException.PreconditionFailedException; | ||
import org.apache.pulsar.functions.fs.FunctionConfig; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Admin interface for function management. | ||
*/ | ||
public interface Functions { | ||
/** | ||
* Get the list of functions. | ||
* <p> | ||
* Get the list of all the Pulsar functions. | ||
* <p> | ||
* Response Example: | ||
* | ||
* <pre> | ||
* <code>["f1", "f2", "f3"]</code> | ||
* </pre> | ||
* | ||
* @throws NotAuthorizedException | ||
* Don't have admin permission | ||
* @throws PulsarAdminException | ||
* Unexpected error | ||
*/ | ||
List<String> getFunctions(String tenant, String namespace) throws PulsarAdminException; | ||
|
||
/** | ||
* Get the configuration for the specified function. | ||
* <p> | ||
* Response Example: | ||
* | ||
* <pre> | ||
* <code>{ serviceUrl : "http://my-broker.example.com:8080/" }</code> | ||
* </pre> | ||
* | ||
* @param tenant | ||
* Tenant name | ||
* @param namespace | ||
* Namespace name | ||
* @param function | ||
* Function name | ||
* | ||
* @return the function configuration | ||
* | ||
* @throws NotAuthorizedException | ||
* You don't have admin permission to get the configuration of the cluster | ||
* @throws NotFoundException | ||
* Cluster doesn't exist | ||
* @throws PulsarAdminException | ||
* Unexpected error | ||
*/ | ||
FunctionConfig getFunction(String tenant, String namespace, String function) throws PulsarAdminException; | ||
|
||
/** | ||
* Create a new cluster. | ||
* <p> | ||
* Provisions a new cluster. This operation requires Pulsar super-user privileges. | ||
* <p> | ||
* The name cannot contain '/' characters. | ||
* | ||
* @param functionConfig | ||
* the function configuration object | ||
* | ||
* @throws NotAuthorized | ||
* You don't have admin permission to create the cluster | ||
* @throws ConflictException | ||
* Cluster already exists | ||
* @throws PulsarAdminException | ||
* Unexpected error | ||
*/ | ||
void createFunction(FunctionConfig functionConfig, byte[] code) throws PulsarAdminException; | ||
|
||
/** | ||
* Update the configuration for a function. | ||
* <p> | ||
* | ||
* @param functionConfig | ||
* the function configuration object | ||
* | ||
* @throws NotAuthorizedException | ||
* You don't have admin permission to create the cluster | ||
* @throws NotFoundException | ||
* Cluster doesn't exist | ||
* @throws PulsarAdminException | ||
* Unexpected error | ||
*/ | ||
void updateFunction(FunctionConfig functionConfig) throws PulsarAdminException; | ||
|
||
/** | ||
* Delete an existing function | ||
* <p> | ||
* Delete a function | ||
* | ||
* @param tenant | ||
* Tenant name | ||
* @param namespace | ||
* Namespace name | ||
* @param function | ||
* Function name | ||
* | ||
* @throws NotAuthorizedException | ||
* You don't have admin permission | ||
* @throws NotFoundException | ||
* Cluster does not exist | ||
* @throws PreconditionFailedException | ||
* Cluster is not empty | ||
* @throws PulsarAdminException | ||
* Unexpected error | ||
*/ | ||
void deleteFunction(String tenant, String namespace, String function) throws PulsarAdminException; | ||
} |
60 changes: 60 additions & 0 deletions
60
...-functions/runtime/src/main/java/org/apache/pulsar/client/admin/PulsarFunctionsAdmin.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,60 @@ | ||
/** | ||
* 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 org.apache.pulsar.client.admin.internal.FunctionsImpl; | ||
import org.apache.pulsar.client.api.*; | ||
|
||
import org.glassfish.jersey.media.multipart.MultiPartFeature; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.net.URL; | ||
|
||
|
||
/** | ||
* Pulsar client admin API client. | ||
*/ | ||
public class PulsarFunctionsAdmin extends PulsarAdmin { | ||
private static final Logger LOG = LoggerFactory.getLogger(PulsarFunctionsAdmin.class); | ||
|
||
private final Functions functions; | ||
|
||
/** | ||
* Construct a new Pulsar Admin client object. | ||
* <p> | ||
* This client object can be used to perform many subsquent API calls | ||
* | ||
* @param serviceUrl | ||
* the Pulsar service URL (eg. "http://my-broker.example.com:8080") | ||
* @param pulsarConfig | ||
* the ClientConfiguration object to be used to talk with Pulsar | ||
*/ | ||
public PulsarFunctionsAdmin(URL serviceUrl, ClientConfiguration pulsarConfig) throws PulsarClientException { | ||
super(serviceUrl, pulsarConfig); | ||
this.functions = new FunctionsImpl(web, auth); | ||
} | ||
|
||
/** | ||
* @return the function management object | ||
*/ | ||
public Functions functions() { | ||
return functions; | ||
} | ||
} |
Oops, something went wrong.