/** * Get the property associated with the key, optionally applying string property replacement as defined in * {@link StringPropertyReplacer#replaceProperties} to the result. * * @param key the hashtable key. * @param defaultValue a default value. * @param doStringReplace boolean indicating whether to apply string property replacement * @return the value in this property list with the specified key valu after optionally being inspected for String property replacement */ public synchronized String getProperty(String key, String defaultValue, boolean doStringReplace) { if (doStringReplace) return StringPropertyReplacer.replaceProperties(getProperty(key, defaultValue)); else return getProperty(key, defaultValue); }
/** * Put a value if the associated key is not present * @param key new key * @param value new value * @return this TypedProperties instance for method chaining * */ public synchronized TypedProperties putIfAbsent(String key, String value) { if (getProperty(key) == null) { put(key, value); } return this; }
public <T extends Enum<T>> T getEnumProperty(String key, Class<T> enumClass, T defaultValue, boolean doStringReplace) { String value = getProperty(key); if (value == null) return defaultValue; value = value.trim(); if (value.length() == 0) return defaultValue; if (doStringReplace) value = StringPropertyReplacer.replaceProperties(value); try { return Enum.valueOf(enumClass, value); } catch (IllegalArgumentException e) { log.unableToConvertStringPropertyToEnum(value, defaultValue.name()); return defaultValue; } }
public long getLongProperty(String key, long defaultValue, boolean doStringReplace) { String value = getProperty(key); if (value == null) return defaultValue; value = value.trim(); if (value.length() == 0) return defaultValue; if (doStringReplace) value = StringPropertyReplacer.replaceProperties(value); try { return Long.parseLong(value); } catch (NumberFormatException nfe) { log.unableToConvertStringPropertyToLong(value, defaultValue); return defaultValue; } }
public boolean getBooleanProperty(String key, boolean defaultValue, boolean doStringReplace) { String value = getProperty(key); if (value == null) return defaultValue; value = value.trim(); if (value.length() == 0) return defaultValue; if (doStringReplace) value = StringPropertyReplacer.replaceProperties(value); try { return Boolean.parseBoolean(value); } catch (Exception e) { log.unableToConvertStringPropertyToBoolean(value, defaultValue); return defaultValue; } }
public int getIntProperty(String key, int defaultValue, boolean doStringReplace) { String value = getProperty(key); if (value == null) return defaultValue; value = value.trim(); if (value.length() == 0) return defaultValue; if (doStringReplace) value = StringPropertyReplacer.replaceProperties(value); try { return Integer.parseInt(value); } catch (NumberFormatException nfe) { log.unableToConvertStringPropertyToInt(value, defaultValue); return defaultValue; } }
@Override public void call() { Configuration cacheConfiguration = cm.getCacheConfiguration("repl-with-default"); TypedProperties properties = cacheConfiguration.indexing().properties(); assertFalse(properties.isEmpty()); assertEquals(properties.getProperty("hibernate.search.default.exclusive_index_use"), "true"); assertEquals(properties.getProperty("hibernate.search.default.reader.strategy"), "shared"); assertEquals(properties.getProperty("hibernate.search.default.indexmanager"), "near-real-time"); assertEquals(properties.getProperty("hibernate.search.default.directory_provider"), "filesystem"); cacheConfiguration = cm.getCacheConfiguration("dist-with-default"); properties = cacheConfiguration.indexing().properties(); assertFalse(properties.isEmpty()); assertEquals(properties.getProperty("hibernate.search.default.directory_provider"), "infinispan"); assertEquals(properties.getProperty("hibernate.search.default.indexmanager"), "org.infinispan.query.indexmanager.InfinispanIndexManager"); assertEquals(properties.getProperty("hibernate.search.default.exclusive_index_use"), "true"); assertEquals(properties.getProperty("hibernate.search.default.reader.strategy"), "shared"); } });
@CacheStarted public void logCacheManagerStart(final CacheStartedEvent event) { Logger log = LogManager.getLogger("MAIN"); EmbeddedCacheManager cacheManager = event.getCacheManager(); if (!cacheManager.getCacheManagerConfiguration().isClustered()) { // Local Infinispan (no cluster) log.info("[CM8008] Infinispan clustering: not configured"); } else if (clusterInfoLogged.compareAndSet(false, true)) { // Clustered Infinispan, log cluster conf for the first start cache event only // to prevent duplicate log lines with same cluster info log.info("[CM8007] Infinispan status: {}", cacheManager.getStatus()); log.info("[CM8009] Infinispan cluster name: {}", cacheManager.getCacheManagerConfiguration().transport().clusterName()); log.info("[CM8010] Infinispan cluster local node logical address: {}", cacheManager.getAddress()); log.info("[CM8019] Infinispan cluster local node physical address(es): {}", cacheManager.getCacheManagerConfiguration().transport().transport().getPhysicalAddresses()); log.info("[CM8011] Infinispan cluster coordinator logical address: {}", cacheManager.getCoordinator()); log.info("[CM8016] Infinispan cluster local node is coordinator: {}", cacheManager.isCoordinator()); log.info("[CM8012] Infinispan cluster members: {}", cacheManager.getMembers()); log.info("[CM8013] Infinispan cluster distributed sync timeout: {}", cacheManager.getCacheManagerConfiguration().transport().distributedSyncTimeout()); log.info("[CM8014] Infinispan cluster JGroups configuration file: {}", cacheManager.getCacheManagerConfiguration().transport().properties().getProperty("configurationFile")); } final Date now = new Date(); log.info("[CM8006] Started Infinispan {} cache {} in {} ms", cacheManager.getCacheConfiguration(event.getCacheName()).clustering().cacheModeString(), event.getCacheName(), now.getTime() - initiationTimestamp.getTime()); } }
transferValueToServiceProperties(CacheFactoryConstants.TRANSPORT__SITE_ID, globalConfig, serviceProperties); String jgroupsXML = globalConfig.transport().properties().getProperty("configurationXml"); if (jgroupsXML != null) { serviceProperties.put(CacheFactoryConstants.TRANSPORT__CONFIGURATION_XML, jgroupsXML);
public void testConfigurationFileParsing() throws IOException { ParserRegistry parserRegistry = new ParserRegistry(Thread.currentThread().getContextClassLoader()); ConfigurationBuilderHolder holder = parserRegistry.parseFile("configuration-parsing-test.xml"); Map<String, ConfigurationBuilder> namedConfigurations = holder.getNamedConfigurationBuilders(); Configuration defaultConfiguration = namedConfigurations.get("default").build(); assertEquals(defaultConfiguration.indexing().properties().size(), 0); assertFalse(defaultConfiguration.indexing().index().isEnabled()); Configuration simpleCfg = namedConfigurations.get("simple").build(); assertFalse(simpleCfg.indexing().index().isEnabled()); assertEquals(simpleCfg.indexing().properties().size(), 0); Configuration memoryCfg = namedConfigurations.get("memory-searchable").build(); assertTrue(memoryCfg.indexing().index().isEnabled()); assertEquals(2, memoryCfg.indexing().properties().size()); assertEquals(memoryCfg.indexing().properties().getProperty("default.directory_provider"), "local-heap"); Configuration diskCfg = namedConfigurations.get("disk-searchable").build(); assertTrue(diskCfg.indexing().index().isEnabled()); assertEquals(diskCfg.indexing().properties().size(), 3); assertEquals(diskCfg.indexing().properties().getProperty("hibernate.search.default.directory_provider"), "filesystem"); assertEquals(diskCfg.indexing().properties().getProperty("hibernate.search.cats.exclusive_index_use"), "true"); Configuration replDefaults = namedConfigurations.get("repl-with-default").build(); assertTrue(replDefaults.indexing().index().isEnabled()); assertFalse(replDefaults.indexing().properties().isEmpty()); Configuration affinity = namedConfigurations.get("dist-with-affinity").build(); assertTrue(affinity.indexing().index().isEnabled()); assertTrue(affinity.indexing().index().isPrimaryOwner()); assertEquals(affinity.indexing().properties().getProperty("default.indexmanager"), AffinityIndexManager.class.getName()); }
assertEquals(defaultConfiguration.indexing().properties().getProperty("hibernate.search.default.directory_provider"), "someDefault"); assertFalse(memoryCfg.indexing().index().isLocalOnly()); assertEquals(memoryCfg.indexing().properties().size(), 2); assertEquals(memoryCfg.indexing().properties().getProperty("hibernate.search.default.directory_provider"), "local-heap"); assertTrue(diskCfg.indexing().index().isLocalOnly()); assertEquals(diskCfg.indexing().properties().size(), 3); assertEquals(diskCfg.indexing().properties().getProperty("hibernate.search.default.directory_provider"), "filesystem"); assertEquals(diskCfg.indexing().properties().getProperty("hibernate.search.cats.exclusive_index_use"), "true");
for(InterceptorConfiguration i : c.customInterceptors().interceptors()) { if (i.asyncInterceptor() instanceof FooInterceptor) { assertEquals(i.properties().getProperty("foo"), "bar");
assertTrue(g.globalJmxStatistics().mbeanServerLookup() instanceof CustomMBeanServerPropertiesTest.TestLookup); assertEquals(1, g.globalJmxStatistics().properties().size()); assertEquals("value", g.globalJmxStatistics().properties().getProperty("key")); assertEquals("udp", g.transport().properties().getProperty("stack-udp")); assertEquals("tcp", g.transport().properties().getProperty("stack-tcp")); assertEquals("jgroups-udp.xml", g.transport().properties().getProperty("stackFilePath-udp")); assertEquals("jgroups-tcp.xml", g.transport().properties().getProperty("stackFilePath-tcp")); assertEquals("tcp", g.transport().properties().getProperty("stack"));