本文整理汇总了Java中org.apache.catalina.tribes.transport.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.apache.catalina.tribes.transport包,在下文中一共展示了Constants类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: waitForAck
import org.apache.catalina.tribes.transport.Constants; //导入依赖的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
示例2: execute
import org.apache.catalina.tribes.transport.Constants; //导入依赖的package包/类
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);
}
}
}
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:35,代码来源:BioReplicationTask.java
示例3: execute
import org.apache.catalina.tribes.transport.Constants; //导入依赖的package包/类
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);
}
}
}
}
开发者ID:how2j,项目名称:lazycat,代码行数:37,代码来源:BioReplicationTask.java
示例4: waitForAck
import org.apache.catalina.tribes.transport.Constants; //导入依赖的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
示例5: waitForAck
import org.apache.catalina.tribes.transport.Constants; //导入依赖的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
注:本文中的org.apache.catalina.tribes.transport.Constants类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论