Package com.hazelcast.core

Examples of com.hazelcast.core.ITopic


    private CombinedClassLoader combinedClassLoader;

    @Override
    public EventProducer getEventProducer(String name, Boolean pubsub) {
        if (pubsub) {
                ITopic topic = instance.getTopic(Constants.TOPIC + Constants.SEPARATOR + name);
                TopicProducer producer = new TopicProducer();
                producer.setInstance(instance);
                producer.setTopic(topic);
                producer.setNode(getNode());
                producer.init();
View Full Code Here


    }

    @Override
    public EventConsumer getEventConsumer(String name, Boolean pubsub) {
        if (pubsub) {
                ITopic topic = instance.getTopic(Constants.TOPIC + Constants.SEPARATOR + name);
                TopicConsumer consumer = new TopicConsumer();
                consumer.setTopic(topic);
                consumer.setInstance(instance);
                consumer.setNode(getNode());
                consumer.setDispatcher(dispatcher);
View Full Code Here

        CountDownLatch l1 = new CountDownLatch(1000);
        CountDownLatch l2 = new CountDownLatch(1000);
        CountDownLatch l3 = new CountDownLatch(1000);

        ITopic t1 = h1.getTopic("foo");
        ITopic t2 = h2.getTopic("foo");
        ITopic t3 = h3.getTopic("foo");

        t1.addMessageListener(createMessageListener(l1));
        t2.addMessageListener(createMessageListener(l2));
        t3.addMessageListener(createMessageListener(l3));

        MemberImpl m1 = (MemberImpl) h1.getCluster().getLocalMember();
        MemberImpl m2 = (MemberImpl) h2.getCluster().getLocalMember();
        MemberImpl m3 = (MemberImpl) h3.getCluster().getLocalMember();
View Full Code Here

public class TopicTest extends HazelcastTestSupport {

    @Test
    public void testDestroyTopicRemovesStatistics() {
        HazelcastInstance instance = createHazelcastInstance();
        final ITopic topic = instance.getTopic("foo");
        topic.publish("foobar");

        //we need to give the message the chance to be processed, else the topic statistics are recreated.
        //so in theory the destroy for the topic is broken.
        sleepSeconds(1);

        topic.destroy();

        final TopicService topicService = getNode(instance).nodeEngine.getService(TopicService.SERVICE_NAME);

        assertTrueEventually(new AssertTask() {
            @Override
            public void run() {
                boolean containsStats = topicService.getStatsMap().containsKey(topic.getName());
                assertFalse(containsStats);
            }
        });
    }
View Full Code Here

    @Test
    public void testPerformance() throws InterruptedException {
        HazelcastInstance hazelcastInstance = createHazelcastInstance();
        int count = 10000;
        final ITopic topic = hazelcastInstance.getTopic("perf");
        ExecutorService ex = Executors.newFixedThreadPool(10);
        final CountDownLatch l = new CountDownLatch(count);
        for (int i = 0; i < count; i++) {
            ex.submit(new Runnable() {
                public void run() {
                    topic.publish("my object");
                    l.countDown();
                }
            });
        }
        assertTrue(l.await(20, TimeUnit.SECONDS));
View Full Code Here

            this.name = s;
        }
    }

    private List<Runnable> loadTopicOperations() {
        ITopic topic = hazelcast.getTopic("myTopic");
        topic.addMessageListener(new MessageListener() {
            public void onMessage(Message message) {
                messagesReceived.incrementAndGet();
            }
        });
        List<Runnable> operations = new ArrayList<Runnable>();
        addOperation(operations, new Runnable() {
            public void run() {
                ITopic topic = hazelcast.getTopic("myTopic");
                topic.publish(String.valueOf(random.nextInt(100000000)));
                messagesSend.incrementAndGet();
            }
        }, 10);
        return operations;
    }
View Full Code Here

TOP

Related Classes of com.hazelcast.core.ITopic

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.