Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
pulsar
提交
39b74071
pulsar
项目概览
apache
/
pulsar
通知
129
Star
40
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
pulsar
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
39b74071
编写于
9月 12, 2016
作者:
M
Matteo Merli
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added better error reporting in PulsarClientToolTest
上级
bd18ebc8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
18 deletion
+16
-18
pulsar-client-tools/src/main/java/com/yahoo/pulsar/client/cli/CmdConsume.java
...src/main/java/com/yahoo/pulsar/client/cli/CmdConsume.java
+3
-2
pulsar-client-tools/src/test/java/com/yahoo/pulsar/client/cli/PulsarClientToolTest.java
...ava/com/yahoo/pulsar/client/cli/PulsarClientToolTest.java
+13
-16
未找到文件。
pulsar-client-tools/src/main/java/com/yahoo/pulsar/client/cli/CmdConsume.java
浏览文件 @
39b74071
...
@@ -130,10 +130,11 @@ public class CmdConsume {
...
@@ -130,10 +130,11 @@ public class CmdConsume {
RateLimiter
limiter
=
(
this
.
consumeRate
>
0
)
?
RateLimiter
.
create
(
this
.
consumeRate
)
:
null
;
RateLimiter
limiter
=
(
this
.
consumeRate
>
0
)
?
RateLimiter
.
create
(
this
.
consumeRate
)
:
null
;
while
(
this
.
numMessagesToConsume
==
0
||
numMessagesConsumed
<
this
.
numMessagesToConsume
)
{
while
(
this
.
numMessagesToConsume
==
0
||
numMessagesConsumed
<
this
.
numMessagesToConsume
)
{
if
(
limiter
!=
null
)
if
(
limiter
!=
null
)
{
limiter
.
acquire
();
limiter
.
acquire
();
}
Message
msg
=
consumer
.
receive
(
20
,
TimeUnit
.
SECONDS
);
Message
msg
=
consumer
.
receive
(
5
,
TimeUnit
.
SECONDS
);
if
(
msg
==
null
)
{
if
(
msg
==
null
)
{
LOG
.
warn
(
"No message to consume after waiting for 20 seconds."
);
LOG
.
warn
(
"No message to consume after waiting for 20 seconds."
);
}
else
{
}
else
{
...
...
pulsar-client-tools/src/test/java/com/yahoo/pulsar/client/cli/PulsarClientToolTest.java
浏览文件 @
39b74071
...
@@ -15,15 +15,12 @@
...
@@ -15,15 +15,12 @@
*/
*/
package
com.yahoo.pulsar.client.cli
;
package
com.yahoo.pulsar.client.cli
;
import
java.io.ByteArrayOutputStream
;
import
java.io.PrintStream
;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.
lang.InterruptedException
;
import
java.
util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.ScheduledExecutorService
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.AfterClass
;
...
@@ -31,7 +28,6 @@ import org.testng.annotations.BeforeClass;
...
@@ -31,7 +28,6 @@ import org.testng.annotations.BeforeClass;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
com.yahoo.pulsar.broker.service.BrokerTestBase
;
import
com.yahoo.pulsar.broker.service.BrokerTestBase
;
import
com.yahoo.pulsar.client.cli.PulsarClientTool
;
@Test
@Test
public
class
PulsarClientToolTest
extends
BrokerTestBase
{
public
class
PulsarClientToolTest
extends
BrokerTestBase
{
...
@@ -56,30 +52,31 @@ public class PulsarClientToolTest extends BrokerTestBase {
...
@@ -56,30 +52,31 @@ public class PulsarClientToolTest extends BrokerTestBase {
String
topicName
=
"persistent://property/ns/topic-scale-ns-0/topic"
;
String
topicName
=
"persistent://property/ns/topic-scale-ns-0/topic"
;
int
numberOfMessages
=
10
0
;
int
numberOfMessages
=
10
;
ScheduledExecutorService
executor
=
Executors
.
newSingleThreadSchedule
dExecutor
();
ExecutorService
executor
=
Executors
.
newSingleThrea
dExecutor
();
Future
<
Boolean
>
future
=
executor
.
submit
(()
->
{
CompletableFuture
<
Void
>
future
=
new
CompletableFuture
<
Void
>();
executor
.
execute
(()
->
{
PulsarClientTool
pulsarClientToolConsumer
;
PulsarClientTool
pulsarClientToolConsumer
;
try
{
try
{
pulsarClientToolConsumer
=
new
PulsarClientTool
(
properties
);
pulsarClientToolConsumer
=
new
PulsarClientTool
(
properties
);
String
[]
args
=
{
"consume"
,
"-t"
,
"Exclusive"
,
"-s"
,
"sub-name"
,
"-n"
,
String
[]
args
=
{
"consume"
,
"-t"
,
"Exclusive"
,
"-s"
,
"sub-name"
,
"-n"
,
Integer
.
toString
(
numberOfMessages
),
"--hex"
,
"-r"
,
"10
0
"
,
topicName
};
Integer
.
toString
(
numberOfMessages
),
"--hex"
,
"-r"
,
"10"
,
topicName
};
Assert
.
assertEquals
(
pulsarClientToolConsumer
.
run
(
args
),
0
);
Assert
.
assertEquals
(
pulsarClientToolConsumer
.
run
(
args
),
0
);
}
catch
(
MalformedURLException
e
)
{
future
.
complete
(
null
);
Assert
.
fail
(
"Exception : "
+
e
.
getMessage
());
}
catch
(
Throwable
t
)
{
return
false
;
future
.
completeExceptionally
(
t
)
;
}
}
return
true
;
});
});
PulsarClientTool
pulsarClientToolProducer
=
new
PulsarClientTool
(
properties
);
PulsarClientTool
pulsarClientToolProducer
=
new
PulsarClientTool
(
properties
);
String
[]
args
=
{
"produce"
,
"--messages"
,
"Have a nice day"
,
"-n"
,
Integer
.
toString
(
numberOfMessages
),
"-r"
,
String
[]
args
=
{
"produce"
,
"--messages"
,
"Have a nice day"
,
"-n"
,
Integer
.
toString
(
numberOfMessages
),
"-r"
,
"20
0
"
,
topicName
};
"20"
,
topicName
};
Assert
.
assertEquals
(
pulsarClientToolProducer
.
run
(
args
),
0
);
Assert
.
assertEquals
(
pulsarClientToolProducer
.
run
(
args
),
0
);
Assert
.
assertTrue
(
future
.
get
(),
"Exception occured while running consume task."
);
future
.
get
();
executor
.
shutdown
();
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录