/** * Constructor accepting the {@link CacheManager} and the {@link TerracottaClientConfiguration} * * @param cacheManager the cache manager to be clustered * @param terracottaClientConfiguration the configuration for the terracotta client */ public TerracottaClient(CacheManager cacheManager, TerracottaClientConfiguration terracottaClientConfiguration) { this.cacheManager = cacheManager; this.terracottaClientConfiguration = terracottaClientConfiguration; if (terracottaClientConfiguration != null) { terracottaClientConfiguration.freezeConfig(); // If we're going clustered and secured and a secret provider is configured, it's time to wrap the // secret provider before the L1 can use it. // We must set this ehcache secret provider as both the L1 and the agent will use a different instance // and will want to fetch the password. In case of a console fetcher, the password would be asked twice. String secretProviderClassname = System.getProperty(CUSTOM_SECRET_PROVIDER_SYSTEM_PROPERTY); String tcUrl = terracottaClientConfiguration.getUrl(); if (tcUrl != null && tcUrl.contains("@") && secretProviderClassname != null) { try { System.setProperty(CUSTOM_SECRET_PROVIDER_SYSTEM_PROPERTY, CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME); Class<?> secretProviderWrapperClass = Class.forName(CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME); secretProviderWrapperClass.getMethod("useAsDelegate", String.class).invoke(secretProviderWrapperClass, secretProviderClassname); } catch (Exception e) { throw new CacheException("Unable to initialize " + CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME, e); } } } }
private void doInit(Configuration configuration) { if (configuration.getTerracottaConfiguration() != null) { configuration.getTerracottaConfiguration().freezeConfig();
/** * Constructor accepting the {@link CacheManager} and the {@link TerracottaClientConfiguration} * * @param cacheManager the cache manager to be clustered * @param terracottaClientConfiguration the configuration for the terracotta client */ public TerracottaClient(CacheManager cacheManager, TerracottaClientConfiguration terracottaClientConfiguration) { this.cacheManager = cacheManager; this.terracottaClientConfiguration = terracottaClientConfiguration; if (terracottaClientConfiguration != null) { terracottaClientConfiguration.freezeConfig(); // If we're going clustered and secured and a secret provider is configured, it's time to wrap the // secret provider before the L1 can use it. // We must set this ehcache secret provider as both the L1 and the agent will use a different instance // and will want to fetch the password. In case of a console fetcher, the password would be asked twice. String secretProviderClassname = System.getProperty(CUSTOM_SECRET_PROVIDER_SYSTEM_PROPERTY); String tcUrl = terracottaClientConfiguration.getUrl(); if (tcUrl != null && tcUrl.contains("@") && secretProviderClassname != null) { try { System.setProperty(CUSTOM_SECRET_PROVIDER_SYSTEM_PROPERTY, CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME); Class<?> secretProviderWrapperClass = Class.forName(CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME); secretProviderWrapperClass.getMethod("useAsDelegate", String.class).invoke(secretProviderWrapperClass, secretProviderClassname); } catch (Exception e) { throw new CacheException("Unable to initialize " + CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME, e); } } } }
/** * Constructor accepting the {@link CacheManager} and the {@link TerracottaClientConfiguration} * * @param cacheManager the cache manager to be clustered * @param terracottaClientConfiguration the configuration for the terracotta client */ public TerracottaClient(CacheManager cacheManager, TerracottaClientConfiguration terracottaClientConfiguration) { this.cacheManager = cacheManager; this.terracottaClientConfiguration = terracottaClientConfiguration; if (terracottaClientConfiguration != null) { terracottaClientConfiguration.freezeConfig(); // If we're going clustered and secured and a secret provider is configured, it's time to wrap the // secret provider before the L1 can use it. // We must set this ehcache secret provider as both the L1 and the agent will use a different instance // and will want to fetch the password. In case of a console fetcher, the password would be asked twice. String secretProviderClassname = System.getProperty(CUSTOM_SECRET_PROVIDER_SYSTEM_PROPERTY); String tcUrl = terracottaClientConfiguration.getUrl(); if (tcUrl != null && tcUrl.contains("@") && secretProviderClassname != null) { try { System.setProperty(CUSTOM_SECRET_PROVIDER_SYSTEM_PROPERTY, CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME); Class<?> secretProviderWrapperClass = Class.forName(CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME); secretProviderWrapperClass.getMethod("useAsDelegate", String.class).invoke(secretProviderWrapperClass, secretProviderClassname); } catch (Exception e) { throw new CacheException("Unable to initialize " + CUSTOM_SECRET_PROVIDER_WRAPPER_CLASSNAME, e); } } } }
/** * Constructor accepting the {@link TerracottaClientRejoinListener} and the {@link TerracottaClientConfiguration} * * @param cacheManager * @param rejoinAction * @param terracottaClientConfiguration */ public TerracottaClient(CacheManager cacheManager, TerracottaClientRejoinListener rejoinAction, TerracottaClientConfiguration terracottaClientConfiguration) { this.cacheManager = cacheManager; this.rejoinListener = rejoinAction; this.terracottaClientConfiguration = terracottaClientConfiguration; if (terracottaClientConfiguration != null) { terracottaClientConfiguration.freezeConfig(); } if (isRejoinEnabled()) { TerracottaRuntimeType type = TerracottaClusteredInstanceHelper.getInstance().getTerracottaRuntimeTypeOrNull(); if (type == null) { throw new InvalidConfigurationException( "Terracotta Rejoin is enabled but can't determine Terracotta Runtime. You are probably missing Terracotta jar(s)."); } if (type != TerracottaRuntimeType.EnterpriseExpress && type != TerracottaRuntimeType.Express) { throw new InvalidConfigurationException("Rejoin cannot be used in Terracotta DSO mode."); } Thread rejoinThread = new Thread(rejoinWorker, "Rejoin Worker Thread [cacheManager: " + cacheManager.getName() + "]"); rejoinThread.setDaemon(true); rejoinThread.start(); } }
private void doInit(Configuration configuration) { if (configuration.getTerracottaConfiguration() != null) { configuration.getTerracottaConfiguration().freezeConfig();
private void doInit(Configuration configuration) { if (configuration.getTerracottaConfiguration() != null) { configuration.getTerracottaConfiguration().freezeConfig();
private void doInit(Configuration configuration) { if (configuration.getTerracottaConfiguration() != null) { configuration.getTerracottaConfiguration().freezeConfig();