`
AliKevin2011
  • 浏览: 118327 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

S4-服务的启动和具体示例的运行(单节点)

阅读更多
AliKevin 写道

   本系列文章不涉及过多的S4的理论内容,因为s4论文中描述相当清楚(我认为我实在是说的不会比论文中更清楚了:)呵呵),论文信息请看论文http://dl.iteye.com/topics/download/704e5924-0dd8-34df-b44f-2efbc91de071


    这一节我们主要运行一下官方提供的两个实例,主要关注s4的功能,故以单节点的方式演示s4的实例功能。

一.speech01 示例

speech01 简单的监听事件流的产生,并将事件流的相关内容打印到控制台上。执行如下代码进行示例的运行:

a.启动s4服务
root@slave:/kevin/s4/build/s4-image# rm -fr $S4_IMAGE/s4-core/conf/lock/*
   root@slave:/kevin/s4/build/s4-image# rm -fr $S4_IMAGE/s4-apps/*
   root@slave:/kevin/s4/build/s4-image# cp -r $S4_IMAGE/s4-example-apps/s4-example-
speech01 $S4_IMAGE/s4-apps/
   $S4_IMAGE/scripts/start-s4.sh -r client-adapter (这里没有带&,非后台启动)
   ....
   ....
  kevin/s4/build/s4-image/s4-apps -e /kevin/s4/build/s4-image/s4-exts -t default -d wall
appName=s4
dequeuer number: 6
[]
[/kevin/s4/build/s4-image/s4-apps/s4-example-speech01/s4-example-speech01-conf.xml]
Adding processing element with bean name eventCatcher, id eventCatcher
adding pe: io.s4.example.speech01.SentenceReceiverPE@987a33
Using ConMapPersister ..

如上信息证明服务已经启动成功,并加载了s4-example-speech01-conf.xml应用配置。再打开一个shell窗口,用以启动adapter.

b.启动adapter服务
root@slave:/kevin/s4# $S4_IMAGE/scripts/run-client-adapter.sh -s client-adapter \
> -g s4 -d $S4_IMAGE/s4-core/conf/default/client-stub-conf.xml
...
...
lt -c /kevin/s4/build/s4-image/s4-core -d /kevin/s4/build/s4-image/s4-core/conf/default/client-stub-conf.xml
appName=client-adapter
dequeuer number: 12
Adding InputStub genericStub
Adding OutputStub genericStub

如上信息证明adapter已经启动成功。

c.查看一下日志

重新启动一个shell,执行如下命令:
root@slave:/kevin/s4/build/s4-image/s4-core# cd $S4_IMAGE
   root@slave:/kevin/s4/build/s4-image# cd s4-core/logs/s4-core
   root@slave:/kevin/s4/build/s4-image/s4-core/logs/s4-core# tail -f *.log
   .....
    2011-10-17 00:15:39,493 s4 INFO (Dispatcher.java:95) Event count is 0; rate 0.0
    2011-10-17 00:15:39,493 s4 INFO (Dispatcher.java:97) Raw event count is 0; rate 0.0
    2011-10-17 00:15:39,498 s4 INFO (Dispatcher.java:95) Event count is 0; rate 0.0
    2011-10-17 00:15:39,499 s4 INFO (Dispatcher.java:97) Raw event count is 0; rate 0.0
    2011-10-17 00:15:39,592 s4 INFO (Dispatcher.java:95) Event count is 0; rate 0.0
    2011-10-17 00:15:39,593 s4 INFO (Dispatcher.java:97) Raw event count is 0; rate 0.0
    2011-10-17 00:15:39,626 s4 INFO (Watcher.java:85) 0 waiting processing
    2011-10-17 00:15:39,626 s4 INFO (Watcher.java:90) Total: 837222400, max 2095
   ....

如果没有异常发生证明我们服务和应用已经成功部署,接下来我们可以发布事件了。:)

d.加载测试数据,产生事件流。

我们的测试数据来源于$S4_IMAGE/s4-example-testinput/speeches.txt 文件,s4为我们提供了数据加载工具。重新打开一个shell窗口,执行如下命令:
root@slave:~# head -20 $S4_IMAGE/s4-example-testinput/speeches.txt | sh $S4_IMAGE/s4-tools-loadgenerator/scripts/generate-load.sh -r 2 -a localhost:2334 -d 1500 -
[: 27: ==: unexpected operator
[: 57: xlocalhost:2334: unexpected operator
[: 61: x2: unexpected operator
[: 65: x1500: unexpected operator
[: 69: x: unexpected operator
{0=io.s4.tools.loadgenerator.LoadGenerator$EventTypeInfo@60420f, 1=io.s4.tools.loadgenerator.LoadGenerator$EventTypeInfo@19106c7, 2=io.s4.tools.loadgenerator.LoadGenerator$EventTypeInfo@540408}
Emitted 19 events
root@slave:~#

同时查看s4服务的shell窗口会打印如下信息:
...
  Sentence is 'But in a larger sense, we cannot dedicate, we cannot consecrate, we cannot hallow this ground.', location null
Sentence is 'The brave men, living and dead who struggled here have consecrated it far above our poor power to add or detract.', location null
Sentence is 'The world will little note nor long remember what we say here, but it can never forget what they did here.', location null
Sentence is 'It is for us the living rather to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced.', location null
...


e.speech01的事件处理流程如下:


f.这些信息证明我们的speech01示例已经运行成功。该示例的整体运行截图如下:


二、speech02 示例

speech02 示例主要是接收 Sentence 事件和Speech事件,并且Sentenc事件会结合(join)Speech事件,获取Sentence所对应的属性(location)。
    运行如下操作进行speech20示例的演示:

a.启动s4服务
root@slave:/kevin/s4/build/s4-image# rm -fr $S4_IMAGE/s4-apps/*
root@slave:/kevin/s4/build/s4-image# rm $S4_IMAGE/s4-core/logs/s4-core/*
root@slave:/kevin/s4/build/s4-image# rm $S4_IMAGE/s4-core/lock/*
root@slave:/kevin/s4/build/s4-image# cp -r $S4_IMAGE/s4-example-apps/s4-example-speech02 $S4_IMAGE/s4-apps/
root@slave:/kevin/s4/build/s4-image# $S4_IMAGE/scripts/start-s4.sh -r client-adapter
appName=s4
dequeuer number: 6
[]
[/kevin/s4/build/s4-image/s4-apps/s4-example-speech02/s4-example-speech02-conf.xml]
Adding processing element with bean name eventCatcher, id eventCatcher
adding pe: io.s4.example.speech01.SentenceReceiverPE@c2ee15
Using ConMapPersister ..
Adding processing element with bean name rerouteSentencePE, id rerouteSentencePE
adding pe: io.s4.processor.ReroutePE@149105b
Using ConMapPersister ..
Adding processing element with bean name rerouteSpeechPE, id rerouteSpeechPE
adding pe: io.s4.processor.ReroutePE@196f4b5
Using ConMapPersister ..
Adding processing element with bean name sentenceJoinPE, id sentenceJoinPE
adding pe: io.s4.processor.JoinPE@1bfc4fc
Using ConMapPersister ..

如上信息说明s4已经启动并且加载了speech02的配置文件[]

b.启动.启动adapter服务
root@slave:/kevin/s4# $S4_IMAGE/scripts/run-client-adapter.sh -s client-adapter -g s4 -d $S4_IMAGE/s4-core/conf/default/client-stub-conf.xml
...
...
t default -c /kevin/s4/build/s4-image/s4-core -d /kevin/s4/build/s4-image/s4-core/conf/default/client-stub-conf.xml
appName=client-adapter
dequeuer number: 12
Adding InputStub genericStub
Adding OutputStub genericStub

如上证明adapter已经启动。

c.查看一下日志

重新启动一个shell,执行如下命令:
root@slave:/kevin/s4/build/s4-image/s4-core# cd $S4_IMAGE
   root@slave:/kevin/s4/build/s4-image# cd s4-core/logs/s4-core
   root@slave:/kevin/s4/build/s4-image/s4-core/logs/s4-core# tail -f *.log
   .....
    0.0
2011-10-17 01:07:26,552 s4 INFO (PEContainer.java:348) PE count 0
2011-10-17 01:07:26,575 s4 INFO (Watcher.java:85) 0 waiting processing
2011-10-17 01:07:26,575 s4 INFO (Watcher.java:90) Total: 837222400, max 2095513600, free 827424576
2011-10-17 01:07:26,940 s4 INFO (Dispatcher.java:95) Event count is 0; rate 0.0
2011-10-17 01:07:26,945 s4 INFO (Dispatcher.java:97) Raw event count is 0; rate 0.0

==> s4-core_8924.log <==
2011-10-17 01:07:32,032 s4 INFO (Dispatcher.java:95) Event count is 0; rate 0.0
2011-10-17 01:07:32,032 s4 INFO (Dispatcher.java:97) Raw event count is 0; rate 0.0
   ....

如果没有异常发生证明我们服务和应用已经成功部署,接下来我们可以发布事件了。:)

d.加载测试数据,发布事件流
root@slave:~# head -30 $S4_IMAGE/s4-example-testinput/speeches.txt | sh $S4_IMAGE/s4-tools-loadgenerator/scripts/generate-load.sh -r 2 -a localhost:2334 -d 1500 -
[: 27: ==: unexpected operator
[: 57: xlocalhost:2334: unexpected operator
[: 61: x2: unexpected operator
[: 65: x1500: unexpected operator
[: 69: x: unexpected operator
{0=io.s4.tools.loadgenerator.LoadGenerator$EventTypeInfo@60420f, 1=io.s4.tools.loadgenerator.LoadGenerator$EventTypeInfo@19106c7, 2=io.s4.tools.loadgenerator.LoadGenerator$EventTypeInfo@540408}
Emitted 29 events

同时查看s4控制台信息如下:
...
  Sentence is 'This is preeminently the time to speak the truth, the whole truth, frankly and boldly.', location washington, dc, us
Sentence is 'Nor need we shrink from honestly facing conditions in our country today.', location washington, dc, us
Sentence is 'This great Nation will endure, as it has endured, will revive and will prosper.', location washington, dc, us
Sentence is 'So, first of all, let me assert my firm belief that the only thing we have to fear is fear itself -- nameless, unreasoning, unjustified terror which paralyzes needed efforts to convert retreat into advance.', location washington, dc, us
...
此时打印的信息和speech01相似,只是在location中有了不是null而是具体的信息。如:  location washington, dc, us

e.speech02的事件处理流程如下:



f.这些信息证明我们的speech02示例已经运行成功。该示例的整体运行截图如下:




分享到:
评论

相关推荐

    S4-challenge:S4 开发者挑战赛

    S4是一个基于Apache Mesos的分布式系统,它将计算任务分布在网络中的多个节点上,以实现高可扩展性和容错性。系统由两个主要组件构成:Processing Elements (PEs) 和 Communication Channels。PEs负责处理数据,而...

    PyPI 官网下载 | s4u.image-2.3.1.tar.gz

    描述中的"资源来自pypi官网,资源全名:s4u.image-2.3.1.tar.gz"进一步确认了这个资源的来源和具体名称,即它是从PyPI官方获取的,压缩文件名为`s4u.image-2.3.1.tar.gz`,这是Python项目常用的打包方式,其中包含了...

    基于Java的Yahoo的分布式流计算平台 S4.zip

    S4的核心理念是将数据处理任务分解为一系列小的、相互协作的计算节点,这些节点可以并行运行,以处理大量实时数据。 ### 二、S4的特点 1. **分布式架构**:S4采用分布式架构,能够在多台机器上部署,提供高可用性...

    基于java的Yahoo的分布式流计算平台 S4.zip

    S4的核心设计理念是事件驱动和分区处理,这意味着每个节点负责处理一部分数据,且能独立运行,增强了系统的可扩展性和可靠性。 1. **事件驱动模型**:在S4中,数据以事件的形式存在,每个事件都有一个时间戳,系统...

    GT30L32S4W_GT30L32S4W_GT30L32S4W数据手册_poetexi.zip

    在实际应用中,GT30L32S4W可能被用于各种电子设备,如嵌入式系统、消费电子产品、工业控制设备或者物联网(IoT)节点。通过数据手册,工程师可以了解其功能特性,如处理能力、外设接口、功耗特性等,从而判断是否适合...

    S4TF-Demo:(暂时搁置)在Swift中试用TensorFlow

    5. **机器学习模型开发**:S4TF-Demo项目可能包含了构建、训练和评估机器学习模型的示例,涵盖了从数据预处理到模型优化的全过程。 6. **源代码结构**:在“S4TF-Demo-master”文件夹中,可能有`main.swift`或其他...

    Yahoo的分布式流计算平台 S4源码

    - **Runtime**:实现S4运行时环境,包括节点管理、事件路由、容错机制等。 - **Examples**:提供了示例应用,帮助开发者快速上手。 - **API**:包括了客户端API和节点API,用于编写处理逻辑。 通过对S4源码的深入...

    移动-AIX营账数据库安装报告oracleracv40-internal.docx

    - **IP地址分配**:文档提供了S3_C_YZ_YZSJK与S4_C_YZ_YZSJK两个节点的详细IP地址配置,包括环回地址、私有IP、虚拟IP等。 - **主机名设置**:确保HACMP的节点名与RAC所用的主机名一致,以便于集群管理和故障转移。 ...

    Oracle10g RAC ASM 环境日常管理命令

    例如,`lsnrctl start listener_hostb`和`lsnrctl stop listener_hostb`分别用于启动和停止hostb上的监听器,确保网络通信的连续性和安全性。 ### 投票盘与OCR的备份与恢复 投票盘(Voting Disk)和OCR(Oracle ...

    操作系统复习资料

    每个节点代表一个任务,箭头表示任务之间的依赖关系。 2. **构建方法**: 在给定的示例中,我们需要根据每条语句的执行顺序构建前驱图。具体步骤如下: - `S1`: a = 5 - x; (无前置条件) - `S2`: b = a * x; ...

    数据结构输入006:S4IN006

    标题中的“数据结构输入006:S4IN006”可能指的是一个关于数据结构的系列教程或课程的一部分,其中“S4IN006”可能是该系列的一个特定章节或者编码,暗示着这是第四个主题或者第四周的课程内容。在IT行业中,数据...

    操作系统chapter52022优秀文档.ppt

    在上述的get、copy和put程序示例中,如果并发执行不当,可能会导致数据丢失或错乱,例如在缓冲区操作中,如果没有适当的同步机制,可能会发生数据复制的不一致。 为了解决这些问题,操作系统提供了进程间通信(IPC...

    《化工过程分析与综合》复习题及习题期末试卷.pptx

    本文将通过详细的解释和示例,帮助学习者更好地理解化工过程分析与综合的基本概念和方法。 1. 流股断裂方法 流股断裂方法是一种用于分析信息流图的方法。该方法遵循的原则是断裂流股数目最少,且将所有循环路打开...

    fortran指针的使用说明和例子fortran指针的使用说明和例子

    ### Fortran指针的使用说明和例子 #### 1. 指针的基本概念 在Fortran语言中,指针是一种特殊类型的变量,它可以指向其他变量或数组元素,并且能够改变指向的目标。指针主要用于提高代码的灵活性和复用性。 #### 2...

    人工智能-人工智能考试重点总结42 精品.pdf

    《人工智能考试重点总结42》主要涵盖了人工智能领域中的关键概念和技术,通过具体的问题解析来阐述这些概念的应用。这里我们主要讨论三个示例问题:状态空间表示法、二阶梵塔问题以及搜索策略。 1. 状态空间表示法...

    编译原理课件

    **示例**:对于句子`abbcde`,通过上述步骤可以识别出句柄`bb`和`cde`,并将其分别归约成`A`和`B`。 #### 三、自底向上分析方法的分类 根据寻找句柄的方法不同,自底向上的分析方法可以分为几种类型: 1. **优先...

    3.2 Distributed Graph Exploration Algorithm 3.2 分布式图探索算法.doc

    在这种情况下,S1和S3被分配给P1处理,而S2和S4则被分配给P2处理。如果S5是通过扩展S3得到的,则S5也将由P1处理。通过这种方式,可以有效地平衡两个处理器之间的负载。 #### 3.2.4 结合已处理列表和等待列表的算法 ...

Global site tag (gtag.js) - Google Analytics