当前位置: 首页>>代码示例>>Java>>正文


Java IoSession.isConnected方法代码示例

本文整理汇总了Java中org.apache.mina.common.IoSession.isConnected方法的典型用法代码示例。如果您正苦于以下问题:Java IoSession.isConnected方法的具体用法?Java IoSession.isConnected怎么用?Java IoSession.isConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mina.common.IoSession的用法示例。


在下文中一共展示了IoSession.isConnected方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getOrAddChannel

import org.apache.mina.common.IoSession; //导入方法依赖的package包/类
static MinaChannel getOrAddChannel(IoSession session, URL url, ChannelHandler handler) {
    if (session == null) {
        return null;
    }
    MinaChannel ret = (MinaChannel) session.getAttribute(CHANNEL_KEY);
    if (ret == null) {
        ret = new MinaChannel(session, url, handler);
        if (session.isConnected()) {
            MinaChannel old = (MinaChannel) session.setAttribute(CHANNEL_KEY, ret);
            if (old != null) {
                session.setAttribute(CHANNEL_KEY, old);
                ret = old;
            }
        }
    }
    return ret;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:MinaChannel.java

示例2: getChannels

import org.apache.mina.common.IoSession; //导入方法依赖的package包/类
public Collection<Channel> getChannels() {
    Set<IoSession> sessions = acceptor.getManagedSessions(getBindAddress());
    Collection<Channel> channels = new HashSet<Channel>();
    for (IoSession session : sessions) {
        if (session.isConnected()) {
            channels.add(MinaChannel.getOrAddChannel(session, getUrl(), this));
        }
    }
    return channels;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:11,代码来源:MinaServer.java

示例3: getChannel

import org.apache.mina.common.IoSession; //导入方法依赖的package包/类
@Override
protected Channel getChannel() {
    IoSession s = session;
    if (s == null || ! s.isConnected())
        return null;
    return MinaChannel.getOrAddChannel(s, getUrl(), this);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:8,代码来源:MinaClient.java

示例4: exceptionCaught

import org.apache.mina.common.IoSession; //导入方法依赖的package包/类
public void exceptionCaught(IoSession session, TairClientException exception) {
  log.error("do async request failed", exception);
  if (session.isConnected()) {
  	log.error("session closing");
  	session.close();
  }
  masterFailCount++;
}
 
开发者ID:alibaba,项目名称:tair-java-client,代码行数:9,代码来源:ConfigServer.java

示例5: createClient

import org.apache.mina.common.IoSession; //导入方法依赖的package包/类
protected Client createClient(String targetIP, int targetPort, int connectTimeout, String key) throws Exception {
  if (isDebugEnabled) {
    LOGGER.debug("create connection to :" + targetIP + ":" + targetPort + ",timeout is:" + connectTimeout + ",key is:" + key);
  }
  SocketConnectorConfig cfg = new SocketConnectorConfig();
  cfg.setThreadModel(ThreadModel.MANUAL);
  if (connectTimeout > 1000) {
    cfg.setConnectTimeout((int) connectTimeout / 1000);
  } else {
    cfg.setConnectTimeout(1);
  }
  cfg.getSessionConfig().setTcpNoDelay(Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.nodelay", "true")));
  cfg.getFilterChain().addLast("objectserialize", new MinaProtocolCodecFilter());
  SocketAddress targetAddress = new InetSocketAddress(targetIP, targetPort);
  MinaClientProcessor processor = new MinaClientProcessor(this, key);
  ConnectFuture connectFuture = ioConnector.connect(targetAddress, null, processor, cfg);
  // wait for connection established
  connectFuture.join();

  IoSession ioSession = connectFuture.getSession();
  if ((ioSession == null) || (!ioSession.isConnected())) {
    String targetUrl = targetIP + ":" + targetPort;
    LOGGER.error("create connection error,targetaddress is " + targetUrl);
    throw new Exception("create connection error,targetaddress is " + targetUrl);
  }
  if (isDebugEnabled) {
    LOGGER.debug(
        "create connection to :" + targetIP + ":" + targetPort + ",timeout is:" + connectTimeout + ",key is:" + key + " successed");
  }
  MinaClient client = new MinaClient(ioSession, key, connectTimeout);
  processor.setClient(client);
  return client;
}
 
开发者ID:leeyazhou,项目名称:nfs-rpc,代码行数:34,代码来源:MinaClientFactory.java

示例6: createClient

import org.apache.mina.common.IoSession; //导入方法依赖的package包/类
private synchronized TairClient createClient(String targetUrl, int connectionTimeout, PacketStreamer pstreamer)
		throws Exception {
	SocketConnectorConfig cfg = new SocketConnectorConfig();
	cfg.setThreadModel(ThreadModel.MANUAL);
	if (connectionTimeout < MIN_CONN_TIMEOUT)
		connectionTimeout = MIN_CONN_TIMEOUT;
	cfg.setConnectTimeout((int) connectionTimeout / 1000);
	cfg.getSessionConfig().setTcpNoDelay(true);
	cfg.getFilterChain().addLast("objectserialize",
			new TairProtocolCodecFilter(pstreamer));
	String address = TairUtil.getHost(targetUrl);
	int port = TairUtil.getPort(targetUrl);
	SocketAddress targetAddress = new InetSocketAddress(address, port);
	TairClientProcessor processor = new TairClientProcessor();
	ConnectFuture connectFuture = ioConnector.connect(targetAddress, null,
			processor, cfg);

	connectFuture.join();
	
	IoSession ioSession = connectFuture.getSession();
	if ((ioSession == null) || (!ioSession.isConnected())) {
		throw new Exception(
				"create tair connection error,targetaddress is "
						+ targetUrl);
	}
	if (LOGGER.isTraceEnabled()) {
		LOGGER.trace("create tair connection success,targetaddress is "
				+ targetUrl);
	}
	TairClient client = new TairClient(this, ioSession,targetUrl);
	processor.setClient(client);
	processor.setFactory(this, targetUrl);
	return client;
}
 
开发者ID:alibaba,项目名称:tair-java-client,代码行数:35,代码来源:TairClientFactory.java

示例7: removeChannelIfDisconnectd

import org.apache.mina.common.IoSession; //导入方法依赖的package包/类
static void removeChannelIfDisconnectd(IoSession session) {
    if (session != null && ! session.isConnected()) {
        session.removeAttribute(CHANNEL_KEY);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:6,代码来源:MinaChannel.java


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