This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | package gurbuz; | |
| import com.hazelcast.client.HazelcastClient; | |
| import com.hazelcast.client.config.ClientConfig; | |
| import com.hazelcast.config.Config; | |
| import com.hazelcast.config.GroupConfig; | |
| import com.hazelcast.config.MapConfig; | |
| import com.hazelcast.config.NearCacheConfig; | |
| import com.hazelcast.core.*; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | new Thread(){ | |
| public void run() { | |
| try { | |
| Thread.sleep(5000); | |
| System.err.println("starting cluster"); | |
| HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); | |
| HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); | |
| Thread.sleep(10000); | |
| System.err.println("shutting down cluster"); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class QueueMemoryLeak { | |
| static { | |
| System.setProperty(GroupProperties.PROP_WAIT_SECONDS_BEFORE_JOIN, "0"); | |
| System.setProperty("java.net.preferIPv4Stack", "true"); | |
| System.setProperty("hazelcast.local.localAddress", "127.0.0.1"); | |
| System.setProperty("hazelcast.version.check.enabled", "false"); | |
| System.setProperty("hazelcast.socket.bind.any", "false"); | |
| Random rand = new Random(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @Test | |
| public void testIssue1309() throws InterruptedException { | |
| final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); | |
| final CountDownLatch latch = new CountDownLatch(1); | |
| new Thread(){ | |
| public void run() { | |
| final IQueue<Integer> q = instance1.getQueue("q"); | |
| for (int i=1; i<=100; i++){ | |
| q.offer(i); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public static void testTopicWithDataSerializable() throws InterruptedException { | |
| final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); | |
| final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); | |
| final CountDownLatch latch = new CountDownLatch(1); | |
| final ITopic<ConfigurationChangeMessage> publisher = instance1.getTopic("message"); | |
| final ITopic<ConfigurationChangeMessage> consumer = instance2.getTopic("message"); | |
| byte[] val = new byte[256]; | |
| final Random random = new Random(System.currentTimeMillis()); | |
| random.nextBytes(val); | |
| final ConfigurationChangeMessage confMessage = new ConfigurationChangeMessage("type", "name", val); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | static void testCluster() throws InterruptedException { | |
| final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(); | |
| final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); | |
| Thread.sleep(10*60*1000); | |
| final HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(); | |
| final HazelcastInstance instance4 = Hazelcast.newHazelcastInstance(); | |
| final HazelcastInstance instance5 = Hazelcast.newHazelcastInstance(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class HazelcastClientUtils { | |
| private static HazelcastClient client = null; | |
| public static void init() { | |
| new Thread() { | |
| public void run() { | |
| while (true) { | |
| if (client == null) { | |
| createClient(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class QueueBackedByMap<I> implements IQueue<I> { | |
| final IQueue<Long> queue; | |
| final IMap<Long, I> map; | |
| final IdGenerator idGenerator; | |
| public QueueBackedByMap(HazelcastInstance instance, String name) { | |
| queue = instance.getQueue(name); | |
| map = instance.getMap(name); | |
| idGenerator = instance.getIdGenerator(name); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class QueueTest { | |
| public static void main(String[] args) throws InterruptedException { | |
| final HazelcastInstance instance = Hazelcast.newHazelcastInstance(); | |
| Thread c = new Thread(new Consumer(instance)); | |
| Thread p = new Thread(new Producer(instance)); | |
| c.start(); | |
| Thread.sleep(5000); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | static void testContainsKey() throws InterruptedException { | |
| final Config config = new Config(); | |
| final MapConfig mapConfig = config.getMapConfig("m"); | |
| mapConfig.setTimeToLiveSeconds(900); | |
| mapConfig.setNearCacheConfig(new NearCacheConfig().setTimeToLiveSeconds(900)); | |
| final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config); | |
| final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config); | 
OlderNewer