Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIP-15: Pulsar Functions #1314

Merged
merged 272 commits into from
Mar 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
272 commits
Select commit Hold shift + click to select a range
5f3b93e
Fix tests (#24)
srkukarni Dec 19, 2017
f883f16
Buffer limit (#25)
srkukarni Dec 19, 2017
5adc066
Relocate packages (#21)
sijie Dec 19, 2017
117f816
System exception (#26)
srkukarni Dec 19, 2017
f026ef8
Refactor cli (#27)
srkukarni Dec 19, 2017
13bbbf7
Use the thread context classloader for loading functions (#28)
sijie Dec 19, 2017
316f834
relocate SerDe classes to `serde` package and add tests (#29)
sijie Dec 20, 2017
275daf0
Make SerDe interface a generic interface and load the serde class in …
sijie Dec 20, 2017
a548bc2
Input and Output Serdes (#31)
sijie Dec 20, 2017
4dd4089
Nomenclature (#32)
srkukarni Dec 20, 2017
48d4aa4
Added Submit Function capability to the pulsar-functions cli (#33)
srkukarni Dec 21, 2017
3227065
Cleanup (#34)
srkukarni Dec 21, 2017
da66b2d
Fix compilation (#35)
srkukarni Dec 21, 2017
3f7d304
Make producer and consumer async
srkukarni Dec 21, 2017
7fbe342
Asyncack (#37)
srkukarni Dec 21, 2017
e90b308
Nonthreadpool (#38)
srkukarni Dec 21, 2017
5c1e369
Provide a jmh benchmark to benchmark thread container (#39)
sijie Dec 22, 2017
4b4bea7
Reconcile (#40)
srkukarni Dec 22, 2017
a1b1ea5
Made Update a put request (#41)
srkukarni Dec 22, 2017
27f4c0b
Enable batching on producer (#42)
sijie Dec 22, 2017
5077d71
Completecli (#43)
srkukarni Dec 22, 2017
0444ac4
Introduce FunctionStats to collection function related stats (#44)
sijie Dec 22, 2017
5ea8065
Fileinterface (#45)
srkukarni Dec 22, 2017
5c4b286
Print (#46)
srkukarni Dec 22, 2017
570d59c
Initial implementation of Pulsar Function Worker (#47)
jerrypeng Dec 27, 2017
103d20d
Fix license header (#48)
sijie Dec 27, 2017
8824efb
Compose `FunctionState` with FunctionConfig and LimitsConfig (#49)
sijie Dec 28, 2017
84a8040
Load function worker configuration from yaml file (#50)
sijie Jan 2, 2018
0c113d7
Rewrite FunctionStateListener to use receiveAsyc (#51)
sijie Jan 2, 2018
59ec630
Rename functionstate (#52)
srkukarni Jan 2, 2018
793b1cf
Renamed FunctionState stuff to something that reflects their function…
srkukarni Jan 2, 2018
d0c231e
Refactor to support at-least-once processing (#54)
sijie Jan 2, 2018
7c10a31
Cleanup Cli commands (#55)
sijie Jan 2, 2018
eefe67e
Invoke spawner upon start/stop of worker (#56)
srkukarni Jan 3, 2018
58a5392
Removed ExecutionResult since its not longer needed (#57)
srkukarni Jan 3, 2018
507b938
fixing log functions (#58)
jerrypeng Jan 3, 2018
4f107d3
Use LinkedBlockingQueue#put and ack before processing for at-most-onc…
sijie Jan 3, 2018
4c973c8
Added atmost once and atleast once semantics (#60)
srkukarni Jan 3, 2018
38a5987
Make sure it works if the function does not have a sink topic (#61)
srkukarni Jan 3, 2018
43a09e6
add/fixes the following: (#62)
jerrypeng Jan 3, 2018
9902a32
Moved FunctionStats to fs since it does not belong to api (#64)
srkukarni Jan 3, 2018
ef7657c
Organize function packages in hierarchy (#65)
sijie Jan 3, 2018
c74e545
Removing ServiceRequest from requestResult (#66)
jerrypeng Jan 3, 2018
d14c23a
Added FunctionActioner to start/stop functions in seperate thread (#68)
srkukarni Jan 4, 2018
61650f3
Add unit tests for dlog classes and rest api (#67)
sijie Jan 4, 2018
5fe559d
Add the missing script for running pulsar worker (#69)
sijie Jan 4, 2018
8a0cd54
Added more logging. Also changed getFunctions to return 404 when not …
srkukarni Jan 4, 2018
4e6adca
Add `@RequiredField` annotation to enforce verification on whether a …
sijie Jan 4, 2018
7e14c8f
More graceful warning when args are missing (#72)
srkukarni Jan 4, 2018
f1081f8
add client side class validation (#70)
jerrypeng Jan 4, 2018
2dc4a5b
Bug fix and add log messages (#75)
jerrypeng Jan 4, 2018
b662fe6
Function Logging (#74)
sijie Jan 5, 2018
992e947
Name our threads (#76)
srkukarni Jan 5, 2018
46d8874
Revert dlog version to stable 0.5.0 (#77)
sijie Jan 5, 2018
638e3c7
Fix spelling (#78)
srkukarni Jan 5, 2018
6a4592a
fixing bugs and adding assignments datastructure (#79)
jerrypeng Jan 5, 2018
8002e3b
Use Reader API instead of Consumer API (#81)
sijie Jan 5, 2018
2fc20b5
Upgrade testng and downgrade log4j2 and remove junit (#80)
sijie Jan 5, 2018
ee0ba86
Fix upload path issue (#83)
sijie Jan 5, 2018
ab3007f
Removed FunctionStats interface and added FunctionStatus class (#82)
srkukarni Jan 5, 2018
5dcf03a
If the function is not found, send 404 (#84)
srkukarni Jan 5, 2018
aa19226
Pulsar worker uses routing appender (#85)
sijie Jan 5, 2018
d5955d8
adding initialize routine to launch existing assignments (#86)
jerrypeng Jan 6, 2018
f4130f8
Added getstatus function (#87)
srkukarni Jan 6, 2018
5650574
Refactor worker to make sure that FunctionActioner is just an actione…
srkukarni Jan 8, 2018
1b0607a
Added ability to propagate user defined configs (#89)
srkukarni Jan 8, 2018
d82a04f
Move worker module out of runtime module (#90)
sijie Jan 9, 2018
71997bb
Make ThreadFactory as thin as possible (#91)
srkukarni Jan 9, 2018
493e54a
Made use of LimitsConfig in JavaInstanceConfig (#92)
srkukarni Jan 9, 2018
f65c4a4
Move most of the instance logic to JavaInstanceRunnable (#93)
srkukarni Jan 9, 2018
72a9804
Moved FunctionId/InstanceId to fs package (#94)
srkukarni Jan 9, 2018
9abeef2
Simplify Container interface (#95)
srkukarni Jan 9, 2018
fe80a6c
adding generated code module (#96)
jerrypeng Jan 9, 2018
d07897a
updating generated code dir (#97)
jerrypeng Jan 9, 2018
ce81cb7
fixing generated dir (#98)
jerrypeng Jan 9, 2018
426ab54
Migrating ServiceRequest to proto (#99)
jerrypeng Jan 10, 2018
7b24f68
Removed FunctionId and InstanceId (#100)
srkukarni Jan 10, 2018
8316228
Refactor functions module structure (#101)
sijie Jan 10, 2018
a0e4204
Rename generated module to proto module (#102)
sijie Jan 10, 2018
ec46e1a
LimitsConfig is always part of WorkerConfig (#103)
srkukarni Jan 10, 2018
d02ae48
Migrating FunctionConfig, FunctionMetaData, and ServiceRequest to pro…
jerrypeng Jan 11, 2018
cb74f21
Added ProcessContainerFactory (#105)
srkukarni Jan 11, 2018
7ea376a
Removed FunctionStatus and use protobuf as the central datastructure …
srkukarni Jan 11, 2018
d400a03
Added Metric Interface (#107)
srkukarni Jan 12, 2018
1c4bbaf
Added metrics sinks interface and added file and prometheus interface…
srkukarni Jan 12, 2018
5bf96a7
Added ability to specify metrics sinks (#109)
srkukarni Jan 12, 2018
674b2a2
Misc bug fixes to get metrics to work (#110)
srkukarni Jan 12, 2018
45c807e
Added system metrics to the list of metrics collected (#111)
srkukarni Jan 13, 2018
8d4ff95
Shade `pulsar-client-admin` (#112)
sijie Jan 15, 2018
4cbec31
adding log4j confs for unit tests (#114)
jerrypeng Jan 15, 2018
882d56f
Adding snapshot feature to Pulsar Functions worker (#113)
jerrypeng Jan 15, 2018
8fcdd09
Refactor serde classes into JavaInstanceRunnable (#115)
srkukarni Jan 16, 2018
693ae3b
Use `pulsar-client-tools-shaded` jar to avoid inconsistency between s…
sijie Jan 16, 2018
2cb75ba
Fixing response and cli (#117)
jerrypeng Jan 16, 2018
ba06963
Added ability for a function to consume multiple input topics (#118)
srkukarni Jan 16, 2018
2e438b5
Add `join` interface to container to wait for a container (#121)
sijie Jan 17, 2018
28ff628
Use a different location for caching the classpath (#122)
sijie Jan 17, 2018
5dfbb27
Move SerDe to api (#120)
srkukarni Jan 17, 2018
b3a8b21
Added publish interface to the api (#123)
srkukarni Jan 17, 2018
65f02b3
Moved JavaInstanceConfig to InstanceConfig (#125)
srkukarni Jan 17, 2018
f2d511e
Added ability to specify subscription type (#124)
srkukarni Jan 17, 2018
6c380c4
Added runtime descriptor in functionConfig (#126)
srkukarni Jan 17, 2018
f50a68e
adding additional worker tests (#127)
jerrypeng Jan 17, 2018
850c1bd
Moved api/examples to api-java and java-examples (#128)
srkukarni Jan 17, 2018
0e84121
Removed RawRequest interface (#130)
srkukarni Jan 18, 2018
624afe7
Renamed RequestHandler to PulsarFunction (#131)
srkukarni Jan 18, 2018
8f571de
Added python api (#132)
srkukarni Jan 18, 2018
b590e8b
Add plumbing to accept python inside worker/container (#133)
srkukarni Jan 19, 2018
0863c22
adding user acking and fixing bugs (#134)
jerrypeng Jan 19, 2018
fea9805
First cut of Python Instance that just parses the arguments and start…
srkukarni Jan 19, 2018
6f853cd
First of cut of windowing for Pulsar Functions (#136)
jerrypeng Jan 22, 2018
0ee69b9
renaming to streamlet (#138)
jerrypeng Jan 22, 2018
0667a47
Provide a copy task in runtime package phase to copy all python-insta…
sijie Jan 22, 2018
d2f32e8
Feature Complete Python Instance. (#139)
srkukarni Jan 23, 2018
a2ed4c2
Kill process upon shutdown (#140)
srkukarni Jan 23, 2018
f1c403c
Quit cleanly upon ctrl-c (#141)
srkukarni Jan 23, 2018
bc074c8
Propagate Auto Acking information to the processes (#142)
srkukarni Jan 23, 2018
937b57d
Support explicit acking in the context just like Java interface (#143)
srkukarni Jan 24, 2018
7af9d02
Moved Stats to java instance since it now only has visibility in java…
srkukarni Jan 24, 2018
331e658
Event time windowing for Pulsar Functions (#145)
jerrypeng Jan 24, 2018
5241991
Remove calculating of quantiles and keep stats simple (#146)
srkukarni Jan 24, 2018
f77cd00
moving windowing code (#147)
jerrypeng Jan 24, 2018
1ebc04d
Overhaul stats in both Java and Python instances (#148)
srkukarni Jan 24, 2018
caddfd7
Periodically check the liveness of the function process (#149)
srkukarni Jan 24, 2018
3682ed0
adding unittest for windowing (#150)
jerrypeng Jan 25, 2018
4b24eb6
Correct spacing (#151)
jerrypeng Jan 25, 2018
907b6e4
changing publish function to accept string for classname (#152)
jerrypeng Jan 25, 2018
27cb857
Added scripts to generate python packages (#153)
srkukarni Jan 25, 2018
86c8897
correcting header files (#154)
jerrypeng Jan 25, 2018
a94e2d8
remove possible race condition (#156)
jerrypeng Jan 25, 2018
f0d9e1d
Convert user config to json in process builder (#157)
srkukarni Jan 25, 2018
5f55daa
Remove type checking since Serde is now exposed (#159)
srkukarni Jan 25, 2018
6e8d14e
localrun uses broker admin url and remove empty module (#160)
sijie Jan 25, 2018
4a82004
Removed the usage of timer since it doesnt seem to be used (#161)
srkukarni Jan 26, 2018
21aec14
State - Counter support (#155)
sijie Jan 26, 2018
46fe5d2
Interrupt instance thread when stopping function container (#162)
sijie Jan 26, 2018
3f963d8
Added SimpleSerDe to ser/deser basic types (#163)
srkukarni Jan 26, 2018
4396db6
Make state storage service url (#164)
sijie Jan 26, 2018
989f59d
Improve pulsar functions logging (#165)
sijie Jan 26, 2018
2f6167e
Improve the logic for finding java instance location (#166)
sijie Jan 26, 2018
efce272
Use Spawner inside Java Instance rather than using JavaInstance direc…
srkukarni Jan 27, 2018
edbae3c
Allow two types of input. (#170)
srkukarni Jan 28, 2018
5f84eb1
Make Output Serde Optional (#171)
srkukarni Jan 28, 2018
3424041
Infer Missing Arguments (#172)
srkukarni Jan 29, 2018
0e4a4da
Add more logs while starting thread container (#173)
srkukarni Jan 29, 2018
bcecfcc
More checks for checking the presence of certain fields (#174)
srkukarni Jan 29, 2018
06e7d74
Change the log file name to the name of the function. This greatly as…
srkukarni Jan 29, 2018
3b7d1f4
Return a valid response upon not being able to get status from spawne…
srkukarni Jan 29, 2018
d498fa9
Move SimpleSerDe to api (#177)
srkukarni Jan 29, 2018
138da83
Simplify DefaultSerde and make users be able to explicitly set it (#178)
srkukarni Jan 30, 2018
14b0fe4
Removed Utf8SerDe now that we have its more generic alternative Defau…
srkukarni Jan 30, 2018
75ce665
Python Instance should resort to default serializer if nothing is spe…
srkukarni Jan 30, 2018
467f6e4
Use the right regexp for extracting class name (#181)
srkukarni Jan 30, 2018
ecf223c
Assume a default output topic if none is specified and create one (#182)
srkukarni Jan 30, 2018
aa36dcb
Fix python location (#168)
sijie Jan 30, 2018
10e45d6
Added more python examples and fix existing (#183)
srkukarni Jan 31, 2018
a954d96
Since server is already module name, rename the variable (#185)
srkukarni Jan 31, 2018
3448c10
during startup self.producer will always be null (#186)
srkukarni Jan 31, 2018
180f01f
Implementing distributed worker mode (#184)
jerrypeng Jan 31, 2018
dfb333f
Added a mechanism to configure user config via cli as well (#187)
srkukarni Feb 1, 2018
79a3b78
Fixing Function get status (#188)
jerrypeng Feb 1, 2018
555a08b
Add more type checks for Java submissions (#189)
srkukarni Feb 2, 2018
0c7e7b5
Check for void type for output serde (#190)
srkukarni Feb 2, 2018
ef5f986
DefaultSerDe needs to be init specially for user publish (#191)
srkukarni Feb 2, 2018
37a0b63
Added Java Native Functions capability (#192)
srkukarni Feb 2, 2018
a025bfe
Added support for Pure Python Functions (#193)
srkukarni Feb 2, 2018
dd8b4a8
Raise an exception if the module is not found (#194)
srkukarni Feb 2, 2018
dfcfe5f
Avoid race condition by making methods synchronized (#195)
srkukarni Feb 3, 2018
ac5ca04
adding check for failures subroutine and fixing worker delete bug (#196)
jerrypeng Feb 3, 2018
922494e
Correct the order of checking (#197)
srkukarni Feb 3, 2018
868d21d
Reload class for the function/serde type checking on submitting funct…
sijie Feb 5, 2018
6779f3a
synchronizing some methods and add comments (#201)
jerrypeng Feb 6, 2018
8df9d54
checking synchronization and adding comments (#202)
jerrypeng Feb 6, 2018
631f22f
Consolidate error handling to Spawner (#203)
srkukarni Feb 6, 2018
a9c2437
Add more information about function in getstatus (#205)
srkukarni Feb 6, 2018
3af1d48
fixing bug in snapshot manager (#204)
jerrypeng Feb 6, 2018
1832b52
fixing worker namespace initialize race condition (#206)
jerrypeng Feb 6, 2018
4b730b1
GetStatus should return a set of recent exceptions (#207)
srkukarni Feb 7, 2018
f11f192
Since we assuming that user key/value are all strings, explicitly tra…
srkukarni Feb 7, 2018
911d289
Fix variable name (#210)
srkukarni Feb 7, 2018
c08b392
Always download because the code might have changed (#209)
srkukarni Feb 7, 2018
0d44440
Fix the way to import pulsarfunction root specific modules (#211)
srkukarni Feb 7, 2018
6fc757e
Add a simpler way to publish (#212)
srkukarni Feb 7, 2018
b64644c
Accomodate native functions (#213)
srkukarni Feb 7, 2018
4b62d14
Don't count first start as a restart (#214)
srkukarni Feb 7, 2018
2dccc85
fixing bug in scheduler (#215)
jerrypeng Feb 9, 2018
7fd924f
Rename FunctionConfig names to make them more consistent (#216)
srkukarni Feb 9, 2018
43ec19b
Added last invocation time to the function status (#217)
srkukarni Feb 9, 2018
21212a1
Added subscription type to function command (#218)
srkukarni Feb 10, 2018
d21341c
Add a cli command to query function state (#200)
sijie Feb 12, 2018
1bb2ccf
Avoid creating pulsar admin client for local run (#219)
sijie Feb 12, 2018
0c94f29
Removed LimitsConfig (#222)
srkukarni Feb 13, 2018
d1699b2
Removed timeout since it is no longer tracked (#223)
srkukarni Feb 13, 2018
4b89453
Allow workers to deploy multiple function instances (#221)
jerrypeng Feb 13, 2018
e724141
For FunctionsCommand make use of required fields (#224)
srkukarni Feb 13, 2018
adcdf68
adding checks for parallelism (#225)
jerrypeng Feb 14, 2018
0393713
adding instance id to get status (#226)
jerrypeng Feb 14, 2018
fe1bb68
Bump functions to 2.0.0-incubating-SNAPSHOT after rebase
sijie Feb 15, 2018
e47af0c
Remove zookeeper from dependency management to avoid pulling in a wro…
sijie Feb 15, 2018
8f1f022
Log before quitting (#228)
srkukarni Feb 16, 2018
f6b914d
Address netty version conflicts causing getFunctionStatus to fail (#229)
sijie Feb 16, 2018
f8152c8
Remove zkServers from worker config (#232)
sijie Feb 20, 2018
fe6747b
Get rid of the leader election trick and use ConsumerEventListener fo…
sijie Feb 20, 2018
64d2b18
Fix NPE on serializing MembershipManager (#235)
sijie Feb 20, 2018
e3403c5
adding worker retry if cannot connect to broker (#237)
jerrypeng Feb 21, 2018
27ad9c7
Use metadata field for worker info (#238)
jerrypeng Feb 21, 2018
8a99e50
Effectively once support (#230)
sijie Feb 22, 2018
cb48b09
Move all the components required for running worker (except rest endp…
sijie Feb 22, 2018
587da92
Revert "Move all the components required for running worker (except r…
jerrypeng Feb 22, 2018
6b0e087
fixing getting assignments from assignment topic (#240)
jerrypeng Feb 23, 2018
914179c
Move all the components required for running worker (except rest end…
sijie Feb 23, 2018
7da9755
Ignore "javax.ws.*" from PowerMockito (address rebase issue)
sijie Feb 23, 2018
f90c4d3
Upgrade state storage client to latest version (#245)
sijie Feb 23, 2018
b1306d6
Cleanup WorkerService (#243)
sijie Feb 23, 2018
fb5e34b
Move function metadata setup logic out of WorkerService (#244)
sijie Feb 23, 2018
753155d
Remove snapshotting (#246)
jerrypeng Feb 23, 2018
2e296ee
Bump log4j2 to 2.10.0
sijie Feb 23, 2018
d5285e2
Remove hardcoded jackson version (#247)
sijie Feb 23, 2018
86f6cdc
Refactored instance related stuff into instance as well as rejiggered…
srkukarni Feb 26, 2018
2d7a7f8
Refactored all metrics stuff into its own module (#249)
srkukarni Feb 27, 2018
0497368
Renamed all container stuff to runtime (#250)
srkukarni Feb 27, 2018
ee77f77
Address merge conflicts
sijie Feb 27, 2018
599077a
Corrected the name of the java instance main (#252)
srkukarni Feb 27, 2018
41c9713
Address conflicts after merged
sijie Feb 27, 2018
2412f80
Added more comments to the JavaDoc (#253)
srkukarni Feb 28, 2018
bbc1242
revert zookeeper dependency
sijie Feb 28, 2018
b7d3083
Upgrade dlog deps (#254)
sijie Feb 28, 2018
9bc41ab
Increase bookkeeper disk usage threshold for pulsar standalone (#255)
sijie Feb 28, 2018
ab93a18
Update threshold (#256)
sijie Feb 28, 2018
2fe4a38
Fix NPE for void functions (#258)
sijie Feb 28, 2018
7370fbc
Added abiltiy to specify broker on cmdline for localrun (#259)
srkukarni Feb 28, 2018
dc8f39c
fix bug in scheduler (#260)
jerrypeng Feb 28, 2018
9114ddc
Moved localrun to process based runtime (#261)
srkukarni Feb 28, 2018
e5ed2ed
Provide a distribution package for pulsar functions (#263)
sijie Mar 1, 2018
e417c57
Support parallelism parameter while running functions locally (#262)
srkukarni Mar 1, 2018
68e1f3c
Fix pulsar-functions on locating java & python instance files (#264)
sijie Mar 1, 2018
981e472
Use `distributedlog-core-shaded` in pulsar worker (#257)
sijie Mar 1, 2018
6652c5a
Move the thread construction to start to avoid illegalstate (#266)
srkukarni Mar 1, 2018
322f3af
Fix serviceUrl for functions cli (#267)
sijie Mar 1, 2018
c350e1d
Improve function package download process (#268)
sijie Mar 1, 2018
a68fb0d
Organize the function packages in tenant/namespace/function hierarchy…
sijie Mar 1, 2018
82bccd1
Resolve rebase conflicts
sijie Mar 1, 2018
ae1ac31
Build classpath using `compile` scope (#272)
sijie Mar 1, 2018
2e49646
Create ProcessBuilder at during start() so that start() can be called…
srkukarni Mar 2, 2018
6ec05f9
If no brokerUrl is specified use localhost (#274)
srkukarni Mar 2, 2018
46bc558
fix scaling up and down as well as updating a function in general (#275)
jerrypeng Mar 2, 2018
03df440
adding SchedulerManager tests (#276)
jerrypeng Mar 2, 2018
433eb8b
Better variable safety (#277)
srkukarni Mar 2, 2018
5245529
Effectively once not yet supported in Python (#278)
srkukarni Mar 2, 2018
12dac7e
- Revert .travis.yml
sijie Mar 4, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ flexible messaging model and an intuitive client API.</description>
<module>docker</module>
<module>tests</module>
<module>pulsar-log4j2-appender</module>
<!-- functions related modules -->
<module>pulsar-functions</module>
</modules>

<issueManagement>
Expand Down
49 changes: 49 additions & 0 deletions pulsar-functions/api-java/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--

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.

-->
<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>
<parent>
<groupId>org.apache.pulsar</groupId>
<artifactId>pulsar-functions</artifactId>
<version>2.0.0-incubating-SNAPSHOT</version>
</parent>

<artifactId>pulsar-functions-api</artifactId>
<name>Pulsar Functions :: API</name>

<dependencies>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>net.jodah</groupId>
<artifactId>typetools</artifactId>
<version>0.5.0</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/**
* 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.
*/
package org.apache.pulsar.functions.api;

import org.slf4j.Logger;

import java.util.Collection;
import java.util.concurrent.CompletableFuture;

/**
* Context provides contextual information to the executing function.
* Features like which message id we are handling, whats the topic name of the
* message, what are our operating constraints, etc can be accessed by the
* executing function
*/
public interface Context {
/**
* Returns the messageId of the message that we are processing
* This messageId is a stringified version of the actual MessageId
* @return the messageId
*/
byte[] getMessageId();

/**
* The topic that this message belongs to
* @return The topic name
*/
String getTopicName();

/**
* Get a list of all source topics
* @return a list of all source topics
*/
Collection<String> getSourceTopics();

/**
* Get sink topic of function
* @return sink topic name
*/
String getSinkTopic();

/**
* Get output Serde class
* @return output serde class
*/
String getOutputSerdeClassName();

/**
* The tenant this function belongs to
* @return the tenant this function belongs to
*/
String getTenant();

/**
* The namespace this function belongs to
* @return the namespace this function belongs to
*/
String getNamespace();

/**
* The name of the function that we are executing
* @return The Function name
*/
String getFunctionName();

/**
* The id of the function that we are executing
* @return The function id
*/
String getFunctionId();

/**
* The id of the instance that invokes this function.
*
* @return the instance id
*/
String getInstanceId();

/**
* The version of the function that we are executing
* @return The version id
*/
String getFunctionVersion();

/**
* The logger object that can be used to log in a function
* @return the logger object
*/
Logger getLogger();

/**
* Increment the builtin distributed counter refered by key
* @param key The name of the key
* @param amount The amount to be incremented
*/
void incrCounter(String key, long amount);

/**
* Get Any user defined key/value
* @param key The key
* @return The value specified by the user for that key. null if no such key
*/
String getUserConfigValue(String key);

/**
* Record a user defined metric
* @param metricName The name of the metric
* @param value The value of the metric
*/
void recordMetric(String metricName, double value);

/**
* Publish an object using serDe for serializing to the topic
* @param topicName The name of the topic for publishing
* @param object The object that needs to be published
* @param serDeClassName The class name of the class that needs to be used to serialize the object before publishing
* @return A future that completes when the framework is done publishing the message
*/
<O> CompletableFuture<Void> publish(String topicName, O object, String serDeClassName);

/**
* Publish an object using DefaultSerDe for serializing to the topic
* @param topicName The name of the topic for publishing
* @param object The object that needs to be published
* @return A future that completes when the framework is done publishing the message
*/
<O> CompletableFuture<Void> publish(String topicName, O object);

/**
* By default acknowledgement management is done transparently by Pulsar Functions framework.
* However users can disable that and do ack management by themselves by using this API.
* @param messageId The messageId that needs to be acknowledged
* @param topic The topic name that the message belongs to that needs to be acknowledged
* @return A future that completes when the framework is done acking the message
*/
CompletableFuture<Void> ack(byte[] messageId, String topic);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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.
*/
package org.apache.pulsar.functions.api;

/**
* This is the core interface of the function api. The process is called
* for every message of the input topic of the function. The incoming input bytes
* are converted to the input type I for simple Java types(String, Integer, Boolean,
* Map, and List types) and for org.Json type. If this serialization approach does not
* meet your needs, you can use the byte stream handler defined in RawRequestHandler.
*/
@FunctionalInterface
public interface PulsarFunction<I, O> {
/**
* Process the input.
* @return the output
*/
O process(I input, Context context) throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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.
*/
package org.apache.pulsar.functions.api;

/**
* An interface for serializer/deserializer.
*/
public interface SerDe<T> {
T deserialize(byte[] input);
byte[] serialize(T input);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* 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.
*/

/**
* Provides a simple model for enabling lightweight computation on Apache Pulsar.
*/
package org.apache.pulsar.functions.api;
Loading