Skip to content

Commit

Permalink
Move SerDe to api (apache#120)
Browse files Browse the repository at this point in the history
* Move SerDe to api

* Incorporate comments
  • Loading branch information
srkukarni authored and sijie committed Mar 4, 2018
1 parent 28ff628 commit 5dfbb27
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.testng.Assert.assertEquals;

import org.apache.pulsar.functions.api.utils.Utf8StringSerDe;
import org.testng.annotations.Test;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pulsar-functions/run-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions pulsar-functions/run-logging-examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5dfbb27

Please sign in to comment.