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


Java Hazelcast.getMap方法代码示例

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


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

示例1: testMultipleLockUnLockFromDifferentCollector

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
/**
 * Test that if a different collector tries to unlock a lock held by another
 * collector it is blocked from doing so.
 * 
 * @throws Exception
 */
@Test
public void testMultipleLockUnLockFromDifferentCollector() throws Exception {

	IMap<String, LockValue> locksMap = Hazelcast.getMap(
			DistributedMapNames.MAP.LOCK_MEMORY_LOCKS_MAP.toString());
	
	final HazelcastLockMemory memory = new HazelcastLockMemory(locksMap);
	/**
	 * (long filePointer, long fileSize,int linePointer, String agentName,
	 * String fileName, String logType)
	 */
	final FileTrackingStatus status = new FileTrackingStatus(new Date(), 0L, 0L, 1,
			"agent1", "file1", "type1", new Date(), 1L);

	SyncPointer pointer = memory.setLock(status, "localhost1");
	assertNotNull(pointer);

	assertNull(memory.removeLock(pointer, "localhost2"));
	assertNotNull(memory.removeLock(pointer, "localhost1"));

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:28,代码来源:TestHazelcastLockMemory.java

示例2: init

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
public void init() {

        //Specific map time to live
        MapConfig myMapConfig = new MapConfig();
        myMapConfig.setName("cachetest");
        myMapConfig.setTimeToLiveSeconds(10);

        //Package config
        Config myConfig = new Config();
        myConfig.addMapConfig(myMapConfig);

        //Symmetric Encryption
        SymmetricEncryptionConfig symmetricEncryptionConfig = new SymmetricEncryptionConfig();
        symmetricEncryptionConfig.setAlgorithm("DESede");
        symmetricEncryptionConfig.setSalt("saltysalt");
        symmetricEncryptionConfig.setPassword("lamepassword");
        symmetricEncryptionConfig.setIterationCount(1337);

        //Weak Network config..
        NetworkConfig networkConfig = new NetworkConfig();
        networkConfig.setSymmetricEncryptionConfig(symmetricEncryptionConfig);

        myConfig.setNetworkConfig(networkConfig);

        Hazelcast.init(myConfig);

        cacheMap = Hazelcast.getMap("cachetest");
    }
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:29,代码来源:HazelcastSymmetric.java

示例3: testRemoveTimedoutLocks

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
/**
 * Create a lock and check when its timedout it is removed.
 * 
 * @throws Exception
 */
@Test
public void testRemoveTimedoutLocks() throws Exception {

	IMap<String, LockValue> locksMap = Hazelcast.getMap(
			DistributedMapNames.MAP.LOCK_MEMORY_LOCKS_MAP.toString());
	
	final HazelcastLockMemory memory = new HazelcastLockMemory(locksMap);
	/**
	 * (long filePointer, long fileSize,int linePointer, String agentName,
	 * String fileName, String logType)
	 */
	final FileTrackingStatus status = new FileTrackingStatus(new Date(), 0L, 0L, 1,
			"agent1", "file1", "type1", new Date(), 1L);

	SyncPointer pointer = memory.setLock(status, "localhost1");

	long timeStamp = memory.lockTimeStamp(status);

	assertEquals(pointer.getTimeStamp(), timeStamp);

	// sleep 1s
	Thread.sleep(1500L);

	memory.removeTimedOutLocks(1000L);

	assertNull(memory.removeLock(pointer, "localhost1"));

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:34,代码来源:TestHazelcastLockMemory.java

示例4: testMultipleLockRequestsConflict

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
/**
 * Test that a lock can only be given once to a collector.
 * 
 * @throws Exception
 */
@Test
public void testMultipleLockRequestsConflict() throws Exception {

	IMap<String, LockValue> locksMap = Hazelcast.getMap(
			DistributedMapNames.MAP.LOCK_MEMORY_LOCKS_MAP.toString());
	
	final HazelcastLockMemory memory = new HazelcastLockMemory(locksMap);
	/**
	 * (long filePointer, long fileSize,int linePointer, String agentName,
	 * String fileName, String logType)
	 */
	final FileTrackingStatus status = new FileTrackingStatus(new Date(), 0L, 0L, 1,
			"agent1", "file1", "type1", new Date(), 1L);

	final AtomicInteger lockCount = new AtomicInteger(0);

	int count = 100;
	final CountDownLatch latch = new CountDownLatch(count);

	ExecutorService service = Executors.newFixedThreadPool(count);
	for (int i = 0; i < count; i++) {
		service.submit(new Runnable() {
			public void run() {
				try {
					if (memory.setLock(status, "localhost") != null) {
						lockCount.incrementAndGet();
					}
				} catch (InterruptedException e) {
					e.printStackTrace();
				}

				latch.countDown();

			}
		});
	}

	latch.await();

	assertEquals(1, lockCount.get());

}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:48,代码来源:TestHazelcastLockMemory.java

示例5: testHazelcast

import com.hazelcast.core.Hazelcast; //导入方法依赖的package包/类
@Test
public void testHazelcast(){
	
	Map<String, String> map = Hazelcast.getMap("mymap");
	map.put("key1", "test1");
	
	
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:9,代码来源:FileTrackingStatusKeyTest.java


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