From commits-return-12743-archive-asf-public=cust-asf.ponee.io@pulsar.incubator.apache.org Mon Aug 13 23:40:22 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id B99A618067A for ; Mon, 13 Aug 2018 23:40:21 +0200 (CEST) Received: (qmail 79699 invoked by uid 500); 13 Aug 2018 21:40:20 -0000 Mailing-List: contact commits-help@pulsar.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pulsar.incubator.apache.org Delivered-To: mailing list commits@pulsar.incubator.apache.org Received: (qmail 79690 invoked by uid 99); 13 Aug 2018 21:40:20 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 Aug 2018 21:40:20 +0000 From: GitBox To: commits@pulsar.apache.org Subject: [GitHub] sijie closed pull request #2354: add function package-url into function-get api response Message-ID: <153419642015.6586.10073157899642598235.gitbox@gitbox.apache.org> Date: Mon, 13 Aug 2018 21:40:20 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit sijie closed pull request #2354: add function package-url into function-get api response URL: https://github.com/apache/incubator-pulsar/pull/2354 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/pulsar-functions/proto/src/main/proto/Function.proto b/pulsar-functions/proto/src/main/proto/Function.proto index 92f14f6f19..77a9c2c0b6 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 c35dd52e80..a697363719 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 @@ -732,9 +732,8 @@ private FunctionDetails validateUpdateRequestParamsWithPkgUrl(String tenant, Str 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; } @@ -788,7 +787,7 @@ private String getFunctionCodeBuiltin(FunctionDetails functionDetails) { } 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"); } @@ -805,7 +804,14 @@ private FunctionDetails validateUpdateRequestParams(String tenant, String namesp 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 missingFields = new LinkedList<>(); ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services