本文整理汇总了Java中org.apache.catalina.tribes.ChannelException类的典型用法代码示例。如果您正苦于以下问题:Java ChannelException类的具体用法?Java ChannelException怎么用?Java ChannelException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChannelException类属于org.apache.catalina.tribes包,在下文中一共展示了ChannelException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}