Java 类org.apache.catalina.tribes.transport.SenderState 实例源码

项目:tomcat7    文件:BioSender.java   
/**
 * 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;
    }
}
项目:tomcat7    文件:BioSender.java   
/**
 * 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);
    }

 }
项目: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",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();
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:BioSender.java   
/**
 * 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;
    }
}
项目:apache-tomcat-7.0.73-with-comment    文件:BioSender.java   
/**
 * 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);
    }

 }
项目:apache-tomcat-7.0.73-with-comment    文件: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",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();
    }
}
项目:lazycat    文件:BioSender.java   
/**
 * 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;
    }
}
项目:lazycat    文件:BioSender.java   
/**
 * 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);
    }

}
项目:class-guard    文件:BioSender.java   
/**
 * 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;
    }
}
项目:class-guard    文件:BioSender.java   
/**
 * 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);
    }

 }
项目:class-guard    文件: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(), 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();
    }
}
项目:apache-tomcat-7.0.57    文件:BioSender.java   
/**
 * 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;
    }
}
项目:apache-tomcat-7.0.57    文件:BioSender.java   
/**
 * 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);
    }

 }
项目:apache-tomcat-7.0.57    文件: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(), 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();
    }
}
项目:apache-tomcat-7.0.57    文件:BioSender.java   
/**
 * 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;
    }
}
项目:apache-tomcat-7.0.57    文件:BioSender.java   
/**
 * 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);
    }

 }
项目:apache-tomcat-7.0.57    文件: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(), 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();
    }
}
项目:WBSAirback    文件:BioSender.java   
/**
 * 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;
    }
}
项目:WBSAirback    文件:BioSender.java   
/**
 * 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);
    }

 }
项目:WBSAirback    文件: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(), 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();
    }
}
项目:tomcat7    文件:ChannelCoordinator.java   
@Override
public void memberAdded(Member member){
    SenderState.getSenderState(member);
    super.memberAdded(member);
}
项目:tomcat7    文件:ChannelCoordinator.java   
@Override
public void memberDisappeared(Member member){
    SenderState.removeSenderState(member);
    super.memberDisappeared(member);
}
项目:tomcat7    文件:MemberImpl.java   
@Override
public boolean isReady() {
    return SenderState.getSenderState(this).isReady();
}
项目:tomcat7    文件:MemberImpl.java   
@Override
public boolean isSuspect() {
    return SenderState.getSenderState(this).isSuspect();
}
项目:tomcat7    文件:MemberImpl.java   
@Override
public boolean isFailing() {
    return SenderState.getSenderState(this).isFailing();
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChannelCoordinator.java   
@Override
public void memberAdded(Member member){
    SenderState.getSenderState(member);
    super.memberAdded(member);
}
项目:apache-tomcat-7.0.73-with-comment    文件:ChannelCoordinator.java   
@Override
public void memberDisappeared(Member member){
    SenderState.removeSenderState(member);
    super.memberDisappeared(member);
}
项目:apache-tomcat-7.0.73-with-comment    文件:MemberImpl.java   
@Override
public boolean isReady() {
    return SenderState.getSenderState(this).isReady();
}
项目:apache-tomcat-7.0.73-with-comment    文件:MemberImpl.java   
@Override
public boolean isSuspect() {
    return SenderState.getSenderState(this).isSuspect();
}
项目:apache-tomcat-7.0.73-with-comment    文件:MemberImpl.java   
@Override
public boolean isFailing() {
    return SenderState.getSenderState(this).isFailing();
}
项目:lazycat    文件:ChannelCoordinator.java   
@Override
public void memberAdded(Member member) {
    SenderState.getSenderState(member);
    super.memberAdded(member);
}
项目:lazycat    文件:ChannelCoordinator.java   
@Override
public void memberDisappeared(Member member) {
    SenderState.removeSenderState(member);
    super.memberDisappeared(member);
}
项目: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.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();
    }
}
项目:lazycat    文件:MemberImpl.java   
@Override
public boolean isReady() {
    return SenderState.getSenderState(this).isReady();
}
项目:lazycat    文件:MemberImpl.java   
@Override
public boolean isSuspect() {
    return SenderState.getSenderState(this).isSuspect();
}
项目:lazycat    文件:MemberImpl.java   
@Override
public boolean isFailing() {
    return SenderState.getSenderState(this).isFailing();
}
项目:class-guard    文件:ChannelCoordinator.java   
@Override
public void memberAdded(Member member){
    SenderState.getSenderState(member);
    super.memberAdded(member);
}
项目:class-guard    文件:ChannelCoordinator.java   
@Override
public void memberDisappeared(Member member){
    SenderState.removeSenderState(member);
    super.memberDisappeared(member);
}
项目:class-guard    文件:MemberImpl.java   
@Override
public boolean isReady() {
    return SenderState.getSenderState(this).isReady();
}
项目:class-guard    文件:MemberImpl.java   
@Override
public boolean isSuspect() {
    return SenderState.getSenderState(this).isSuspect();
}