本文整理汇总了Java中org.infinispan.client.hotrod.RemoteCache.addClientListener方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteCache.addClientListener方法的具体用法?Java RemoteCache.addClientListener怎么用?Java RemoteCache.addClientListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.infinispan.client.hotrod.RemoteCache
的用法示例。
在下文中一共展示了RemoteCache.addClientListener方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
@Override
public InfinispanEventListener start(InfinispanConsumer consumer) {
if (consumer.getConfiguration().isSync()) {
throw new UnsupportedOperationException("Sync listeners not supported for remote caches.");
}
RemoteCache<?, ?> remoteCache = InfinispanUtil.asRemote(consumer.getCache());
InfinispanConfiguration configuration = consumer.getConfiguration();
InfinispanEventListener listener;
if (configuration.hasCustomListener()) {
listener = configuration.getCustomListener();
listener.setInfinispanConsumer(consumer);
} else {
listener = new InfinispanRemoteEventListener(consumer, configuration.getEventTypes());
}
remoteCache.addClientListener(listener);
listener.setCacheName(remoteCache.getName());
return listener;
}
示例2: main
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException {
// Create a configuration for a locally-running server
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer().host("127.0.0.1").port(ConfigurationProperties.DEFAULT_HOTROD_PORT);
// Connect to the server
RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
// Obtain the remote cache
RemoteCache<String, String> cache = cacheManager.getCache();
// Register a listener
MyListener listener = new MyListener();
cache.addClientListener(listener);
// Store some values
cache.put("key1", "value1");
cache.put("key2", "value2");
cache.put("key1", "newValue");
// Remote events are asynchronous, so wait a bit
Thread.sleep(1000);
// Remove listener
cache.removeClientListener(listener);
// Stop the cache manager and release all resources
cacheManager.stop();
}
示例3: main
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
// Create a configuration for a locally-running server
ConfigurationBuilder builder = new ConfigurationBuilder();
int BeosBankCacheAfricaPort = 11322;
builder.addServer().host("127.0.0.1").port(BeosBankCacheAfricaPort);
// Connect to the server
RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
// Obtain the remote cache
RemoteCache<String, Object> cache = cacheManager.getCache("beosbank-repl");
cache.addClientListener(new DatagridClientListener());
// Create a Money Transfer Object from XML Message using BeaoIO API
try {
StreamFactory factory = StreamFactory.newInstance();
factory.loadResource("mapping.xml");
Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");
String record;
// Read Transactions and put in cache
for (String inputFile : inputFileNames) {
record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
cache.put(mt.getId() + "", mt);
}
// Inspect the cache .
System.out.println(cache.size());
System.out.println(cache.get("3"));
// Stop the cache
cache.stop();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例4: main
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
// Create a configuration for a locally-running server
ConfigurationBuilder builder = new ConfigurationBuilder();
int BeosBankCacheAfricaPort = 11322;
builder.addServer().host("127.0.0.1").port(BeosBankCacheAfricaPort);
// Connect to the server
RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
// Obtain the remote cache
RemoteCache<String, Object> cache = cacheManager.getCache();
cache.addClientListener(new DatagridClientListener());
// Create a Money Transfer Object from XML Message using BeaoIO API
try {
StreamFactory factory = StreamFactory.newInstance();
factory.loadResource("mapping.xml");
Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");
String record;
// Read Transactions and put in cache
for (String inputFile : inputFileNames) {
record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
cache.put(mt.getId() + "", mt);
}
// Inspect the cache .
System.out.println(cache.size());
System.out.println(cache.get("3"));
// Stop the cache
cache.stop();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例5: main
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
// Create a configuration for a locally-running server
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer().host("127.0.0.1").port(ConfigurationProperties.DEFAULT_HOTROD_PORT);
// Connect to the server
RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
// Obtain the remote cache
RemoteCache<String, Object> cache = cacheManager.getCache();
cache.addClientListener(new DatagridClientListener());
// Create a Money Transfer Object from XML Message using BeaoIO API
try {
StreamFactory factory = StreamFactory.newInstance();
factory.loadResource("mapping.xml");
Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");
String record;
// Read Transactions and put in cache
for (String inputFile : inputFileNames) {
record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
cache.put(mt.getId() + "", mt);
}
// Inspect the cache .
System.out.println(cache.size());
System.out.println(cache.get("3"));
// Stop the cache
cache.stop();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例6: main
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer().host(ISPN_IP).port(ConfigurationProperties.DEFAULT_HOTROD_PORT);
RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
RemoteCache<String, byte[]> cacheImg = cacheManager.getCache(IMAGE_CACHE_NAME);
RemoteCache<String, String> jpgCache = cacheManager.getCache(JPG_CACHE_NAME);
RemoteCache<String, String> resultCache = cacheManager.getCache(RESULT_CACHE_NAME);
cacheImg.addClientListener(new MnistListener(MODEL_PATH, CHECKPOINT_PATH, jpgCache, resultCache));
System.out.printf("Client will be listening for %d minutes\n", DURATION);
Thread.sleep(TimeUnit.MINUTES.toMillis(DURATION));
cacheManager.stop();
}
示例7: execute
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
@Override
public void execute(String restOfTheLine) throws Exception {
RemoteCache defaultCache = insureConnected();
//noinspection unchecked
Set<Object> listeners = defaultCache.getListeners();
if (!listeners.isEmpty()) {
throw new UserErrorException("a listener has been already registered");
}
defaultCache.addClientListener(new CacheClientListener());
//defaultCache.addClientListener(new StatisticsEnabledCacheClientListener());
}
示例8: main
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
// Create a configuration for a locally-running server
ConfigurationBuilder builder = new ConfigurationBuilder();
int BeosBankCacheAfricaPort = 11322;
builder.addServer().host("127.0.0.1").port(BeosBankCacheAfricaPort);
// Connect to the server
RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
// Obtain the remote cache
RemoteCache<String, Object> cache = cacheManager.getCache("beosbank-repl");
cache.addClientListener(new DatagridClientListener());
// Create a Money Transfer Object from XML Message using BeaoIO API
try {
StreamFactory factory = StreamFactory.newInstance();
factory.loadResource("mapping.xml");
Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");
String record;
// Read Transactions and put in cache
for (String inputFile : inputFileNames) {
record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
cache.put(mt.getId() + "", mt);
}
// Inspect the cache .
System.out.println(cache.size());
System.out.println(cache.get("3"));
// Stop the cache
cache.stop();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例9: main
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) {
// Create a configuration for a locally-running server
ConfigurationBuilder builder = new ConfigurationBuilder();
int BeosBankCacheAfricaPort = 11322;
builder.addServer().host("127.0.0.1").port(BeosBankCacheAfricaPort);
// Connect to the server
RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build());
// Obtain the remote cache
RemoteCache<String, Object> cache = cacheManager.getCache("beosbank-repl");
cache.addClientListener(new DatagridClientListener());
// Create a Money Transfer Object from XML Message using BeaoIO API
try {
StreamFactory factory = StreamFactory.newInstance();
factory.loadResource("mapping.xml");
Unmarshaller unmarshaller = factory.createUnmarshaller("MoneyTransferStream");
String record;
// Read Transactions and put in cache
for (String inputFile : inputFileNames) {
record = FileUtils.getContentsAsString(new File(INPUT_DIR + inputFile));
MoneyTransfert mt = (MoneyTransfert) unmarshaller.unmarshal(record);
cache.put(mt.getId() + "", mt);
}
// Inspect the cache .
System.out.println(cache.size());
System.out.println(cache.get("3"));
// Stop the cache
cache.stop();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}