Java 类com.hazelcast.core.ISet 实例源码

项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
    public void destroy() {
        HazelcastClient hClient = getHazelcastClient();
        ISet<Integer> set = hClient.getSet("destroy");
        for (int i = 0; i < 100; i++) {
            assertTrue(set.add(i));
        }
        ISet<Integer> set2 = hClient.getSet("destroy");
        assertTrue(set == set2);
        assertTrue(set.getId().equals(set2.getId()));
        set.destroy();
        set2 = hClient.getSet("destroy");
        assertFalse(set == set2);
//        for(int i=0;i<100;i++){
//          assertNull(list2.get(i));
//        }
    }
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void size() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("size");
    int count = 100;
    assertTrue(set.isEmpty());
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    assertEquals(count, set.size());
    for (int i = 0; i < count / 2; i++) {
        assertFalse(set.add(i));
    }
    assertFalse(set.isEmpty());
    assertEquals(count, set.size());
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void remove() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("remove");
    int count = 100;
    assertTrue(set.isEmpty());
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    assertEquals(count, set.size());
    for (int i = 0; i < count; i++) {
        assertTrue(set.remove((Object) i));
    }
    assertTrue(set.isEmpty());
    for (int i = count; i < 2 * count; i++) {
        assertFalse(set.remove((Object) i));
    }
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void iterate() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("iterate");
    set.add(1);
    set.add(2);
    set.add(2);
    set.add(3);
    assertEquals(3, set.size());
    Map<Integer, Integer> counter = new HashMap<Integer, Integer>();
    counter.put(1, 1);
    counter.put(2, 1);
    counter.put(3, 1);
    for (Iterator<Integer> iterator = set.iterator(); iterator.hasNext(); ) {
        Integer integer = iterator.next();
        counter.put(integer, counter.get(integer) - 1);
        iterator.remove();
    }
    assertEquals(Integer.valueOf(0), counter.get(1));
    assertEquals(Integer.valueOf(0), counter.get(2));
    assertEquals(Integer.valueOf(0), counter.get(3));
    assertTrue(set.isEmpty());
}
项目:hazelcast-examples    文件:HazelcastSetInterpreter.java   
@Override
protected void execute(String... args) {
    withHazelcast(hazelcast -> {
        String name = "default";
        ISet<Integer> set = hazelcast.getSet(name);

        if (args.length > 0) {
            if ("master".equals(args[0])) {
                IntStream.rangeClosed(1, 10).forEach(set::add);
            }
        }

        readConsoleWhile(hazelcast,
                name,
                () -> {
                    set.forEach(e -> show("element = %d.", e));
                    return null;
                },
                set::size);
    });
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
    public void destroy() {
        HazelcastClient hClient = getHazelcastClient();
        ISet<Integer> set = hClient.getSet("destroy");
        for (int i = 0; i < 100; i++) {
            assertTrue(set.add(i));
        }
        ISet<Integer> set2 = hClient.getSet("destroy");
        assertTrue(set == set2);
        assertTrue(set.getId().equals(set2.getId()));
        set.destroy();
        set2 = hClient.getSet("destroy");
        assertFalse(set == set2);
//        for(int i=0;i<100;i++){
//          assertNull(list2.get(i));
//        }
    }
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void size() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("size");
    int count = 100;
    assertTrue(set.isEmpty());
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    assertEquals(count, set.size());
    for (int i = 0; i < count / 2; i++) {
        assertFalse(set.add(i));
    }
    assertFalse(set.isEmpty());
    assertEquals(count, set.size());
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void remove() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("remove");
    int count = 100;
    assertTrue(set.isEmpty());
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    assertEquals(count, set.size());
    for (int i = 0; i < count; i++) {
        assertTrue(set.remove((Object) i));
    }
    assertTrue(set.isEmpty());
    for (int i = count; i < 2 * count; i++) {
        assertFalse(set.remove((Object) i));
    }
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void iterate() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("iterate");
    set.add(1);
    set.add(2);
    set.add(2);
    set.add(3);
    assertEquals(3, set.size());
    Map<Integer, Integer> counter = new HashMap<Integer, Integer>();
    counter.put(1, 1);
    counter.put(2, 1);
    counter.put(3, 1);
    for (Iterator<Integer> iterator = set.iterator(); iterator.hasNext(); ) {
        Integer integer = iterator.next();
        counter.put(integer, counter.get(integer) - 1);
        iterator.remove();
    }
    assertEquals(Integer.valueOf(0), counter.get(1));
    assertEquals(Integer.valueOf(0), counter.get(2));
    assertEquals(Integer.valueOf(0), counter.get(3));
    assertTrue(set.isEmpty());
}
项目:ahome-tooling-server-hazelcast    文件:HazelcastContextInstance.java   
@Override
@SuppressWarnings("unchecked")
public <E> ISet<E> getISet(String name)
{
    name = Objects.requireNonNull(name);

    final ISet<E> valu = getBeanSafely(name, ISet.class);

    if (null != valu)
    {
        return valu;
    }
    return hz().getSet(name);
}
项目:hazelcast-archive    文件:SetClientProxy.java   
@Override
public boolean equals(Object o) {
    if (o instanceof ISet && o != null) {
        return getName().equals(((ISet) o).getName());
    } else {
        return false;
    }
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void addRemoveItemListener() throws InterruptedException {
    HazelcastClient hClient = getHazelcastClient();
    final ISet<String> set = hClient.getSet("addRemoveItemListenerSet");
    final CountDownLatch addLatch = new CountDownLatch(2);
    final CountDownLatch removeLatch = new CountDownLatch(2);
    ItemListener<String> listener = new CountDownItemListener<String>(addLatch, removeLatch);
    set.addItemListener(listener, true);
    set.add("hello");
    set.add("hello");
    set.remove("hello");
    set.remove("hello");
    for (int i = 0; i < 100; i++) {
        if (removeLatch.getCount() != 1 || addLatch.getCount() != 1) {
            Thread.sleep(50);
        } else {
            break;
        }
    }
    assertEquals(1, removeLatch.getCount());
    assertEquals(1, addLatch.getCount());
    set.removeItemListener(listener);
    set.add("hello");
    set.add("hello");
    set.remove("hello");
    set.remove("hello");
    Thread.sleep(50);
    assertEquals(1, addLatch.getCount());
    assertEquals(1, removeLatch.getCount());
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void add() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("add");
    int count = 100;
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    for (int i = 0; i < count; i++) {
        assertFalse(set.add(i));
    }
    assertEquals(count, set.size());
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void contains() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("contains");
    int count = 100;
    for (int i = 0; i < count; i++) {
        set.add(i);
    }
    for (int i = 0; i < count; i++) {
        assertTrue(set.contains(i));
    }
    for (int i = count; i < 2 * count; i++) {
        assertFalse(set.contains(i));
    }
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void addAll() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("addAll");
    List<Integer> arr = new ArrayList<Integer>();
    int count = 100;
    for (int i = 0; i < count; i++) {
        arr.add(i);
    }
    assertTrue(set.addAll(arr));
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void containsAll() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("containsAll");
    List<Integer> arrList = new ArrayList<Integer>();
    int count = 100;
    for (int i = 0; i < count; i++) {
        arrList.add(i);
    }
    assertTrue(set.addAll(arrList));
    assertTrue(set.containsAll(arrList));
    arrList.set((int) count / 2, count + 1);
    assertFalse(set.containsAll(arrList));
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void clear() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("clear");
    int count = 100;
    assertTrue(set.isEmpty());
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    assertEquals(count, set.size());
    set.clear();
    assertTrue(set.isEmpty());
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void removeAll() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("removeAll");
    List<Integer> arrList = new ArrayList<Integer>();
    int count = 100;
    for (int i = 0; i < count; i++) {
        arrList.add(i);
    }
    assertTrue(set.addAll(arrList));
    assertTrue(set.removeAll(arrList));
    assertFalse(set.removeAll(arrList.subList(0, count / 10)));
}
项目:health-and-care-developer-network    文件:SetClientProxy.java   
@Override
public boolean equals(Object o) {
    if (o instanceof ISet && o != null) {
        return getName().equals(((ISet) o).getName());
    } else {
        return false;
    }
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void addRemoveItemListener() throws InterruptedException {
    HazelcastClient hClient = getHazelcastClient();
    final ISet<String> set = hClient.getSet("addRemoveItemListenerSet");
    final CountDownLatch addLatch = new CountDownLatch(2);
    final CountDownLatch removeLatch = new CountDownLatch(2);
    ItemListener<String> listener = new CountDownItemListener<String>(addLatch, removeLatch);
    set.addItemListener(listener, true);
    set.add("hello");
    set.add("hello");
    set.remove("hello");
    set.remove("hello");
    for (int i = 0; i < 100; i++) {
        if (removeLatch.getCount() != 1 || addLatch.getCount() != 1) {
            Thread.sleep(50);
        } else {
            break;
        }
    }
    assertEquals(1, removeLatch.getCount());
    assertEquals(1, addLatch.getCount());
    set.removeItemListener(listener);
    set.add("hello");
    set.add("hello");
    set.remove("hello");
    set.remove("hello");
    Thread.sleep(50);
    assertEquals(1, addLatch.getCount());
    assertEquals(1, removeLatch.getCount());
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void add() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("add");
    int count = 100;
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    for (int i = 0; i < count; i++) {
        assertFalse(set.add(i));
    }
    assertEquals(count, set.size());
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void contains() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("contains");
    int count = 100;
    for (int i = 0; i < count; i++) {
        set.add(i);
    }
    for (int i = 0; i < count; i++) {
        assertTrue(set.contains(i));
    }
    for (int i = count; i < 2 * count; i++) {
        assertFalse(set.contains(i));
    }
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void addAll() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("addAll");
    List<Integer> arr = new ArrayList<Integer>();
    int count = 100;
    for (int i = 0; i < count; i++) {
        arr.add(i);
    }
    assertTrue(set.addAll(arr));
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void containsAll() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("containsAll");
    List<Integer> arrList = new ArrayList<Integer>();
    int count = 100;
    for (int i = 0; i < count; i++) {
        arrList.add(i);
    }
    assertTrue(set.addAll(arrList));
    assertTrue(set.containsAll(arrList));
    arrList.set((int) count / 2, count + 1);
    assertFalse(set.containsAll(arrList));
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void clear() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("clear");
    int count = 100;
    assertTrue(set.isEmpty());
    for (int i = 0; i < count; i++) {
        assertTrue(set.add(i));
    }
    assertEquals(count, set.size());
    set.clear();
    assertTrue(set.isEmpty());
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void removeAll() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<Integer> set = hClient.getSet("removeAll");
    List<Integer> arrList = new ArrayList<Integer>();
    int count = 100;
    for (int i = 0; i < count; i++) {
        arrList.add(i);
    }
    assertTrue(set.addAll(arrList));
    assertTrue(set.removeAll(arrList));
    assertFalse(set.removeAll(arrList.subList(0, count / 10)));
}
项目:xm-ms-entity    文件:WebConfigurerIntTest.java   
@Override
public <E> ISet<E> getSet(String s) {
    return null;
}
项目:lannister    文件:Hazelcast.java   
public <V> ISet<V> getSet(String name) {
    return substance.getSet(name);
}
项目:Camel    文件:HazelcastSetConsumer.java   
public HazelcastSetConsumer(HazelcastInstance hazelcastInstance, Endpoint endpoint, Processor processor, String cacheName) {
    super(hazelcastInstance, endpoint, processor, cacheName);

    ISet<Object> set = hazelcastInstance.getSet(cacheName);
    set.addItemListener(new CamelItemListener(this, cacheName), true);
}
项目:DSC    文件:HazelcastService.java   
@Override
public <T> ISet<T> getSet(String SetName) {
    ISet<T> set = client.getSet(SetName);
    return set;
}
项目:quartz-scheduler-hazelcast-jobstore    文件:HazelcastJobStore.java   
protected ISet getSet(String name) {
  return hazelcastClient.getSet(name);
}
项目:microservices-sample    文件:HazelcastServiceRegistry.java   
@Override
public <S> void register(PublishedServiceInfo<S> serviceInfo) {
    //when a service register itself, all other processes will be notified (thanks to Hazelcast)
    ISet<Object> set = hazelcastInstance.getSet(PUBLISHED_SERVICES);
    set.add(serviceInfo);
}
项目:microservices-sample    文件:HazelcastServiceRegistry.java   
@Override
public <S> void deRegister(PublishedServiceInfo<S> serviceInfo) {
    ISet<Object> set = hazelcastInstance.getSet(PUBLISHED_SERVICES);
    set.remove(serviceInfo);
}
项目:Cherry    文件:HazelcastService.java   
@Override
public <E> ISet<E> getSet(final String name) {
  return getHazelcastInstance().getSet(name);
}
项目:hazelcast-archive    文件:SetMBean.java   
public SetMBean(ISet<?> managedObject, ManagementService managementService) {
    super(managedObject, managementService);
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test(expected = NullPointerException.class)
public void testAddNull() throws InterruptedException {
    HazelcastClient hClient = getHazelcastClient();
    ISet<?> set = hClient.getSet("testAddNull");
    set.add(null);
}
项目:hazelcast-archive    文件:HazelcastClientSetTest.java   
@Test
public void getSetName() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<String> set = hClient.getSet("getSetName");
    assertEquals("getSetName", set.getName());
}
项目:health-and-care-developer-network    文件:SetMBean.java   
public SetMBean(ISet<?> managedObject, ManagementService managementService) {
    super(managedObject, managementService);
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test(expected = NullPointerException.class)
public void testAddNull() throws InterruptedException {
    HazelcastClient hClient = getHazelcastClient();
    ISet<?> set = hClient.getSet("testAddNull");
    set.add(null);
}
项目:health-and-care-developer-network    文件:HazelcastClientSetTest.java   
@Test
public void getSetName() {
    HazelcastClient hClient = getHazelcastClient();
    ISet<String> set = hClient.getSet("getSetName");
    assertEquals("getSetName", set.getName());
}