【注:以下内容参考自pravega.io,所做内容仅为作者愚见不代表所在公司】
Pravega入门
了解Pravega最好方法就是自己动手部署一个,然后跑一把Pravega示例。
部署Pravega其实很简单,以下是步骤:
Java版本:Java 8
下载Pravega
可以从 https://github.com/pravega/pravega/releases 下载Pravega编译好的发行版。如果您想自己构建Pravega,也可以自己下载代码并运行:
$./gradlew distribution
多细节可以查看Pravega README.md( https://github.com/pravega/pravega/blob/master/README.md)。
解压
$ tar xfvz pravega-0.1.0.tgz
然后以standalone模式运行Pravega,这种模式会在本地机器上启动Pravega的所有组件。注意:这仅用于测试/演示目的,请勿在生产环境中使用!更多内容请查看 http://pravega.io/docs/latest/deployment/deployment/
$ cd pravega-0.1.0
$ bin / pravega-standalone
执行这个命令即可拉起一个本地化的pravega 集群, 这样就可以跑pravega。
Pravega“Hello World”示例
Pravega为示例维护一个单独的github库:https://github.com/pravega/pravega-samples
Pravega依赖关系会自动从maven中心拉下来。注意:示例还可以使用本地编译的Pravega。有关这方面的更多信息,请参阅README.md(https://github.com/pravega/pravega/blob/master/README.md)中maven发布的注释。
下载Pravega-Samples git库
$ git clone https://github.com/pravega/pravega-samples
$ cd pravega-samples
生成示例程序
$ ./gradlew installDist
运行示例“HelloWorldWriter”,将“hello world”消息作为事件写入Pravega stream。
$ cd pravega-samples/standalone-examples/build/install/pravega-standalone-examples
$ bin/helloWorldWriter
HelloWorldWriter的输出
...
Writing message: 'hello world' with routing-key: 'helloRoutingKey' to stream 'examples / helloStream'
...
若想使用不同的参数运行HelloWorldWriter,更多信息请参阅pravegs-samples中的readme.md文件
运行示例“HelloWorldReader”
$ cd pravega-samples/standalone-examples/build/install/pravega-standalone-examples
$ bin/helloWorldReader
示例HelloWorldReader的输出
...
Reading all the events from examples/helloStream
...
Read event 'hello world'
No more events from examples/helloStream
...
有关HelloWorldReader的更多详细信息,请参阅pravega-samples中的readme.md文件
领取专属 10元无门槛券
私享最新 技术干货