org.infinispan.client.hotrod.configuration.ClientIntelligence Java Examples
The following examples show how to use
org.infinispan.client.hotrod.configuration.ClientIntelligence.
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: 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 #2
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 #3
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 #4
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 #5
Source File: CustomPropertiesTest.java From infinispan-spring-boot with Apache License 2.0 | 4 votes |
@Test public void testDefaultClient() throws Exception { //when Configuration configuration = remoteCacheManager.getConfiguration(); String hostObtainedFromPropertiesFile = configuration.servers().get(0).host(); int portObtainedFromPropertiesFile = configuration.servers().get(0).port(); // Connection assertThat(hostObtainedFromPropertiesFile).isEqualTo("127.0.0.1"); assertThat(portObtainedFromPropertiesFile).isEqualTo(6667); assertThat(configuration.tcpNoDelay()).isFalse(); assertThat(configuration.tcpKeepAlive()).isTrue(); assertThat(configuration.clientIntelligence()).isEqualTo(ClientIntelligence.TOPOLOGY_AWARE); assertThat(configuration.socketTimeout()).isEqualTo(3000); assertThat(configuration.connectionTimeout()).isEqualTo(5000); assertThat(configuration.maxRetries()).isEqualTo(42); assertThat(configuration.batchSize()).isEqualTo(90); assertThat(configuration.version()).isEqualTo(ProtocolVersion.PROTOCOL_VERSION_28); // Connection pool properties assertThat(configuration.connectionPool().maxActive()).isEqualTo(91); assertThat(configuration.connectionPool().exhaustedAction()).isEqualTo(ExhaustedAction.EXCEPTION); assertThat(configuration.connectionPool().maxWait()).isEqualTo(20001); assertThat(configuration.connectionPool().minIdle()).isEqualTo(1001); assertThat(configuration.connectionPool().minEvictableIdleTime()).isEqualTo(9001); assertThat(configuration.connectionPool().maxPendingRequests()).isEqualTo(846); // Thread pool properties assertThat(configuration.asyncExecutorFactory().factoryClass()).isEqualTo(DefaultAsyncExecutorFactory.class); // TODO: how to assert thread pool size ? default_executor_factory.pool_size // Marshalling properties assertThat(configuration.marshallerClass()).isEqualTo(JavaSerializationMarshaller.class); assertThat(configuration.keySizeEstimate()).isEqualTo(123456); assertThat(configuration.valueSizeEstimate()).isEqualTo(789012); assertThat(configuration.forceReturnValues()).isTrue(); assertThat(configuration.serialWhitelist()).contains("SERIAL-KILLER"); // TODO: Consistent Hash Impl ?? //assertThat(configuration.consistentHashImpl().getClass().toString()).isEqualTo(""); // Encryption properties assertThat(configuration.security().ssl().enabled()).isTrue(); assertThat(configuration.security().ssl().keyStoreFileName()).isEqualTo("keyStoreFile"); assertThat(configuration.security().ssl().keyStoreType()).isEqualTo("JKS"); assertThat(configuration.security().ssl().keyStorePassword()).hasSize(12); assertThat(configuration.security().ssl().keyAlias()).isEqualTo("aliasKey"); assertThat(configuration.security().ssl().keyStoreCertificatePassword()).hasSize(9); assertThat(configuration.security().ssl().trustStoreFileName()).isEqualTo("trustFileName"); assertThat(configuration.security().ssl().trustStorePath()).isNull(); assertThat(configuration.security().ssl().trustStoreType()).isEqualTo("LOL"); assertThat(configuration.security().ssl().trustStorePassword().length).isEqualTo(13); assertThat(configuration.security().ssl().sniHostName()).isEqualTo("oihost"); assertThat(configuration.security().ssl().protocol()).isEqualTo("TLSv1.3"); // authentication assertThat(configuration.security().authentication().enabled()).isTrue(); assertThat(configuration.security().authentication().saslMechanism()).isEqualTo("DIGEST-MD5"); assertThat(configuration.security().authentication().callbackHandler()).isInstanceOf(BasicCallbackHandler.class); assertThat(configuration.security().authentication().serverName()).isEqualTo("my_ela_server_name"); BasicCallbackHandler basicCallbackHandler = (BasicCallbackHandler) configuration.security().authentication().callbackHandler(); NameCallback nameCallback = new NameCallback("test", "test"); PasswordCallback passwordCallback = new PasswordCallback("test", false); RealmCallback realmCallback = new RealmCallback("test", "test"); basicCallbackHandler.handle(new Callback[]{nameCallback, passwordCallback, realmCallback}); assertThat(nameCallback.getName()).isEqualTo("elaia"); assertThat(passwordCallback.getPassword()).isEqualTo("elapass".toCharArray()); assertThat(realmCallback.getText()).isEqualTo("elarealm"); assertThat(configuration.security().authentication().saslProperties()).hasSize(1); assertThat(configuration.security().authentication().saslProperties()).containsOnlyKeys("prop1"); assertThat(configuration.security().authentication().saslProperties()).containsValues("value1"); // Transaction properties // TODO: transaction_manager_lookup?? assertThat(configuration.transaction().transactionMode()).isEqualTo(TransactionMode.FULL_XA); assertThat(configuration.transaction().timeout()).isEqualTo(50001); // near cache assertThat(configuration.nearCache().mode()).isEqualTo(NearCacheMode.INVALIDATED); assertThat(configuration.nearCache().maxEntries()).isEqualTo(10000); assertThat(configuration.nearCache().cacheNamePattern().pattern()).isEqualTo("nearSuperCache*"); // xsite assertThat(configuration.clusters()).hasSize(2); ClusterConfiguration siteA = configuration.clusters().get(0); ClusterConfiguration siteB = configuration.clusters().get(1); assertThat(siteA.getClusterName()).isEqualTo("siteA"); assertThat(siteB.getClusterName()).isEqualTo("siteB"); assertThat(siteA.getCluster()).extracting("host", "port").containsExactly(tuple("hostA1", 11222), tuple("hostA2", 11223)); assertThat(siteB.getCluster()).extracting("host", "port").containsExactly(tuple("hostB1", 11224), tuple("hostB2", 11225)); // statistics assertThat(configuration.statistics().enabled()).isTrue(); assertThat(configuration.statistics().jmxEnabled()).isTrue(); assertThat(configuration.statistics().jmxName()).isEqualTo("elaJmx"); assertThat(configuration.statistics().jmxDomain()).isEqualTo("elaJmxDom2"); }
Example #6
Source File: ApplicationPropertiesTest.java From infinispan-spring-boot with Apache License 2.0 | 4 votes |
@Test public void testDefaultClient() throws Exception { //when Configuration configuration = remoteCacheManager.getConfiguration(); String hostObtainedFromPropertiesFile = configuration.servers().get(0).host(); int portObtainedFromPropertiesFile = configuration.servers().get(0).port(); configuration.asyncExecutorFactory().factoryClass(); // properties assertThat(hostObtainedFromPropertiesFile).isEqualTo("180.567.112.333"); assertThat(portObtainedFromPropertiesFile).isEqualTo(6668); assertThat(configuration.tcpNoDelay()).isFalse(); assertThat(configuration.tcpKeepAlive()).isTrue(); assertThat(configuration.clientIntelligence()).isEqualTo(ClientIntelligence.TOPOLOGY_AWARE); assertThat(configuration.socketTimeout()).isEqualTo(500); assertThat(configuration.connectionTimeout()).isEqualTo(200); assertThat(configuration.maxRetries()).isEqualTo(30); assertThat(configuration.batchSize()).isEqualTo(91); assertThat(configuration.version()).isEqualTo(ProtocolVersion.PROTOCOL_VERSION_24); // pool assertThat(configuration.connectionPool().maxActive()).isEqualTo(90); assertThat(configuration.connectionPool().maxWait()).isEqualTo(20000); assertThat(configuration.connectionPool().minIdle()).isEqualTo(1000); assertThat(configuration.connectionPool().maxPendingRequests()).isEqualTo(845); assertThat(configuration.connectionPool().minEvictableIdleTime()).isEqualTo(9000); assertThat(configuration.connectionPool().exhaustedAction()).isEqualTo(ExhaustedAction.CREATE_NEW); // Thread pool properties assertThat(configuration.asyncExecutorFactory().factoryClass()).isEqualTo(DefaultAsyncExecutorFactory.class); // TODO: how to assert thread pool size ? default-executor-factory-pool-size // Marshalling properties assertThat(configuration.marshallerClass()).isEqualTo(JavaSerializationMarshaller.class); assertThat(configuration.keySizeEstimate()).isEqualTo(88889); assertThat(configuration.valueSizeEstimate()).isEqualTo(11112); assertThat(configuration.forceReturnValues()).isTrue(); assertThat(configuration.serialWhitelist()).contains("APP-KILLER1", "APP-KILLER2"); // TODO: Consistent Hash Impl ?? //assertThat(configuration.consistentHashImpl().getClass().toString()).isEqualTo(""); // Encryption properties assertThat(configuration.security().ssl().enabled()).isTrue(); assertThat(configuration.security().ssl().keyStoreFileName()).isEqualTo("superKeyStoreFile"); assertThat(configuration.security().ssl().keyStoreType()).isEqualTo("SKL"); assertThat(configuration.security().ssl().keyStorePassword().length).isEqualTo(17); assertThat(configuration.security().ssl().keyAlias()).isEqualTo("superAliasKey"); assertThat(configuration.security().ssl().keyStoreCertificatePassword()).hasSize(13); assertThat(configuration.security().ssl().trustStoreFileName()).isEqualTo("superTrustFileName"); assertThat(configuration.security().ssl().trustStorePath()).isNull(); assertThat(configuration.security().ssl().trustStoreType()).isEqualTo("CKO"); assertThat(configuration.security().ssl().trustStorePassword().length).isEqualTo(18); assertThat(configuration.security().ssl().sniHostName()).isEqualTo("elahost"); assertThat(configuration.security().ssl().protocol()).isEqualTo("TLSv1.4"); // authentication assertThat(configuration.security().authentication().enabled()).isTrue(); assertThat(configuration.security().authentication().callbackHandler().getClass()).isEqualTo(BasicCallbackHandler.class); assertThat(configuration.security().authentication().saslMechanism()).isEqualTo("my-sasl-mechanism"); assertThat(configuration.security().authentication().serverName()).isEqualTo("my-server-name"); BasicCallbackHandler basicCallbackHandler = (BasicCallbackHandler) configuration.security().authentication().callbackHandler(); NameCallback nameCallback = new NameCallback("test", "test"); PasswordCallback passwordCallback = new PasswordCallback("test", false); RealmCallback realmCallback = new RealmCallback("test", "test"); basicCallbackHandler.handle(new Callback[]{nameCallback, passwordCallback, realmCallback}); assertThat(nameCallback.getName()).isEqualTo("oihana"); assertThat(passwordCallback.getPassword()).isEqualTo("oipass".toCharArray()); assertThat(realmCallback.getText()).isEqualTo("oirealm"); assertThat(configuration.security().authentication().saslProperties()).hasSize(2); assertThat(configuration.security().authentication().saslProperties()).extracting("prop1", "prop2").containsExactly("value1", "value2"); // transactions assertThat(configuration.transaction().transactionMode()).isEqualTo(TransactionMode.NON_DURABLE_XA); assertThat(configuration.transaction().timeout()).isEqualTo(50000); // near cache assertThat(configuration.nearCache().mode()).isEqualTo(NearCacheMode.INVALIDATED); assertThat(configuration.nearCache().maxEntries()).isEqualTo(2000); assertThat(configuration.nearCache().cacheNamePattern().pattern()).isEqualTo("appCache*"); // xsite assertThat(configuration.clusters()).hasSize(1); ClusterConfiguration site = configuration.clusters().get(0); assertThat(site.getCluster()).extracting("host", "port").containsExactly(tuple("hostOi1", 21222), tuple("hostOi2", 21223)); // statistics assertThat(configuration.statistics().enabled()).isTrue(); assertThat(configuration.statistics().jmxEnabled()).isTrue(); assertThat(configuration.statistics().jmxName()).isEqualTo("oiJmx"); assertThat(configuration.statistics().jmxDomain()).isEqualTo("oiJmxDom"); }