Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a0143c83
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a0143c83
编写于
6月 05, 2013
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8003895: java/nio/channels/AsynchronousChannelGroup/Unbounded.java failing again [win64]
Reviewed-by: chegar
上级
5d320939
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
46 deletion
+17
-46
test/ProblemList.txt
test/ProblemList.txt
+0
-3
test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
...java/nio/channels/AsynchronousChannelGroup/Unbounded.java
+17
-43
未找到文件。
test/ProblemList.txt
浏览文件 @
a0143c83
...
@@ -230,9 +230,6 @@ java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all
...
@@ -230,9 +230,6 @@ java/nio/channels/DatagramChannel/ChangingAddress.java macosx-all
# 7132677
# 7132677
java/nio/channels/Selector/OutOfBand.java macosx-all
java/nio/channels/Selector/OutOfBand.java macosx-all
# 8003895
java/nio/channels/AsynchronousChannelGroup/Unbounded.java windows-amd64
############################################################################
############################################################################
# jdk_rmi
# jdk_rmi
...
...
test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
浏览文件 @
a0143c83
...
@@ -43,47 +43,24 @@ public class Unbounded {
...
@@ -43,47 +43,24 @@ public class Unbounded {
static
volatile
boolean
finished
;
static
volatile
boolean
finished
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// all accepted connections are added to a queue
final
ArrayBlockingQueue
<
AsynchronousSocketChannel
>
queue
=
new
ArrayBlockingQueue
<
AsynchronousSocketChannel
>(
CONCURRENCY_COUNT
);
// create listener to accept connections
// create listener to accept connections
final
AsynchronousServerSocketChannel
listener
=
AsynchronousServerSocketChannel
listener
=
AsynchronousServerSocketChannel
.
open
()
AsynchronousServerSocketChannel
.
open
()
.
bind
(
new
InetSocketAddress
(
0
));
.
bind
(
new
InetSocketAddress
(
0
));
listener
.
accept
((
Void
)
null
,
new
CompletionHandler
<
AsynchronousSocketChannel
,
Void
>()
{
public
void
completed
(
AsynchronousSocketChannel
ch
,
Void
att
)
{
queue
.
add
(
ch
);
listener
.
accept
((
Void
)
null
,
this
);
}
public
void
failed
(
Throwable
exc
,
Void
att
)
{
if
(!
finished
)
{
failed
=
true
;
System
.
err
.
println
(
"accept failed: "
+
exc
);
}
}
});
System
.
out
.
println
(
"Listener created."
);
// establish lots of connections
// establish connections
AsynchronousSocketChannel
[]
clients
=
new
AsynchronousSocketChannel
[
CONCURRENCY_COUNT
];
AsynchronousSocketChannel
[]
peers
=
new
AsynchronousSocketChannel
[
CONCURRENCY_COUNT
];
int
port
=
((
InetSocketAddress
)(
listener
.
getLocalAddress
())).
getPort
();
int
port
=
((
InetSocketAddress
)(
listener
.
getLocalAddress
())).
getPort
();
SocketAddress
sa
=
new
InetSocketAddress
(
InetAddress
.
getLocalHost
(),
port
);
SocketAddress
sa
=
new
InetSocketAddress
(
InetAddress
.
getLocalHost
(),
port
);
AsynchronousSocketChannel
[]
channels
=
new
AsynchronousSocketChannel
[
CONCURRENCY_COUNT
];
for
(
int
i
=
0
;
i
<
CONCURRENCY_COUNT
;
i
++)
{
for
(
int
i
=
0
;
i
<
CONCURRENCY_COUNT
;
i
++)
{
int
attempts
=
0
;
clients
[
i
]
=
AsynchronousSocketChannel
.
open
();
for
(;;)
{
Future
<
Void
>
result
=
clients
[
i
].
connect
(
sa
);
try
{
peers
[
i
]
=
listener
.
accept
().
get
();
channels
[
i
]
=
AsynchronousSocketChannel
.
open
();
result
.
get
();
channels
[
i
].
connect
(
sa
).
get
();
break
;
}
catch
(
IOException
x
)
{
// probably resource issue so back off and retry
if
(++
attempts
>=
3
)
throw
x
;
Thread
.
sleep
(
50
);
}
}
}
}
System
.
out
.
println
(
"All connection established."
);
System
.
out
.
println
(
"All connection established."
);
...
@@ -91,9 +68,9 @@ public class Unbounded {
...
@@ -91,9 +68,9 @@ public class Unbounded {
final
CyclicBarrier
barrier
=
new
CyclicBarrier
(
CONCURRENCY_COUNT
+
1
);
final
CyclicBarrier
barrier
=
new
CyclicBarrier
(
CONCURRENCY_COUNT
+
1
);
// initiate a read operation on each channel.
// initiate a read operation on each channel.
for
(
int
i
=
0
;
i
<
CONCURRENCY_COUNT
;
i
++
)
{
for
(
AsynchronousSocketChannel
client:
clients
)
{
ByteBuffer
buf
=
ByteBuffer
.
allocateDirect
(
100
);
ByteBuffer
buf
=
ByteBuffer
.
allocateDirect
(
100
);
c
hannels
[
i
].
read
(
buf
,
channels
[
i
]
,
c
lient
.
read
(
buf
,
client
,
new
CompletionHandler
<
Integer
,
AsynchronousSocketChannel
>()
{
new
CompletionHandler
<
Integer
,
AsynchronousSocketChannel
>()
{
public
void
completed
(
Integer
bytesRead
,
AsynchronousSocketChannel
ch
)
{
public
void
completed
(
Integer
bytesRead
,
AsynchronousSocketChannel
ch
)
{
try
{
try
{
...
@@ -113,13 +90,10 @@ public class Unbounded {
...
@@ -113,13 +90,10 @@ public class Unbounded {
System
.
out
.
println
(
"All read operations outstanding."
);
System
.
out
.
println
(
"All read operations outstanding."
);
// write data to each of the accepted connections
// write data to each of the accepted connections
int
remaining
=
CONCURRENCY_COUNT
;
for
(
AsynchronousSocketChannel
peer:
peers
)
{
while
(
remaining
>
0
)
{
peer
.
write
(
ByteBuffer
.
wrap
(
"welcome"
.
getBytes
())).
get
();
AsynchronousSocketChannel
ch
=
queue
.
take
();
peer
.
shutdownOutput
();
ch
.
write
(
ByteBuffer
.
wrap
(
"welcome"
.
getBytes
())).
get
();
peer
.
close
();
ch
.
shutdownOutput
();
ch
.
close
();
remaining
--;
}
}
// wait for all threads to reach the barrier
// wait for all threads to reach the barrier
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录