Esempio n. 1
0
 public RingbufferConfig getRingbufferConfig(String name) {
   String baseName = getBaseName(name);
   RingbufferConfig config = lookupByPattern(ringbufferConfigs, baseName);
   if (config != null) {
     return config;
   }
   RingbufferConfig defConfig = ringbufferConfigs.get("default");
   if (defConfig == null) {
     defConfig = new RingbufferConfig("default");
     addRingBufferConfig(defConfig);
   }
   config = new RingbufferConfig(name, defConfig);
   addRingBufferConfig(config);
   return config;
 }
  @Before
  public void setupCluster() {
    Config config = new Config();
    config.addRingBufferConfig(
        new RingbufferConfig("when*").setCapacity(100).setTimeToLiveSeconds(5));
    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();
  }
  @Before
  public void setup() {
    ReliableTopicConfig topicConfig = new ReliableTopicConfig("reliableTopic*");

    RingbufferConfig ringbufferConfig = new RingbufferConfig(topicConfig.getName());
    ringbufferConfig.setCapacity(CAPACITY);

    Config config = new Config();
    config.addReliableTopicConfig(topicConfig);
    config.addRingBufferConfig(ringbufferConfig);

    HazelcastInstance[] instances = newInstances(config);
    local = instances[0];
    HazelcastInstance target = instances[instances.length - 1];

    String name = randomNameOwnedBy(target, "reliableTopic");
    topic = (ReliableTopicProxy<String>) local.<String>getReliableTopic(name);
  }