Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
ed90dd3a
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看板
提交
ed90dd3a
编写于
6月 15, 2010
作者:
M
mchung
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
8e93a3ee
ed15c7a1
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
95 addition
and
94 deletion
+95
-94
test/ProblemList.txt
test/ProblemList.txt
+0
-15
test/java/nio/channels/DatagramChannel/Connect.java
test/java/nio/channels/DatagramChannel/Connect.java
+18
-21
test/java/nio/channels/DatagramChannel/EmptyBuffer.java
test/java/nio/channels/DatagramChannel/EmptyBuffer.java
+13
-19
test/java/nio/channels/DatagramChannel/NoSender.java
test/java/nio/channels/DatagramChannel/NoSender.java
+1
-1
test/java/nio/channels/DatagramChannel/SRTest.java
test/java/nio/channels/DatagramChannel/SRTest.java
+41
-9
test/java/nio/channels/DatagramChannel/Sender.java
test/java/nio/channels/DatagramChannel/Sender.java
+22
-29
未找到文件。
test/ProblemList.txt
浏览文件 @
ed90dd3a
...
...
@@ -752,18 +752,9 @@ com/sun/nio/sctp/SctpChannel/Shutdown.java generic-all
# at SetLastModified.main(SetLastModified.java:107)
java/io/File/SetLastModified.java generic-all
# Fails on Solaris 10 x64, address already in use
java/nio/channels/DatagramChannel/SRTest.java generic-all
# Fails on Solaris 10 x86, times out
java/nio/channels/DatagramChannel/Sender.java generic-all
# Fails on Fedora 9 x86, address in use
java/nio/channels/Selector/SelectWrite.java generic-all
# Fails on Fedora 9 32bit times out
java/nio/channels/DatagramChannel/EmptyBuffer.java generic-all
# Fails on Windows 2000, times out
java/nio/channels/FileChannel/Transfer.java generic-all
...
...
@@ -821,12 +812,6 @@ java/nio/channels/AsynchronousSocketChannel/Leaky.java windows-5.0
java/nio/channels/AsynchronousSocketChannel/StressLoopback.java windows-5.0
java/nio/channels/Channels/Basic2.java windows-5.0
# Solaris sparc timeout
java/nio/channels/DatagramChannel/Connect.java generic-all
# Solaris i586 timeouts
java/nio/channels/DatagramChannel/EmptyBuffer.java solaris-all
# Failed loopback connection? On windows 32bit?
# Considered a stress test, can consume all resources.
java/nio/channels/Selector/LotsOfChannels.java generic-all
...
...
test/java/nio/channels/DatagramChannel/Connect.java
浏览文件 @
ed90dd3a
...
...
@@ -42,15 +42,15 @@ public class Connect {
}
static
void
test
()
throws
Exception
{
invoke
(
new
Actor
(),
new
Reactor
());
Reactor
r
=
new
Reactor
();
Actor
a
=
new
Actor
(
r
.
port
());
invoke
(
a
,
r
);
}
static
void
invoke
(
Sprintable
reader
,
Sprintable
writer
)
throws
Exception
{
Thread
writerThread
=
new
Thread
(
writer
);
writerThread
.
start
();
while
(!
writer
.
ready
())
Thread
.
sleep
(
50
);
Thread
readerThread
=
new
Thread
(
reader
);
readerThread
.
start
();
...
...
@@ -64,34 +64,31 @@ public class Connect {
public
interface
Sprintable
extends
Runnable
{
public
void
throwException
()
throws
Exception
;
public
boolean
ready
();
}
public
static
class
Actor
implements
Sprintable
{
final
int
port
;
Exception
e
=
null
;
Actor
(
int
port
)
{
this
.
port
=
port
;
}
public
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
}
private
volatile
boolean
ready
=
false
;
public
boolean
ready
()
{
return
ready
;
}
public
void
run
()
{
try
{
DatagramChannel
dc
=
DatagramChannel
.
open
();
ready
=
true
;
// Send a message
ByteBuffer
bb
=
ByteBuffer
.
allocateDirect
(
256
);
bb
.
put
(
"hello"
.
getBytes
());
bb
.
flip
();
InetAddress
address
=
InetAddress
.
getLocalHost
();
InetSocketAddress
isa
=
new
InetSocketAddress
(
address
,
8888
);
InetSocketAddress
isa
=
new
InetSocketAddress
(
address
,
port
);
dc
.
connect
(
isa
);
dc
.
write
(
bb
);
...
...
@@ -123,26 +120,26 @@ public class Connect {
}
public
static
class
Reactor
implements
Sprintable
{
final
DatagramChannel
dc
;
Exception
e
=
null
;
public
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
Reactor
()
throws
IOException
{
dc
=
DatagramChannel
.
open
().
bind
(
new
InetSocketAddress
(
0
));
}
private
volatile
boolean
ready
=
false
;
int
port
()
{
return
dc
.
socket
().
getLocalPort
();
}
public
boolean
ready
()
{
return
ready
;
public
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
}
public
void
run
()
{
try
{
// Listen for a message
DatagramChannel
dc
=
DatagramChannel
.
open
();
dc
.
socket
().
bind
(
new
InetSocketAddress
(
8888
));
ByteBuffer
bb
=
ByteBuffer
.
allocateDirect
(
100
);
ready
=
true
;
SocketAddress
sa
=
dc
.
receive
(
bb
);
bb
.
flip
();
CharBuffer
cb
=
Charset
.
forName
(
"US-ASCII"
).
...
...
test/java/nio/channels/DatagramChannel/EmptyBuffer.java
浏览文件 @
ed90dd3a
...
...
@@ -42,18 +42,16 @@ public class EmptyBuffer {
}
static
void
test
()
throws
Exception
{
S
printable
server
=
new
Server
();
S
erver
server
=
new
Server
();
Thread
serverThread
=
new
Thread
(
server
);
serverThread
.
start
();
while
(!
server
.
ready
())
Thread
.
sleep
(
50
);
DatagramChannel
dc
=
DatagramChannel
.
open
();
ByteBuffer
bb
=
ByteBuffer
.
allocateDirect
(
12
);
bb
.
order
(
ByteOrder
.
BIG_ENDIAN
);
bb
.
putInt
(
1
).
putLong
(
1
);
bb
.
flip
();
InetAddress
address
=
InetAddress
.
getLocalHost
();
InetSocketAddress
isa
=
new
InetSocketAddress
(
address
,
8888
);
InetSocketAddress
isa
=
new
InetSocketAddress
(
address
,
server
.
port
()
);
dc
.
connect
(
isa
);
dc
.
write
(
bb
);
bb
.
rewind
();
...
...
@@ -65,24 +63,23 @@ public class EmptyBuffer {
server
.
throwException
();
}
public
interface
Sprintable
extends
Runnable
{
public
void
throwException
()
throws
Exception
;
public
boolean
ready
();
public
static
class
Server
implements
Runnable
{
final
DatagramChannel
dc
;
Exception
e
=
null
;
Server
()
throws
IOException
{
this
.
dc
=
DatagramChannel
.
open
().
bind
(
new
InetSocketAddress
(
0
));
}
public
static
class
Server
implements
Sprintable
{
Exception
e
=
null
;
private
volatile
boolean
ready
=
false
;
int
port
()
{
return
dc
.
socket
().
getLocalPort
()
;
}
public
void
throwException
()
throws
Exception
{
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
}
public
boolean
ready
()
{
return
ready
;
}
void
showBuffer
(
String
s
,
ByteBuffer
bb
)
{
log
.
println
(
s
);
bb
.
rewind
();
...
...
@@ -97,9 +94,6 @@ public class EmptyBuffer {
SocketAddress
sa
=
null
;
int
numberReceived
=
0
;
try
{
DatagramChannel
dc
=
DatagramChannel
.
open
();
dc
.
socket
().
bind
(
new
InetSocketAddress
(
8888
));
ready
=
true
;
ByteBuffer
bb
=
ByteBuffer
.
allocateDirect
(
12
);
bb
.
clear
();
// Only one clear. The buffer will be full after
...
...
test/java/nio/channels/DatagramChannel/NoSender.java
浏览文件 @
ed90dd3a
...
...
@@ -33,7 +33,7 @@ import java.nio.channels.*;
public
class
NoSender
{
public
static
void
main
(
String
argv
[])
throws
Exception
{
DatagramChannel
dc
=
DatagramChannel
.
open
();
dc
.
socket
().
bind
(
new
InetSocketAddress
(
5441
));
dc
.
socket
().
bind
(
new
InetSocketAddress
(
0
));
dc
.
configureBlocking
(
false
);
ByteBuffer
buf1
=
ByteBuffer
.
allocateDirect
(
256
);
SocketAddress
sa1
=
dc
.
receive
(
buf1
);
...
...
test/java/nio/channels/DatagramChannel/SRTest.java
浏览文件 @
ed90dd3a
...
...
@@ -42,16 +42,23 @@ public class SRTest {
}
static
void
test
()
throws
Exception
{
invoke
(
new
ClassicReader
(),
new
ClassicWriter
());
ClassicReader
classicReader
;
NioReader
nioReader
;
classicReader
=
new
ClassicReader
();
invoke
(
classicReader
,
new
ClassicWriter
(
classicReader
.
port
()));
log
.
println
(
"Classic RW: OK"
);
invoke
(
new
ClassicReader
(),
new
NioWriter
());
classicReader
=
new
ClassicReader
();
invoke
(
classicReader
,
new
NioWriter
(
classicReader
.
port
()));
log
.
println
(
"Classic R, Nio W: OK"
);
invoke
(
new
NioReader
(),
new
ClassicWriter
());
nioReader
=
new
NioReader
();
invoke
(
nioReader
,
new
ClassicWriter
(
nioReader
.
port
()));
log
.
println
(
"Classic W, Nio R: OK"
);
invoke
(
new
NioReader
(),
new
NioWriter
());
nioReader
=
new
NioReader
();
invoke
(
nioReader
,
new
NioWriter
(
nioReader
.
port
()));
log
.
println
(
"Nio RW: OK"
);
}
...
...
@@ -75,8 +82,13 @@ public class SRTest {
}
public
static
class
ClassicWriter
implements
Sprintable
{
final
int
port
;
Exception
e
=
null
;
ClassicWriter
(
int
port
)
{
this
.
port
=
port
;
}
public
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
...
...
@@ -89,7 +101,7 @@ public class SRTest {
byte
[]
data
=
dataString
.
getBytes
();
InetAddress
address
=
InetAddress
.
getLocalHost
();
DatagramPacket
dp
=
new
DatagramPacket
(
data
,
data
.
length
,
address
,
8888
);
address
,
port
);
ds
.
send
(
dp
);
Thread
.
sleep
(
50
);
ds
.
send
(
dp
);
...
...
@@ -100,8 +112,13 @@ public class SRTest {
}
public
static
class
NioWriter
implements
Sprintable
{
final
int
port
;
Exception
e
=
null
;
NioWriter
(
int
port
)
{
this
.
port
=
port
;
}
public
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
...
...
@@ -114,7 +131,7 @@ public class SRTest {
bb
.
put
(
"hello"
.
getBytes
());
bb
.
flip
();
InetAddress
address
=
InetAddress
.
getLocalHost
();
InetSocketAddress
isa
=
new
InetSocketAddress
(
address
,
8888
);
InetSocketAddress
isa
=
new
InetSocketAddress
(
address
,
port
);
dc
.
send
(
bb
,
isa
);
Thread
.
sleep
(
50
);
dc
.
send
(
bb
,
isa
);
...
...
@@ -125,8 +142,17 @@ public class SRTest {
}
public
static
class
ClassicReader
implements
Sprintable
{
final
DatagramSocket
ds
;
Exception
e
=
null
;
ClassicReader
()
throws
IOException
{
this
.
ds
=
new
DatagramSocket
();
}
int
port
()
{
return
ds
.
getLocalPort
();
}
public
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
...
...
@@ -136,7 +162,6 @@ public class SRTest {
try
{
byte
[]
buf
=
new
byte
[
256
];
DatagramPacket
dp
=
new
DatagramPacket
(
buf
,
buf
.
length
);
DatagramSocket
ds
=
new
DatagramSocket
(
8888
);
ds
.
receive
(
dp
);
String
received
=
new
String
(
dp
.
getData
());
log
.
println
(
received
);
...
...
@@ -148,8 +173,17 @@ public class SRTest {
}
public
static
class
NioReader
implements
Sprintable
{
final
DatagramChannel
dc
;
Exception
e
=
null
;
NioReader
()
throws
IOException
{
this
.
dc
=
DatagramChannel
.
open
().
bind
(
new
InetSocketAddress
(
0
));
}
int
port
()
{
return
dc
.
socket
().
getLocalPort
();
}
public
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
...
...
@@ -157,8 +191,6 @@ public class SRTest {
public
void
run
()
{
try
{
DatagramChannel
dc
=
DatagramChannel
.
open
();
dc
.
socket
().
bind
(
new
InetSocketAddress
(
8888
));
ByteBuffer
bb
=
ByteBuffer
.
allocateDirect
(
100
);
SocketAddress
sa
=
dc
.
receive
(
bb
);
bb
.
flip
();
...
...
test/java/nio/channels/DatagramChannel/Sender.java
浏览文件 @
ed90dd3a
...
...
@@ -42,13 +42,11 @@ public class Sender {
}
static
void
test
()
throws
Exception
{
S
printable
server
=
new
Server
();
Sprintable
client
=
new
Client
(
);
S
erver
server
=
new
Server
();
Client
client
=
new
Client
(
server
.
port
()
);
Thread
serverThread
=
new
Thread
(
server
);
serverThread
.
start
();
while
(!
server
.
ready
())
Thread
.
sleep
(
50
);
Thread
clientThread
=
new
Thread
(
client
);
clientThread
.
start
();
...
...
@@ -60,23 +58,17 @@ public class Sender {
client
.
throwException
();
}
public
interface
Sprintable
extends
Runnable
{
public
void
throwException
()
throws
Exception
;
public
boolean
ready
();
}
public
static
class
Client
implements
Sprintable
{
public
static
class
Client
implements
Runnable
{
final
int
port
;
Exception
e
=
null
;
public
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
Client
(
int
port
)
{
this
.
port
=
port
;
}
private
volatile
boolean
ready
=
false
;
public
boolean
ready
()
{
return
ready
;
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
}
public
void
run
()
{
...
...
@@ -87,7 +79,7 @@ public class Sender {
bb
.
putInt
(
1
).
putLong
(
1
);
bb
.
flip
();
InetAddress
address
=
InetAddress
.
getLocalHost
();
InetSocketAddress
isa
=
new
InetSocketAddress
(
address
,
8888
);
InetSocketAddress
isa
=
new
InetSocketAddress
(
address
,
port
);
dc
.
connect
(
isa
);
dc
.
write
(
bb
);
}
catch
(
Exception
ex
)
{
...
...
@@ -96,17 +88,21 @@ public class Sender {
}
}
public
static
class
Server
implements
Sprintable
{
public
static
class
Server
implements
Runnable
{
final
DatagramChannel
dc
;
Exception
e
=
null
;
private
volatile
boolean
ready
=
false
;
public
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
Server
()
throws
IOException
{
dc
=
DatagramChannel
.
open
().
bind
(
new
InetSocketAddress
(
0
));
}
int
port
()
{
return
dc
.
socket
().
getLocalPort
();
}
public
boolean
ready
()
{
return
ready
;
void
throwException
()
throws
Exception
{
if
(
e
!=
null
)
throw
e
;
}
void
showBuffer
(
String
s
,
ByteBuffer
bb
)
{
...
...
@@ -123,13 +119,10 @@ public class Sender {
SocketAddress
sa
=
null
;
try
{
DatagramChannel
dc
=
DatagramChannel
.
open
();
dc
.
socket
().
bind
(
new
InetSocketAddress
(
8888
));
dc
.
configureBlocking
(
false
);
ready
=
true
;
ByteBuffer
bb
=
ByteBuffer
.
allocateDirect
(
12
);
bb
.
clear
();
// Get the one valid datagram
dc
.
configureBlocking
(
false
);
while
(
sa
==
null
)
sa
=
dc
.
receive
(
bb
);
sa
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录