org.infinispan.client.hotrod.RemoteCacheManager Java Examples
The following examples show how to use
org.infinispan.client.hotrod.RemoteCacheManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RemoteCaches.java From khan-session with GNU Lesser General Public License v2.1 | 6 votes |
public void test2() { RemoteCacheManager cacheManager = new RemoteCacheManager("192.168.0.58:11322;192.168.0.58:11422", true); RemoteCache<Object, Object> cache = cacheManager.getCache("KHAN_SESSION_LOGIN"); Set<Object> keySet = cache.keySet(); Iterator<Object> i = keySet.iterator(); System.out.println("============= KHAN_SESSION_LOGIN"); while (i.hasNext()) { Object key = i.next(); System.out.println("> key=" + key); Object value = cache.get(key); System.out.println("> value=" + value); System.out.println(""); } System.out.println("============="); }
Example #2
Source File: InfinispanRemoteContinuousQuery.java From infinispan-simple-tutorials with Apache License 2.0 | 6 votes |
private static void addInstapostsSchema(RemoteCacheManager cacheManager) throws IOException { // Get the serialization context of the client SerializationContext ctx = MarshallerUtil.getSerializationContext(cacheManager); // Use ProtoSchemaBuilder to define a Protobuf schema on the client ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder(); String fileName = "instapost.proto"; String protoFile = protoSchemaBuilder .fileName(fileName) .addClass(InstaPost.class) .packageName("tutorial") .build(ctx); // Retrieve metadata cache RemoteCache<String, String> metadataCache = cacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME); // Define the new schema on the server too metadataCache.putIfAbsent(fileName, protoFile); }
Example #3
Source File: InfinispanRemoteQuery.java From infinispan-simple-tutorials with Apache License 2.0 | 6 votes |
private static void addPersonSchema(RemoteCacheManager cacheManager) throws IOException { // Get the serialization context of the client SerializationContext ctx = MarshallerUtil.getSerializationContext(cacheManager); // Use ProtoSchemaBuilder to define a Protobuf schema on the client ProtoSchemaBuilder protoSchemaBuilder = new ProtoSchemaBuilder(); String fileName = "person.proto"; String protoFile = protoSchemaBuilder .fileName(fileName) .addClass(Person.class) .packageName("tutorial") .build(ctx); // Retrieve metadata cache RemoteCache<String, String> metadataCache = cacheManager.getCache(PROTOBUF_METADATA_CACHE_NAME); // Define the new schema on the server too metadataCache.put(fileName, protoFile); }
Example #4
Source File: InfinispanRemote.java From infinispan-simple-tutorials with Apache License 2.0 | 6 votes |
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) .security().authentication() //Add user credentials. .username("username") .password("password") .realm("default") .saslMechanism("DIGEST-MD5"); // Connect to the server RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build()); // Create test cache, if such does not exist cacheManager.administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).getOrCreateCache("test", DefaultTemplate.DIST_SYNC); // Obtain the remote cache RemoteCache<String, String> cache = cacheManager.getCache("test"); /// Store a value cache.put("key", "value"); // Retrieve the value and print it out System.out.printf("key = %s\n", cache.get("key")); // Stop the cache manager and release all resources cacheManager.stop(); }
Example #5
Source File: InfinispanNearCache.java From infinispan-simple-tutorials with Apache License 2.0 | 6 votes |
public static void main(String[] args) { // Create a client configuration connecting to a local server ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServer().host("127.0.0.1").port(ConfigurationProperties.DEFAULT_HOTROD_PORT); builder.nearCache().mode(NearCacheMode.INVALIDATED).maxEntries(20).cacheNamePattern("near-.*"); // Connect to the server RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build()); // Create one remote cache with near caching disabled and one with near caching enabled RemoteCache<Integer, String> numbers = cacheManager.administration().getOrCreateCache("numbers", DefaultTemplate.DIST_SYNC); RemoteCache<Integer, String> nearNumbers = cacheManager.administration().getOrCreateCache("near-numbers", DefaultTemplate.DIST_SYNC); for (int i = 1; i<= 20; i++) { numbers.put(i, String.valueOf(i)); nearNumbers.put(i, String.valueOf(i)); } // Read both caches data readCache(numbers); readCache(nearNumbers); // Stop the cache manager and release all resources cacheManager.stop(); }
Example #6
Source File: InfinispanScripting.java From infinispan-simple-tutorials with Apache License 2.0 | 6 votes |
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.administration().getOrCreateCache("test", DefaultTemplate.DIST_SYNC); // 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(); }
Example #7
Source File: RemoteCaches.java From khan-session with GNU Lesser General Public License v2.1 | 6 votes |
public void test() { RemoteCacheManager cacheManager = new RemoteCacheManager("192.168.0.58:11322;192.168.0.58:11422", true); RemoteCache<Object, Object> cache = cacheManager.getCache("KHAN_SESSION"); Set<Object> keySet = cache.keySet(); Iterator<Object> i = keySet.iterator(); System.out.println("============= KHAN_SESSION"); while (i.hasNext()) { Object key = i.next(); System.out.println("> key=" + key); Object value = cache.get(key); System.out.println("> value=" + value); System.out.println(""); } System.out.println("============="); }
Example #8
Source File: RemoteCaches.java From khan-session with GNU Lesser General Public License v2.1 | 6 votes |
public void testRemoteCache() { RemoteCacheManager cacheManager = new RemoteCacheManager("192.168.0.58:11422;192.168.0.58:11322", true); RemoteCache<Object, Object> cache = cacheManager.getCache("KHAN_SESSION_REMOTE"); Set<Object> keySet = cache.keySet(); Iterator<Object> i = keySet.iterator(); System.out.println("============= KHAN_SESSION_REMOTE"); while (i.hasNext()) { Object key = i.next(); System.out.println("> key=" + key); Object value = cache.get(key); System.out.println("> value=" + value); System.out.println(""); } System.out.println("============="); }
Example #9
Source File: RemoteCaches.java From khan-session with GNU Lesser General Public License v2.1 | 6 votes |
public void testRemoteLoginCache() { RemoteCacheManager cacheManager = new RemoteCacheManager("192.168.0.58:11422;192.168.0.58:11322", true); RemoteCache<Object, Object> cache = cacheManager.getCache("KHAN_SESSION_LOGIN_REMOTE"); Set<Object> keySet = cache.keySet(); Iterator<Object> i = keySet.iterator(); System.out.println("============= KHAN_SESSION_LOGIN_REMOTE"); while (i.hasNext()) { Object key = i.next(); System.out.println("> key=" + key); Object value = cache.get(key); System.out.println("> value=" + value); System.out.println(""); } System.out.println("============="); }
Example #10
Source File: Infinispan10Driver.java From hazelcast-simulator with Apache License 2.0 | 6 votes |
@Override public void startVendorInstance() throws Exception { String workerType = get("WORKER_TYPE"); if ("javaclient".equals(workerType)) { Properties hotrodProperties = new Properties(); hotrodProperties.setProperty("infinispan.client.hotrod.server_list", get("server_list")); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder().withProperties(hotrodProperties); Configuration configuration = configurationBuilder.build(); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(configuration); this.cacheContainer = remoteCacheManager; } else { DefaultCacheManager defaultCacheManager = new DefaultCacheManager("infinispan.xml"); this.cacheContainer = defaultCacheManager; HotRodServerConfiguration hotRodServerConfiguration = new HotRodServerConfigurationBuilder() .host(get("PRIVATE_ADDRESS")).port(11222).build(); this.hotRodServer = new HotRodServer(); hotRodServer.start(hotRodServerConfiguration, defaultCacheManager); } }
Example #11
Source File: Infinispan9Driver.java From hazelcast-simulator with Apache License 2.0 | 6 votes |
@Override public void startVendorInstance() throws Exception { String workerType = get("WORKER_TYPE"); if ("javaclient".equals(workerType)) { Properties hotrodProperties = new Properties(); hotrodProperties.setProperty("infinispan.client.hotrod.server_list", get("server_list")); ConfigurationBuilder configurationBuilder = new ConfigurationBuilder().withProperties(hotrodProperties); Configuration configuration = configurationBuilder.build(); RemoteCacheManager remoteCacheManager = new RemoteCacheManager(configuration); this.cacheContainer = remoteCacheManager; } else { DefaultCacheManager defaultCacheManager = new DefaultCacheManager("infinispan.xml"); this.cacheContainer = defaultCacheManager; HotRodServerConfiguration hotRodServerConfiguration = new HotRodServerConfigurationBuilder() .host(get("PRIVATE_ADDRESS")).port(11222).build(); this.hotRodServer = new HotRodServer(); hotRodServer.start(hotRodServerConfiguration, defaultCacheManager); } }
Example #12
Source File: ServerFoo.java From camelinaction2 with Apache License 2.0 | 5 votes |
public void boot() throws Exception { Properties props = new Properties(); // list of urls for the infinispan server // as we run in domain node we have two servers out of the box, and can therefore include both // that the client can load balance/failover to be highly available props.setProperty("infinispan.client.hotrod.server_list", "localhost:11222;localhost:11372"); // by default, previously existing values for java.util.Map operations // are not returned for remote caches but they are required for the route // policy to work. props.setProperty("infinispan.client.hotrod.force_return_values", "true"); // create remote infinispan cache manager and start it RemoteCacheManager remote = new RemoteCacheManager( new ConfigurationBuilder().withProperties(props).build(), true ); // setup Camel infinispan configuration to use the remote cache manager InfinispanConfiguration ic = new InfinispanConfiguration(); ic.setCacheContainer(remote); // setup the hazelcast route policy InfinispanRoutePolicy routePolicy = new InfinispanRoutePolicy(ic); // the lock names must be same in the foo and bar server routePolicy.setLockMapName("myLock"); routePolicy.setLockKey("myLockKey"); // the lock value identifies the node routePolicy.setLockValue("foo"); main = new Main(); // bind the hazelcast route policy to the name myPolicy which we refer to from the route main.bind("myPolicy", routePolicy); // add the route and and let the route be named Bar and use a little delay when processing the files main.addRouteBuilder(new FileConsumerRoute("Foo", 100)); main.run(); }
Example #13
Source File: Reader.java From infinispan-simple-tutorials with Apache License 2.0 | 5 votes |
public Reader(BasqueNamesRepository repository, RemoteCacheManager remoteCacheManager) { this.repository = repository; random = new Random(); cache = remoteCacheManager.administration().getOrCreateCache(Data.BASQUE_NAMES_CACHE, new XMLStringConfiguration(XML)); try { cache.clearAsync().get(1, TimeUnit.MINUTES); } catch (Exception e) { logger.error("Unable to clear the cache", e); } }
Example #14
Source File: InfinispanRemoteListen.java From infinispan-simple-tutorials with Apache License 2.0 | 5 votes |
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) .security().authentication() //Add user credentials. .username("username") .password("password") .realm("default") .saslMechanism("DIGEST-MD5"); // Connect to the server RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build()); // Get the cache, create it if needed with an existing template name RemoteCache<String, String> cache = cacheManager.administration() .withFlags(CacheContainerAdmin.AdminFlag.VOLATILE) .getOrCreateCache("listen", DefaultTemplate.DIST_SYNC); // 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(); }
Example #15
Source File: InfinispanRemoteAdminCache.java From infinispan-simple-tutorials with Apache License 2.0 | 5 votes |
private InfinispanRemoteAdminCache() { // Create a configuration for a locally running server. ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServer() .host("127.0.0.1") .port(ConfigurationProperties.DEFAULT_HOTROD_PORT) .security().authentication() //Add user credentials. .username("username") .password("password") .realm("default") .saslMechanism("DIGEST-MD5"); manager = new RemoteCacheManager(builder.build()); }
Example #16
Source File: InfinispanServerTasks.java From infinispan-simple-tutorials with Apache License 2.0 | 5 votes |
private static RemoteCache<String,String> getExecCache() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServer().host("127.0.0.1").port(11222); RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build()); return cacheManager.administration() .withFlags(CacheContainerAdmin.AdminFlag.VOLATILE) .getOrCreateCache("data", DefaultTemplate.DIST_SYNC); }
Example #17
Source File: InfinispanRemotePerCache.java From infinispan-simple-tutorials with Apache License 2.0 | 5 votes |
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) .security().authentication() //Add user credentials. .username("username") .password("password") .realm("default") .saslMechanism("DIGEST-MD5"); //Add per-cache configuration that uses an org.infinispan cache template. builder.remoteCache("my-cache") .templateName("org.infinispan.DIST_SYNC"); //Add per-cache configuration with a cache definition in XML format. builder.remoteCache("another-cache") .configuration("<infinispan><cache-container><distributed-cache name=\"another-cache\"><encoding media-type=\"application/x-protostream\"/></distributed-cache></cache-container></infinispan>"); // Connect to the server try (RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build())) { // Obtain a remote cache that does not exist. // Rather than return null, create the cache from a template. RemoteCache<String, String> cache = cacheManager.getCache("my-cache"); /// Store a value cache.put("hello", "world"); // Retrieve the value and print it out System.out.printf("key = %s\n", cache.get("hello")); } }
Example #18
Source File: AbstractCacheProvider.java From enmasse with Apache License 2.0 | 5 votes |
@PostConstruct public void start() throws Exception { var config = new ConfigurationBuilder() .addServer() .host(this.properties.getHost()) .port(this.properties.getPort()); if (this.properties.isUseTls()) { config.security() .ssl() .enable() .sniHostName(sniHostName(this.properties.getHost())) .trustStorePath(this.properties.getTrustStorePath()); } if (this.properties.getUsername() != null) { config .security() .authentication() .realm(this.properties.getSaslRealm()) .serverName(this.properties.getSaslServerName()) .username(this.properties.getUsername()) .password(this.properties.getPassword()); } customizeServerConfiguration(config); this.remoteCacheManager = new RemoteCacheManager(config.build()); }
Example #19
Source File: InfinispanRemoteSecured.java From infinispan-simple-tutorials with Apache License 2.0 | 5 votes |
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); // Workaround for docker 4 mac builder.clientIntelligence(ClientIntelligence.BASIC); //Configure the security properties builder.security().authentication() .username("Titus Bramble") .password("Shambles") .saslMechanism("DIGEST-MD5") .realm("default") .serverName("infinispan"); // Connect to the server RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build()); // Create test cache, if such does not exist cacheManager.administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).getOrCreateCache("test", DefaultTemplate.DIST_SYNC); // Obtain the remote cache RemoteCache<String, String> cache = cacheManager.getCache("test"); /// Store a value cache.put("key", "value"); // Retrieve the value and print it out System.out.printf("key = %s\n", cache.get("key")); // Stop the cache manager and release all resources cacheManager.stop(); }
Example #20
Source File: InfinispanRemoteMultimap.java From infinispan-simple-tutorials with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { // Create a configuration for a locally-running server ConfigurationBuilder builder = new ConfigurationBuilder(); builder.addServer() .host("127.0.0.1") .port(ConfigurationProperties.DEFAULT_HOTROD_PORT) .security().authentication() //Add user credentials. .username("username") .password("password") .realm("default") .saslMechanism("DIGEST-MD5"); // Connect to the server and create a cache RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build()); // Create people cache if needed with an existing template name cacheManager.administration() .withFlags(CacheContainerAdmin.AdminFlag.VOLATILE) .getOrCreateCache(PEOPLE_MULTIMAP, DefaultTemplate.DIST_SYNC); // Retrieve the MultimapCacheManager from the CacheManager. MultimapCacheManager multimapCacheManager = RemoteMultimapCacheManagerFactory.from(cacheManager); // Retrieve the multimap cache. RemoteMultimapCache<Integer, String> people = multimapCacheManager.get(PEOPLE_MULTIMAP); people.put(2016, "Alberto"); people.put(2016, "Oihana"); people.put(2016, "Roman"); people.put(2016, "Ane"); people.put(2017, "Paula"); people.put(2017, "Aimar"); people.put(2018, "Elaia"); people.get(2016).whenComplete((v, ex) -> { System.out.println(v); }).join(); // Stop the cache manager and release all resources cacheManager.stop(); }
Example #21
Source File: HotRodSearchClientTest.java From apicurio-registry with Apache License 2.0 | 5 votes |
private static RemoteCacheManager raw() { ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); clientBuilder.addServer() .host("localhost") .port(11222) .security() .authentication().username("user").password("pass").realm("default").serverName("infinispan") .clientIntelligence(ClientIntelligence.BASIC); return new RemoteCacheManager(clientBuilder.build()); }
Example #22
Source File: ServerBar.java From camelinaction2 with Apache License 2.0 | 5 votes |
public void boot() throws Exception { Properties props = new Properties(); // list of urls for the infinispan server // as we run in domain node we have two servers out of the box, and can therefore include both // that the client can load balance/failover to be highly available props.setProperty("infinispan.client.hotrod.server_list", "localhost:11222;localhost:11372"); // by default, previously existing values for java.util.Map operations // are not returned for remote caches but they are required for the route // policy to work. props.setProperty("infinispan.client.hotrod.force_return_values", "true"); // create remote infinispan cache manager and start it RemoteCacheManager remote = new RemoteCacheManager( new ConfigurationBuilder().withProperties(props).build(), true ); // setup Camel infinispan configuration to use the remote cache manager InfinispanConfiguration ic = new InfinispanConfiguration(); ic.setCacheContainer(remote); // setup the hazelcast route policy InfinispanRoutePolicy routePolicy = new InfinispanRoutePolicy(ic); // the lock names must be same in the foo and bar server routePolicy.setLockMapName("myLock"); routePolicy.setLockKey("myLockKey"); // the lock value identifies the node routePolicy.setLockValue("bar"); main = new Main(); // bind the hazelcast route policy to the name myPolicy which we refer to from the route main.bind("myPolicy", routePolicy); // add the route and and let the route be named Bar and use a little delay when processing the files main.addRouteBuilder(new FileConsumerRoute("Bar", 100)); main.run(); }
Example #23
Source File: InfinispanHotRodImpl.java From khan-session with GNU Lesser General Public License v2.1 | 5 votes |
/** * 초기화 함수, 설정파일을 읽어서 캐시를 초기화한다. * * @param configFile * @param cacheName * @param loginCacheName * @throws IOException */ @Override public void initialize(String configFile, String cacheName, String loginCacheName) throws IOException { StringUtils.isNotNull("configFile", configFile); Configuration configuration = null; ConfigurationBuilder builder = new ConfigurationBuilder(); ClassLoader cl = Thread.currentThread().getContextClassLoader(); builder.classLoader(cl); InputStream stream = cl.getResourceAsStream(configFile); if (stream == null) { logger.error("Can't Found configFile=" + configFile); } else { try { builder.withProperties(loadFromStream(stream)); } finally { Util.close(stream); } } configuration = builder.build(); cacheManager = new RemoteCacheManager(configuration); cache = cacheManager.getCache(cacheName); loginCache = cacheManager.getCache(loginCacheName); waitForConnectionReady(); }
Example #24
Source File: InfinispanRemoteCacheConfig.java From spring4-sandbox with Apache License 2.0 | 5 votes |
@Override @Bean public CacheManager cacheManager() { return new SpringRemoteCacheManager( new RemoteCacheManager( new ConfigurationBuilder() .addServer() .host("localhost") .build() ) ); }
Example #25
Source File: RemoteCacheProvider.java From keycloak with Apache License 2.0 | 5 votes |
public void stop() { logger.debugf("Shutdown %d registered secured remoteCache managers", managedManagers.size()); for (RemoteCacheManager mgr : managedManagers.values()) { mgr.stop(); } }
Example #26
Source File: RemoteCacheProvider.java From keycloak with Apache License 2.0 | 5 votes |
protected synchronized RemoteCache loadRemoteCache(String cacheName) { RemoteCache remoteCache = InfinispanUtil.getRemoteCache(cacheManager.getCache(cacheName)); Boolean remoteStoreSecurity = config.getBoolean("remoteStoreSecurityEnabled"); if (remoteStoreSecurity == null) { try { logger.debugf("Detecting remote security settings of HotRod server, cache %s. Disable by explicitly setting \"remoteStoreSecurityEnabled\" property in spi=connectionsInfinispan/provider=default", cacheName); remoteStoreSecurity = false; final RemoteCache<Object, Object> scriptCache = remoteCache.getRemoteCacheManager().getCache(SCRIPT_CACHE_NAME); if (scriptCache == null) { logger.debug("Cannot detect remote security settings of HotRod server, disabling."); } else { scriptCache.containsKey(""); } } catch (HotRodClientException ex) { logger.debug("Seems that HotRod server requires authentication, enabling."); remoteStoreSecurity = true; } } if (remoteStoreSecurity) { logger.infof("Remote store security for cache %s is enabled. Disable by setting \"remoteStoreSecurityEnabled\" property to \"false\" in spi=connectionsInfinispan/provider=default", cacheName); RemoteCacheManager securedMgr = getOrCreateSecuredRemoteCacheManager(config, cacheName, remoteCache.getRemoteCacheManager()); return securedMgr.getCache(remoteCache.getName()); } else { logger.infof("Remote store security for cache %s is disabled. If server fails to connect to remote JDG server, enable it.", cacheName); return remoteCache; } }
Example #27
Source File: DistributedCacheConcurrentWritesTest.java From keycloak with Apache License 2.0 | 5 votes |
public static BasicCache<String, SessionEntityWrapper<UserSessionEntity>> createRemoteCache(String nodeName) { int port = ("node1".equals(nodeName)) ? 12232 : 13232; org.infinispan.client.hotrod.configuration.ConfigurationBuilder builder = new org.infinispan.client.hotrod.configuration.ConfigurationBuilder(); org.infinispan.client.hotrod.configuration.Configuration cfg = builder .addServer().host("localhost").port(port) .version(ProtocolVersion.PROTOCOL_VERSION_26) .build(); RemoteCacheManager mgr = new RemoteCacheManager(cfg); return mgr.getCache(InfinispanConnectionProvider.USER_SESSION_CACHE_NAME); }
Example #28
Source File: CacheProcessInstancesIT.java From kogito-runtimes with Apache License 2.0 | 5 votes |
@Test public void testBasicFlow() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder .addServer() .host("127.0.0.1") .port(ConfigurationProperties.DEFAULT_HOTROD_PORT) .security() .authentication() .username("admin") .password("admin") .realm("default") .serverName("infinispan") .saslMechanism("DIGEST-MD5") .clientIntelligence(ClientIntelligence.BASIC); RemoteCacheManager cacheManager = new RemoteCacheManager(builder.build()); BpmnProcess process = (BpmnProcess) BpmnProcess.from(new ClassPathResource("BPMN2-UserTask.bpmn2")).get(0); process.setProcessInstancesFactory(new CacheProcessInstancesFactory(cacheManager)); process.configure(); ProcessInstance<BpmnVariables> processInstance = process.createInstance(BpmnVariables.create(Collections.singletonMap("test", "test"))); processInstance.start(); assertEquals(STATE_ACTIVE, processInstance.status()); SecurityPolicy asJohn = SecurityPolicy.of(new StaticIdentityProvider("john")); WorkItem workItem = processInstance.workItems(asJohn).get(0); assertNotNull(workItem); assertEquals("john", workItem.getParameters().get("ActorId")); processInstance.completeWorkItem(workItem.getId(), null, asJohn); assertEquals(STATE_COMPLETED, processInstance.status()); }
Example #29
Source File: HotRodSearchClient.java From apicurio-registry with Apache License 2.0 | 5 votes |
@Override protected void initialize(Properties properties, String host, int port, String username, String password, String cacheName) { String realm = property(properties, "search.realm", "default"); String serverName = property(properties, "search.server-name", "infinispan"); ClientIntelligence ci = ClientIntelligence.valueOf(property(properties, "search.client-intelligence", "BASIC")); ConfigurationBuilder clientBuilder = new ConfigurationBuilder(); clientBuilder .addServer().host(host).port(port) .security().authentication().username(username).password(password).realm(realm).serverName(serverName) .clientIntelligence(ci) .marshaller(new ProtoStreamMarshaller()); manager = new RemoteCacheManager(clientBuilder.build()); }
Example #30
Source File: HotRodSearchClientTest.java From apicurio-registry with Apache License 2.0 | 5 votes |
boolean isServerRunning() { RemoteCacheManager manager = null; try { manager = raw(); Set<String> cacheNames = manager.getCacheNames(); return cacheNames != null; } catch (Throwable ignored) { return false; } finally { IoUtil.closeIgnore(manager); } }