Java Code Examples for org.eclipse.jetty.util.thread.Sweeper

Following code examples demonstrate how to use org.eclipse.jetty.util.thread.Sweeper from jetty. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.eclipse.jetty.util.thread.Sweeper and various code implementation of this class.
Example 1
Project : jetty Source File : DuplexConnectionPool.java View Source Code on GitHub

    @Override
    public boolean sweep()
    {
        List<Connection> toSweep;
        lock();
        try
        {
            toSweep = activeConnections.stream()
                    .filter(connection -> connection instanceof Sweeper.Sweepable)
                    .collect(Collectors.toList());
        }
        finally
        {
            unlock();
        }

        for (Connection connection : toSweep)
        {
            if (((Sweeper.Sweepable)connection).sweep())
            {
                boolean removed = remove(connection, true);
                LOG.warn("Connection swept: {}{}{} from active connections{}{}",
                        connection,
                        System.lineSeparator(),
                        removed ? "Removed" : "Not removed",
                        System.lineSeparator(),
                        dump());
            }
        }

        return false;
    }
			
Example 2
Project : jetty Source File : MultiplexConnectionPool.java View Source Code on GitHub

    @Override
    public boolean sweep()
    {
        List<Connection> toSweep = new ArrayList<>();
        lock();
        try
        {
            busyConnections.values().stream()
                    .map(holder -> holder.connection)
                    .filter(connection -> connection instanceof Sweeper.Sweepable)
                    .collect(Collectors.toCollection(() -> toSweep));
            muxedConnections.values().stream()
                    .map(holder -> holder.connection)
                    .filter(connection -> connection instanceof Sweeper.Sweepable)
                    .collect(Collectors.toCollection(() -> toSweep));
        }
        finally
        {
            unlock();
        }

        for (Connection connection : toSweep)
        {
            if (((Sweeper.Sweepable)connection).sweep())
            {
                boolean removed = remove(connection, true);
                LOG.warn("Connection swept: {}{}{} from active connections{}{}",
                        connection,
                        System.lineSeparator(),
                        removed ? "Removed" : "Not removed",
                        System.lineSeparator(),
                        dump());
            }
        }

        return false;
    }
			
Example 3
Project : jetty Source File : PoolingHttpDestination.java View Source Code on GitHub

    @Override
    protected void doStart() throws Exception
    {
        HttpClient client = getHttpClient();
        this.connectionPool = newConnectionPool(client);
        addBean(connectionPool);
        super.doStart();
        Sweeper sweeper = client.getBean(Sweeper.class);
        if (sweeper != null)
            sweeper.offer(connectionPool);
    }
			
Example 4
Project : jetty Source File : PoolingHttpDestination.java View Source Code on GitHub

    @Override
    protected void doStop() throws Exception
    {
        HttpClient client = getHttpClient();
        Sweeper sweeper = client.getBean(Sweeper.class);
        if (sweeper != null)
            sweeper.remove(connectionPool);
        super.doStop();
        removeBean(connectionPool);
    }