Package org.apache.qpid.proton.engine

Examples of org.apache.qpid.proton.engine.Connection


                _logger.fine(this + " about to stop");
            }
            //close all connections
            for (Connector<?> c : _driver.connectors())
            {
                Connection connection = c.getConnection();
                connection.close();
            }
            //stop listeners
            for (Listener<?> l : _driver.listeners())
            {
                try
View Full Code Here


    {
        int count = 0;
        if (_driver != null) {
            for (Connector<?> c : _driver.connectors())
            {
                Connection connection = c.getConnection();
                for (Link link : new Links(connection, ACTIVE, ANY))
                {
                    if (outgoing)
                    {
                        if (link instanceof Sender) count += link.getQueued();
View Full Code Here

        //process active listeners
        for (Listener<?> l = _driver.listener(); l != null; l = _driver.listener())
        {
            _worked = true;
            Connector<?> c = l.accept();
            Connection connection = Proton.connection();
            connection.setContainer(_name);
            ListenerContext ctx = (ListenerContext) l.getContext();
            connection.setContext(new ConnectionContext(ctx.getAddress(), c));
            c.setConnection(connection);
            Transport transport = c.getTransport();
            //TODO: full SASL
            Sasl sasl = c.sasl();
            if (sasl != null)
            {
                sasl.server();
                sasl.setMechanisms(new String[]{"ANONYMOUS"});
                sasl.done(Sasl.SaslOutcome.PN_SASL_OK);
            }
            transport.ssl(ctx.getDomain());
            connection.open();
        }
        // process connectors, reclaiming credit on closed connectors
        for (Connector<?> c = _driver.connector(); c != null; c = _driver.connector())
        {
            _worked = true;
View Full Code Here

        distributeCredit();
    }

    private void processEndpoints(Connector c)
    {
        Connection connection = c.getConnection();

        if (connection.getLocalState() == EndpointState.UNINITIALIZED)
        {
            connection.open();
        }

        Delivery delivery = connection.getWorkHead();
        while (delivery != null)
        {
            Link link = delivery.getLink();
            if (delivery.isUpdated())
            {
                if (link instanceof Sender)
                {
                    delivery.disposition(delivery.getRemoteState());
                }
                StoreEntry e = (StoreEntry) delivery.getContext();
                if (e != null) e.updated();
            }

            if (delivery.isReadable())
            {
                pumpIn( link.getSource().getAddress(), (Receiver)link );
            }

            Delivery next = delivery.getWorkNext();
            delivery.clear();
            delivery = next;
        }

        for (Session session : new Sessions(connection, UNINIT, ANY))
        {
            session.open();
            _logger.log(Level.FINE, "Opened session " + session);
        }
        for (Link link : new Links(connection, UNINIT, ANY))
        {
            //TODO: the following is not correct; should only copy those properties that we understand
            link.setSource(link.getRemoteSource());
            link.setTarget(link.getRemoteTarget());
            linkAdded(link);
            link.open();
            _logger.log(Level.FINE, "Opened link " + link);
        }

        distributeCredit();

        for (Link link : new Links(connection, ACTIVE, ACTIVE))
        {
            if (link instanceof Sender)
            {
                pumpOut(link.getTarget().getAddress(), (Sender)link);
            }
        }

        for (Session session : new Sessions(connection, ACTIVE, CLOSED))
        {
            session.close();
        }

        for (Link link : new Links(connection, ANY, CLOSED))
        {
            if (link.getLocalState() == EndpointState.ACTIVE)
            {
                link.close();
            }
            else
            {
                reclaimLink(link);
            }
        }

        if (connection.getRemoteState() == EndpointState.CLOSED)
        {
            if (connection.getLocalState() == EndpointState.ACTIVE)
            {
                connection.close();
            }
        }
    }
View Full Code Here

    private Connection lookup(Address address)
    {
        for (Connector<?> c : _driver.connectors())
        {
            Connection connection = c.getConnection();
            ConnectionContext ctx = (ConnectionContext) connection.getContext();
            if (ctx.matches(address))
            {
                return connection;
            }
        }
View Full Code Here

        }
    }

    private <C extends Link> C getLink(Address address, LinkFinder<C> finder)
    {
        Connection connection = lookup(address);
        if (connection == null)
        {
            String host = address.getHost();
            int port = Integer.valueOf(address.getImpliedPort());
            Connector<?> connector = _driver.createConnector(host, port, null);
            _logger.log(Level.FINE, "Connecting to " + host + ":" + port);
            connection = Proton.connection();
            connection.setContainer(_name);
            connection.setHostname(host);
            connection.setContext(new ConnectionContext(address, connector));
            connector.setConnection(connection);
            Sasl sasl = connector.sasl();
            if (sasl != null)
            {
                sasl.client();
                sasl.setMechanisms(new String[]{"ANONYMOUS"});
            }
            if ("amqps".equalsIgnoreCase(address.getScheme())) {
                Transport transport = connector.getTransport();
                SslDomain domain = makeDomain(address, SslDomain.Mode.CLIENT);
                if (_trustedDb != null) {
                    domain.setPeerAuthentication(SslDomain.VerifyMode.VERIFY_PEER);
                    //domain.setPeerAuthentication(SslDomain.VerifyMode.VERIFY_PEER_NAME);
                } else {
                    domain.setPeerAuthentication(SslDomain.VerifyMode.ANONYMOUS_PEER);
                }
                Ssl ssl = transport.ssl(domain);
                //ssl.setPeerHostname(host);
            }
            connection.open();
        }

        for (Link link : new Links(connection, ACTIVE, ANY))
        {
            C result = finder.test(link);
            if (result != null) return result;
        }
        Session session = connection.session();
        session.open();
        C link = finder.create(session);
        linkAdded(link);
        link.open();
        return link;
View Full Code Here

                //        pn_connector_process(ctor);
                //        return false;
                //    }
                // }

                Connection connection = c.getConnection();
                for (Link link : new Links(connection, ACTIVE, ANY))
                {
                    if (link instanceof Sender)
                    {
                        total += link.getQueued();
View Full Code Here

        {
            //do we have at least one pending message?
            if (_incomingStore.size() > 0) return true;
            for (Connector<?> c : _driver.connectors())
            {
                Connection connection = c.getConnection();
                Delivery delivery = connection.getWorkHead();
                while (delivery != null)
                {
                    if (delivery.isReadable() && !delivery.isPartial())
                    {
                        return true;
View Full Code Here

        public boolean matches(Address address)
        {
            String host = address.getHost();
            String port = address.getImpliedPort();
            Connection conn = _connector.getConnection();
            return host.equals(conn.getRemoteContainer()) ||
                (_address.getHost().equals(host) && _address.getImpliedPort().equals(port));
        }
View Full Code Here

    public void stop()
    {
        //close all connections
        for (Connector c : _driver.connectors())
        {
            Connection connection = c.getConnection();
            connection.close();
            try
            {
                c.process();
                c.close();
            }
View Full Code Here

TOP

Related Classes of org.apache.qpid.proton.engine.Connection

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.