本文整理汇总了Java中org.apache.catalina.tribes.transport.SenderState类的典型用法代码示例。如果您正苦于以下问题:Java SenderState类的具体用法?Java SenderState怎么用?Java SenderState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SenderState类属于org.apache.catalina.tribes.transport包,在下文中一共展示了SenderState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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);
}
}
示例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();
}
}
示例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;
}
}
示例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);
}
}
示例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;
}
}
示例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);
}
}
示例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();
}
}
示例9: memberAdded
import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public void memberAdded(Member member){
SenderState.getSenderState(member);
super.memberAdded(member);
}
示例10: memberDisappeared
import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public void memberDisappeared(Member member){
SenderState.removeSenderState(member);
super.memberDisappeared(member);
}
示例11: isReady
import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public boolean isReady() {
return SenderState.getSenderState(this).isReady();
}
示例12: isSuspect
import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public boolean isSuspect() {
return SenderState.getSenderState(this).isSuspect();
}
示例13: isFailing
import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public boolean isFailing() {
return SenderState.getSenderState(this).isFailing();
}
示例14: memberAdded
import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public void memberAdded(Member member) {
SenderState.getSenderState(member);
super.memberAdded(member);
}
示例15: memberDisappeared
import org.apache.catalina.tribes.transport.SenderState; //导入依赖的package包/类
@Override
public void memberDisappeared(Member member) {
SenderState.removeSenderState(member);
super.memberDisappeared(member);
}