Package org.apache.qpid.transport

Examples of org.apache.qpid.transport.SenderException


        {
            socket.setSoTimeout(i);
        }
        catch (Exception e)
        {
            throw new SenderException(e);
        }
    }
View Full Code Here


            {
                tearDownSSLConnection();
            }
            catch(Exception e)
            {
                throw new SenderException("Error closing SSL connection",e);
            }


            synchronized(_sslStatus.getSslLock())
            {
View Full Code Here

    public void send(ByteBuffer appData)
    {
        if (closed.get())
        {
            throw new SenderException("SSL Sender is closed");
        }

        HandshakeStatus handshakeStatus;
        Status status;

        while(appData.hasRemaining() && !_sslStatus.getSslErrorFlag())
        {
            int read = 0;
            try
            {
                SSLEngineResult result = engine.wrap(appData, netData);
                read   = result.bytesProduced();
                status = result.getStatus();
                handshakeStatus = result.getHandshakeStatus();
            }
            catch(SSLException e)
            {
                // Should this set _sslError??
                throw new SenderException("SSL, Error occurred while encrypting data",e);
            }

            if(read > 0)
            {
                int limit = netData.limit();
                netData.limit(netData.position());
                netData.position(netData.position() - read);

                ByteBuffer data = netData.slice();

                netData.limit(limit);
                netData.position(netData.position() + read);

                delegate.send(data);
            }

            switch(status)
            {
                case CLOSED:
                    throw new SenderException("SSLEngine is closed");

                case BUFFER_OVERFLOW:
                    netData.clear();
                    continue;

                case OK:
                    break; // do nothing

                default:
                    throw new IllegalStateException("SSLReceiver: Invalid State " + status);
            }

            switch (handshakeStatus)
            {
                case NEED_WRAP:
                    if (netData.hasRemaining())
                    {
                        continue;
                    }

                case NEED_TASK:
                    doTasks();
                    break;

                case NEED_UNWRAP:
                    flush();
                    synchronized(_sslStatus.getSslLock())
                    {
                        switch (engine.getHandshakeStatus())
                        {
                        case NEED_UNWRAP:
                            long start = System.currentTimeMillis();
                            try
                            {
                                _sslStatus.getSslLock().wait(timeout);
                            }
                            catch(InterruptedException e)
                            {
                                // pass
                            }

                            if (System.currentTimeMillis()- start >= timeout)
                            {                               
                                throw new SenderException(
                                                          "SSL Engine timed out waiting for a response." +
                                                          "To get more info,run with -Djavax.net.debug=ssl");
                            }
                            break;
                        }
View Full Code Here

                    byte[] out = getSaslClient().unwrap(netData, 0, length);
                    delegate.received(ByteBuffer.wrap(out));
                }
                catch (SaslException e)
                {
                    throw new SenderException("SASL Sender, Error occurred while encrypting data",e);
                }
            }           
        }
        else
        {
View Full Code Here

                {
                    getSaslClient().dispose();
                }
                catch (SaslException e)
                {
                    throw new SenderException("Error closing SASL Sender",e);
                }
            }
        }
    }
View Full Code Here

    public void send(ByteBuffer buf)
    {       
        if (closed.get())
        {
            throw new SenderException("SSL Sender is closed");
        }
       
        if (isSecurityLayerEstablished())
        {
            while (buf.hasRemaining())
            {
                int length = Math.min(buf.remaining(), getSendBuffSize());
                log.debug("sendBuffSize %s", getSendBuffSize());
                log.debug("buf.remaining() %s", buf.remaining());
               
                buf.get(appData, 0, length);
                try
                {
                    byte[] out = getSaslClient().wrap(appData, 0, length);
                    log.debug("out.length %s", out.length);
                   
                    delegate.send(ByteBuffer.wrap(out));
                }
                catch (SaslException e)
                {
                    log.error("Exception while encrypting data.",e);
                    throw new SenderException("SASL Sender, Error occurred while encrypting data",e);
                }
            }           
        }
        else
        {
View Full Code Here

        {
            throw new SenderClosedException("sender is closed", exception);
        }
        if(!senderThread.isAlive())
        {
            throw new SenderException("sender thread not alive");
        }

        final int size = buffer.length;
        int remaining = buf.remaining();

        while (remaining > 0)
        {
            final int hd = head;
            final int tl = tail;

            if (hd - tl >= size)
            {
                flush();
                synchronized (notFull)
                {
                    long start = System.currentTimeMillis();
                    long elapsed = 0;
                    while (!closed.get() && head - tail >= size && elapsed < timeout)
                    {
                        try
                        {
                            notFull.wait(timeout - elapsed);
                        }
                        catch (InterruptedException e)
                        {
                            // pass
                        }
                        elapsed += System.currentTimeMillis() - start;
                    }

                    if (closed.get())
                    {
                        throw new SenderClosedException("sender is closed", exception);
                    }

                    if (head - tail >= size)
                    {
                        throw new SenderException(String.format("write timed out: %s, %s", head, tail));
                    }
                }
                continue;
            }
View Full Code Here

                {
                    senderThread.join(timeout);
                    if (senderThread.isAlive())
                    {
                        log.error("join timed out");
                        throw new SenderException("join timed out");
                    }
                }
            }
            catch (InterruptedException e)
            {
                log.error("interrupted whilst waiting for sender thread to stop");
                throw new SenderException(e);
            }
            finally
            {
                closeListeners();
            }
            if (reportException && exception != null)
            {
                throw new SenderException(exception);
            }
        }
    }
View Full Code Here

            }
        }

        if (ex != null)
        {
            throw new SenderException(ex.getMessage(), ex);
        }
    }
View Full Code Here

        {
            socket.setSoTimeout(i);
        }
        catch (Exception e)
        {
            throw new SenderException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.qpid.transport.SenderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.