您确定要退出登录吗?

修改密码

原密码
新密码
确认新密码

t-io集群服务器

talent-tan


框架/工具 t-io tio

功能介绍

t-io集群服务器是基于t-io写的一个TCP服务器,该服务器会维护连接上来的TCP客户端

产品价值

基于t-io集群服务器,开发人员可以更轻松地开发出有集群能力的应用以及RPC、MSG等垂直工具

t-io集群参考架构

产品稳定性

在谭聊的测试机上,已经连续运行近3979小时(约165天),各项性能指标非常稳定(见下图)

代码一览

package org.tio.clu.server.handler;

/**
 * 透传请求
 * @author tanyaowu
 */
@CommandHandler(Command.TransferReq)
public class TransferReqHandler extends AbsCluServerHandler {
	private static Logger log = LoggerFactory.getLogger(TransferReqHandler.class);

	public TransferReqHandler() {
	}

	@Override
	public void myHandler(CluPacket cluPacket, ServerChannelContext serverChannelContext) throws Exception {
		TransferReq transferReq = Clu.getBodyObj(cluPacket, TransferReq.class);

		byte tt = transferReq.getBt();
		BindType bindType = BindType.from(tt);

		String v = transferReq.getV();
		String[] vs = transferReq.getVs();

		CollectionWithLock<? extends Collection<String>, String> setWithLock = null;
		if (bindType == BindType.All || bindType == BindType.ChannelId) {
			setWithLock = Nodes.BS_NODE_CGIDS;
		} else {
			log.warn("收到透传请求{} : {}", bindType, v);
			setWithLock = getSetWithLock(Nodes.getXxx_Cids(bindType), v, vs);
		}

		TransferNtf transferNtf = TransferNtf.fromReq(transferReq);
		transfer(cluPacket, serverChannelContext, setWithLock, transferNtf);
	}

	/**
	 * @param mapSetWithLock
	 * @param v
	 * @param vs
	 * @return
	 * @author tanyaowu
	 */
	private SetWithLock<String> getSetWithLock(MapSetWithLock<String, String> mapSetWithLock, String v, String[] vs) {
		SetWithLock<String> setWithLock = null;
		if (StrUtil.isNotBlank(v)) {
			setWithLock = mapSetWithLock.get(v);
		}
		if (ArrayUtil.isNotEmpty(vs)) {
			SetWithLock<String> temSetWithLock = new SetWithLock<String>(new HashSet<String>());
			for (String v1 : vs) {
				if (StrUtil.isNotBlank(v1)) {
					SetWithLock<String> setWithLock1 = mapSetWithLock.get(v1);
					setWithLock1.handle(new ReadLockHandler<Set<String>>() {
						@Override
						public void handler(Set<String> set) {
							temSetWithLock.getObj().addAll(set);
						}
					});
				}
			}
			setWithLock = temSetWithLock;
		}
		return setWithLock;
	}
}


登录 和大家一起讨论吧!

重置 发表评论


确定要删除该条评论吗?

案例不存在!