You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ur...@apache.org on 2022/11/24 18:01:46 UTC
[pulsar-site] branch main updated: Docs sync done from apache/pulsar(#bf3ee85)
This is an automated email from the ASF dual-hosted git repository.
urfree pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pulsar-site.git
The following commit(s) were added to refs/heads/main by this push:
new 105974789c8 Docs sync done from apache/pulsar(#bf3ee85)
105974789c8 is described below
commit 105974789c89fa0ac54e9cfcc4b28fded4acc3cf
Author: Pulsar Site Updater <de...@pulsar.apache.org>
AuthorDate: Thu Nov 24 18:01:40 2022 +0000
Docs sync done from apache/pulsar(#bf3ee85)
---
site2/website-next/docs/client-libraries-java.md | 1 +
.../docs/functions-deploy-cluster-builtin.md | 16 ++++
.../website-next/docs/functions-deploy-cluster.md | 1 +
site2/website-next/docs/functions-package-java.md | 101 ++++++++++++++++++++-
site2/website-next/sidebars.json | 3 +-
5 files changed, 120 insertions(+), 2 deletions(-)
diff --git a/site2/website-next/docs/client-libraries-java.md b/site2/website-next/docs/client-libraries-java.md
index 7127368cf24..b35d7c13d91 100644
--- a/site2/website-next/docs/client-libraries-java.md
+++ b/site2/website-next/docs/client-libraries-java.md
@@ -1129,6 +1129,7 @@ You can use the available parameters in the `loadConf` configuration or related
|---|---|---|---|---
| `topic` | string | yes | The topic name of the TableView. | N/A
| `autoUpdatePartitionInterval` | int | no | The interval to check for newly added partitions. | 60 (seconds)
+| `subscriptionName` | string | no | The subscription name of the TableView. | null
### Register listeners
diff --git a/site2/website-next/docs/functions-deploy-cluster-builtin.md b/site2/website-next/docs/functions-deploy-cluster-builtin.md
new file mode 100644
index 00000000000..2e0e3b3cd38
--- /dev/null
+++ b/site2/website-next/docs/functions-deploy-cluster-builtin.md
@@ -0,0 +1,16 @@
+---
+id: functions-deploy-cluster-builtin
+title: Use built-in functions
+sidebar_label: "Use built-in functions"
+---
+
+Similar to built-in connectors, the code of Java functions [packaged as NAR](functions-package-java.md) that are placed in the `functions` directory of the function worker are loaded at startup and can be referenced when creating a function.
+
+For instance if you have a built-in function with name `exclamation` in its `pulsar-io.yaml`, you can create a function instance with:
+
+```bash
+bin/pulsar-admin functions create \
+ --function-type exclamation \
+ --inputs persistent://public/default/input-1 \
+ --output persistent://public/default/output-1
+```
diff --git a/site2/website-next/docs/functions-deploy-cluster.md b/site2/website-next/docs/functions-deploy-cluster.md
index 042d5a3d2ed..ccfd36e63de 100644
--- a/site2/website-next/docs/functions-deploy-cluster.md
+++ b/site2/website-next/docs/functions-deploy-cluster.md
@@ -31,4 +31,5 @@ bin/pulsar-admin functions update \
* [Enable parallel processing](functions-deploy-cluster-parallelism.md)
* [Enable end-to-end encryption](functions-deploy-cluster-encryption.md)
* [Enable package management service](functions-deploy-cluster-package.md)
+* [Use built-in functions](functions-deploy-cluster-builtin.md)
diff --git a/site2/website-next/docs/functions-package-java.md b/site2/website-next/docs/functions-package-java.md
index f2187a14357..daa3bf8aa4c 100644
--- a/site2/website-next/docs/functions-package-java.md
+++ b/site2/website-next/docs/functions-package-java.md
@@ -4,13 +4,25 @@ title: Package Java Functions
sidebar_label: "Package Java Functions"
---
+There are two methods to package Java Functions, that is [uber JAR](#package-as-jar) and [NAR](#package-as-nar).
+
:::note
+If you plan to package and distribute your function for others to use, you are obligated to
+license and copyright your own code properly. Remember to add the license and copyright to
+all libraries your code uses and to your distribution.
+
+If you use the [NAR](#package-as-nar) method, the NAR plugin
+automatically creates a `DEPENDENCIES` file in the generated NAR package, including the proper
+licensing and copyrights of all libraries of your function.
+
For the runtime Java version, refer to [Pulsar Runtime Java Version Recommendation](https://github.com/apache/pulsar/blob/master/README.md#pulsar-runtime-java-version-recommendation) according to your target Pulsar version.
:::
-To package a Java function, complete the following steps.
+## Package as JAR
+
+To package a Java function as JAR, complete the following steps.
1. Create a new maven project with a pom file. In the following code sample, the value of `mainClass` is your package name.
@@ -106,3 +118,90 @@ To package a Java function, complete the following steps.
07:55:03.724 [main] INFO org.apache.pulsar.functions.runtime.ProcessRuntime - Started process successfully
...
```
+
+## Package as NAR
+
+To package a Java function as NAR, complete the following steps.
+
+1. Create a new maven project with a pom file.
+
+ ```xml
+ <?xml version="1.0" encoding="UTF-8"?>
+ <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>
+
+ <groupId>java-function</groupId>
+ <artifactId>java-function</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.pulsar</groupId>
+ <artifactId>pulsar-functions-api</artifactId>
+ <version>@pulsar:version@</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.nifi</groupId>
+ <artifactId>nifi-nar-maven-plugin</artifactId>
+ <version>1.2.0</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <release>17</release>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ </project>
+ ```
+
+ You must also create a `resources/META-INF/services/pulsar-io.yaml` file. In the following code sample, the value of `functionClass` is your function class name. The `name` is the one used when the Function is deployed as a [built-in](functions-deploy-cluster-builtin.md) one.
+
+ ```yaml
+ name: java-function
+ description: my java function
+ functionClass: org.example.test.ExclamationFunction
+ ```
+
+2. Package your Java function.
+
+ ```bash
+ mvn package
+ ```
+
+ After the Java function is packaged, a `target` directory is created automatically. Open the `target` directory to check if there is a NAR package similar to `java-function-1.0-SNAPSHOT.nar`.
+
+3. Copy the packaged NAR file to the Pulsar image.
+
+ ```bash
+ docker cp <path of java-function-1.0-SNAPSHOT.nar> CONTAINER ID:/pulsar
+ ```
+
+4. Run the Java function using the following command.
+
+ ```bash
+ ./bin/pulsar-admin functions localrun \
+ --jar java-function-1.0-SNAPSHOT.nar \
+ --inputs persistent://public/default/my-topic-1 \
+ --output persistent://public/default/test-1 \
+ --tenant public \
+ --namespace default \
+ --name JavaFunction
+ ```
+
+ The following log indicates that the Java function starts successfully.
+
+ ```text
+ ...
+ 07:55:03.724 [main] INFO org.apache.pulsar.functions.runtime.ProcessRuntime - Started process successfully
+ ...
+ ```
diff --git a/site2/website-next/sidebars.json b/site2/website-next/sidebars.json
index 0e80e22c9e2..630ce31f8a9 100644
--- a/site2/website-next/sidebars.json
+++ b/site2/website-next/sidebars.json
@@ -102,7 +102,8 @@
"functions-deploy-cluster-resource",
"functions-deploy-cluster-parallelism",
"functions-deploy-cluster-encryption",
- "functions-deploy-cluster-package"
+ "functions-deploy-cluster-package",
+ "functions-deploy-cluster-builtin"
]
},
"functions-deploy-trigger"