本文整理汇总了Java中org.apache.catalina.tribes.ChannelException类的典型用法代码示例。如果您正苦于以下问题:Java ChannelException类的具体用法?Java ChannelException怎么用?Java ChannelException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChannelException类属于org.apache.catalina.tribes包,在下文中一共展示了ChannelException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: put
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
public V put(K key, V value, boolean notify) {
MapEntry<K,V> entry = new MapEntry<K,V>(key,value);
entry.setBackup(false);
entry.setProxy(false);
entry.setCopy(false);
entry.setPrimary(channel.getLocalMember(false));
V old = null;
//make sure that any old values get removed
if ( containsKey(key) ) old = remove(key);
try {
if ( notify ) {
Member[] backup = publishEntryInfo(key, value);
entry.setBackupNodes(backup);
}
} catch (ChannelException x) {
log.error("Unable to replicate out data for a AbstractReplicatedMap.put operation", x);
}
innerMap.put(key,entry);
return old;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:AbstractReplicatedMap.java
示例2: sendMessage
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
throws ChannelException {
try {
super.sendMessage(destination, msg, payload);
} catch (ChannelException cx) {
FaultyMember[] mbrs = cx.getFaultyMembers();
for (int i = 0; i < mbrs.length; i++) {
if (mbrs[i].getCause() != null && (!(mbrs[i].getCause() instanceof RemoteProcessException))) {// RemoteProcessException's
// are
// ok
this.memberDisappeared(mbrs[i].getMember());
} // end if
} // for
throw cx;
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:TcpFailureDetector.java
示例3: testTcpMcastFail
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Test
public void testTcpMcastFail() throws Exception {
System.out.println("testTcpMcastFail()");
clear();
channel1.start(Channel.DEFAULT);
channel2.start(Channel.DEFAULT);
//Thread.sleep(1000);
assertEquals("Expecting member count to be equal",mbrlist1.members.size(),mbrlist2.members.size());
channel2.stop(Channel.MBR_TX_SEQ);
ByteMessage msg = new ByteMessage(new byte[1024]);
try {
Thread.sleep(5000);
assertEquals("Expecting member count to be equal",mbrlist1.members.size(),mbrlist2.members.size());
channel1.send(channel1.getMembers(), msg, 0);
} catch ( ChannelException x ) {
fail("Message send should have succeeded.");
}
channel1.stop(Channel.DEFAULT);
channel2.stop(Channel.DEFAULT);
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:21,代码来源:TestTcpFailureDetector.java
示例4: sendMessage
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
if ( access.addAndGet(1) == 1 ) txStart = System.currentTimeMillis();
long bytes = XByteBuffer.getDataPackageLength(((ChannelData)msg).getDataPackageLength());
try {
super.sendMessage(destination, msg, payload);
}catch ( ChannelException x ) {
msgTxErr.addAndGet(1);
if ( access.get() == 1 ) access.addAndGet(-1);
throw x;
}
mbTx += (bytes*destination.length)/(1024d*1024d);
mbAppTx += bytes/(1024d*1024d);
if ( access.addAndGet(-1) == 0 ) {
long stop = System.currentTimeMillis();
timeTx += (stop - txStart) / 1000d;
if ((msgTxCnt.get() / interval) >= lastCnt) {
lastCnt++;
report(timeTx);
}
}
msgTxCnt.addAndGet(1);
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:ThroughputInterceptor.java
示例5: sendElectionMsgToNextInline
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
protected void sendElectionMsgToNextInline(MemberImpl local, CoordinationMessage msg) throws ChannelException {
int next = Arrays.nextIndex(local,msg.getMembers());
int current = next;
msg.leader = msg.getMembers()[0];
boolean sent = false;
while ( !sent && current >= 0 ) {
try {
sendElectionMsg(local, msg.getMembers()[current], msg);
sent = true;
}catch ( ChannelException x ) {
log.warn("Unable to send election message to:"+msg.getMembers()[current]);
current = Arrays.nextIndex(msg.getMembers()[current],msg.getMembers());
if ( current == next ) throw x;
}
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:NonBlockingCoordinator.java
示例6: handleMyToken
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
protected void handleMyToken(MemberImpl local, CoordinationMessage msg, Member sender, Membership merged)
throws ChannelException {
if (local.equals(msg.getLeader())) {
// no leadership change
if (Arrays.sameMembers(msg.getMembers(), merged.getMembers())) {
msg.type = COORD_CONF;
super.sendMessage(Arrays.remove(msg.getMembers(), local), createData(msg, local), null);
handleViewConf(msg, local, merged);
} else {
// membership change
suggestedView = new Membership(local, AbsoluteOrder.comp, true);
suggestedviewId = msg.getId();
Arrays.fill(suggestedView, merged.getMembers());
msg.view = merged.getMembers();
sendElectionMsgToNextInline(local, msg);
}
} else {
// leadership change
suggestedView = null;
suggestedviewId = null;
msg.view = merged.getMembers();
sendElectionMsgToNextInline(local, msg);
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:25,代码来源:NonBlockingCoordinator.java
示例7: handleMyToken
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
protected void handleMyToken(MemberImpl local, CoordinationMessage msg, Member sender,Membership merged) throws ChannelException {
if ( local.equals(msg.getLeader()) ) {
//no leadership change
if ( Arrays.sameMembers(msg.getMembers(),merged.getMembers()) ) {
msg.type = COORD_CONF;
super.sendMessage(Arrays.remove(msg.getMembers(),local),createData(msg,local),null);
handleViewConf(msg,local,merged);
} else {
//membership change
suggestedView = new Membership(local,AbsoluteOrder.comp,true);
suggestedviewId = msg.getId();
Arrays.fill(suggestedView,merged.getMembers());
msg.view = merged.getMembers();
sendElectionMsgToNextInline(local,msg);
}
} else {
//leadership change
suggestedView = null;
suggestedviewId = null;
msg.view = merged.getMembers();
sendElectionMsgToNextInline(local,msg);
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:NonBlockingCoordinator.java
示例8: handleViewConf
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
protected void handleViewConf(CoordinationMessage msg, Member sender,Membership merged) throws ChannelException {
if ( viewId != null && msg.getId().equals(viewId) ) return;//we already have this view
view = new Membership((MemberImpl)getLocalMember(false),AbsoluteOrder.comp,true);
Arrays.fill(view,msg.getMembers());
viewId = msg.getId();
if ( viewId.equals(suggestedviewId) ) {
suggestedView = null;
suggestedviewId = null;
}
if (suggestedView != null && AbsoluteOrder.comp.compare(suggestedView.getMembers()[0],merged.getMembers()[0])<0 ) {
suggestedView = null;
suggestedviewId = null;
}
viewChange(viewId,view.getMembers());
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_CONF_RX,this,"Accepted View"));
if ( suggestedviewId == null && hasHigherPriority(merged.getMembers(),membership.getMembers()) ) {
startElection(false);
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:NonBlockingCoordinator.java
示例9: testTcpSendFailureMemberDrop
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Test
public void testTcpSendFailureMemberDrop() throws Exception {
System.out.println("testTcpSendFailureMemberDrop()");
clear();
channel1.start(Channel.DEFAULT);
channel2.start(Channel.DEFAULT);
//Thread.sleep(1000);
assertEquals("Expecting member count to be equal",mbrlist1.members.size(),mbrlist2.members.size());
channel2.stop(Channel.SND_RX_SEQ);
ByteMessage msg = new ByteMessage(new byte[1024]);
try {
channel1.send(channel1.getMembers(), msg, 0);
fail("Message send should have failed.");
} catch ( ChannelException x ) {
// Ignore
}
assertEquals("Expecting member count to not be equal",mbrlist1.members.size()+1,mbrlist2.members.size());
channel1.stop(Channel.DEFAULT);
channel2.stop(Channel.DEFAULT);
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:21,代码来源:TestTcpFailureDetector.java
示例10: messageReceived
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Override
public void messageReceived(ChannelMessage msg) {
if ( Arrays.contains(msg.getMessage().getBytesDirect(),0,COORD_ALIVE,0,COORD_ALIVE.length) ) {
//ignore message, its an alive message
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE,this,"Alive Message"));
} else if ( Arrays.contains(msg.getMessage().getBytesDirect(),0,COORD_HEADER,0,COORD_HEADER.length) ) {
try {
CoordinationMessage cmsg = new CoordinationMessage(msg.getMessage());
Member[] cmbr = cmsg.getMembers();
fireInterceptorEvent(new CoordinationEvent(CoordinationEvent.EVT_MSG_ARRIVE,this,"Coord Msg Arrived("+Arrays.toNameString(cmbr)+")"));
processCoordMessage(cmsg, msg.getAddress());
}catch ( ChannelException x ) {
log.error("Error processing coordination message. Could be fatal.",x);
}
} else {
super.messageReceived(msg);
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:20,代码来源:NonBlockingCoordinator.java
示例11: broadcast
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Override
public void broadcast(ChannelMessage message) throws ChannelException {
if (impl == null || (impl.startLevel & Channel.MBR_TX_SEQ) != Channel.MBR_TX_SEQ)
throw new ChannelException("Multicast send is not started or enabled.");
byte[] data = XByteBuffer.createDataPackage((ChannelData) message);
if (data.length > McastServiceImpl.MAX_PACKET_SIZE) {
throw new ChannelException("Packet length[" + data.length + "] exceeds max packet size of "
+ McastServiceImpl.MAX_PACKET_SIZE + " bytes.");
}
DatagramPacket packet = new DatagramPacket(data, 0, data.length);
try {
impl.send(false, packet);
} catch (Exception x) {
throw new ChannelException(x);
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:McastService.java
示例12: sendMessage
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
throws ChannelException {
if (access.addAndGet(1) == 1)
txStart = System.currentTimeMillis();
long bytes = XByteBuffer.getDataPackageLength(((ChannelData) msg).getDataPackageLength());
try {
super.sendMessage(destination, msg, payload);
} catch (ChannelException x) {
msgTxErr.addAndGet(1);
if (access.get() == 1)
access.addAndGet(-1);
throw x;
}
mbTx += (bytes * destination.length) / (1024d * 1024d);
mbAppTx += bytes / (1024d * 1024d);
if (access.addAndGet(-1) == 0) {
long stop = System.currentTimeMillis();
timeTx += (stop - txStart) / 1000d;
if ((msgTxCnt.get() / interval) >= lastCnt) {
lastCnt++;
report(timeTx);
}
}
msgTxCnt.addAndGet(1);
}
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:ThroughputInterceptor.java
示例13: testOptionConflict
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Test
public void testOptionConflict() throws Exception {
boolean error = false;
channel.setOptionCheck(true);
ChannelInterceptor i = new TestInterceptor();
i.setOptionFlag(128);
channel.addInterceptor(i);
i = new TestInterceptor();
i.setOptionFlag(128);
channel.addInterceptor(i);
try {
channel.start(Channel.DEFAULT);
}catch ( ChannelException x ) {
if ( x.getMessage().indexOf("option flag conflict") >= 0 ) error = true;
}
assertTrue(error);
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:18,代码来源:TestGroupChannelOptionFlag.java
示例14: start
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Override
public void start(int svc) throws ChannelException {
// start the thread
if (!run) {
synchronized (this) {
if (!run && ((svc & Channel.SND_TX_SEQ) == Channel.SND_TX_SEQ)) {// only
// start
// with
// the
// sender
startQueue();
} // end if
} // sync
} // end if
super.start(svc);
}
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:MessageDispatchInterceptor.java
示例15: broadcast
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Override
public void broadcast(ChannelMessage message) throws ChannelException {
if (impl==null || (impl.startLevel & Channel.MBR_TX_SEQ)!=Channel.MBR_TX_SEQ )
throw new ChannelException("Multicast send is not started or enabled.");
byte[] data = XByteBuffer.createDataPackage((ChannelData)message);
if (data.length>McastServiceImpl.MAX_PACKET_SIZE) {
throw new ChannelException("Packet length["+data.length+"] exceeds max packet size of "+McastServiceImpl.MAX_PACKET_SIZE+" bytes.");
}
DatagramPacket packet = new DatagramPacket(data,0,data.length);
try {
impl.send(false, packet);
} catch (Exception x) {
throw new ChannelException(x);
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:McastService.java
示例16: testOptionNoConflict
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Test
public void testOptionNoConflict() throws Exception {
boolean error = false;
channel.setOptionCheck(true);
ChannelInterceptor i = new TestInterceptor();
i.setOptionFlag(128);
channel.addInterceptor(i);
i = new TestInterceptor();
i.setOptionFlag(64);
channel.addInterceptor(i);
i = new TestInterceptor();
i.setOptionFlag(256);
channel.addInterceptor(i);
try {
channel.start(Channel.DEFAULT);
}catch ( ChannelException x ) {
if ( x.getMessage().indexOf("option flag conflict") >= 0 ) error = true;
}
assertFalse(error);
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:21,代码来源:TestGroupChannelOptionFlag.java
示例17: broadcast
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
/**
* Helper method to broadcast a message to all members in a channel
*
* @param msgtype
* int
* @param rpc
* boolean
* @throws ChannelException
*/
protected void broadcast(int msgtype, boolean rpc) throws ChannelException {
Member[] members = channel.getMembers();
// No destination.
if (members.length == 0)
return;
// send out a map membership message, only wait for the first reply
MapMessage msg = new MapMessage(this.mapContextName, msgtype, false, null, null, null,
channel.getLocalMember(false), null);
if (rpc) {
Response[] resp = rpcChannel.send(members, msg, RpcChannel.FIRST_REPLY, (channelSendOptions), rpcTimeout);
if (resp.length > 0) {
for (int i = 0; i < resp.length; i++) {
mapMemberAdded(resp[i].getSource());
messageReceived(resp[i].getMessage(), resp[i].getSource());
}
} else {
log.warn("broadcast received 0 replies, probably a timeout.");
}
} else {
channel.send(channel.getMembers(), msg, channelSendOptions);
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:32,代码来源:AbstractReplicatedMap.java
示例18: broadcast
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
/**
* Helper method to broadcast a message to all members in a channel
* @param msgtype int
* @param rpc boolean
* @throws ChannelException
*/
protected void broadcast(int msgtype, boolean rpc) throws ChannelException {
Member[] members = channel.getMembers();
// No destination.
if (members.length == 0 ) return;
//send out a map membership message, only wait for the first reply
MapMessage msg = new MapMessage(this.mapContextName, msgtype,
false, null, null, null, channel.getLocalMember(false), null);
if ( rpc) {
Response[] resp = rpcChannel.send(members, msg,
RpcChannel.FIRST_REPLY, (channelSendOptions), rpcTimeout);
if (resp.length > 0) {
for (int i = 0; i < resp.length; i++) {
mapMemberAdded(resp[i].getSource());
messageReceived(resp[i].getMessage(), resp[i].getSource());
}
} else {
log.warn("broadcast received 0 replies, probably a timeout.");
}
} else {
channel.send(channel.getMembers(),msg,channelSendOptions);
}
}
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:29,代码来源:AbstractReplicatedMap.java
示例19: start
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
@Override
public synchronized void start(int svc) throws ChannelException {
super.start(svc);
running = true;
if (thread == null && useThread) {
thread = new PingThread();
thread.setDaemon(true);
String channelName = "";
if (getChannel() instanceof GroupChannel && ((GroupChannel) getChannel()).getName() != null) {
channelName = "[" + ((GroupChannel) getChannel()).getName() + "]";
}
thread.setName("TcpPingInterceptor.PingThread" + channelName + "-" + cnt.addAndGet(1));
thread.start();
}
// acquire the interceptors to invoke on send ping events
ChannelInterceptor next = getNext();
while (next != null) {
if (next instanceof TcpFailureDetector)
failureDetector = new WeakReference<TcpFailureDetector>((TcpFailureDetector) next);
if (next instanceof StaticMembershipInterceptor)
staticMembers = new WeakReference<StaticMembershipInterceptor>((StaticMembershipInterceptor) next);
next = next.getNext();
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:TcpPingInterceptor.java
示例20: put
import org.apache.catalina.tribes.ChannelException; //导入依赖的package包/类
public V put(K key, V value, boolean notify) {
MapEntry<K, V> entry = new MapEntry<K, V>(key, value);
entry.setBackup(false);
entry.setProxy(false);
entry.setCopy(false);
entry.setPrimary(channel.getLocalMember(false));
V old = null;
// make sure that any old values get removed
if (containsKey(key))
old = remove(key);
try {
if (notify) {
Member[] backup = publishEntryInfo(key, value);
entry.setBackupNodes(backup);
}
} catch (ChannelException x) {
log.error("Unable to replicate out data for a AbstractReplicatedMap.put operation", x);
}
innerMap.put(key, entry);
return old;
}
开发者ID:how2j,项目名称:lazycat,代码行数:24,代码来源:AbstractReplicatedMap.java
注:本文中的org.apache.catalina.tribes.ChannelException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论