本文整理汇总了Java中org.apache.catalina.tribes.transport.nio.NioSender类的典型用法代码示例。如果您正苦于以下问题:Java NioSender类的具体用法?Java NioSender怎么用?Java NioSender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NioSender类属于org.apache.catalina.tribes.transport.nio包,在下文中一共展示了NioSender类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.catalina.tribes.transport.nio.NioSender; //导入依赖的package包/类
public void init() throws Exception {
synchronized (Selector.class) {
// Selector.open() isn't thread safe
// http://bugs.sun.com/view_bug.do?bug_id=6427854
// Affects 1.6.0_29, fixed in 1.7.0_01
selector = Selector.open();
}
mbr = new MemberImpl("localhost",4444,0);
NioSender sender = new NioSender();
sender.setDestination(mbr);
sender.setDirectBuffer(true);
sender.setSelector(selector);
sender.setMessage(XByteBuffer.createDataPackage(getMessage(mbr)));
sender.connect();
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:NioSenderTest.java
示例2: init
import org.apache.catalina.tribes.transport.nio.NioSender; //导入依赖的package包/类
public void init() throws Exception {
selector = Selector.open();
mbr = new MemberImpl("localhost",4444,0);
NioSender sender = new NioSender();
sender.setDestination(mbr);
sender.setDirectBuffer(true);
sender.setSelector(selector);
sender.setMessage(XByteBuffer.createDataPackage(getMessage(mbr)));
sender.connect();
}
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:11,代码来源:NioSenderTest.java
示例3: main
import org.apache.catalina.tribes.transport.nio.NioSender; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Selector selector;
synchronized (Selector.class) {
// Selector.open() isn't thread safe
// http://bugs.sun.com/view_bug.do?bug_id=6427854
// Affects 1.6.0_29, fixed in 1.7.0_01
selector = Selector.open();
}
Member mbr = new MemberImpl("localhost", 9999, 0);
byte seq = 0;
byte[] buf = new byte[50000];
Arrays.fill(buf,seq);
int len = buf.length;
BigDecimal total = new BigDecimal((double)0);
BigDecimal bytes = new BigDecimal((double)len);
NioSender sender = new NioSender();
sender.setDestination(mbr);
sender.setDirectBuffer(true);
sender.setSelector(selector);
sender.connect();
sender.setMessage(buf);
System.out.println("Writing to 9999");
long start = 0;
double mb = 0;
boolean first = true;
int count = 0;
DecimalFormat df = new DecimalFormat("##.00");
while (count<100000) {
if (first) {
first = false;
start = System.currentTimeMillis();
}
sender.setMessage(buf);
int selectedKeys = 0;
try {
selectedKeys = selector.select(0);
} catch (Exception e) {
e.printStackTrace();
continue;
}
if (selectedKeys == 0) {
continue;
}
Iterator<SelectionKey> it = selector.selectedKeys().iterator();
while (it.hasNext()) {
SelectionKey sk = it.next();
it.remove();
try {
int readyOps = sk.readyOps();
sk.interestOps(sk.interestOps() & ~readyOps);
if (sender.process(sk, false)) {
total = total.add(bytes);
sender.reset();
seq++;
Arrays.fill(buf,seq);
sender.setMessage(buf);
mb += ( (double) len) / 1024 / 1024;
if ( ( (++count) % 10000) == 0) {
long time = System.currentTimeMillis();
double seconds = ( (double) (time - start)) / 1000;
System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds, total "+mb+" MB, total "+total+" bytes.");
}
}
} catch (Throwable t) {
t.printStackTrace();
return;
}
}
}
System.out.println("Complete, sleeping 15 seconds");
Thread.sleep(15000);
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:77,代码来源:SocketNioValidateSend.java
示例4: main
import org.apache.catalina.tribes.transport.nio.NioSender; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Selector selector;
synchronized (Selector.class) {
// Selector.open() isn't thread safe
// http://bugs.sun.com/view_bug.do?bug_id=6427854
// Affects 1.6.0_29, fixed in 1.7.0_01
selector = Selector.open();
}
Member mbr = new MemberImpl("localhost", 9999, 0);
ChannelData data = new ChannelData();
data.setOptions(Channel.SEND_OPTIONS_BYTE_MESSAGE);
data.setAddress(mbr);
byte[] buf = new byte[8192 * 4];
data.setMessage(new XByteBuffer(buf,false));
buf = XByteBuffer.createDataPackage(data);
int len = buf.length;
BigDecimal total = new BigDecimal((double)0);
BigDecimal bytes = new BigDecimal((double)len);
NioSender sender = new NioSender();
sender.setDestination(mbr);
sender.setDirectBuffer(true);
sender.setSelector(selector);
sender.setTxBufSize(1024*1024);
sender.connect();
sender.setMessage(buf);
System.out.println("Writing to 9999");
long start = 0;
double mb = 0;
boolean first = true;
int count = 0;
DecimalFormat df = new DecimalFormat("##.00");
while (count<100000) {
if (first) {
first = false;
start = System.currentTimeMillis();
}
sender.setMessage(buf);
int selectedKeys = 0;
try {
selectedKeys = selector.select(0);
} catch (Exception e) {
e.printStackTrace();
continue;
}
if (selectedKeys == 0) {
continue;
}
Iterator<SelectionKey> it = selector.selectedKeys().iterator();
while (it.hasNext()) {
SelectionKey sk = it.next();
it.remove();
try {
int readyOps = sk.readyOps();
sk.interestOps(sk.interestOps() & ~readyOps);
if (sender.process(sk, false)) {
total = total.add(bytes);
sender.reset();
sender.setMessage(buf);
mb += ( (double) len) / 1024 / 1024;
if ( ( (++count) % 10000) == 0) {
long time = System.currentTimeMillis();
double seconds = ( (double) (time - start)) / 1000;
System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds, total "+mb+" MB, total "+total+" bytes.");
}
}
} catch (Throwable t) {
t.printStackTrace();
return;
}
}
selector.selectedKeys().clear();
}
System.out.println("Complete, sleeping 15 seconds");
Thread.sleep(15000);
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:79,代码来源:SocketNioSend.java
示例5: run
import org.apache.catalina.tribes.transport.nio.NioSender; //导入依赖的package包/类
public void run() {
while (true) {
int selectedKeys = 0;
try {
selectedKeys = selector.select(100);
// if ( selectedKeys == 0 ) {
// System.out.println("No registered interests. Sleeping for a second.");
// Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
continue;
}
if (selectedKeys == 0) {
continue;
}
Iterator<SelectionKey> it = selector.selectedKeys().iterator();
while (it.hasNext()) {
SelectionKey sk = it.next();
it.remove();
try {
int readyOps = sk.readyOps();
sk.interestOps(sk.interestOps() & ~readyOps);
NioSender sender = (NioSender) sk.attachment();
if ( sender.process(sk, (testOptions&Channel.SEND_OPTIONS_USE_ACK)==Channel.SEND_OPTIONS_USE_ACK) ) {
System.out.println("Message completed for handler:"+sender);
Thread.sleep(2000);
sender.reset();
sender.setMessage(XByteBuffer.createDataPackage(getMessage(mbr)));
}
} catch (Throwable t) {
t.printStackTrace();
return;
}
}
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:42,代码来源:NioSenderTest.java
示例6: main
import org.apache.catalina.tribes.transport.nio.NioSender; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Selector selector = Selector.open();
Member mbr = new MemberImpl("localhost", 9999, 0);
byte seq = 0;
byte[] buf = new byte[50000];
Arrays.fill(buf,seq);
int len = buf.length;
BigDecimal total = new BigDecimal((double)0);
BigDecimal bytes = new BigDecimal((double)len);
NioSender sender = new NioSender();
sender.setDestination(mbr);
sender.setDirectBuffer(true);
sender.setSelector(selector);
sender.connect();
sender.setMessage(buf);
System.out.println("Writing to 9999");
long start = 0;
double mb = 0;
boolean first = true;
int count = 0;
DecimalFormat df = new DecimalFormat("##.00");
while (count<100000) {
if (first) {
first = false;
start = System.currentTimeMillis();
}
sender.setMessage(buf);
int selectedKeys = 0;
try {
selectedKeys = selector.select(0);
} catch (Exception e) {
e.printStackTrace();
continue;
}
if (selectedKeys == 0) {
continue;
}
Iterator<SelectionKey> it = selector.selectedKeys().iterator();
while (it.hasNext()) {
SelectionKey sk = it.next();
it.remove();
try {
int readyOps = sk.readyOps();
sk.interestOps(sk.interestOps() & ~readyOps);
if (sender.process(sk, false)) {
total = total.add(bytes);
sender.reset();
seq++;
Arrays.fill(buf,seq);
sender.setMessage(buf);
mb += ( (double) len) / 1024 / 1024;
if ( ( (++count) % 10000) == 0) {
long time = System.currentTimeMillis();
double seconds = ( (double) (time - start)) / 1000;
System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds, total "+mb+" MB, total "+total+" bytes.");
}
}
} catch (Throwable t) {
t.printStackTrace();
return;
}
}
}
System.out.println("Complete, sleeping 15 seconds");
Thread.sleep(15000);
}
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:71,代码来源:SocketNioValidateSend.java
示例7: main
import org.apache.catalina.tribes.transport.nio.NioSender; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Selector selector = Selector.open();
Member mbr = new MemberImpl("localhost", 9999, 0);
ChannelData data = new ChannelData();
data.setOptions(Channel.SEND_OPTIONS_BYTE_MESSAGE);
data.setAddress(mbr);
byte[] buf = new byte[8192 * 4];
data.setMessage(new XByteBuffer(buf,false));
buf = XByteBuffer.createDataPackage(data);
int len = buf.length;
BigDecimal total = new BigDecimal((double)0);
BigDecimal bytes = new BigDecimal((double)len);
NioSender sender = new NioSender();
sender.setDestination(mbr);
sender.setDirectBuffer(true);
sender.setSelector(selector);
sender.setTxBufSize(1024*1024);
sender.connect();
sender.setMessage(buf);
System.out.println("Writing to 9999");
long start = 0;
double mb = 0;
boolean first = true;
int count = 0;
DecimalFormat df = new DecimalFormat("##.00");
while (count<100000) {
if (first) {
first = false;
start = System.currentTimeMillis();
}
sender.setMessage(buf);
int selectedKeys = 0;
try {
selectedKeys = selector.select(0);
} catch (Exception e) {
e.printStackTrace();
continue;
}
if (selectedKeys == 0) {
continue;
}
Iterator<SelectionKey> it = selector.selectedKeys().iterator();
while (it.hasNext()) {
SelectionKey sk = it.next();
it.remove();
try {
int readyOps = sk.readyOps();
sk.interestOps(sk.interestOps() & ~readyOps);
if (sender.process(sk, false)) {
total = total.add(bytes);
sender.reset();
sender.setMessage(buf);
mb += ( (double) len) / 1024 / 1024;
if ( ( (++count) % 10000) == 0) {
long time = System.currentTimeMillis();
double seconds = ( (double) (time - start)) / 1000;
System.out.println("Throughput " + df.format(mb / seconds) + " MB/seconds, total "+mb+" MB, total "+total+" bytes.");
}
}
} catch (Throwable t) {
t.printStackTrace();
return;
}
}
selector.selectedKeys().clear();
}
System.out.println("Complete, sleeping 15 seconds");
Thread.sleep(15000);
}
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:73,代码来源:SocketNioSend.java
示例8: run
import org.apache.catalina.tribes.transport.nio.NioSender; //导入依赖的package包/类
public void run() {
while (true) {
int selectedKeys = 0;
try {
selectedKeys = selector.select(100);
// if ( selectedKeys == 0 ) {
// System.out.println("No registered interests. Sleeping for a second.");
// Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
continue;
}
if (selectedKeys == 0) {
continue;
}
Iterator<SelectionKey> it = selector.selectedKeys().iterator();
while (it.hasNext()) {
SelectionKey sk = it.next();
it.remove();
try {
int readyOps = sk.readyOps();
sk.interestOps(sk.interestOps() & ~readyOps);
NioSender sender = (NioSender) sk.attachment();
if ( sender.process(sk, (testOptions&Channel.SEND_OPTIONS_USE_ACK)==Channel.SEND_OPTIONS_USE_ACK) ) {
System.out.println("Message completed for handler:"+sender);
Thread.sleep(2000);
sender.reset();
sender.setMessage(XByteBuffer.createDataPackage(getMessage(mbr)));
}
} catch (Throwable t) {
t.printStackTrace();
return;
}
}
}
}
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:42,代码来源:NioSenderTest.java
注:本文中的org.apache.catalina.tribes.transport.nio.NioSender类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论