当前位置: 首页>>代码示例>>Java>>正文


Java IList.add方法代码示例

本文整理汇总了Java中com.hazelcast.core.IList.add方法的典型用法代码示例。如果您正苦于以下问题:Java IList.add方法的具体用法?Java IList.add怎么用?Java IList.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hazelcast.core.IList的用法示例。


在下文中一共展示了IList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addRemoveItemListener

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test
@Ignore
public void addRemoveItemListener() throws InterruptedException {
    HazelcastClient hClient = getHazelcastClient();
    final IList<String> list = hClient.getList("addRemoveItemListenerList");
    final CountDownLatch addLatch = new CountDownLatch(4);
    final CountDownLatch removeLatch = new CountDownLatch(4);
    ItemListener<String> listener = new CountDownItemListener<String>(addLatch, removeLatch);
    list.addItemListener(listener, true);
    list.add("hello");
    list.add("hello");
    list.remove("hello");
    list.remove("hello");
    list.removeItemListener(listener);
    list.add("hello");
    list.add("hello");
    list.remove("hello");
    list.remove("hello");
    Thread.sleep(10);
    assertEquals(2, addLatch.getCount());
    assertEquals(2, removeLatch.getCount());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:23,代码来源:HazelcastClientListTest.java

示例2: iterate

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test
public void iterate() {
    HazelcastClient hClient = getHazelcastClient();
    IList<Integer> list = hClient.getList("iterate");
    list.add(1);
    list.add(2);
    list.add(2);
    list.add(3);
    assertEquals(4, list.size());
    Map<Integer, Integer> counter = new HashMap<Integer, Integer>();
    counter.put(1, 1);
    counter.put(2, 2);
    counter.put(3, 1);
    for (Iterator<Integer> iterator = list.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(list.isEmpty());
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:24,代码来源:HazelcastClientListTest.java

示例3: applyChange

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Override
public void applyChange(ConfigChangeRequest configChange) {
    if(readOnly){
        return;
    }
    IMap<String,String> config = hazelcastInstance.getMap(mapReference);
    for(Map.Entry<String, String> en: configChange.getAddedProperties().entrySet()){
        String metaVal = configChange.getAddedProperties().get("_" + en.getKey()+".ttl");
        if(metaVal!=null){
            try {
                long ms = Long.parseLong(metaVal);
                config.put(en.getKey(), en.getValue(), ms, TimeUnit.MILLISECONDS);
            }catch(Exception e){
                LOG.log(Level.WARNING, "Failed to parse TTL in millis: " + metaVal +
                        " for '"+ en.getKey()+"'", e);
                config.put(en.getKey(), en.getValue());
            }
        }else {
            config.put(en.getKey(), en.getValue());
        }
    }
    for(String key: configChange.getRemovedProperties()){
        config.remove(key);
    }
    IList<String> taList = hazelcastInstance.getList("_tamaya.transactions");
    taList.add(configChange.getTransactionID());
    config.put("_tamaya.transaction.lastId", configChange.getTransactionID(), 1, TimeUnit.DAYS);
    config.put("_tamaya.transaction.startedAt", String.valueOf(configChange.getStartedAt()), 1, TimeUnit.DAYS);
    config.flush();
    refresh();
}
 
开发者ID:apache,项目名称:incubator-tamaya-sandbox,代码行数:32,代码来源:HazelcastPropertySource.java

示例4: contains

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test
public void contains() {
    HazelcastClient hClient = getHazelcastClient();
    IList<Integer> list = hClient.getList("contains");
    int count = 100;
    for (int i = 0; i < count; i++) {
        list.add(i);
    }
    for (int i = 0; i < count; i++) {
        assertTrue(list.contains(i));
    }
    for (int i = count; i < 2 * count; i++) {
        assertFalse(list.contains(i));
    }
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:16,代码来源:HazelcastClientListTest.java

示例5: prepare

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Prepare(global = true)
public void prepare() {
    IList<Long> accounts = targetInstance.getList(name);
    for (int i = 0; i < maxAccounts; i++) {
        accounts.add(initialAccountValue);
    }
    totalInitialValue = initialAccountValue * maxAccounts;
    logger.info("totalInitialValue=" + totalInitialValue);
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:10,代码来源:TryLockTimeOutTest.java

示例6: testListMapper

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test( timeout = 30000 )
public void testListMapper()
    throws Exception
{
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory( 4 );
    final CountingManagedContext context = new CountingManagedContext();
    final Config config = new Config();
    config.setManagedContext( context );

    HazelcastInstance h1 = nodeFactory.newHazelcastInstance( config );
    HazelcastInstance h2 = nodeFactory.newHazelcastInstance( config );
    HazelcastInstance h3 = nodeFactory.newHazelcastInstance( config );

    IList<Integer> m1 = h1.getList( LIST_NAME );
    for ( int i = 0; i < 100; i++ )
    {
        m1.add( i );
    }

    MapReduceTaskFactory factory = MapReduceTaskFactory.newInstance( h1 );
    MapReduceTask<Integer, Integer, String, Integer> task = factory.build( m1 );
    Map<String, List<Integer>> result = task.mapper( new TestMapper() ).submit();
    assertEquals( 1, result.size() );
    for ( List<Integer> value : result.values() )
    {
        assertEquals( 100, value.size() );
    }

    Set<String> hazelcastNames = context.getHazelcastNames();
    assertEquals( 0, hazelcastNames.size() );
}
 
开发者ID:noctarius,项目名称:castmapr,代码行数:32,代码来源:IListMapReduceTest.java

示例7: testListMapperReducer

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test( timeout = 30000 )
public void testListMapperReducer()
    throws Exception
{
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory( 4 );
    final CountingManagedContext context = new CountingManagedContext();
    final Config config = new Config();
    config.setManagedContext( context );

    HazelcastInstance h1 = nodeFactory.newHazelcastInstance( config );
    HazelcastInstance h2 = nodeFactory.newHazelcastInstance( config );
    HazelcastInstance h3 = nodeFactory.newHazelcastInstance( config );

    int expectedResult = 0;
    IList<Integer> m1 = h1.getList( LIST_NAME );
    for ( int i = 0; i < 100; i++ )
    {
        m1.add( i );
        expectedResult += i;
    }

    MapReduceTaskFactory factory = MapReduceTaskFactory.newInstance( h1 );
    MapReduceTask<Integer, Integer, String, Integer> task = factory.build( m1 );
    Map<String, Integer> result = task.mapper( new TestMapper() ).reducer( new TestReducer() ).submit();

    assertEquals( 1, result.size() );
    for ( Integer value : result.values() )
    {
        assertEquals( expectedResult, (int) value );
    }

    Set<String> hazelcastNames = context.getHazelcastNames();
    assertEquals( 0, hazelcastNames.size() );
}
 
开发者ID:noctarius,项目名称:castmapr,代码行数:35,代码来源:IListMapReduceTest.java

示例8: testListMapperDistributedReducer

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test( timeout = 30000 )
public void testListMapperDistributedReducer()
    throws Exception
{
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory( 4 );
    final CountingManagedContext context = new CountingManagedContext();
    final Config config = new Config();
    config.setManagedContext( context );

    HazelcastInstance h1 = nodeFactory.newHazelcastInstance( config );
    HazelcastInstance h2 = nodeFactory.newHazelcastInstance( config );
    HazelcastInstance h3 = nodeFactory.newHazelcastInstance( config );

    int expectedResult = 0;
    IList<Integer> m1 = h1.getList( LIST_NAME );
    for ( int i = 0; i < 100; i++ )
    {
        m1.add( i );
        expectedResult += i;
    }

    MapReduceTaskFactory factory = MapReduceTaskFactory.newInstance( h1 );
    MapReduceTask<Integer, Integer, String, Integer> task = factory.build( m1 );
    Map<String, Integer> result =
        task.mapper( new TestMapper() ).reducer( new TestDistributableReducer() ).submit();

    assertEquals( 1, result.size() );
    for ( Integer value : result.values() )
    {
        assertEquals( expectedResult, (int) value );
    }

    Set<String> hazelcastNames = context.getHazelcastNames();
    assertEquals( 0, hazelcastNames.size() );
}
 
开发者ID:noctarius,项目名称:castmapr,代码行数:36,代码来源:IListMapReduceTest.java

示例9: testClientListMapper

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test( timeout = 30000 )
public void testClientListMapper()
    throws Exception
{
    final CountingManagedContext context = new CountingManagedContext();
    final Config config = new Config();
    config.setManagedContext( context );

    HazelcastInstance h1 = Hazelcast.newHazelcastInstance( config );
    HazelcastInstance h2 = Hazelcast.newHazelcastInstance( config );
    HazelcastInstance h3 = Hazelcast.newHazelcastInstance( config );

    HazelcastInstance client = HazelcastClient.newHazelcastClient( null );
    IList<Integer> m1 = client.getList( LIST_NAME );
    for ( int i = 0; i < 100; i++ )
    {
        m1.add( i );
    }

    MapReduceTaskFactory factory = MapReduceTaskFactory.newInstance( client );
    MapReduceTask<Integer, Integer, String, Integer> task = factory.build( m1 );
    Map<String, List<Integer>> result = task.mapper( new TestMapper() ).submit();
    assertEquals( 1, result.size() );
    for ( List<Integer> value : result.values() )
    {
        assertEquals( 100, value.size() );
    }

    Set<String> hazelcastNames = context.getHazelcastNames();
    assertEquals( 0, hazelcastNames.size() );
}
 
开发者ID:noctarius,项目名称:castmapr,代码行数:32,代码来源:IListMapReduceTest.java

示例10: testIssue73

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test
public void testIssue73() throws Exception {
    IList list = Hazelcast.getList("default");
    list.clear();

    Transaction txn1 = Hazelcast.getTransaction();
    txn1.begin();
    list.add("1");
    list.add("2");
    list.add("4");
    txn1.commit();

    assertEquals(3, list.size());
    assertEquals("1", list.get(0));
    assertEquals("2", list.get(1));
    assertEquals("4", list.get(2));

    Transaction txn2 = Hazelcast.getTransaction();
    txn2.begin();
    list.add(0, "0");
    list.add(3, "3");
    txn2.commit();

    assertEquals(5, list.size());
    assertEquals("0", list.get(0));
    assertEquals("1", list.get(1));
    assertEquals("2", list.get(2));
    assertEquals("3", list.get(3));
    assertEquals("4", list.get(4));
}
 
开发者ID:health-and-care-developer-network,项目名称:health-and-care-developer-network,代码行数:31,代码来源:ClusterListTest.java

示例11: fillList

import com.hazelcast.core.IList; //导入方法依赖的package包/类
static <R> void fillList(IList<R> list, Function<Integer, R> mapper) {
    for (int i = 0; i < COUNT; i++) {
        list.add(mapper.apply(i));
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:6,代码来源:AbstractStreamTest.java

示例12: fillListWithInts

import com.hazelcast.core.IList; //导入方法依赖的package包/类
protected static void fillListWithInts(IList<Integer> list, int count) {
    for (int i = 0; i < count; i++) {
        list.add(i);
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:6,代码来源:JetTestSupport.java

示例13: addNull

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test(expected = NullPointerException.class)
public void addNull() {
    HazelcastClient hClient = getHazelcastClient();
    IList<?> list = hClient.getList("addNull");
    list.add(null);
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:7,代码来源:HazelcastClientListTest.java

示例14: afterRun

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@AfterRun
public void afterRun(ThreadState state) {
    IList<TxnCounter> results = targetInstance.getList(name + "results");
    results.add(state.counter);
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:6,代码来源:TxnQueueWithLockTest.java

示例15: testAsyncListMapper

import com.hazelcast.core.IList; //导入方法依赖的package包/类
@Test( timeout = 30000 )
public void testAsyncListMapper()
    throws Exception
{
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory( 4 );
    final CountingManagedContext context = new CountingManagedContext();
    final Config config = new Config();
    config.setManagedContext( context );

    HazelcastInstance h1 = nodeFactory.newHazelcastInstance( config );
    HazelcastInstance h2 = nodeFactory.newHazelcastInstance( config );
    HazelcastInstance h3 = nodeFactory.newHazelcastInstance( config );

    IList<Integer> m1 = h1.getList( LIST_NAME );
    for ( int i = 0; i < 100; i++ )
    {
        m1.add( i );
    }

    final Map<String, List<Integer>> listenerResults = new HashMap<String, List<Integer>>();
    final Semaphore semaphore = new Semaphore( 1 );
    semaphore.acquire();

    MapReduceTaskFactory factory = MapReduceTaskFactory.newInstance( h1 );
    MapReduceTask<Integer, Integer, String, Integer> task = factory.build( m1 );
    task.mapper( new TestMapper() ).submitAsync( new MapReduceListener<String, List<Integer>>()
    {

        @Override
        public void onCompletion( Map<String, List<Integer>> reducedResults )
        {
            listenerResults.putAll( reducedResults );
            semaphore.release();
        }
    } );

    semaphore.acquire();

    assertEquals( 1, listenerResults.size() );
    for ( List<Integer> value : listenerResults.values() )
    {
        assertEquals( 100, value.size() );
    }

    Set<String> hazelcastNames = context.getHazelcastNames();
    assertEquals( 0, hazelcastNames.size() );
}
 
开发者ID:noctarius,项目名称:castmapr,代码行数:48,代码来源:IListMapReduceTest.java


注:本文中的com.hazelcast.core.IList.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。