Skip to content

Commit

Permalink
Added pulsar C++ client
Browse files Browse the repository at this point in the history
  • Loading branch information
rdhabalia authored and Sahaya Andrews committed Feb 2, 2017
1 parent de2a611 commit 11c53aa
Show file tree
Hide file tree
Showing 146 changed files with 37,598 additions and 2 deletions.
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@

language: java
language: java C++
jdk:
- oraclejdk8

cache:
directories:
- $HOME/.m2

- $HOME/pulsar-dep

# Reconstruct the gpg keys to sign the artifacts
before_deploy:
- echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import --batch || true
- echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust --batch || true

install:
- sudo bash -x $TRAVIS_BUILD_DIR/pulsar-client-cpp/build.sh $HOME/pulsar-dep $TRAVIS_BUILD_DIR dep

after_success:
- sudo bash -x $TRAVIS_BUILD_DIR/pulsar-client-cpp/build.sh $HOME/pulsar-dep $TRAVIS_BUILD_DIR compile

deploy:
-
provider: script
Expand All @@ -27,6 +33,7 @@ deploy:
on:
tags: true
-

provider: releases
api_key:
secure: mIACMQlTzepBa9wWbKlME1Ig9/vKLHz63fn2zR2fbYjaAgXCPVe1lbTLbOZb62yB0XL7rUekyKIf0DEFH/cS1XjCb7aDKo4pLh6uiHdIIS8t1qEJJT54vbLwnWJXjo+14QHvaXgDlO/YoxpyOicrKI++b3fScD0zK2I8R6Lmwan/ZQze9uhRO0RKGChsDAszy+98C6JJxQXWQ0YjnUhwP5PtZX3Fm1rxtuCIk2Fl9gQdp9/j9U6vRKtWaO22Q2YaaaPGGoVyTwV6iMSOXDMb6zhjEQ3aiuJMJHUJRcGEU4fV7hkiUukWdo5+5C/mASNiJDYefG86KfCktMniPMzyAPXNc6hUzbOZuLNI1/f1QqBwzTJbH7NIUjz5f0hjNsHuYvkL8TcxE9pDA0Qkr8OIWR8M3+H7WKuiSTaVSeCobGBE8g6ymanlRvOQZblFpgw91B/KmZucsin0+rV5tVRlqTBYHL5f6fXEyhKdGYRiHaNR29mBBJsZng2tR6wVjPGqyEfdwFVOs44d2Rkt885VjZthap/Yw+SJKOvbJv1zaRglmbvbl629LvYOgT6ptYPDJyu/J/kzPrWnzvyTf72M6bR991Kx8gEkT4WRwCRBAuhg8i2bmIcsjbXtLcB0YRHgrBueJD0SuLREtcxJYvkgMI1UZon5UrCTkJDc0oFLO28=
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ flexible messaging model and an intuitive client API.</description>
<exclude>logs/**</exclude>
<exclude>**/*.versionsBackup</exclude>
<exclude>**/circe/**</exclude>
<exclude>pulsar-client-cpp/lib/checksum/int_types.h</exclude>
<exclude>pulsar-client-cpp/lib/checksum/crc32c*</exclude>
<exclude>pulsar-client-cpp/lib/lz4/lz4.*</exclude>
<exclude>pulsar-client-cpp/lib/PulsarApi.pb.*</exclude>
<exclude>pulsar-client-cpp/CMakeFiles/**</exclude>
</excludes>
<mapping>
<proto>JAVADOC_STYLE</proto>
Expand Down
58 changes: 58 additions & 0 deletions pulsar-client-cpp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Compiled Object files
*.slo
*.lo
*.o
*.obj
*.os
*.scons*

# Compiled Dynamic libraries
*.so
*.dylib
*.dll
*.so.1

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# Dependency file
*.d

# Mac swap file
*.DS_Store

# Linux swap file
*.swp

# Exclude compiled executables
/examples/SampleProducer
/examples/SampleConsumer
/examples/SampleAsyncProducer
/examples/SampleConsumerListener
/tests/main
/perf/PerfProducer
/perf/PerfConsumer
/system-test/SystemTest

# Eclipse generated files
.cproject
.project
.settings/
.pydevproject

# doxygen files
apidocs/

# CMAKE
Makefile
cmake_install.cmake
CMakeFiles
CMakeCache.txt
65 changes: 65 additions & 0 deletions pulsar-client-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#
# Copyright 2016 Yahoo Inc.
#
# Licensed 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.
#

cmake_minimum_required(VERSION 2.8)
project (pulsar-cpp)

set(Boost_NO_BOOST_CMAKE ON)

set (CMAKE_CXX_FLAGS "-Wno-deprecated-declarations ${CMAKE_CXX_FLAGS}")

find_package(Boost REQUIRED COMPONENTS program_options filesystem regex thread system)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(ProtoBuf QUIET)
if(NOT ProtoBuf_FOUND)
find_library(PROTOBUF_LIBRARIES protobuf)
endif()
find_library(LOG4CXX_LIBRARY_PATH log4cxx)
find_library(CURL_LIBRARY_PATH curl)
find_path(LOG4CXX_INCLUDE_PATH log4cxx/logger.h)

include_directories(
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/include
${Boost_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${ZLIB_INCLUDE_DIR}
${PROTOBUF_INCLUDE_DIR}
${LOG4CXX_INCLUDE_PATH}
)

set(COMMON_LIBS
${COMMON_LIBS}
${Boost_LIBRARIES}
${OPENSSL_LIBRARIES}
${ZLIB_LIBRARIES}
${PROTOBUF_LIBRARIES}
${LOG4CXX_LIBRARY_PATH}
${CURL_LIBRARY_PATH}
)

link_directories(${CMAKE_BINARY_DIR}/lib)

set(CLIENT_LIBS
${COMMON_LIBS}
pulsar
)

add_subdirectory(lib)
add_subdirectory(perf)
add_subdirectory(examples)
add_subdirectory(tests)
33 changes: 33 additions & 0 deletions pulsar-client-cpp/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

Pulsar C++ Client Library

Copyright 2016 Yahoo Inc.

Licensed 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.


This product contain sources from LZ4 - Fast LZ compression algorithm:
* Copyright (C) 2011-2015, Yann Collet.
* LICENSE: BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
* HOMEPAGE: https://github.com/Cyan4973/lz4


This product contains sources from Circe CRC library:
* Copyright 2014 Trevor Robinson
* LICENSE : Apache License, Version 2.0
* HOMEPAGE: https://github.com/trevorr/circe

This product contains sources from Adler CRC32c implementation:
* Copyright (C) 2013 Mark Adler
* LICENSE: ZLib License (https://opensource.org/licenses/Zlib)
* HOMEPAGE: https://github.com/baruch/crcbench/blob/master/crc-mark-adler.c
66 changes: 66 additions & 0 deletions pulsar-client-cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

### Pulsar C++ client library

Examples for using the API to publish and consume messages can be found on
https://github.com/yahoo/pulsar/tree/master/pulsar-client-cpp/examples

#### Requirements

* CMake
* Boost
* [Protocol Buffer 2.6](https://developers.google.com/protocol-buffers/)
* [Log4CXX](https://logging.apache.org/log4cxx)
* LibCurl
* [GTest](https://github.com/google/googletest)


#### Compile on Ubuntu Server 16.04

Install all dependencies:

```shell
apt-get install cmake libssl-dev libcurl4-openssl-dev liblog4cxx-dev \
libprotobuf-dev libboost-all-dev libgtest-dev
```

Compile and install Google Test:

```shell
cd /usr/src/gtest
sudo cmake .
sudo make
sudo cp *.a /usr/lib
```


Compile Pulsar client library:

```shell
cd pulsar/pulsar-client-cpp
cmake .
make
```

Client library will be placed in
```
lib/libpulsar.so
lib/libpulsar.a
```

Tools :

```
perf/perfProducer
perf/perfConsumer
```

Tests:

```
1. Start the standalone pulsar
export PULSAR_STANDALONE_CONF=tests/standalone.conf
../bin/pulsar standalone
2. Run tests
tests/main
```
71 changes: 71 additions & 0 deletions pulsar-client-cpp/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

# Copyright 2016 Yahoo Inc.
#
# Licensed 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.

function usage() {
echo "$0: <unpack location> <build directory> [all|dep|compile]";
echo " Unpack Location is used to store downloaded dependant packages";
echo " Build directory is pulsar base folder";
exit 1;
}

if [ $# -ne 3 ]; then
usage
fi

if [ ! -d $1 ]; then
echo "Unpack directory $1 does not exists"
echo ""
usage;
fi

if [ ! -d $2 ]; then
echo "Build directory $2 does not exists"
echo ""
usage;
fi

if [ "$3" != "all" -a "$3" != "dep" -a "$3" != "compile" ]; then
echo "Unknown command $3. Supported commands all|dep|compile";
echo ""
usage;
fi

exec_cmd() {
eval $*
if [ $? -ne 0 ]; then
echo "Command $* failed"
usage
fi
return $!
}

if [ "$3" = "all" -o "$3" = "dep" ]; then
# Install dependant packages
exec_cmd "apt-get install -y cmake libssl-dev libcurl4-openssl-dev liblog4cxx10-dev libprotobuf-dev libboost1.55-all-dev libgtest-dev";
exec_cmd "pushd $1/ && wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz && popd";
exec_cmd "pushd /usr/src/gtest && cmake . && make && cp *.a /usr/lib && popd";
exec_cmd "pushd $1/ && tar xvfz $1/protobuf-2.6.1.tar.gz && pushd $1/protobuf-2.6.1 && ./configure && make && make install && popd && popd";
fi

if [ "$3" = "all" -o "$3" = "compile" ]; then
# Compile and run unit tests
PULSAR_VERSION=`cat $2/pom.xml | grep -Po '(<?<version>)[^<]+' | sed 's/.*>//' | head -1`;
exec_cmd "pushd $2/pulsar-client-cpp && PULSAR_VERSION=$PULSAR_VERSION cmake . && make && popd";
PULSAR_STANDALONE_CONF=$2/pulsar-client-cpp/tests/standalone.conf $2/bin/pulsar standalone &
pid=$!;
exec_cmd "sleep 10 && pushd $2/pulsar-client-cpp/tests && ./main && popd";
exec_cmd "kill -SIGTERM $pid";
fi
Loading

0 comments on commit 11c53aa

Please sign in to comment.