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

Java SenderState类代码示例

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

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



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

示例1: sendMessage

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
/**
 * Send message.
 */
public  void sendMessage(byte[] data, boolean waitForAck) throws IOException {
    IOException exception = null;
    setAttempt(0);
    try {
         // first try with existing connection
         pushMessage(data,false,waitForAck);
    } catch (IOException x) {
        SenderState.getSenderState(getDestination()).setSuspect();
        exception = x;
        if (log.isTraceEnabled()) log.trace(sm.getString("IDataSender.send.again", getAddress().getHostAddress(), Integer.valueOf(getPort())),x);
        while ( getAttempt()<getMaxRetryAttempts() ) {
            try {
                setAttempt(getAttempt()+1);
                // second try with fresh connection
                pushMessage(data, true,waitForAck);
                exception = null;
            } catch (IOException xx) {
                exception = xx;
                closeSocket();
            }
        }
    } finally {
        setRequestCount(getRequestCount()+1);
        keepalive();
        if ( exception != null ) throw exception;
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:31,代码来源:BioSender.java


示例2: openSocket

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
/**
 * open real socket and set time out when waitForAck is enabled
 * is socket open return directly
 */
protected void openSocket() throws IOException {
   if(isConnected()) return ;
   try {
       socket = new Socket();
       InetSocketAddress sockaddr = new InetSocketAddress(getAddress(), getPort());
       socket.connect(sockaddr,(int)getTimeout());
       socket.setSendBufferSize(getTxBufSize());
       socket.setReceiveBufferSize(getRxBufSize());
       socket.setSoTimeout( (int) getTimeout());
       socket.setTcpNoDelay(getTcpNoDelay());
       socket.setKeepAlive(getSoKeepAlive());
       socket.setReuseAddress(getSoReuseAddress());
       socket.setOOBInline(getOoBInline());
       socket.setSoLinger(getSoLingerOn(),getSoLingerTime());
       socket.setTrafficClass(getSoTrafficClass());
       setConnected(true);
       soOut = socket.getOutputStream();
       soIn  = socket.getInputStream();
       setRequestCount(0);
       setConnectTime(System.currentTimeMillis());
       if (log.isDebugEnabled())
           log.debug(sm.getString("IDataSender.openSocket", getAddress().getHostAddress(), Integer.valueOf(getPort()), Long.valueOf(0)));
  } catch (IOException ex1) {
      SenderState.getSenderState(getDestination()).setSuspect();
      if (log.isDebugEnabled())
          log.debug(sm.getString("IDataSender.openSocket.failure",getAddress().getHostAddress(), Integer.valueOf(getPort()), Long.valueOf(0)), ex1);
      throw (ex1);
    }
    
 }
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:35,代码来源:BioSender.java


示例3: waitForAck

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
/**
 * Wait for Acknowledgement from other server.
 * FIXME Please, not wait only for three characters, better control that the wait ack message is correct.
 * @throws java.io.IOException
 * @throws java.net.SocketTimeoutException
 */
protected void waitForAck() throws java.io.IOException {
    try {
        boolean ackReceived = false;
        boolean failAckReceived = false;
        ackbuf.clear();
        int bytesRead = 0;
        int i = soIn.read();
        while ((i != -1) && (bytesRead < Constants.ACK_COMMAND.length)) {
            bytesRead++;
            byte d = (byte)i;
            ackbuf.append(d);
            if (ackbuf.doesPackageExist() ) {
                byte[] ackcmd = ackbuf.extractDataPackage(true).getBytes();
                ackReceived = Arrays.equals(ackcmd,org.apache.catalina.tribes.transport.Constants.ACK_DATA);
                failAckReceived = Arrays.equals(ackcmd,org.apache.catalina.tribes.transport.Constants.FAIL_ACK_DATA);
                ackReceived = ackReceived || failAckReceived;
                break;
            }
            i = soIn.read();
        }
        if (!ackReceived) {
            if (i == -1) throw new IOException(sm.getString("IDataSender.ack.eof",getAddress(), Integer.valueOf(socket.getLocalPort())));
            else throw new IOException(sm.getString("IDataSender.ack.wrong",getAddress(), Integer.valueOf(socket.getLocalPort())));
        } else if ( failAckReceived && getThrowOnFailedAck()) {
            throw new RemoteProcessException("Received a failed ack:org.apache.catalina.tribes.transport.Constants.FAIL_ACK_DATA");
        }
    } catch (IOException x) {
        String errmsg = sm.getString("IDataSender.ack.missing", getAddress(), Integer.valueOf(socket.getLocalPort()), Long.valueOf(getTimeout()));
        if ( SenderState.getSenderState(getDestination()).isReady() ) {
            SenderState.getSenderState(getDestination()).setSuspect();
            if ( log.isWarnEnabled() ) log.warn(errmsg, x);
        } else {
            if ( log.isDebugEnabled() )log.debug(errmsg, x);
        }
        throw x;
    } finally {
        ackbuf.clear();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:46,代码来源:BioSender.java


示例4: sendMessage

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
/**
 * Send message.
 */
public void sendMessage(byte[] data, boolean waitForAck) throws IOException {
	IOException exception = null;
	setAttempt(0);
	try {
		// first try with existing connection
		pushMessage(data, false, waitForAck);
	} catch (IOException x) {
		SenderState.getSenderState(getDestination()).setSuspect();
		exception = x;
		if (log.isTraceEnabled())
			log.trace(sm.getString("IDataSender.send.again", getAddress().getHostAddress(),
					Integer.valueOf(getPort())), x);
		while (getAttempt() < getMaxRetryAttempts()) {
			try {
				setAttempt(getAttempt() + 1);
				// second try with fresh connection
				pushMessage(data, true, waitForAck);
				exception = null;
			} catch (IOException xx) {
				exception = xx;
				closeSocket();
			}
		}
	} finally {
		setRequestCount(getRequestCount() + 1);
		keepalive();
		if (exception != null)
			throw exception;
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:34,代码来源:BioSender.java


示例5: openSocket

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
/**
 * open real socket and set time out when waitForAck is enabled is socket
 * open return directly
 */
protected void openSocket() throws IOException {
	if (isConnected())
		return;
	try {
		socket = new Socket();
		InetSocketAddress sockaddr = new InetSocketAddress(getAddress(), getPort());
		socket.connect(sockaddr, (int) getTimeout());
		socket.setSendBufferSize(getTxBufSize());
		socket.setReceiveBufferSize(getRxBufSize());
		socket.setSoTimeout((int) getTimeout());
		socket.setTcpNoDelay(getTcpNoDelay());
		socket.setKeepAlive(getSoKeepAlive());
		socket.setReuseAddress(getSoReuseAddress());
		socket.setOOBInline(getOoBInline());
		socket.setSoLinger(getSoLingerOn(), getSoLingerTime());
		socket.setTrafficClass(getSoTrafficClass());
		setConnected(true);
		soOut = socket.getOutputStream();
		soIn = socket.getInputStream();
		setRequestCount(0);
		setConnectTime(System.currentTimeMillis());
		if (log.isDebugEnabled())
			log.debug(sm.getString("IDataSender.openSocket", getAddress().getHostAddress(),
					Integer.valueOf(getPort()), Long.valueOf(0)));
	} catch (IOException ex1) {
		SenderState.getSenderState(getDestination()).setSuspect();
		if (log.isDebugEnabled())
			log.debug(sm.getString("IDataSender.openSocket.failure", getAddress().getHostAddress(),
					Integer.valueOf(getPort()), Long.valueOf(0)), ex1);
		throw (ex1);
	}

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


示例6: sendMessage

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
/**
 * Send message.
 */
public  void sendMessage(byte[] data, boolean waitForAck) throws IOException {
    IOException exception = null;
    setAttempt(0);
    try {
         // first try with existing connection
         pushMessage(data,false,waitForAck);
    } catch (IOException x) {
        SenderState.getSenderState(getDestination()).setSuspect();
        exception = x;
        if (log.isTraceEnabled()) log.trace(sm.getString("IDataSender.send.again", getAddress().getHostAddress(),new Integer(getPort())),x);
        while ( getAttempt()<getMaxRetryAttempts() ) {
            try {
                setAttempt(getAttempt()+1);
                // second try with fresh connection
                pushMessage(data, true,waitForAck);
                exception = null;
            } catch (IOException xx) {
                exception = xx;
                closeSocket();
            }
        }
    } finally {
        setRequestCount(getRequestCount()+1);
        keepalive();
        if ( exception != null ) throw exception;
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:31,代码来源:BioSender.java


示例7: openSocket

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
/**
 * open real socket and set time out when waitForAck is enabled
 * is socket open return directly
 */
protected void openSocket() throws IOException {
   if(isConnected()) return ;
   try {
       socket = new Socket();
       InetSocketAddress sockaddr = new InetSocketAddress(getAddress(), getPort());
       socket.connect(sockaddr,(int)getTimeout());
       socket.setSendBufferSize(getTxBufSize());
       socket.setReceiveBufferSize(getRxBufSize());
       socket.setSoTimeout( (int) getTimeout());
       socket.setTcpNoDelay(getTcpNoDelay());
       socket.setKeepAlive(getSoKeepAlive());
       socket.setReuseAddress(getSoReuseAddress());
       socket.setOOBInline(getOoBInline());
       socket.setSoLinger(getSoLingerOn(),getSoLingerTime());
       socket.setTrafficClass(getSoTrafficClass());
       setConnected(true);
       soOut = socket.getOutputStream();
       soIn  = socket.getInputStream();
       setRequestCount(0);
       setConnectTime(System.currentTimeMillis());
       if (log.isDebugEnabled())
           log.debug(sm.getString("IDataSender.openSocket", getAddress().getHostAddress(), new Integer(getPort()), new Long(0)));
  } catch (IOException ex1) {
      SenderState.getSenderState(getDestination()).setSuspect();
      if (log.isDebugEnabled())
          log.debug(sm.getString("IDataSender.openSocket.failure",getAddress().getHostAddress(), new Integer(getPort()),new Long(0)), ex1);
      throw (ex1);
    }
    
 }
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:35,代码来源:BioSender.java


示例8: waitForAck

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
/**
 * Wait for Acknowledgement from other server.
 * FIXME Please, not wait only for three characters, better control that the wait ack message is correct.
 * @throws java.io.IOException
 * @throws java.net.SocketTimeoutException
 */
protected void waitForAck() throws java.io.IOException {
    try {
        boolean ackReceived = false;
        boolean failAckReceived = false;
        ackbuf.clear();
        int bytesRead = 0;
        int i = soIn.read();
        while ((i != -1) && (bytesRead < Constants.ACK_COMMAND.length)) {
            bytesRead++;
            byte d = (byte)i;
            ackbuf.append(d);
            if (ackbuf.doesPackageExist() ) {
                byte[] ackcmd = ackbuf.extractDataPackage(true).getBytes();
                ackReceived = Arrays.equals(ackcmd,org.apache.catalina.tribes.transport.Constants.ACK_DATA);
                failAckReceived = Arrays.equals(ackcmd,org.apache.catalina.tribes.transport.Constants.FAIL_ACK_DATA);
                ackReceived = ackReceived || failAckReceived;
                break;
            }
            i = soIn.read();
        }
        if (!ackReceived) {
            if (i == -1) throw new IOException(sm.getString("IDataSender.ack.eof",getAddress(), new Integer(socket.getLocalPort())));
            else throw new IOException(sm.getString("IDataSender.ack.wrong",getAddress(), new Integer(socket.getLocalPort())));
        } else if ( failAckReceived && getThrowOnFailedAck()) {
            throw new RemoteProcessException("Received a failed ack:org.apache.catalina.tribes.transport.Constants.FAIL_ACK_DATA");
        }
    } catch (IOException x) {
        String errmsg = sm.getString("IDataSender.ack.missing", getAddress(),new Integer(socket.getLocalPort()), new Long(getTimeout()));
        if ( SenderState.getSenderState(getDestination()).isReady() ) {
            SenderState.getSenderState(getDestination()).setSuspect();
            if ( log.isWarnEnabled() ) log.warn(errmsg, x);
        } else {
            if ( log.isDebugEnabled() )log.debug(errmsg, x);
        }
        throw x;
    } finally {
        ackbuf.clear();
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:46,代码来源:BioSender.java


示例9: memberAdded

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public void memberAdded(Member member){
    SenderState.getSenderState(member);
    super.memberAdded(member);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:6,代码来源:ChannelCoordinator.java


示例10: memberDisappeared

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public void memberDisappeared(Member member){
    SenderState.removeSenderState(member);
    super.memberDisappeared(member);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:6,代码来源:ChannelCoordinator.java


示例11: isReady

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public boolean isReady() {
    return SenderState.getSenderState(this).isReady();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:5,代码来源:MemberImpl.java


示例12: isSuspect

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public boolean isSuspect() {
    return SenderState.getSenderState(this).isSuspect();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:5,代码来源:MemberImpl.java


示例13: isFailing

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public boolean isFailing() {
    return SenderState.getSenderState(this).isFailing();
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:5,代码来源:MemberImpl.java


示例14: memberAdded

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public void memberAdded(Member member) {
	SenderState.getSenderState(member);
	super.memberAdded(member);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:6,代码来源:ChannelCoordinator.java


示例15: memberDisappeared

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public void memberDisappeared(Member member) {
	SenderState.removeSenderState(member);
	super.memberDisappeared(member);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:6,代码来源:ChannelCoordinator.java


示例16: waitForAck

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
/**
 * Wait for Acknowledgement from other server. FIXME Please, not wait only
 * for three characters, better control that the wait ack message is
 * correct.
 * 
 * @throws java.io.IOException
 * @throws java.net.SocketTimeoutException
 */
protected void waitForAck() throws java.io.IOException {
	try {
		boolean ackReceived = false;
		boolean failAckReceived = false;
		ackbuf.clear();
		int bytesRead = 0;
		int i = soIn.read();
		while ((i != -1) && (bytesRead < Constants.ACK_COMMAND.length)) {
			bytesRead++;
			byte d = (byte) i;
			ackbuf.append(d);
			if (ackbuf.doesPackageExist()) {
				byte[] ackcmd = ackbuf.extractDataPackage(true).getBytes();
				ackReceived = Arrays.equals(ackcmd, org.apache.catalina.tribes.transport.Constants.ACK_DATA);
				failAckReceived = Arrays.equals(ackcmd,
						org.apache.catalina.tribes.transport.Constants.FAIL_ACK_DATA);
				ackReceived = ackReceived || failAckReceived;
				break;
			}
			i = soIn.read();
		}
		if (!ackReceived) {
			if (i == -1)
				throw new IOException(
						sm.getString("IDataSender.ack.eof", getAddress(), Integer.valueOf(socket.getLocalPort())));
			else
				throw new IOException(sm.getString("IDataSender.ack.wrong", getAddress(),
						Integer.valueOf(socket.getLocalPort())));
		} else if (failAckReceived && getThrowOnFailedAck()) {
			throw new RemoteProcessException(
					"Received a failed ack:org.apache.catalina.tribes.transport.Constants.FAIL_ACK_DATA");
		}
	} catch (IOException x) {
		String errmsg = sm.getString("IDataSender.ack.missing", getAddress(),
				Integer.valueOf(socket.getLocalPort()), Long.valueOf(getTimeout()));
		if (SenderState.getSenderState(getDestination()).isReady()) {
			SenderState.getSenderState(getDestination()).setSuspect();
			if (log.isWarnEnabled())
				log.warn(errmsg, x);
		} else {
			if (log.isDebugEnabled())
				log.debug(errmsg, x);
		}
		throw x;
	} finally {
		ackbuf.clear();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:57,代码来源:BioSender.java


示例17: isReady

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public boolean isReady() {
	return SenderState.getSenderState(this).isReady();
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:5,代码来源:MemberImpl.java


示例18: isSuspect

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public boolean isSuspect() {
	return SenderState.getSenderState(this).isSuspect();
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:5,代码来源:MemberImpl.java


示例19: isFailing

import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public boolean isFailing() {
	return SenderState.getSenderState(this).isFailing();
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:5,代码来源:MemberImpl.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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