Search in sources :

Example 1 with ClientReliableTopicConfig

use of com.hazelcast.client.config.ClientReliableTopicConfig in project hazelcast by hazelcast.

the class ClientReliableTopicOverloadTest method setupCluster.

@Before
public void setupCluster() {
    Config config = new Config();
    config.addRingBufferConfig(new RingbufferConfig("when*").setCapacity(100).setTimeToLiveSeconds(Integer.MAX_VALUE));
    hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenError_*").setTopicOverloadPolicy(TopicOverloadPolicy.ERROR));
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenDiscardOldest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_OLDEST));
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenDiscardNewest_*").setTopicOverloadPolicy(TopicOverloadPolicy.DISCARD_NEWEST));
    clientConfig.addReliableTopicConfig(new ClientReliableTopicConfig("whenBlock_*").setTopicOverloadPolicy(TopicOverloadPolicy.BLOCK));
    HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
    serializationService = ((HazelcastClientProxy) client).getSerializationService();
    String topicName = getTestMethodName();
    topic = client.<String>getReliableTopic(topicName);
    ringbuffer = ((ClientReliableTopicProxy<String>) topic).getRingbuffer();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Example 2 with ClientReliableTopicConfig

use of com.hazelcast.client.config.ClientReliableTopicConfig in project hazelcast by hazelcast.

the class ClientReliableTopicBlockTest method setup.

@Before
public void setup() {
    Config config = smallInstanceConfig();
    config.addRingBufferConfig(new RingbufferConfig("blockingReliableTopic*").setCapacity(10).setTimeToLiveSeconds(60));
    hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig().addReliableTopicConfig(new ClientReliableTopicConfig("blockingReliableTopic*").setReadBatchSize(10).setTopicOverloadPolicy(TopicOverloadPolicy.BLOCK));
    client = hazelcastFactory.newHazelcastClient(clientConfig);
}
Also used : ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) Config(com.hazelcast.config.Config) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Example 3 with ClientReliableTopicConfig

use of com.hazelcast.client.config.ClientReliableTopicConfig in project hazelcast by hazelcast.

the class ClientDomConfigProcessor method handleReliableTopicNode.

protected void handleReliableTopicNode(Node node) {
    String name = getName(node);
    ClientReliableTopicConfig config = new ClientReliableTopicConfig(name);
    for (Node child : childElements(node)) {
        String nodeName = cleanNodeName(child);
        if (matches("topic-overload-policy", nodeName)) {
            config.setTopicOverloadPolicy(TopicOverloadPolicy.valueOf(getTextContent(child)));
        } else if (matches("read-batch-size", lowerCaseInternal(nodeName))) {
            config.setReadBatchSize(Integer.parseInt(getTextContent(child)));
        }
    }
    clientConfig.addReliableTopicConfig(config);
}
Also used : ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) Node(org.w3c.dom.Node)

Example 4 with ClientReliableTopicConfig

use of com.hazelcast.client.config.ClientReliableTopicConfig in project hazelcast by hazelcast.

the class TestClientApplicationContext method testReliableTopicConfig.

@Test
public void testReliableTopicConfig() {
    ClientConfig clientConfig = hazelcastReliableTopic.getClientConfig();
    ClientReliableTopicConfig topicConfig = clientConfig.getReliableTopicConfig("rel-topic");
    assertEquals(100, topicConfig.getReadBatchSize());
    assertEquals(TopicOverloadPolicy.DISCARD_NEWEST, topicConfig.getTopicOverloadPolicy());
}
Also used : ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with ClientReliableTopicConfig

use of com.hazelcast.client.config.ClientReliableTopicConfig in project hazelcast by hazelcast.

the class ClientReliableTopicStressTest method setup.

@Before
public void setup() {
    logger = Logger.getLogger(getClass());
    Config config = new Config();
    RingbufferConfig ringbufferConfig = new RingbufferConfig("foobar");
    ringbufferConfig.setCapacity(10000000);
    config.addRingBufferConfig(ringbufferConfig);
    ClientConfig clientConfig = new ClientConfig();
    ClientReliableTopicConfig topicConfig = new ClientReliableTopicConfig("foobar");
    clientConfig.addReliableTopicConfig(topicConfig);
    HazelcastInstance hz = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
    topic = client.getReliableTopic(topicConfig.getName());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) ClientReliableTopicConfig(com.hazelcast.client.config.ClientReliableTopicConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Before(org.junit.Before)

Aggregations

ClientReliableTopicConfig (com.hazelcast.client.config.ClientReliableTopicConfig)5 ClientConfig (com.hazelcast.client.config.ClientConfig)4 Config (com.hazelcast.config.Config)3 RingbufferConfig (com.hazelcast.config.RingbufferConfig)3 Before (org.junit.Before)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1