diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/SerDe.java b/pulsar-functions/api/src/main/java/org/apache/pulsar/functions/api/SerDe.java similarity index 94% rename from pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/SerDe.java rename to pulsar-functions/api/src/main/java/org/apache/pulsar/functions/api/SerDe.java index fb58b3228a0c4..f9efa3d8f8e88 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/SerDe.java +++ b/pulsar-functions/api/src/main/java/org/apache/pulsar/functions/api/SerDe.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.pulsar.functions.runtime.serde; +package org.apache.pulsar.functions.api; /** * An interface for serializer/deserializer. diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/JavaSerDe.java b/pulsar-functions/api/src/main/java/org/apache/pulsar/functions/api/utils/JavaSerDe.java similarity index 96% rename from pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/JavaSerDe.java rename to pulsar-functions/api/src/main/java/org/apache/pulsar/functions/api/utils/JavaSerDe.java index 1df4fcc58af05..909f150d5738e 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/JavaSerDe.java +++ b/pulsar-functions/api/src/main/java/org/apache/pulsar/functions/api/utils/JavaSerDe.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.pulsar.functions.runtime.serde; +package org.apache.pulsar.functions.api.utils; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -25,6 +25,7 @@ import java.io.ObjectOutput; import java.io.ObjectOutputStream; import lombok.extern.slf4j.Slf4j; +import org.apache.pulsar.functions.api.SerDe; /** * Java Serialization based SerDe diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/Utf8StringSerDe.java b/pulsar-functions/api/src/main/java/org/apache/pulsar/functions/api/utils/Utf8StringSerDe.java similarity index 82% rename from pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/Utf8StringSerDe.java rename to pulsar-functions/api/src/main/java/org/apache/pulsar/functions/api/utils/Utf8StringSerDe.java index ee5e62a309643..591c001407b91 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/Utf8StringSerDe.java +++ b/pulsar-functions/api/src/main/java/org/apache/pulsar/functions/api/utils/Utf8StringSerDe.java @@ -16,9 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.pulsar.functions.runtime.serde; +package org.apache.pulsar.functions.api.utils; -import static com.google.common.base.Charsets.UTF_8; +import org.apache.pulsar.functions.api.SerDe; + +import java.nio.charset.StandardCharsets; /** * A simple Serde that treats the bytes as Java String @@ -33,11 +35,11 @@ public static Utf8StringSerDe of() { @Override public byte[] serialize(String string) { - return string.getBytes(UTF_8); + return string.getBytes(StandardCharsets.UTF_8); } @Override public String deserialize(byte[] data) { - return new String(data, UTF_8); + return new String(data, StandardCharsets.UTF_8); } } \ No newline at end of file diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/serde/JavaSerDeTest.java b/pulsar-functions/api/src/test/java/org/apache/pulsar/functions/api/utils/JavaSerDeTest.java similarity index 96% rename from pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/serde/JavaSerDeTest.java rename to pulsar-functions/api/src/test/java/org/apache/pulsar/functions/api/utils/JavaSerDeTest.java index 1a8ac06eab481..5f43e3c6233bb 100644 --- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/serde/JavaSerDeTest.java +++ b/pulsar-functions/api/src/test/java/org/apache/pulsar/functions/api/utils/JavaSerDeTest.java @@ -25,6 +25,7 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.ToString; +import org.apache.pulsar.functions.api.utils.JavaSerDe; import org.testng.annotations.Test; /** diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/serde/Utf8StringSerDeTest.java b/pulsar-functions/api/src/test/java/org/apache/pulsar/functions/api/utils/Utf8StringSerDeTest.java similarity index 95% rename from pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/serde/Utf8StringSerDeTest.java rename to pulsar-functions/api/src/test/java/org/apache/pulsar/functions/api/utils/Utf8StringSerDeTest.java index 71f59515daed9..2262486cbfecf 100644 --- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/serde/Utf8StringSerDeTest.java +++ b/pulsar-functions/api/src/test/java/org/apache/pulsar/functions/api/utils/Utf8StringSerDeTest.java @@ -20,6 +20,7 @@ import static org.testng.Assert.assertEquals; +import org.apache.pulsar.functions.api.utils.Utf8StringSerDe; import org.testng.annotations.Test; /** diff --git a/pulsar-functions/cli/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java b/pulsar-functions/cli/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java index 69cdc1ca9202f..7f8b388263abc 100644 --- a/pulsar-functions/cli/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java +++ b/pulsar-functions/cli/src/main/java/org/apache/pulsar/admin/cli/CmdFunctions.java @@ -24,7 +24,6 @@ import com.google.common.annotations.VisibleForTesting; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; import com.google.gson.JsonParser; import com.google.protobuf.util.JsonFormat; import lombok.Getter; @@ -33,7 +32,7 @@ import org.apache.pulsar.functions.api.RequestHandler; import org.apache.pulsar.functions.proto.Function.FunctionConfig; import org.apache.pulsar.functions.runtime.container.ThreadFunctionContainerFactory; -import org.apache.pulsar.functions.runtime.serde.SerDe; +import org.apache.pulsar.functions.api.SerDe; import org.apache.pulsar.functions.fs.LimitsConfig; import org.apache.pulsar.functions.runtime.spawner.Spawner; import org.apache.pulsar.functions.utils.FunctionConfigUtils; diff --git a/pulsar-functions/cli/src/test/java/org/apache/pulsar/admin/cli/CmdFunctionsTest.java b/pulsar-functions/cli/src/test/java/org/apache/pulsar/admin/cli/CmdFunctionsTest.java index fe6e6cf9d9b14..2d96234b417f4 100644 --- a/pulsar-functions/cli/src/test/java/org/apache/pulsar/admin/cli/CmdFunctionsTest.java +++ b/pulsar-functions/cli/src/test/java/org/apache/pulsar/admin/cli/CmdFunctionsTest.java @@ -43,7 +43,7 @@ import org.apache.pulsar.client.api.ClientConfiguration; import org.apache.pulsar.functions.api.RequestHandler; import org.apache.pulsar.functions.proto.Function.FunctionConfig; -import org.apache.pulsar.functions.runtime.serde.Utf8StringSerDe; +import org.apache.pulsar.functions.api.utils.Utf8StringSerDe; import org.apache.pulsar.functions.utils.Reflections; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; diff --git a/pulsar-functions/run-examples.sh b/pulsar-functions/run-examples.sh index 3542eed181c66..a69ad302fb4a0 100755 --- a/pulsar-functions/run-examples.sh +++ b/pulsar-functions/run-examples.sh @@ -21,7 +21,7 @@ bin/pulsar-functions functions localrun \ --function-config conf/example.yml \ --source-topics persistent://sample/standalone/ns1/test_src \ --sink-topic persistent://sample/standalone/ns1/test_result \ - --input-serde-classnames org.apache.pulsar.functions.runtime.serde.Utf8StringSerDe \ - --output-serde-classname org.apache.pulsar.functions.runtime.serde.Utf8StringSerDe \ + --input-serde-classnames org.apache.pulsar.functions.api.utils.Utf8StringSerDe \ + --output-serde-classname org.apache.pulsar.functions.api.utils.Utf8StringSerDe \ --function-classname org.apache.pulsar.functions.api.examples.ExclamationFunction \ --jar `pwd`/api-examples/target/pulsar-functions-api-examples.jar diff --git a/pulsar-functions/run-logging-examples.sh b/pulsar-functions/run-logging-examples.sh index ebf195535a590..92ee6d36d4d97 100755 --- a/pulsar-functions/run-logging-examples.sh +++ b/pulsar-functions/run-logging-examples.sh @@ -21,7 +21,7 @@ bin/pulsar-functions functions localrun \ --function-config conf/example.yml \ --source-topics persistent://sample/standalone/ns1/test_src \ --sink-topic persistent://sample/standalone/ns1/test_result \ - --input-serde-classnames org.apache.pulsar.functions.runtime.serde.Utf8StringSerDe \ - --output-serde-classname org.apache.pulsar.functions.runtime.serde.Utf8StringSerDe \ + --input-serde-classnames org.apache.pulsar.functions.api.utils.Utf8StringSerDe \ + --output-serde-classname org.apache.pulsar.functions.api.utils.Utf8StringSerDe \ --function-classname org.apache.pulsar.functions.api.examples.LoggingFunction \ --jar `pwd`/api-examples/target/pulsar-functions-api-examples.jar diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstance.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstance.java index c0fbc88454e29..6417e3a232474 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstance.java +++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstance.java @@ -28,13 +28,13 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import lombok.Getter; + import lombok.extern.slf4j.Slf4j; import net.jodah.typetools.TypeResolver; import org.apache.pulsar.functions.api.RawRequestHandler; import org.apache.pulsar.functions.api.RequestHandler; import org.apache.pulsar.functions.proto.InstanceCommunication; -import org.apache.pulsar.functions.runtime.serde.SerDe; +import org.apache.pulsar.functions.api.SerDe; import org.apache.pulsar.functions.utils.Reflections; import java.lang.reflect.Type; diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstanceRunnable.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstanceRunnable.java index c1599cd65e0c7..0ce66c65fd5f5 100644 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstanceRunnable.java +++ b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/instance/JavaInstanceRunnable.java @@ -28,7 +28,7 @@ import org.apache.pulsar.functions.proto.Function.FunctionConfig; import org.apache.pulsar.functions.proto.InstanceCommunication; import org.apache.pulsar.functions.runtime.functioncache.FunctionCacheManager; -import org.apache.pulsar.functions.runtime.serde.SerDe; +import org.apache.pulsar.functions.api.SerDe; import org.apache.pulsar.functions.stats.FunctionStats; import org.apache.pulsar.functions.utils.FunctionConfigUtils; import org.apache.pulsar.functions.utils.Reflections; diff --git a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/package-info.java b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/package-info.java deleted file mode 100644 index bfe727d241dec..0000000000000 --- a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/serde/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * 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. - */ -/** - * SerDe used at functions runtime. - */ -package org.apache.pulsar.functions.runtime.serde; \ No newline at end of file diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/container/ThreadFunctionContainerTest.java b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/container/ThreadFunctionContainerTest.java index 488018b4df09f..30a65feb1b276 100644 --- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/container/ThreadFunctionContainerTest.java +++ b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/container/ThreadFunctionContainerTest.java @@ -73,7 +73,7 @@ FunctionConfig createFunctionConfig() { functionConfigBuilder.setNamespace(TEST_NAMESPACE); functionConfigBuilder.setName(TEST_NAME); functionConfigBuilder.setClassName("org.apache.pulsar.functions.runtime.functioncache.AddFunction"); - functionConfigBuilder.putInputs(TEST_NAME + "-source", "org.apache.pulsar.functions.runtime.serde.Utf8StringSerDe"); + functionConfigBuilder.putInputs(TEST_NAME + "-source", "org.apache.pulsar.functions.api.utils.Utf8StringSerDe"); functionConfigBuilder.setSinkTopic(TEST_NAME + "-sink"); return functionConfigBuilder.build(); } diff --git a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/instance/JavaInstanceTest.java b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/instance/JavaInstanceTest.java index b4c072ca104a6..bdb7f6077a949 100644 --- a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/instance/JavaInstanceTest.java +++ b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/instance/JavaInstanceTest.java @@ -31,8 +31,8 @@ import org.apache.pulsar.functions.api.RequestHandler; import org.apache.pulsar.functions.fs.LimitsConfig; import org.apache.pulsar.functions.proto.Function.FunctionConfig; -import org.apache.pulsar.functions.runtime.serde.JavaSerDe; -import org.apache.pulsar.functions.runtime.serde.Utf8StringSerDe; +import org.apache.pulsar.functions.api.utils.JavaSerDe; +import org.apache.pulsar.functions.api.utils.Utf8StringSerDe; import org.testng.annotations.Test; import java.util.Arrays; diff --git a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/rest/api/v1/ApiV1ResourceTest.java b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/rest/api/v1/ApiV1ResourceTest.java index 50df10755ea91..69bc3069f8d61 100644 --- a/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/rest/api/v1/ApiV1ResourceTest.java +++ b/pulsar-functions/worker/src/test/java/org/apache/pulsar/functions/worker/rest/api/v1/ApiV1ResourceTest.java @@ -51,13 +51,12 @@ import org.apache.pulsar.functions.proto.Function.PackageLocationMetaData; import org.apache.pulsar.functions.proto.Function.FunctionConfig; import org.apache.pulsar.functions.proto.Function.FunctionMetaData; -import org.apache.pulsar.functions.runtime.serde.Utf8StringSerDe; +import org.apache.pulsar.functions.api.utils.Utf8StringSerDe; import org.apache.pulsar.functions.fs.LimitsConfig; import org.apache.pulsar.functions.worker.FunctionRuntimeInfo; import org.apache.pulsar.functions.worker.Utils; import org.apache.pulsar.functions.worker.WorkerConfig; import org.apache.pulsar.functions.worker.request.RequestResult; -import org.apache.pulsar.functions.worker.rest.RestUtils; import org.apache.pulsar.functions.worker.FunctionRuntimeManager; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.powermock.core.classloader.annotations.PowerMockIgnore;