项目:tomcat7
文件:BioSender.java
/**
* 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",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",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();
}
}
项目:tomcat7
文件:BioReplicationTask.java
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 asynchronized 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);
}
}
}
}
项目:apache-tomcat-7.0.73-with-comment
文件:BioSender.java
/**
* Wait for AckNowledgement from other server.
* FIXME Please,x);
}
throw x;
} finally {
ackbuf.clear();
}
}
项目:apache-tomcat-7.0.73-with-comment
文件:BioReplicationTask.java
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 asynchronized 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);
}
}
}
}
项目:lazycat
文件:BioReplicationTask.java
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);
}
}
}
}
项目:class-guard
文件:BioSender.java
/**
* Wait for AckNowledgement from other server.
* FIXME Please,new Integer(socket.getLocalPort())));
else throw new IOException(sm.getString("IDataSender.ack.wrong",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",new Integer(socket.getLocalPort()),new Long(getTimeout()));
if ( SenderState.getSenderState(getDestination()).isReady() ) {
SenderState.getSenderState(getDestination()).setSUSPECT();
if ( log.isWarnEnabled() ) log.warn(errmsg,x);
}
throw x;
} finally {
ackbuf.clear();
}
}
项目:class-guard
文件:BioReplicationTask.java
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 asynchronized 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);
}
}
}
}
项目:apache-tomcat-7.0.57
文件:BioSender.java
/**
* Wait for AckNowledgement from other server.
* FIXME Please,x);
}
throw x;
} finally {
ackbuf.clear();
}
}
项目:apache-tomcat-7.0.57
文件:BioReplicationTask.java
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 asynchronized 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);
}
}
}
}
项目:WBSAirback
文件:BioSender.java
/**
* Wait for AckNowledgement from other server.
* FIXME Please,x);
}
throw x;
} finally {
ackbuf.clear();
}
}
项目:WBSAirback
文件:BioReplicationTask.java
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 asynchronized 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);
}
}
}
}
项目:lazycat
文件:BioSender.java
/**
* 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.FAIL_ACK_DATA);
ackReceived = ackReceived || failAckReceived;
break;
}
i = soIn.read();
}
if (!ackReceived) {
if (i == -1)
throw new IOException(
sm.getString("IDataSender.ack.eof",Integer.valueOf(socket.getLocalPort())));
else
throw new IOException(sm.getString("IDataSender.ack.wrong",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",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();
}
}