本文整理汇总了Java中org.infinispan.client.hotrod.RemoteCache.put方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteCache.put方法的具体用法?Java RemoteCache.put怎么用?Java RemoteCache.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.infinispan.client.hotrod.RemoteCache
的用法示例。
在下文中一共展示了RemoteCache.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerProtoBufSchema
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
private void registerProtoBufSchema() {
SerializationContext serCtx = ProtoStreamMarshaller.getSerializationContext(cacheManager);
String generatedSchema = null;
try {
ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder();
generatedSchema = protoSchemaBuilder.fileName("heschema.proto").packageName("model")
.addClass(HEElementModel.class).addClass(HEElementCategoryModel.class).build(serCtx);
// register the schemas with the server too
RemoteCache<String, String> metadataCache = cacheManager
.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put("heschema.proto", generatedSchema);
} catch (Exception e1) {
StringBuilder sb = new StringBuilder();
sb.append("No schema generated because of Exception");
log.error(sb.toString(), e1);
}
log.debug(generatedSchema);
}
示例2: setUp
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
@Before
public void setUp() {
ConfigurationBuilder builder = new ConfigurationBuilder().addServer().host("localhost").port(11222)
.marshaller(new ProtoStreamMarshaller());
cacheManager = new RemoteCacheManager(builder.build());
SerializationContext serCtx = ProtoStreamMarshaller.getSerializationContext(cacheManager);
ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder();
String memoSchemaFile = null;
try {
memoSchemaFile = protoSchemaBuilder.fileName("file.proto").packageName("test").addClass(Author.class)
.build(serCtx);
} catch (ProtoSchemaBuilderException | IOException e) {
e.printStackTrace();
}
// register the schemas with the server too
RemoteCache<String, String> metadataCache = cacheManager
.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put("file.proto", memoSchemaFile);
}
示例3: doGet
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String host = System.getenv("DATAGRID_APP_HOTROD_SERVICE_HOST");
int port = Integer.parseInt(System.getenv("DATAGRID_APP_HOTROD_SERVICE_PORT"));
Configuration conf = new ConfigurationBuilder().addServer().host(host).port(port).build();
RemoteCacheManager manager = new RemoteCacheManager(conf);
RemoteCache cache = manager.getCache();
char[] data = new char[1000000];
int index = 0;
while (true) {
System.out.println("populating the cache index " + index);
cache.put(index++, data,1, TimeUnit.DAYS);
}
}
示例4: execute
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
@Override
public void execute(String restOfTheLine) throws Exception {
if (restOfTheLine == null || restOfTheLine.trim().length() == 0) {
throw new UserErrorException("key name missing");
}
int i = restOfTheLine.indexOf(' ');
if (i == -1) {
throw new UserErrorException("key value pair missing");
}
String keyName = restOfTheLine.substring(0, i);
restOfTheLine = restOfTheLine.substring(i + 1);
String keyValue = restOfTheLine.replaceAll(" .*$", "");
RemoteCache defaultCache = insureConnected();
defaultCache.put(keyName, keyValue);
}
示例5: doPreSetup
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
@Override
protected void doPreSetup() throws IOException {
ConfigurationBuilder builder = new ConfigurationBuilder()
.addServer()
.host("localhost")
.port(11222)
.marshaller(new ProtoStreamMarshaller());
manager = new RemoteCacheManager(builder.build());
RemoteCache<String, String> metadataCache = manager
.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache
.put("sample_bank_account/bank.proto",
Util.read(InfinispanRemoteQueryProducerIT.class
.getResourceAsStream("/sample_bank_account/bank.proto")));
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller
.getSerializationContext(manager));
SerializationContext serCtx = ProtoStreamMarshaller
.getSerializationContext(manager);
serCtx.registerProtoFiles(FileDescriptorSource
.fromResources("/sample_bank_account/bank.proto"));
serCtx.registerMarshaller(new UserMarshaller());
serCtx.registerMarshaller(new GenderMarshaller());
}
示例6: doPostSetup
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
@Override
protected void doPostSetup() throws Exception {
// pre-load data
RemoteCache<Object, Object> cache = manager.getCache("remote_query");
assertNotNull(cache);
cache.clear();
assertTrue(cache.isEmpty());
for (final User user : USERS) {
String key = createKey(user);
cache.put(key, user);
assertTrue(cache.containsKey(key));
}
}
示例7: 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());
// Retrieve the cache containing the scripts
RemoteCache<String, String> scriptCache = cacheManager.getCache("___script_cache");
// Create a simple script which multiplies to numbers
scriptCache.put("simple.js", "multiplicand * multiplier");
// Obtain the remote cache
RemoteCache<String, Integer> cache = cacheManager.getCache();
// Create the parameters for script execution
Map<String, Object> params = new HashMap<>();
params.put("multiplicand", 10);
params.put("multiplier", 20);
// Run the script on the server, passing in the parameters
Object result = cache.execute("simple.js", params);
// Print the result
System.out.printf("Result = %s\n", result);
// Stop the cache manager and release resources
cacheManager.stop();
}
示例8: 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();
}
示例9: setupMetadataCache
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
private boolean setupMetadataCache() throws IOException {
log.log(Level.INFO, "setupMetadataCache");
try {
final RemoteCache<String, String> metadataCache = cacheManagerForIndexableCaches.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put(RULE_PROTOBUF_DEFINITION_RESOURCE, readResource(RULE_PROTOBUF_DEFINITION_RESOURCE));
metadataCache.put(CUSTOM_LIST_PROTOBUF_DEFINITION_RESOURCE, readResource(CUSTOM_LIST_PROTOBUF_DEFINITION_RESOURCE));
final String errors = metadataCache.get(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX);
if (errors != null) {
log.log(Level.SEVERE, "Protobuffer files, either Rule or CustomLists contained errors:\n" + errors);
return false;
}
} catch (TransportException ex) {
return false;
}
return true;
}
示例10: 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();
}
}
示例11: 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();
}
}
示例12: 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();
}
}
示例13: startInternal
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
protected void startInternal() throws Exception {
SerializationContext serializationContext = ProtoStreamMarshaller.getSerializationContext(remoteCacheManager);
String protoFile = builder.build(serializationContext);
//initialize server-side serialization context
RemoteCache<String, String> metadataCache = remoteCacheManager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put(fileName, protoFile);
Object error = metadataCache.get(fileName + ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX);
if (error != null) {
throw new IllegalStateException("Protobuf metadata failed: " + error);
}
}
示例14: doPreSetup
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
@Override
protected void doPreSetup() throws IOException {
ConfigurationBuilder builder = new ConfigurationBuilder()
.addServer()
.host("localhost")
.port(11222)
.marshaller(new ProtoStreamMarshaller());
manager = new RemoteCacheManager(builder.build());
RemoteCache<String, String> metadataCache = manager.getCache(
ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
metadataCache.put(
"sample_bank_account/bank.proto",
Util.read(InfinispanContinuousQueryIT.class.getResourceAsStream("/sample_bank_account/bank.proto")));
MarshallerRegistration.registerMarshallers(ProtoStreamMarshaller.getSerializationContext(manager));
SerializationContext serCtx = ProtoStreamMarshaller.getSerializationContext(manager);
serCtx.registerProtoFiles(FileDescriptorSource.fromResources("/sample_bank_account/bank.proto"));
serCtx.registerMarshaller(new UserMarshaller());
serCtx.registerMarshaller(new GenderMarshaller());
// pre-load data
cache = manager.getCache("remote_query");
cache.clear();
}
示例15: main
import org.infinispan.client.hotrod.RemoteCache; //导入方法依赖的package包/类
public static void main(String[] args) throws UnknownHostException {
// Obtain the Infinispan address
String infinispanAddress = args[0];
// Adjust log levels
Logger.getLogger("org").setLevel(Level.WARN);
// Create the remote cache manager
Configuration build = new ConfigurationBuilder().addServer().host(infinispanAddress).build();
RemoteCacheManager remoteCacheManager = new RemoteCacheManager(build);
// Obtain the remote cache
RemoteCache<Integer, Temperature> cache = remoteCacheManager.getCache();
// Add some data
cache.put(1, new Temperature(21, "London"));
cache.put(2, new Temperature(34, "Rome"));
cache.put(3, new Temperature(33, "Barcelona"));
cache.put(4, new Temperature(8, "Oslo"));
// Create java spark context
SparkConf conf = new SparkConf().setAppName("infinispan-spark-simple-job");
JavaSparkContext jsc = new JavaSparkContext(conf);
// Create InfinispanRDD
ConnectorConfiguration config = new ConnectorConfiguration().setServerList(infinispanAddress);
JavaPairRDD<Integer, Temperature> infinispanRDD = InfinispanJavaRDD.createInfinispanRDD(jsc, config);
// Convert RDD to RDD of doubles
JavaDoubleRDD javaDoubleRDD = infinispanRDD.values().mapToDouble(Temperature::getValue);
// Calculate average temperature
Double meanTemp = javaDoubleRDD.mean();
System.out.printf("\nAVERAGE TEMPERATURE: %f C\n", meanTemp);
// Calculate standard deviation
Double stdDev = javaDoubleRDD.sampleStdev();
System.out.printf("STD DEVIATION: %f C\n ", stdDev);
// Calculate histogram of temperatures
System.out.println("TEMPERATURE HISTOGRAM:");
double[] buckets = {0d, 10d, 20d, 30d, 40d};
long[] histogram = javaDoubleRDD.histogram(buckets);
for (int i = 0; i < buckets.length - 1; i++) {
System.out.printf("Between %f C and %f C: %d cities\n", buckets[i], buckets[i + 1], histogram[i]);
}
}