/** * Builder method to set the URL. * * @param url * the URL to set * @return this configuration instance */ public final TerracottaClientConfiguration url(String url) { setUrl(url); return this; }
/** * Builder method to set rejoin * * @param rejoin * @return this instance */ public TerracottaClientConfiguration rejoin(boolean rejoin) { this.setRejoin(rejoin); return this; }
/** * 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 init() { if (tcConfigConfiguration == null) { return; } if (tcConfigConfiguration.getUrl() != null) { addAttribute(new SimpleNodeAttribute("url", tcConfigConfiguration.getUrl()).optional(true)); } addAttribute(new SimpleNodeAttribute("rejoin", tcConfigConfiguration.isRejoin()).optional(true).defaultValue( TerracottaClientConfiguration.DEFAULT_REJOIN_VALUE)); addAttribute(new SimpleNodeAttribute("wanEnabledTSA", tcConfigConfiguration.isWanEnabledTSA()).optional(true).defaultValue( TerracottaClientConfiguration.DEFAULT_WAN_ENABLED_TSA_VALUE)); if (tcConfigConfiguration.getOriginalEmbeddedConfig() != null) { addChildElement(new TCConfigElement(this, tcConfigConfiguration.getOriginalEmbeddedConfig())); } }
public static EhcacheTcConfig create(TerracottaClientConfiguration config) { if (config.isUrlConfig()) { String urlOrFilePath = config.getUrl(); if (isFile(urlOrFilePath)) { return new EhcacheTcConfig(Type.FILE, slurpFile(urlOrFilePath)); } else if (isValidURL(urlOrFilePath)) { return new EhcacheTcConfig(Type.EMBEDDED_TC_CONFIG, fetchConfigFromURL(urlOrFilePath)); } else { return new EhcacheTcConfig(Type.URL, urlOrFilePath); } } else { return new EhcacheTcConfig(Type.EMBEDDED_TC_CONFIG, config.getEmbeddedConfig()); } }
TerracottaClientConfiguration terracottaConfig = new TerracottaClientConfiguration(); terracottaConfig.setUrl(serverUrlsString); terracottaConfig.setRejoin(true); configuration.addTerracottaConfig(terracottaConfig);
private void init() { if (tcConfigConfiguration == null) { return; } if (tcConfigConfiguration.getUrl() != null) { addAttribute(new SimpleNodeAttribute("url", tcConfigConfiguration.getUrl()).optional(true)); } addAttribute(new SimpleNodeAttribute("rejoin", tcConfigConfiguration.isRejoin()).optional(true).defaultValue( TerracottaClientConfiguration.DEFAULT_REJOIN_VALUE)); if (tcConfigConfiguration.getOriginalEmbeddedConfig() != null) { addChildElement(new TCConfigElement(this, tcConfigConfiguration.getOriginalEmbeddedConfig())); } }
private void doInit(Configuration configuration) { if (configuration.getTerracottaConfiguration() != null) { configuration.getTerracottaConfiguration().freezeConfig(); if (configuration.getTerracottaConfiguration().isWanEnabledTSA()) { terracottaClient.waitForOrchestrator(getName());
/** * Set url */ public final void setUrl(String url) { this.url = url; validateConfiguration(); }
/** * @return Whether terracotta clustering is being used and rejoin is enabled */ public boolean isTerracottaRejoin() { TerracottaClientConfiguration terracottaConfiguration = getTerracottaConfiguration(); return terracottaConfiguration != null && terracottaConfiguration.isRejoin(); }
private ManagementRESTServiceConfiguration getDefaultClusteredManagementRESTServiceConfiguration(Configuration configuration) { ManagementRESTServiceConfiguration managementRESTService; managementRESTService = new ManagementRESTServiceConfiguration(); String url = configuration.getTerracottaConfiguration().getUrl(); if (url != null && url.contains("@")) { managementRESTService.setSslEnabled(true); } managementRESTService.setEnabled(true); managementRESTService.setBind(ManagementRESTServiceConfiguration.NO_BIND); managementRESTService.setSecurityServiceLocation(ManagementRESTServiceConfiguration.AUTO_LOCATION); return managementRESTService; }
public void afterPropertiesSet() throws IOException, CacheException { logger.info("Initializing EHCache CacheManager"); this.configuration = ConfigurationFactory.parseConfiguration(this.configLocation.getInputStream()); if (this.diskStorePath != null) { logger.info("diskStorePath=" + this.diskStorePath); DiskStoreConfiguration dsConfig = new DiskStoreConfiguration(); dsConfig.setPath(this.diskStorePath); logger.info("diskStorePath (translated)=" + dsConfig.getPath()); configuration.addDiskStore(dsConfig); } if (this.terracottaUrl != null) { logger.info("terracottaUrl=" + this.terracottaUrl); TerracottaClientConfiguration tcConfig = new TerracottaClientConfiguration(); tcConfig.setUrl(this.terracottaUrl); configuration.addTerracottaConfig(tcConfig); } }
/** * 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(); } }
/** * Builder method to set wanEnabledTSA * * @param wanEnabledTSA * @return this instance */ public TerracottaClientConfiguration wanEnabledTSA(boolean wanEnabledTSA) { this.setWanEnabledTSA(wanEnabledTSA); return this; }
private void terracotaConfig(final Config config) { TerracottaClientConfiguration terracota = new TerracottaClientConfiguration(); sbool("ehcache.terracottaConfig", config, "rejoin", terracota::setRejoin); sstr("ehcache.terracottaConfig", config, "url", terracota::setUrl); sbool("ehcache.terracottaConfig", config, "wanEnabledTSA", terracota::setWanEnabledTSA); eh.addTerracottaConfig(terracota); }
void setUpWanConfig() { if (!cache.getCacheManager().getConfiguration().getTerracottaConfiguration().isWanEnabledTSA()) { toolkitInstanceFactory.markCacheWanDisabled(cache.getCacheManager().getName(), cache.getName()); } }
private void init() { if (tcConfigConfiguration == null) { return; } if (tcConfigConfiguration.getUrl() != null) { addAttribute(new SimpleNodeAttribute("url", tcConfigConfiguration.getUrl()).optional(true)); } addAttribute(new SimpleNodeAttribute("rejoin", tcConfigConfiguration.isRejoin()).optional(true).defaultValue( TerracottaClientConfiguration.DEFAULT_REJOIN_VALUE)); addAttribute(new SimpleNodeAttribute("wanEnabledTSA", tcConfigConfiguration.isWanEnabledTSA()).optional(true).defaultValue( TerracottaClientConfiguration.DEFAULT_WAN_ENABLED_TSA_VALUE)); if (tcConfigConfiguration.getOriginalEmbeddedConfig() != null) { addChildElement(new TCConfigElement(this, tcConfigConfiguration.getOriginalEmbeddedConfig())); } }
private void doInit(Configuration configuration) { if (configuration.getTerracottaConfiguration() != null) { configuration.getTerracottaConfiguration().freezeConfig(); if (configuration.getTerracottaConfiguration().isWanEnabledTSA()) { terracottaClient.waitForOrchestrator(getName());
/** * Tell the BeanHandler to extract the entire subtree xml as text at element{@code <tc-config/>}. Expects * to receive the contents of the{@code <tc-config/>} tag and will wrap it in a proper tc-config header / footer. */ public final void extractTcconfig(String text) { this.embeddedConfig = text; validateConfiguration(); }
private boolean isRejoinEnabled() { return terracottaClientConfiguration != null && terracottaClientConfiguration.isRejoin(); }