@Test
 public void values() throws InterruptedException {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> multiMap = hClient.getMultiMap("entrySet");
   Map<String, List<String>> valueKeyListMap = new HashMap<String, List<String>>();
   int count = 100;
   for (int i = 0; i < count; i++) {
     for (int j = 0; j <= i; j++) {
       String key = String.valueOf(i);
       String value = String.valueOf(j);
       multiMap.put(key, value);
       if (valueKeyListMap.get(value) == null) {
         valueKeyListMap.put(value, new ArrayList<String>());
       }
       valueKeyListMap.get(value).add(key);
     }
   }
   assertEquals(count * (count + 1) / 2, multiMap.size());
   Collection<String> collection = multiMap.values();
   assertEquals(count * (count + 1) / 2, collection.size());
   Iterator<String> iterator = collection.iterator();
   System.out.println(iterator.getClass());
   for (; iterator.hasNext(); ) {
     String value = iterator.next();
     assertNotNull(valueKeyListMap.get(value).remove(0));
     if (valueKeyListMap.get(value).size() == 0) {
       valueKeyListMap.remove(value);
     }
   }
   assertTrue(valueKeyListMap.isEmpty());
 }
  @Test
  public void test_construction_permutations() {
    for (int a = 0; a < 6; a++) {
      compare_order(newSet(a), setOf(a));
      for (int b = 0; b < 6; b++) {
        compare_order(newSet(a, b), setOf(a, b));
        for (int c = 0; c < 6; c++) {
          compare_order(newSet(a, b, c), setOf(a, b, c));
          for (int d = 0; d < 6; d++) {
            compare_order(newSet(a, b, c, d), setOf(a, b, c, d));
            for (int e = 0; e < 6; e++) {
              compare_order(newSet(a, b, c, d, e), setOf(a, b, c, d, e));
              for (int f = 0; f < 6; f++) {
                Integer[] elements = new Integer[] {a, b, c, d, e, f};
                Set<Integer> expected = newSet(elements);
                Collection<Integer> collection = Arrays.asList(elements);

                // setOf
                compare_order(expected, setOf(a, b, c, d, e, f));
                // asSet(array)
                compare_order(expected, asSet(elements));
                // asSet(collection)
                compare_order(expected, asSet(collection));
                // asSet(iterator)
                compare_order(expected, asSet(collection.iterator()));
              }
            }
          }
        }
      }
    }
  }
 @Test
 public void testNetworkConfig() {
   NetworkConfig networkConfig = config.getNetworkConfig();
   assertNotNull(networkConfig);
   assertEquals(5700, networkConfig.getPort());
   assertFalse(networkConfig.isPortAutoIncrement());
   final Collection<String> allowedPorts = networkConfig.getOutboundPortDefinitions();
   assertEquals(2, allowedPorts.size());
   Iterator portIter = allowedPorts.iterator();
   assertEquals("35000-35100", portIter.next());
   assertEquals("36000,36100", portIter.next());
   assertFalse(networkConfig.getJoin().getMulticastConfig().isEnabled());
   assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeoutSeconds(), 8);
   assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeToLive(), 16);
   assertFalse(networkConfig.getInterfaces().isEnabled());
   assertEquals(1, networkConfig.getInterfaces().getInterfaces().size());
   assertEquals("10.10.1.*", networkConfig.getInterfaces().getInterfaces().iterator().next());
   TcpIpConfig tcp = networkConfig.getJoin().getTcpIpConfig();
   assertNotNull(tcp);
   assertTrue(tcp.isEnabled());
   assertTrue(networkConfig.getSymmetricEncryptionConfig().isEnabled());
   final List<String> members = tcp.getMembers();
   assertEquals(members.toString(), 2, members.size());
   assertEquals("127.0.0.1:5700", members.get(0));
   assertEquals("127.0.0.1:5701", members.get(1));
   assertEquals("127.0.0.1:5700", tcp.getRequiredMember());
   AwsConfig aws = networkConfig.getJoin().getAwsConfig();
   assertFalse(aws.isEnabled());
   assertEquals("sample-access-key", aws.getAccessKey());
   assertEquals("sample-secret-key", aws.getSecretKey());
   assertEquals("sample-region", aws.getRegion());
   assertEquals("sample-group", aws.getSecurityGroupName());
   assertEquals("sample-tag-key", aws.getTagKey());
   assertEquals("sample-tag-value", aws.getTagValue());
 }
 // Check all iterators for correct size counts
 private void checkSizes(int expectedSize) {
   assertEquals("size()", _nbhm.size(), expectedSize);
   Collection<String> vals = _nbhm.values();
   checkSizes("values()", vals.size(), vals.iterator(), expectedSize);
   Set<String> keys = _nbhm.keySet();
   checkSizes("keySet()", keys.size(), keys.iterator(), expectedSize);
   Set<Entry<String, String>> ents = _nbhm.entrySet();
   checkSizes("entrySet()", ents.size(), ents.iterator(), expectedSize);
 }
  @Test
  public void testUserDefinedCompaction() throws Exception {
    Keyspace keyspace = Keyspace.open(KEYSPACE1);
    final String cfname = "Standard3"; // use clean(no sstable) CF
    ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cfname);

    // disable compaction while flushing
    cfs.disableAutoCompaction();

    final int ROWS_PER_SSTABLE = 10;
    for (int i = 0; i < ROWS_PER_SSTABLE; i++) {
      DecoratedKey key = Util.dk(String.valueOf(i));
      Mutation rm = new Mutation(KEYSPACE1, key.getKey());
      rm.add(
          cfname,
          Util.cellname("col"),
          ByteBufferUtil.EMPTY_BYTE_BUFFER,
          System.currentTimeMillis());
      rm.applyUnsafe();
    }
    cfs.forceBlockingFlush();
    Collection<SSTableReader> sstables = cfs.getSSTables();

    assertEquals(1, sstables.size());
    SSTableReader sstable = sstables.iterator().next();

    int prevGeneration = sstable.descriptor.generation;
    String file = new File(sstable.descriptor.filenameFor(Component.DATA)).getAbsolutePath();
    // submit user defined compaction on flushed sstable
    CompactionManager.instance.forceUserDefinedCompaction(file);
    // wait until user defined compaction finishes
    do {
      Thread.sleep(100);
    } while (CompactionManager.instance.getPendingTasks() > 0
        || CompactionManager.instance.getActiveCompactions() > 0);
    // CF should have only one sstable with generation number advanced
    sstables = cfs.getSSTables();
    assertEquals(1, sstables.size());
    assertEquals(prevGeneration + 1, sstables.iterator().next().descriptor.generation);
  }
 @Test
 public void testMultiMapPutAndGet() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> map = hClient.getMultiMap("testMultiMapPutAndGet");
   map.put("Hello", "World");
   Collection<String> values = map.get("Hello");
   assertEquals("World", values.iterator().next());
   map.put("Hello", "Europe");
   map.put("Hello", "America");
   map.put("Hello", "Asia");
   map.put("Hello", "Africa");
   map.put("Hello", "Antarctica");
   map.put("Hello", "Australia");
   values = map.get("Hello");
   assertEquals(7, values.size());
   assertTrue(map.containsKey("Hello"));
   assertFalse(map.containsKey("Hi"));
 }
 @Test
 public void get() throws InterruptedException {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, Integer> multiMap = hClient.getMultiMap("get");
   assertTrue(multiMap.put("a", 1));
   assertTrue(multiMap.put("a", 2));
   Map<Integer, CountDownLatch> map = new HashMap<Integer, CountDownLatch>();
   map.put(1, new CountDownLatch(1));
   map.put(2, new CountDownLatch(1));
   Collection<Integer> collection = multiMap.get("a");
   assertEquals(Values.class, collection.getClass());
   assertEquals(2, collection.size());
   for (Iterator<Integer> it = collection.iterator(); it.hasNext(); ) {
     Integer o = it.next();
     map.get(o).countDown();
   }
   assertTrue(map.get(1).await(10, TimeUnit.SECONDS));
   assertTrue(map.get(2).await(10, TimeUnit.SECONDS));
 }