org.infinispan.commons.marshall.JavaSerializationMarshaller Java Examples
The following examples show how to use
org.infinispan.commons.marshall.JavaSerializationMarshaller.
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: InfinispanConfiguration.java From apicurio-registry with Apache License 2.0 | 6 votes |
@ApplicationScoped @Produces public EmbeddedCacheManager cacheManager( @RegistryProperties("registry.infinispan.transport") Properties properties ) { GlobalConfigurationBuilder gConf = GlobalConfigurationBuilder.defaultClusteredBuilder(); gConf.serialization() .marshaller(new JavaSerializationMarshaller()) .whiteList() .addRegexps( "io.apicurio.registry.storage.", TupleId.class.getName(), MapValue.class.getName() ); TransportConfigurationBuilder tConf = gConf.transport(); tConf.clusterName(clusterName); if (properties.size() > 0) { tConf.withProperties(properties); } return new DefaultCacheManager(gConf.build(), true); }
Example #2
Source File: SpringApp.java From infinispan-simple-tutorials with Apache License 2.0 | 5 votes |
@Bean public InfinispanGlobalConfigurer globalCustomizer() { return () -> { GlobalConfigurationBuilder builder = GlobalConfigurationBuilder.defaultClusteredBuilder(); builder.serialization().marshaller(new JavaSerializationMarshaller()); builder.serialization().whiteList().addClass("org.springframework.session.MapSession"); builder.serialization().whiteList().addRegexp("java.util.*"); return builder.build(); }; }
Example #3
Source File: InfinispanRemoteAutoConfiguration.java From infinispan-spring-boot with Apache License 2.0 | 4 votes |
@Bean @Conditional({ConditionalOnCacheType.class, ConditionalOnConfiguration.class}) @ConditionalOnMissingBean @Qualifier(REMOTE_CACHE_MANAGER_BEAN_QUALIFIER) public RemoteCacheManager remoteCacheManager() throws IOException { boolean hasHotRodPropertiesFile = ctx.getResource(infinispanProperties.getClientProperties()).exists(); boolean hasConfigurer = infinispanRemoteConfigurer != null; boolean hasProperties = StringUtils.hasText(infinispanProperties.getServerList()); ConfigurationBuilder builder; if (hasConfigurer) { org.infinispan.client.hotrod.configuration.Configuration configuration = infinispanRemoteConfigurer.getRemoteConfiguration(); Objects.nonNull(configuration); builder = new ConfigurationBuilder().read(configuration); cacheCustomizers.forEach(c -> c.customize(builder)); } else if (hasHotRodPropertiesFile) { String remoteClientPropertiesLocation = infinispanProperties.getClientProperties(); Resource hotRodClientPropertiesFile = ctx.getResource(remoteClientPropertiesLocation); Properties hotrodClientProperties = new Properties(); try (InputStream stream = hotRodClientPropertiesFile.getURL().openStream()) { hotrodClientProperties.load(stream); builder = new ConfigurationBuilder().withProperties(hotrodClientProperties); cacheCustomizers.forEach(c -> c.customize(builder)); } } else if (hasProperties) { builder = infinispanProperties.getConfigurationBuilder(); cacheCustomizers.forEach(c -> c.customize(builder)); } else if (infinispanConfiguration != null) { builder = new ConfigurationBuilder().read(infinispanConfiguration); cacheCustomizers.forEach(c -> c.customize(builder)); } else { throw new IllegalStateException("Not enough data to create RemoteCacheManager. Check InfinispanRemoteCacheManagerChecker" + "and update conditions."); } org.infinispan.client.hotrod.configuration.Configuration config = builder.build(); List<String> whiteList = new ArrayList<>(config.serialWhitelist()); whiteList.forEach(builder::addJavaSerialWhiteList); builder.addJavaSerialWhiteList("java.util.*", "java.time.*", "org.springframework.*", "org.infinispan.spring.common.*", "org.infinispan.spring.remote.*"); builder.marshaller(new JavaSerializationMarshaller()); return new RemoteCacheManager(builder.build()); }
Example #4
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 #5
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"); }