• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ChannelMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.catalina.tribes.ChannelMessage的典型用法代码示例。如果您正苦于以下问题:Java ChannelMessage类的具体用法?Java ChannelMessage怎么用?Java ChannelMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChannelMessage类属于org.apache.catalina.tribes包,在下文中一共展示了ChannelMessage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sendMessage

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的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


示例2: messageReceived

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的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


示例3: messageReceived

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void messageReceived(ChannelMessage msg) {
    if ( !okToProcess(msg.getOptions()) ) {
        super.messageReceived(msg);
        return;
    }
    int msgnr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-4);
    msg.getMessage().trim(4);
    MessageOrder order = new MessageOrder(msgnr,(ChannelMessage)msg.deepclone());
    try {
        inLock.writeLock().lock();
        if ( processIncoming(order) ) processLeftOvers(msg.getAddress(),false);
    }finally {
        inLock.writeLock().unlock();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:OrderInterceptor.java


示例4: sendMessage

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage message) throws ChannelException {
    if ( !connected ) throw new ChannelException("Sender not connected.");
    ParallelNioSender sender = (ParallelNioSender)getSender();
    if (sender == null) {
        ChannelException cx = new ChannelException("Unable to retrieve a data sender, time out("+getMaxWait()+" ms) error.");
        for (int i = 0; i < destination.length; i++) cx.addFaultyMember(destination[i], new NullPointerException("Unable to retrieve a sender from the sender pool"));
        throw cx;
    } else {
        try {
            sender.sendMessage(destination, message);
            sender.keepalive();
        } catch (ChannelException x) {
            sender.disconnect();
            throw x;
        } finally {
            returnSender(sender);
            if (!connected) disconnect();
        }
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:22,代码来源:PooledParallelSender.java


示例5: broadcast

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的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


示例6: messageReceived

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void messageReceived(ChannelMessage msg) {
	if (!okToProcess(msg.getOptions())) {
		super.messageReceived(msg);
		return;
	}
	int msgnr = XByteBuffer.toInt(msg.getMessage().getBytesDirect(), msg.getMessage().getLength() - 4);
	msg.getMessage().trim(4);
	MessageOrder order = new MessageOrder(msgnr, (ChannelMessage) msg.deepclone());
	try {
		inLock.writeLock().lock();
		if (processIncoming(order))
			processLeftOvers(msg.getAddress(), false);
	} finally {
		inLock.writeLock().unlock();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:18,代码来源:OrderInterceptor.java


示例7: sendMessage

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的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


示例8: messageReceived

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void messageReceived(ChannelMessage msg) {
	// catch incoming
	boolean process = true;
	if (okToProcess(msg.getOptions())) {
		// check to see if it is a testMessage, if so, process = false
		process = ((msg.getMessage().getLength() != TCP_FAIL_DETECT.length)
				|| (!Arrays.equals(TCP_FAIL_DETECT, msg.getMessage().getBytes())));
	} // end if

	// ignore the message, it doesnt have the flag set
	if (process)
		super.messageReceived(msg);
	else if (log.isDebugEnabled())
		log.debug("Received a failure detector packet:" + msg);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:TcpFailureDetector.java


示例9: sendMessage

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage message) throws ChannelException {
	if (!connected)
		throw new ChannelException("Sender not connected.");
	ParallelNioSender sender = (ParallelNioSender) getSender();
	if (sender == null) {
		ChannelException cx = new ChannelException(
				"Unable to retrieve a data sender, time out(" + getMaxWait() + " ms) error.");
		for (int i = 0; i < destination.length; i++)
			cx.addFaultyMember(destination[i],
					new NullPointerException("Unable to retrieve a sender from the sender pool"));
		throw cx;
	} else {
		try {
			sender.sendMessage(destination, message);
			sender.keepalive();
		} catch (ChannelException x) {
			sender.disconnect();
			throw x;
		} finally {
			returnSender(sender);
			if (!connected)
				disconnect();
		}
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:PooledParallelSender.java


示例10: broadcast

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的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


示例11: sendMessage

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
/**
 * Send a message to one or more members in the cluster
 * 
 * @param destination
 *            Member[] - the destinations, null or zero length means all
 * @param msg
 *            ClusterMessage - the message to send
 * @param payload
 *            TBA
 */
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
		throws ChannelException {
	if (destination == null)
		destination = membershipService.getMembers();
	if ((msg.getOptions() & Channel.SEND_OPTIONS_MULTICAST) == Channel.SEND_OPTIONS_MULTICAST) {
		membershipService.broadcast(msg);
	} else {
		clusterSender.sendMessage(msg, destination);
	}
	if (Logs.MESSAGES.isTraceEnabled()) {
		Logs.MESSAGES.trace("ChannelCoordinator - Sent msg:" + new UniqueId(msg.getUniqueId()) + " at "
				+ new java.sql.Timestamp(System.currentTimeMillis()) + " to " + Arrays.toNameString(destination));
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:26,代码来源:ChannelCoordinator.java


示例12: sendMessage

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
/**
 * Send a message to one or more members in the cluster
 * @param destination Member[] - the destinations, null or zero length means all
 * @param msg ClusterMessage - the message to send
 * @param payload TBA
 */
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
    if ( destination == null ) destination = membershipService.getMembers();
    if ((msg.getOptions()&Channel.SEND_OPTIONS_MULTICAST) == Channel.SEND_OPTIONS_MULTICAST) {
        membershipService.broadcast(msg);
    } else {
        clusterSender.sendMessage(msg,destination);
    }
    if ( Logs.MESSAGES.isTraceEnabled() ) {
        Logs.MESSAGES.trace("ChannelCoordinator - Sent msg:" + new UniqueId(msg.getUniqueId()) + " at " +new java.sql.Timestamp(System.currentTimeMillis())+ " to "+Arrays.toNameString(destination));
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:ChannelCoordinator.java


示例13: messageReceived

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void messageReceived(ChannelMessage msg) {
    if ( Logs.MESSAGES.isTraceEnabled() ) {
        Logs.MESSAGES.trace("ChannelCoordinator - Received msg:" + new UniqueId(msg.getUniqueId()) + " at " +new java.sql.Timestamp(System.currentTimeMillis())+ " from "+msg.getAddress().getName());
    }
    super.messageReceived(msg);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:8,代码来源:ChannelCoordinator.java


示例14: messageReceived

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void messageReceived(ChannelMessage msg) {
	boolean isFrag = XByteBuffer.toBoolean(msg.getMessage().getBytesDirect(), msg.getMessage().getLength() - 1);
	msg.getMessage().trim(1);
	if (isFrag) {
		defrag(msg);
	} else {
		super.messageReceived(msg);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:11,代码来源:FragmentationInterceptor.java


示例15: execute

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
protected void execute(ObjectReader reader) throws Exception {
	int pkgcnt = reader.count();

	if (pkgcnt > 0) {
		ChannelMessage[] msgs = reader.execute();
		for (int i = 0; i < msgs.length; i++) {
			/**
			 * Use send ack here if you want to ack the request to the
			 * remote server before completing the request This is
			 * considered an asynchronous request
			 */
			if (ChannelData.sendAckAsync(msgs[i].getOptions()))
				sendAck(Constants.ACK_COMMAND);
			try {
				// process the message
				getCallback().messageDataReceived(msgs[i]);
				/**
				 * Use send ack here if you want the request to complete on
				 * this server before sending the ack to the remote server
				 * This is considered a synchronized request
				 */
				if (ChannelData.sendAckSync(msgs[i].getOptions()))
					sendAck(Constants.ACK_COMMAND);
			} catch (Exception x) {
				if (ChannelData.sendAckSync(msgs[i].getOptions()))
					sendAck(Constants.FAIL_ACK_COMMAND);
				log.error("Error thrown from messageDataReceived.", x);
			}
			if (getUseBufferPool()) {
				BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage());
				msgs[i].setMessage(null);
			}
		}
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:37,代码来源:BioReplicationTask.java


示例16: sendMessage

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的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:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:TcpFailureDetector.java


示例17: messageReceived

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void messageReceived(ChannelMessage msg) {
    //catch incoming
    boolean process = true;
    if ( okToProcess(msg.getOptions()) ) {
        //check to see if it is a testMessage, if so, process = false
        process = ( (msg.getMessage().getLength() != TCP_FAIL_DETECT.length) ||
                    (!Arrays.equals(TCP_FAIL_DETECT,msg.getMessage().getBytes()) ) );
    }//end if

    //ignore the message, it doesnt have the flag set
    if ( process ) super.messageReceived(msg);
    else if ( log.isDebugEnabled() ) log.debug("Received a failure detector packet:"+msg);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:15,代码来源:TcpFailureDetector.java


示例18: messageReceived

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void messageReceived(ChannelMessage msg) {
    //catch incoming 
    boolean process = true;
    if ( okToProcess(msg.getOptions()) ) {
        //check to see if it is a ping message, if so, process = false
        process = ( (msg.getMessage().getLength() != TCP_PING_DATA.length) ||
                    (!Arrays.equals(TCP_PING_DATA,msg.getMessage().getBytes()) ) );
    }//end if

    //ignore the message, it doesnt have the flag set
    if ( process ) super.messageReceived(msg);
    else if ( log.isDebugEnabled() ) log.debug("Received a TCP ping packet:"+msg);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:15,代码来源:TcpPingInterceptor.java


示例19: sendMessage

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)
		throws ChannelException {
	if (!okToProcess(msg.getOptions())) {
		super.sendMessage(destination, msg, payload);
		return;
	}
	ChannelException cx = null;
	for (int i = 0; i < destination.length; i++) {
		try {
			int nr = 0;
			try {
				outLock.writeLock().lock();
				nr = incCounter(destination[i]);
			} finally {
				outLock.writeLock().unlock();
			}
			// reduce byte copy
			msg.getMessage().append(nr);
			try {
				getNext().sendMessage(new Member[] { destination[i] }, msg, payload);
			} finally {
				msg.getMessage().trim(4);
			}
		} catch (ChannelException x) {
			if (cx == null)
				cx = x;
			cx.addFaultyMember(x.getFaultyMembers());
		}
	} // for
	if (cx != null)
		throw cx;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:34,代码来源:OrderInterceptor.java


示例20: messageReceived

import org.apache.catalina.tribes.ChannelMessage; //导入依赖的package包/类
@Override
public void messageReceived(ChannelMessage msg) {
    boolean isFrag = XByteBuffer.toBoolean(msg.getMessage().getBytesDirect(),msg.getMessage().getLength()-1);
    msg.getMessage().trim(1);
    if ( isFrag ) {
        defrag(msg);
    } else {
        super.messageReceived(msg);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:11,代码来源:FragmentationInterceptor.java



注:本文中的org.apache.catalina.tribes.ChannelMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ImageLoadHandler类代码示例发布时间:2022-05-23
下一篇:
Java SetSplitState类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap