You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by si...@apache.org on 2018/08/13 21:40:20 UTC
[incubator-pulsar] branch master updated: add function package-url
into function-get api response (#2354)
This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new cb2f4ee add function package-url into function-get api response (#2354)
cb2f4ee is described below
commit cb2f4ee3960fc841ad42bc6e6b1209a92b88d5d9
Author: Rajan Dhabalia <rd...@apache.org>
AuthorDate: Mon Aug 13 14:40:18 2018 -0700
add function package-url into function-get api response (#2354)
### Motivation
Right now, we mostly use function by submitting function with url and many times, we want to verify function package-url to confirm the package-version. So, function-admin api should return packageurl along with function metadata.
### Modifications
return function pacakge-url along with function-metadata on get-function api call.
---
pulsar-functions/proto/src/main/proto/Function.proto | 1 +
.../pulsar/functions/worker/rest/api/FunctionsImpl.java | 14 ++++++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/pulsar-functions/proto/src/main/proto/Function.proto b/pulsar-functions/proto/src/main/proto/Function.proto
index 92f14f6..77a9c2c 100644
--- a/pulsar-functions/proto/src/main/proto/Function.proto
+++ b/pulsar-functions/proto/src/main/proto/Function.proto
@@ -58,6 +58,7 @@ message FunctionDetails {
SourceSpec source = 11;
SinkSpec sink = 12;
Resources resources = 13;
+ string packageUrl = 14; //present only if function submitted with package-url
}
message SourceSpec {
diff --git a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java
index b71e6cd..4bb6e49 100644
--- a/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java
+++ b/pulsar-functions/worker/src/main/java/org/apache/pulsar/functions/worker/rest/api/FunctionsImpl.java
@@ -733,9 +733,8 @@ public class FunctionsImpl {
throw new IllegalArgumentException("Function Package url is not valid. supported url (http/https/file)");
}
Utils.validateFileUrl(functionPkgUrl, workerServiceSupplier.get().getWorkerConfig().getDownloadDirectory());
- File jarWithFileUrl = functionPkgUrl.startsWith(FILE) ? (new File((new URL(functionPkgUrl)).toURI())) : null;
FunctionDetails functionDetails = validateUpdateRequestParams(tenant, namespace, functionName,
- functionDetailsJson, jarWithFileUrl);
+ functionDetailsJson, functionPkgUrl);
return functionDetails;
}
@@ -789,7 +788,7 @@ public class FunctionsImpl {
}
private FunctionDetails validateUpdateRequestParams(String tenant, String namespace, String functionName,
- String functionDetailsJson, File jarWithFileUrl) throws IllegalArgumentException {
+ String functionDetailsJson, String functionPkgUrl) throws IllegalArgumentException {
if (tenant == null) {
throw new IllegalArgumentException("Tenant is not provided");
}
@@ -806,7 +805,14 @@ public class FunctionsImpl {
try {
FunctionDetails.Builder functionDetailsBuilder = FunctionDetails.newBuilder();
org.apache.pulsar.functions.utils.Utils.mergeJson(functionDetailsJson, functionDetailsBuilder);
- validateFunctionClassTypes(jarWithFileUrl, functionDetailsBuilder);
+ if (isNotBlank(functionPkgUrl)) {
+ // validate function details by loading function-jar from local file-system
+ File jarWithFileUrl = functionPkgUrl.startsWith(FILE) ? (new File((new URL(functionPkgUrl)).toURI()))
+ : null;
+ validateFunctionClassTypes(jarWithFileUrl, functionDetailsBuilder);
+ // set package-url if present
+ functionDetailsBuilder.setPackageUrl(functionPkgUrl);
+ }
FunctionDetails functionDetails = functionDetailsBuilder.build();
List<String> missingFields = new LinkedList<>();