Package ru.decipher.proxy.impl

Examples of ru.decipher.proxy.impl.DefaultProxyManager.take()


                new DefaultProxyManager(new Mock3GoodHttpProxyNoDelayLoader(), 0, 1000, 10, 0);
        class Task implements Runnable {
            @Override
            public void run() {
                try {
                    final HttpProxyConfig proxy = manager.take();
                    //do something
                    manager.compliment(proxy);
                } catch (Exception e) {
                    e.printStackTrace();
                    throw new RuntimeException(e);
View Full Code Here


        final Random random = new Random();
        for (int i = 0; i < 100; i++) {
            tasks.add(Executors.callable(new Runnable() {
                @Override
                public void run() {
                    HttpProxyConfig take = manager.take();
                    try {
                        sleep(100);
                    } catch (InterruptedException ignored) {
                    }
                    manager.compliment(take);
View Full Code Here

                    try {
                        sleep(100);
                    } catch (InterruptedException ignored) {
                    }
                    manager.compliment(take);
                    take = manager.take();
                    try {
                        sleep(100);
                    } catch (InterruptedException ignored) {
                    }
                    if (random.nextBoolean()) {
View Full Code Here

    }

    @Test
    public void testThatUpdateRateLimitWorksWell() throws Exception {
        final DefaultProxyManager manager = new DefaultProxyManager(new LocalhostNoProxyLoader(), 0, 0, 0, 1000);
        final HttpProxyConfig config = manager.take();
        manager.ban(config);
        long time = System.currentTimeMillis();
        manager.take();
        time = System.currentTimeMillis() - time;
        assertTrue("update rate limits failed", time >= 1000);
View Full Code Here

    public void testThatUpdateRateLimitWorksWell() throws Exception {
        final DefaultProxyManager manager = new DefaultProxyManager(new LocalhostNoProxyLoader(), 0, 0, 0, 1000);
        final HttpProxyConfig config = manager.take();
        manager.ban(config);
        long time = System.currentTimeMillis();
        manager.take();
        time = System.currentTimeMillis() - time;
        assertTrue("update rate limits failed", time >= 1000);

    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.