Examples of OfferRequest


Examples of com.hazelcast.queue.client.OfferRequest

        offer(e, -1, TimeUnit.MILLISECONDS);
    }

    public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
        Data data = getContext().getSerializationService().toData(e);
        OfferRequest request = new OfferRequest(name, unit.toMillis(timeout), data);
        final Boolean result = invokeInterruptibly(request);
        return result;
    }
View Full Code Here

Examples of com.hazelcast.queue.client.OfferRequest

        ConstructorFunction<Integer, Portable>[] constructors = new ConstructorFunction[IS_EMPTY + 1];

        constructors[OFFER] = new ConstructorFunction<Integer, Portable>() {
            @Override
            public Portable createNew(Integer arg) {
                return new OfferRequest();
            }
        };
        constructors[SIZE] = new ConstructorFunction<Integer, Portable>() {
            @Override
            public Portable createNew(Integer arg) {
View Full Code Here

Examples of com.hazelcast.queue.client.OfferRequest

        offer(e, -1, TimeUnit.MILLISECONDS);
    }

    public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
        Data data = getContext().getSerializationService().toData(e);
        OfferRequest request = new OfferRequest(name, unit.toMillis(timeout), data);
        final Boolean result = invokeInterruptibly(request);
        return result;
    }
View Full Code Here

Examples of com.hazelcast.queue.impl.client.OfferRequest

        offer(e, -1, TimeUnit.MILLISECONDS);
    }

    public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
        Data data = getContext().getSerializationService().toData(e);
        OfferRequest request = new OfferRequest(name, unit.toMillis(timeout), data);
        final Boolean result = invokeInterruptibly(request);
        return result;
    }
View Full Code Here

Examples of com.hazelcast.queue.impl.client.OfferRequest

        ConstructorFunction<Integer, Portable>[] constructors = new ConstructorFunction[IS_EMPTY + 1];

        constructors[OFFER] = new ConstructorFunction<Integer, Portable>() {
            @Override
            public Portable createNew(Integer arg) {
                return new OfferRequest();
            }
        };
        constructors[SIZE] = new ConstructorFunction<Integer, Portable>() {
            @Override
            public Portable createNew(Integer arg) {
View Full Code Here

Examples of com.hazelcast.queue.impl.client.OfferRequest

    @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
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.