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


Java EmbeddedCacheManager.start方法代码示例

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


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

示例1: testStart

import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
/**
 * Run multiple instances and check that all instances are online.
 * 
 * @throws ExecutionException 
 * @throws TimeoutException 
 */
@Test
public void testStart() throws IOException, InterruptedException, ExecutionException {
	int nodeNumber = 3;
	prepareCluster(nodeNumber, null);
	
	// start test instance
	EmbeddedCacheManager cacheManager = new TestCacheManagerBuilder("node main", null).build();
	this.cacheManager = cacheManager;
	cacheManager.start();
	
	LOGGER.debug("waiting nodes");
	try {
		waitNodes(cacheManager, nodeNumber + 1, 30, TimeUnit.SECONDS);
	} catch (TimeoutException e) {
		Assert.fail(String.format("Node number %d not reached before timeout", nodeNumber + 1));
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:24,代码来源:TestSimpleCluster.java

示例2: run

import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
@Override
public void run() {
	final EmbeddedCacheManager cacheManager = new TestCacheManagerBuilder(nodeName, taskName).build();
	cacheManager.start();
	
	while (!Thread.currentThread().isInterrupted()) {
		try {
			Object object = new Object();
			// synchronized to become object owner
			LOGGER.debug("Start main loop");
			synchronized (object) {
				object.wait();
			}
		} catch (InterruptedException e) {
			LOGGER.warn("Thread interrupted while wait");
			Thread.currentThread().interrupt();
		}
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:20,代码来源:SimpleProcess.java

示例3: testConfigBuilder

import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
public void testConfigBuilder() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).location(tmpDataDirectory)
         .expiredLocation(tmpExpiredDirectory).implementationType(LevelDBStoreConfiguration.ImplementationType.AUTO).build();

   StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
   assertTrue(cacheLoaderConfig instanceof LevelDBStoreConfiguration);
   LevelDBStoreConfiguration leveldbConfig = (LevelDBStoreConfiguration) cacheLoaderConfig;
   assertEquals(tmpDataDirectory, leveldbConfig.location());
   assertEquals(tmpExpiredDirectory, leveldbConfig.expiredLocation());

   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there");
   cache.stop();
   cacheManager.stop();
}
 
开发者ID:danberindei,项目名称:infinispan-cachestore-leveldb,代码行数:24,代码来源:ConfigurationTest.java

示例4: testLegacyJavaConfig

import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
@Test(enabled = false, description = "ISPN-3388")
public void testLegacyJavaConfig() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(LevelDBStoreConfigurationBuilder.class).addProperty("location", tmpDataDirectory)
         .addProperty("expiredLocation", tmpExpiredDirectory).addProperty("implementationType", LevelDBStoreConfiguration.ImplementationType.AUTO.toString()).build();

   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there legacy java");
   cache.stop();
   cacheManager.stop();
}
 
开发者ID:danberindei,项目名称:infinispan-cachestore-leveldb,代码行数:19,代码来源:ConfigurationTest.java

示例5: testConfigBuilder

import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
public void testConfigBuilder() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(MapDBStoreConfigurationBuilder.class)
         .location(tmpDirectory)
         .compression(true)
         .build();

   StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
   assertTrue(cacheLoaderConfig instanceof MapDBStoreConfiguration);
   MapDBStoreConfiguration config = (MapDBStoreConfiguration) cacheLoaderConfig;
   assertEquals(true, config.compression());
   
   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there");
   cache.stop();
   cacheManager.stop();
}
 
开发者ID:saturnism,项目名称:infinispan-cachestore-mapdb,代码行数:25,代码来源:ConfigurationTest.java

示例6: testConfigBuilder

import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
public void testConfigBuilder() {
   GlobalConfiguration globalConfig = new GlobalConfigurationBuilder().globalJmxStatistics().transport().defaultTransport().build();

   Configuration cacheConfig = new ConfigurationBuilder().persistence().addStore(OffheapStoreConfigurationBuilder.class)
         .compression(true)
         .build();

   StoreConfiguration cacheLoaderConfig = cacheConfig.persistence().stores().get(0);
   assertTrue(cacheLoaderConfig instanceof OffheapStoreConfiguration);
   OffheapStoreConfiguration config = (OffheapStoreConfiguration) cacheLoaderConfig;
   assertEquals(true, config.compression());
   
   EmbeddedCacheManager cacheManager = new DefaultCacheManager(globalConfig);

   cacheManager.defineConfiguration("testCache", cacheConfig);

   cacheManager.start();
   Cache<String, String> cache = cacheManager.getCache("testCache");

   cache.put("hello", "there");
   cache.stop();
   cacheManager.stop();
}
 
开发者ID:saturnism,项目名称:infinispan-cachestore-offheap,代码行数:24,代码来源:ConfigurationTest.java

示例7: testMessage

import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
/**
 * Simple messaging test.
 * 
 * @throws IOException
 * @throws InterruptedException
 * @throws ExecutionException
 * @throws TimeoutException
 */
@Test
public void testMessage() throws IOException, InterruptedException, ExecutionException, TimeoutException {
	final int nodeNumber = 3;
	
	// start test instance
	EmbeddedCacheManager cacheManager = new TestCacheManagerBuilder("node main", null).build();
	this.cacheManager = cacheManager;
	
	final Object monitor = new Object();
	final Map<Address, String> messages = Maps.newConcurrentMap();
	
	cacheManager.start();
	cacheManager.getCache(TestConstants.CACHE_DEFAULT).addListener(new NodeMessageListener<String>() {
		@Override
		public void onMessage(Message<String> value) {
			messages.put(value.getAddress(), value.getMessage());
			synchronized (monitor) {
				monitor.notify();
			}
		}
	});
	
	prepareCluster(nodeNumber, SimpleMessagingTask.class);
	
	// wait for n (n=nodeNumber) messages
	Callable<Boolean> test = new Callable<Boolean>() {
		@Override
		public Boolean call() throws Exception {
			return messages.keySet().size() >= nodeNumber;
		}
	};
	waitForEvent(monitor, test, 10, TimeUnit.SECONDS);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:42,代码来源:TestMessage.java

示例8: testMessage

import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
/**
 * Simple messaging test with other nodes' restart.
 * 
 * @throws IOException
 * @throws InterruptedException
 * @throws ExecutionException
 * @throws TimeoutException
 */
@Test
public void testMessage() throws IOException, InterruptedException, ExecutionException, TimeoutException {
	final int nodeNumber = 3;
	
	// start test instance
	final EmbeddedCacheManager cacheManager = new TestCacheManagerBuilder("node main", null).build();
	this.cacheManager = cacheManager;
	
	final Object monitor = new Object();
	final Map<Address, String> messages = Maps.newConcurrentMap();
	
	cacheManager.start();
	cacheManager.getCache(TestConstants.CACHE_DEFAULT).addListener(new NodeMessageListener<String>() {
		@Override
		public void onMessage(Message<String> value) {
			messages.put(value.getAddress(), value.getMessage());
			synchronized (monitor) {
				monitor.notify();
			}
		}
	});
	
	// SimpleMessagingTask: on connect, each node send a message
	prepareCluster(nodeNumber, SimpleMessagingTask.class);
	
	// wait for n (n=nodeNumber) messages
	Callable<Boolean> testOne = new Callable<Boolean>() {
		@Override
		public Boolean call() throws Exception {
			return messages.keySet().size() == nodeNumber;
		}
	};
	// wait for messages from other nodes
	waitForEvent(monitor, testOne, 10, TimeUnit.SECONDS);
	
	// shutdown all nodes
	shutdownProcesses(false);
	
	// wait alone state (1 node)
	Callable<Boolean> aloneTest = new Callable<Boolean>() {
		@Override
		public Boolean call() throws Exception {
			return cacheManager.getMembers().size() == 1;
		}
	};
	waitForEvent(monitor, aloneTest, 20, TimeUnit.SECONDS);
	
	// start new nodes
	prepareCluster(nodeNumber, SimpleMessagingTask.class);
	
	// wait joining nodes
	Callable<Boolean> allTest = new Callable<Boolean>() {
		@Override
		public Boolean call() throws Exception {
			return cacheManager.getMembers().size() == 4;
		}
	};
	waitForEvent(monitor, allTest, 20, TimeUnit.SECONDS);
	
	// wait 6 messages (as new nodes use new addresses, new messages are added)
	Callable<Boolean> testTwo = new Callable<Boolean>() {
		@Override
		public Boolean call() throws Exception {
			return messages.keySet().size() == 6;
		}
	};
	waitForEvent(monitor, testTwo, 10, TimeUnit.SECONDS);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:77,代码来源:TestRestart.java

示例9: testBatch

import org.infinispan.manager.EmbeddedCacheManager; //导入方法依赖的package包/类
/**
 * Test {@link AdvancedCache#startBatch()} (to handle concurrent read / update).
 * We lock to keys (A and B) and asks for second nodes (using message) to confirm that these keys cannot be locked
 * concurrently.
 * After keys' release, confirm that second node can now lock these keys.
 * 
 * @throws IOException
 * @throws InterruptedException
 * @throws TimeoutException
 * @throws ExecutionException
 */
@Test
public void testBatch() throws IOException, InterruptedException, TimeoutException, ExecutionException {
	// start infinispan
	final int nodeNumber = 1;
	
	// start test instance
	final EmbeddedCacheManager cacheManager = new TestCacheManagerBuilder("node main", null).build();
	this.cacheManager = cacheManager;
	
	final Object monitor = new Object();
	final Map<Address, String> messages = Maps.newConcurrentMap();
	
	cacheManager.start();
	cacheManager.getCache(TestConstants.CACHE_MESSAGE).addListener(new NodeMessageListener<String>() {
		@Override
		public void onMessage(Message<String> value) {
			messages.put(value.getAddress(), value.getMessage());
			synchronized (monitor) {
				monitor.notify();
			}
		}
	});
	// initializes two keys A and B
	cacheManager.getCache(TestConstants.CACHE_DEFAULT).put("A", "A");
	cacheManager.getCache(TestConstants.CACHE_DEFAULT).put("B", "B");
	
	// start another node that register a task that waits a message to lock A and B
	prepareCluster(nodeNumber, LockTask.class);
	
	// startBatch
	AdvancedCache<Object, Object> cache = cacheManager.<Object, Object>getCache(TestConstants.CACHE_DEFAULT).getAdvancedCache();
	cache.startBatch();
	boolean successful = false;
	final Address address = cacheManager.getAddress();
	
	Callable<Boolean> test = new Callable<Boolean>() {
		@Override
		public Boolean call() throws Exception {
			return ! address.equals(cacheManager.<String, Message<String>>getCache(TestConstants.CACHE_MESSAGE).get(TestConstants.CACHE_KEY_MESSAGE_BUS).getAddress());
		}
	};
	
	try {
		// lock A and B
		cache.lock("A", "B");
		// send message -> second node cannot lock -> message TimeoutException
		cacheManager.getCache(TestConstants.CACHE_MESSAGE).put(TestConstants.CACHE_KEY_MESSAGE_BUS, Message.from(address, LockTask.TRY_LOCK));
		// must be set accordingly with lockAcquisitionTimeout
		waitForEvent(monitor, test, 25, TimeUnit.SECONDS);
		Assert.assertEquals(LockTask.TIMEOUT_EXCEPTION, cacheManager.<String, Message<String>>getCache(TestConstants.CACHE_MESSAGE).get(TestConstants.CACHE_KEY_MESSAGE_BUS).getMessage());
		successful = true;
	} finally {
		// stopBatch
		cache.endBatch(successful);
	}
	// second node can lock
	cacheManager.getCache(TestConstants.CACHE_MESSAGE).put(TestConstants.CACHE_KEY_MESSAGE_BUS, Message.from(address, LockTask.TRY_LOCK));
	// must be set accordingly with lockAcquisitionTimeout
	waitForEvent(monitor, test, 25, TimeUnit.SECONDS);
	Assert.assertEquals(LockTask.LOCK_SUCCESS, cacheManager.<String, Message<String>>getCache(TestConstants.CACHE_MESSAGE).get(TestConstants.CACHE_KEY_MESSAGE_BUS).getMessage());
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:73,代码来源:TestTransaction.java


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