Package com.hazelcast.client

Examples of com.hazelcast.client.SimpleClient


        q.offer("item2");
        q.offer("item3");
        q.offer("item4");
        q.offer("item5");

        final SimpleClient client = getClient();
        client.send(new DrainRequest(queueName, 1));
        PortableCollection result = (PortableCollection) client.receive();
        Collection<Data> coll = result.getCollection();
        assertEquals(1, coll.size());
        assertEquals("item1", ss.toObject(coll.iterator().next()));
        assertEquals(4, q.size());
    }
View Full Code Here


        q.offer("item2");
        q.offer("item3");
        q.offer("item4");
        q.offer("item5");

        final SimpleClient client = getClient();
        client.send(new IteratorRequest(queueName));
        PortableCollection result = (PortableCollection) client.receive();
        Collection<Data> coll = result.getCollection();
        int i = 1;
        for (Data data : coll) {
            assertEquals("item" + i, ss.toObject(data));
            i++;
View Full Code Here

    @Test
    public void testOffer() throws IOException, InterruptedException {
        final IQueue q = getQueue();

        final SimpleClient client = getClient();
        client.send(new OfferRequest(queueName, ss.toData("item1")));
        Object result = client.receive();
        assertTrue((Boolean) result);
        Object item = q.peek();
        assertEquals(item, "item1");

        q.offer("item2");
        q.offer("item3");
        q.offer("item4");
        q.offer("item5");
        q.offer("item6");

        final CountDownLatch latch = new CountDownLatch(1);
        new Thread() {
            public void run() {
                try {
                    latch.await(30, TimeUnit.SECONDS);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                q.poll();
            }
        }.start();

        client.send(new OfferRequest(queueName, 500, ss.toData("item7")));
        result = client.receive();
        assertFalse((Boolean) result);

        client.send(new OfferRequest(queueName, 10 * 1000, ss.toData("item7")));
        Thread.sleep(1000);
        latch.countDown();
        result = client.receive();
        assertTrue((Boolean) result);
    }
View Full Code Here

    @Test
    public void testPeek() throws IOException {
        IQueue q = getQueue();

        final SimpleClient client = getClient();
        client.send(new PeekRequest(queueName));
        Object result = client.receive();
        assertNull(result);

        q.offer("item1");
        client.send(new PeekRequest(queueName));
        result = client.receive();
        assertEquals("item1", result);
        assertEquals(1, q.size());
    }
View Full Code Here

    }

    @Test
    public void testPoll() throws IOException {
        final IQueue q = getQueue();
        final SimpleClient client = getClient();
        client.send(new PollRequest(queueName));
        Object result = client.receive();
        assertNull(result);

        q.offer("item1");
        client.send(new PollRequest(queueName));
        result = client.receive();
        assertEquals("item1", result);
        assertEquals(0, q.size());

        new Thread() {
            public void run() {
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                q.offer("item2");
            }
        }.start();
        client.send(new PollRequest(queueName, 10 * 1000));
        result = client.receive();
        assertEquals("item2", result);
        assertEquals(0, q.size());
    }
View Full Code Here

        final IQueue q = getQueue();
        q.offer("item1");
        q.offer("item2");
        q.offer("item3");

        final SimpleClient client = getClient();
        client.send(new RemoveRequest(queueName, ss.toData("item2")));
        Boolean result = (Boolean) client.receive();
        assertTrue(result);
        assertEquals(2, q.size());

        client.send(new RemoveRequest(queueName, ss.toData("item2")));
        result = (Boolean) client.receive();
        assertFalse(result);
        assertEquals(2, q.size());
    }
View Full Code Here

        final IQueue q = getQueue();
        q.offer("item1");
        q.offer("item2");
        q.offer("item3");

        final SimpleClient client = getClient();
        client.send(new SizeRequest(queueName));
        int result = (Integer) client.receive();
        assertEquals(result, q.size());
    }
View Full Code Here

    @Test
    public void testIsEmpty() throws IOException {
        final IQueue queue = getQueue();

        final SimpleClient client = getClient();
        client.send(new IsEmptyRequest(queueName));
        boolean result = (Boolean) client.receive();
        assertEquals(0, queue.size());
        assertTrue(result);
    }
View Full Code Here

        createConfig();
        IQueue queue = getQueue();
        queue.offer("item1");
        queue.offer("item2");

        final SimpleClient client = getClient();
        client.send(new RemainingCapacityRequest(queueName));
        int result = (Integer) client.receive();
        assertEquals(4, result);
    }
View Full Code Here

            public void run() throws Exception {
                assertEquals(2, addCounter.get());
            }
        });

        final SimpleClient client = getClient();
        client.send(new RemoveListenerRequest(queueName, registrationId));
        boolean result = (Boolean) client.receive();

        assertTrue(result);
        queue.offer("item3");
        assertSizeEventually(3, queue);
        assertNotEquals(3, addCounter.get());
View Full Code Here

TOP

Related Classes of com.hazelcast.client.SimpleClient

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.