當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。