private static void GetWebCache(CacheServerConfig cache, Hashtable settings) { if (settings.ContainsKey("shared")) { cache.InProc = !Convert.ToBoolean(settings["shared"]); } }
private static void GetCacheClasses(CacheServerConfig cache, Hashtable settings) { if (settings.ContainsKey(cache.Name)) { GetClassifiedCache(cache, (Hashtable)settings[cache.Name]); } }
private static void GetClassifiedCache(CacheServerConfig cache, Hashtable settings) { if (settings.ContainsKey("data-load-balancing")) { cache.AutoLoadBalancing = GetAutoLoadBalancing((Hashtable)settings["data-load-balancing"]); } if (settings.ContainsKey("cluster")) { cache.Cluster = GetCluster(settings); } if (settings.ContainsKey("internal-cache")) { GetInternalCache(cache, (Hashtable)settings["internal-cache"]); } else { GetInternalCache(cache, settings); } if (settings.ContainsKey("notifications")) { cache.Notifications = GetNotifications((Hashtable)settings["notifications"]); } }
private static Hashtable GetCacheClasses(CacheServerConfig cache) { Hashtable settings = new Hashtable(); settings.Add(cache.Name, GetClassifiedCache(cache)); return(settings); }
private static void GetInternalCache(Hashtable source, CacheServerConfig cache, bool localCache) { if (cache.QueryIndices != null) { source.Add("indexes", GetIndexes(cache.QueryIndices)); } if (cache.Storage != null) { source.Add("storage", GetStorage(cache.Storage)); } if (!localCache) { source.Add("type", "local-cache"); source.Add("id", "internal-cache"); } if (cache.EvictionPolicy != null) { source.Add("scavenging-policy", GetEvictionPolicy(cache.EvictionPolicy)); } if (cache.Cleanup != null) { source.Add("clean-interval", cache.Cleanup.Interval.ToString()); } }
public static Hashtable GetCache(CacheServerConfig cache) { Hashtable settings = new Hashtable(); settings.Add("name", cache.Name); if (cache.Log != null) { settings.Add("log", GetLog(cache.Log)); } settings.Add("config-id", cache.ConfigID); settings.Add("config-version", cache.ConfigVersion); settings.Add("deployment-version", cache.DeploymentVersion); if (cache.LastModified != null) { settings.Add("last-modified", cache.LastModified); } if (cache.DataFormat != null) { settings.Add("data-format", cache.DataFormat); } settings.Add("cache-classes", GetCacheClasses(cache)); settings.Add("class", cache.Name); if (cache.PerfCounters != null) { settings.Add("perf-counters", cache.PerfCounters.Enabled); } return(settings); }
// 20110124 #region ICloneable Members public object Clone() { CacheServerConfig config = new CacheServerConfig(); config.Name = Name != null ? (string)Name.Clone(): null; config.cacheType = this.cacheType; config.InProc = InProc; config.ConfigID = ConfigID; config.LastModified = LastModified != null ? (string)LastModified.Clone() : null; config.clientNodes = clientNodes != null?clientNodes.Clone() as ClientNodes : null; config.Log = Log != null ? (Log)Log.Clone(): null; config.PerfCounters = PerfCounters != null ? (PerfCounters)PerfCounters.Clone(): null; config.autoBalancing = this.autoBalancing != null ? (AutoLoadBalancing)this.autoBalancing.Clone() : null; config.Cleanup = Cleanup != null ? (Cleanup)Cleanup.Clone() : null; config.Storage = Storage != null ? (Storage)Storage.Clone() : null; config.EvictionPolicy = EvictionPolicy != null ? (EvictionPolicy)EvictionPolicy.Clone() : null; config.Cluster = Cluster != null ? (Cluster)Cluster.Clone() : null; config.QueryIndices = QueryIndices != null ? (QueryIndex)QueryIndices.Clone() : null; config.IsRegistered = this.IsRegistered; config.IsRunning = this.IsRunning; config.licenseIsExpired = this.licenseIsExpired; config.RuntimeContext = this.RuntimeContext; return(config); }
public static CacheServerConfig[] GetConfig(Hashtable config) { CacheServerConfig[] caches = new CacheServerConfig[config.Count]; int i = 0; foreach (Hashtable cache in config.Values) caches[i++] = GetCacheConfiguration(CollectionsUtil.CreateCaseInsensitiveHashtable(cache)); return caches; }
public static Hashtable GetWebCache(CacheServerConfig cache) { Hashtable settings = new Hashtable(); settings.Add("shared", (!cache.InProc).ToString().ToLower()); settings.Add("cache-id", cache.Name); return(settings); }
private static CacheServerConfig GetCacheConfiguration(Hashtable settings) { CacheServerConfig cache = new CacheServerConfig(); cache.Name = settings["id"].ToString(); if (settings.ContainsKey("web-cache")) GetWebCache(cache, (Hashtable)settings["web-cache"]); if (settings.ContainsKey("cache")) GetCache(cache, (Hashtable)settings["cache"]); return cache; }
public static CacheServerConfig[] GetConfig(Hashtable config) { CacheServerConfig[] caches = new CacheServerConfig[config.Count]; int i = 0; foreach (Hashtable cache in config.Values) { caches[i++] = GetCacheConfiguration(CollectionsUtil.CreateCaseInsensitiveHashtable(cache)); } return(caches); }
public static Hashtable GetCacheConfiguration(CacheServerConfig cache) { Hashtable config = new Hashtable(); config.Add("type", "cache-configuration"); config.Add("id", cache.Name); config.Add("cache", GetCache(cache)); config.Add("web-cache", GetWebCache(cache)); return(config); }
private static void GetCache(CacheServerConfig cache, Hashtable settings) { if (settings.ContainsKey("config-id")) cache.ConfigID = Convert.ToDouble(settings["config-id"]); if (settings.ContainsKey("last-modified")) cache.LastModified = settings["last-modified"].ToString(); if (settings.ContainsKey("log")) cache.Log = GetLog((Hashtable)settings["log"]); if (settings.ContainsKey("cache-classes")) GetCacheClasses(cache, (Hashtable)settings["cache-classes"]); if (settings.ContainsKey("perf-counters")) cache.PerfCounters = GetPerfCounters(settings); }
public object Clone() { CacheServerConfig config = new CacheServerConfig(); config.Name = Name != null ? (string)Name.Clone() : null; config.cacheType = this.cacheType; config.InProc = InProc; config.clientNodes = clientNodes != null?clientNodes.Clone() as ClientNodes : null; config.Log = Log != null ? (Log)Log.Clone() : null; config.PerfCounters = PerfCounters != null ? (PerfCounters)PerfCounters.Clone() : null; #if COMMUNITY || CLIENT config.ReplicationStrategy = ReplicationStrategy != null ? (ReplicationStrategy)ReplicationStrategy.Clone() : null; config.autoBalancing = this.autoBalancing != null ? (AutoLoadBalancing)this.autoBalancing.Clone() : null; #endif config.Cleanup = Cleanup != null ? (Cleanup)Cleanup.Clone() : null; config.Storage = Storage != null ? (Storage)Storage.Clone() : null; config.EvictionPolicy = EvictionPolicy != null ? (EvictionPolicy)EvictionPolicy.Clone() : null; config.ExpirationPolicy = ExpirationPolicy != null ? (ExpirationPolicy)ExpirationPolicy.Clone() : null; config.Cluster = Cluster != null ? (Cluster)Cluster.Clone() : null; config.backingSource = this.backingSource != null ? (BackingSource)this.backingSource.Clone() : null; config.QueryIndices = QueryIndices != null ? (QueryIndex)QueryIndices.Clone() : null; config.Notifications = Notifications != null ? (Notifications)Notifications.Clone() : null; config.SQLDependencyConfig = SQLDependencyConfig != null ? (SQLDependencyConfig)SQLDependencyConfig.Clone() : null; config.TaskConfiguration = TaskConfiguration != null ? (TaskConfiguration)TaskConfiguration.Clone() : null; config.ClientDeathDetection = ClientDeathDetection != null ? (ClientDeathDetection)ClientDeathDetection.Clone() : null; config.SynchronizationStrategy = SynchronizationStrategy != null ? (SynchronizationStrategy)SynchronizationStrategy.Clone() : null; config.ClientActivityNotification = ClientActivityNotification != null ? (ClientActivityNotification)ClientActivityNotification.Clone() : null; config.IsRegistered = this.IsRegistered; config.IsRunning = this.IsRunning; config.licenseIsExpired = this.licenseIsExpired; config.RuntimeContext = this.RuntimeContext; config.DataFormat = this.DataFormat; return(config); }
private static void GetInternalCache(CacheServerConfig cache, Hashtable settings) { if (settings.ContainsKey("storage")) { cache.Storage = GetStorage((Hashtable)settings["storage"]); } if (settings.ContainsKey("scavenging-policy")) { cache.EvictionPolicy = GetEvictionPolicy((Hashtable)settings["scavenging-policy"]); } if (settings.ContainsKey("clean-interval")) { cache.Cleanup = GetCleanup(settings); } }
private static CacheServerConfig GetCacheConfiguration(Hashtable settings) { CacheServerConfig cache = new CacheServerConfig(); cache.Name = settings["id"].ToString(); if (settings.ContainsKey("web-cache")) { GetWebCache(cache, (Hashtable)settings["web-cache"]); } if (settings.ContainsKey("cache")) { GetCache(cache, (Hashtable)settings["cache"]); } return(cache); }
private static List <Alachisoft.NCache.Config.NewDom.CacheServerConfig> convertToNewDom(List <CacheServerConfig> oldCacheConfigsList) { List <Alachisoft.NCache.Config.NewDom.CacheServerConfig> newCacheConfigsList = new List <Alachisoft.NCache.Config.NewDom.CacheServerConfig>(); IEnumerator itr = oldCacheConfigsList.GetEnumerator(); while (itr.MoveNext()) { Alachisoft.NCache.Config.Dom.CacheServerConfig tempOldCacheConfig = (Alachisoft.NCache.Config.Dom.CacheServerConfig)itr.Current; try { Alachisoft.NCache.Config.NewDom.CacheServerConfig tempNewCacheConfig = Alachisoft.NCache.Config.NewDom.DomHelper.convertToNewDom(tempOldCacheConfig); newCacheConfigsList.Add(tempNewCacheConfig); } catch (Exception) { } } return(newCacheConfigsList); }
private static Hashtable GetClassifiedCache(CacheServerConfig cache) { Hashtable settings = new Hashtable(); settings.Add("id", cache.Name); if (cache.AutoLoadBalancing != null) { settings.Add("data-load-balancing", GetAutoLoadBalancing(cache.AutoLoadBalancing)); } if (cache.Cluster == null) { settings.Add("type", "local-cache"); GetInternalCache(settings, cache, true); } else { GetCluster(settings, cache); } return(settings); }
public static Hashtable GetCacheConfiguration(CacheServerConfig cache) { Hashtable config = new Hashtable(); CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); config.Add("type", "cache-configuration"); config.Add("id", cache.Name); config.Add("cache", GetCache(cache)); config.Add("web-cache", GetWebCache(cache)); } finally { System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo; } return(config); }
private static void GetCluster(Hashtable settings, CacheServerConfig cache) { settings.Add("type", cache.Cluster.Topology); settings.Add("stats-repl-interval", cache.Cluster.StatsRepInterval.ToString()); settings.Add("op-timeout", cache.Cluster.OpTimeout.ToString()); if (cache.Cleanup != null) { settings.Add("clean-interval", cache.Cleanup.Interval.ToString()); } settings.Add("internal-cache", new Hashtable()); GetInternalCache((Hashtable)settings["internal-cache"], cache, false); Hashtable cluster = new Hashtable(); cluster.Add("group-id", cache.Name); cluster.Add("class", "tcp"); cluster.Add("channel", GetChannel(cache.Cluster.Channel, false)); settings.Add("cluster", cluster); }
private static void GetCache(CacheServerConfig cache, Hashtable settings) { if (settings.ContainsKey("config-id")) { cache.ConfigID = Convert.ToDouble(settings["config-id"]); } if (settings.ContainsKey("last-modified")) { cache.LastModified = settings["last-modified"].ToString(); } if (settings.ContainsKey("log")) { cache.Log = GetLog((Hashtable)settings["log"]); } if (settings.ContainsKey("cache-classes")) { GetCacheClasses(cache, (Hashtable)settings["cache-classes"]); } if (settings.ContainsKey("perf-counters")) { cache.PerfCounters = GetPerfCounters(settings); } }
private static CacheServerConfig GetCacheConfiguration(Hashtable settings) { CacheServerConfig cache = new CacheServerConfig(); CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; try { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); cache.Name = settings["id"].ToString(); if (settings.ContainsKey("web-cache")) { GetWebCache(cache, (Hashtable)settings["web-cache"]); } if (settings.ContainsKey("cache")) { GetCache(cache, (Hashtable)settings["cache"]); } } finally { System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo; } return(cache); }
/// <summary> /// Populates the object from specified configuration object. /// </summary> /// <param name="configuration"></param> /// <returns></returns> internal static CacheConfig FromConfiguration(CacheServerConfig configuration) { CacheConfig cConfig = null; if (configuration != null) { cConfig = new CacheConfig(); cConfig._useInProc = configuration.InProc; cConfig.CacheId = configuration.Name; if (configuration.Cluster != null) { if (configuration.Cluster.Channel != null) { cConfig._clusterPort = configuration.Cluster.Channel.TcpPort; cConfig._clusterPortRange = configuration.Cluster.Channel.PortRange; } cConfig._useHeartBeat = configuration.Cluster.UseHeartbeat; cConfig._servers = FromHostListToServers(configuration.Cluster.Channel.InitialHosts); string topology = string.Empty; switch (configuration.Cluster.Topology) { case "partitioned": topology = "partitioned-server"; break; case "replicated": topology = "replicated-server"; break; } cConfig._cacheType = topology; } else { cConfig._cacheType = "local-cache"; } if (configuration.Cleanup != null) { cConfig._cleanInterval = configuration.Cleanup.Interval * 1000; ///to millisec } if (configuration.EvictionPolicy != null) { cConfig._evictRatio = (float)Decimal.ToDouble(configuration.EvictionPolicy.EvictionRatio); } if (configuration.Storage != null) { cConfig._cacheMaxSize = configuration.Storage.Size * 1048576; ///from mb to bytes } if (configuration.Log != null) { cConfig._errorLogsEnabled = configuration.Log.TraceErrors; cConfig._detailedLogsEnabled = configuration.Log.TraceDebug; } } return cConfig; }
/// <summary> /// Populates the object from specified configuration object. /// </summary> /// <param name="configuration"></param> /// <returns></returns> public static CacheConfig FromDom(CacheServerConfig config) { Hashtable props = ConfigConverter.ToHashtable(config); return FromProperties(props); }
public static Hashtable GetCacheConfiguration(CacheServerConfig cache) { Hashtable config = new Hashtable(); config.Add("type", "cache-configuration"); config.Add("id", cache.Name); config.Add("cache", GetCache(cache)); config.Add("web-cache", GetWebCache(cache)); return config; }
private static Hashtable GetClassifiedCache(CacheServerConfig cache) { Hashtable settings = new Hashtable(); settings.Add("id", cache.Name); if (cache.AutoLoadBalancing != null) { settings.Add("data-load-balancing", GetAutoLoadBalancing(cache.AutoLoadBalancing)); } if (cache.Cluster == null) { settings.Add("type", "local-cache"); GetInternalCache(settings, cache, true); } else GetCluster(settings, cache); return settings; }
/// <summary> /// The main entry point for the tool. /// </summary> public void SetBridgeCacheMode() { try { _bridgeService = new NCBridgeRPCService(BridgeServer); _bridgeServer = _bridgeService.GetBridgeServer(TimeSpan.FromSeconds(30)); NCacheRPCService nService = new NCacheRPCService(CacheServer); cacheServer = nService.GetCacheServer(new TimeSpan(0, 0, 0, 30)); if (!ValidateParameters()) { return; } //********************************** config = cacheServer.GetCacheConfiguration(CacheName); if (config == null) { OutputProvider.WriteErrorLine("Error : The cache'{0}' does not exist on server {1}:{2} .", CacheName, NCache.ServerName, NCache.Port); return; } if (config.CacheType.ToLower().Equals("local-cache")) { OutputProvider.WriteLine("Local Cache cannot be Set as a bridge cache"); return; } //cacheServer = GetCacheServers(config.Cluster.GetAllConfiguredNodes()); bool isNotMaster = false; int passiveCount = 0; TargetCacheCofiguration targtCacheConfig = null; if (_bridgeServer != null) { try { OutputProvider.WriteLine("Setting Cache Mode To Bridge '{0}' on {1}:{2}.", BridgeId, _bridgeService.ServerName, _bridgeService.Port); Alachisoft.NCache.Bridging.Configuration.BridgeConfiguration bridgeConfig = _bridgeServer.GetBridgeConfiguration(BridgeId); ToolsUtil.VerifyBridgeConfigurations(bridgeConfig, BridgeId); List <TargetCacheCofiguration> previouslyAddedCaches = bridgeConfig.TargetCacheConfigList; if (previouslyAddedCaches.Count >= 1) { //checking validations regarding bridge foreach (TargetCacheCofiguration pCache in previouslyAddedCaches) { if (pCache.CacheID.ToLower().Equals(CacheName.ToLower())) { isNotMaster = !pCache.IsMaster; targtCacheConfig = pCache; } if (pCache.Status.Equals("passive")) { passiveCount++; } } } else { OutputProvider.WriteErrorLine("No Cache Exists in Bridge {0}", BridgeId); } if (passiveCount >= 1 && State.Equals(BridgeCacheStateParam.Passive)) { OutputProvider.WriteErrorLine("There is already a Passive cache in Bridge", BridgeId); return; } if (!isNotMaster) { OutputProvider.WriteErrorLine("Bridge Cache '{0}' is a master Node,please change masterNode first", CacheName); return; } if (targtCacheConfig.Status.Equals(State.ToString())) { OutputProvider.WriteErrorLine("Bridge Cache '{0}' is already {1}", CacheName, State.ToString()); return; } // //Adding Bridge to config.ncconf BridgeConfig bridgeConf = config.Bridge; bridgeConf.Status = State.ToString(); config.Bridge = bridgeConf; WriteToClientConf(); WriteToBridgeConf(bridgeConfig, targtCacheConfig); OutputProvider.WriteLine("Cache '{0}' mode set to {1}", BridgeId, State.ToString()); } catch (SecurityException e) { OutputProvider.WriteErrorLine("Failed to Add Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message); } catch (Exception e) { OutputProvider.WriteErrorLine("Failed to Add Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message); } } } catch (Exception e) { OutputProvider.WriteErrorLine("Error: {0}", e.Message); } finally { if (_bridgeService != null) { _bridgeService.Dispose(); } if (NCache != null) { NCache.Dispose(); } } }
public static Hashtable ToHashtable(CacheServerConfig[] configs) { return DomToHashtable.GetConfig(configs); }
private static void GetWebCache(CacheServerConfig cache, Hashtable settings) { if (settings.ContainsKey("shared")) cache.InProc = !Convert.ToBoolean(settings["shared"]); }
public static Hashtable GetWebCache(CacheServerConfig cache) { Hashtable settings = new Hashtable(); settings.Add("shared", (!cache.InProc).ToString().ToLower()); settings.Add("cache-id", cache.Name); return settings; }
/// <summary> /// The main entry point for the tool. /// </summary> public void AddBridgeCache() { try { if (!ValidateParameters()) { return; } _bridgeService = new NCBridgeRPCService(BridgeServer); if (Port == -1) { _bridgeService.Port = _bridgeService.UseTcp ? BridgeConfigurationManager.NCacheTcpPort : BridgeConfigurationManager.NCacheHttpPort; } else { _bridgeService.Port = Port; } if (!string.IsNullOrEmpty(BridgeServer)) { _bridgeService.ServerName = BridgeServer; } _bridgeServer = _bridgeService.GetBridgeServer(TimeSpan.FromSeconds(30)); NCacheRPCService nService = new NCacheRPCService(CacheServer); cacheServer = nService.GetCacheServer(new TimeSpan(0, 0, 0, 30)); //********************************** config = cacheServer.GetCacheConfiguration(CacheName); if (config == null) { OutputProvider.WriteErrorLine("Error : The cache'{0}' does not exist on server {1}:{2} .", CacheName, NCache.ServerName, NCache.Port); return; } if (config.CacheType.ToLower().Equals("local-cache")) { OutputProvider.WriteLine("Local Cache cannot be added as a bridge cache"); return; } //cacheServer = GetCacheServers(config.Cluster.GetAllConfiguredNodes()); if (_bridgeServer != null) { try { OutputProvider.WriteLine("Adding Cache To Bridge '{0}' on {1}:{2}.", BridgeId, _bridgeService.ServerName, _bridgeService.Port); Alachisoft.NCache.Bridging.Configuration.BridgeConfiguration bridgeConfig = _bridgeServer.GetBridgeConfiguration(BridgeId); if (bridgeConfig == null) { OutputProvider.WriteErrorLine("No Bridge with Bridge ID '{0} exists' on Server {1}:{2}.", BridgeId, _bridgeService.ServerName, _bridgeService.Port); return; } TargetCacheCofiguration targtCacheConfig = new TargetCacheCofiguration(); targtCacheConfig.CacheID = CacheName; targtCacheConfig.CacheAlias = Alias; // set the Alias, null if name is different. Alachisoft.NCache.Config.NewDom.CacheServerConfig serverConfig = cacheServer.GetNewConfiguration(CacheName); string servers = String.Empty; foreach (Address node in serverConfig.CacheDeployment.Servers.GetAllConfiguredNodes()) { servers += node.IpAddress + ","; } servers = servers.Remove(servers.Length - 1); targtCacheConfig.Servers = servers; targtCacheConfig.IsConnected = true; if (State.Equals(BridgeCacheStateParam.Active)) { if (!VerifyBridgeMasterCache(BridgeId, false, bridgeConfig)) { targtCacheConfig.IsMaster = true; } targtCacheConfig.Status = BridgeCacheStateParam.Active.ToString(); } else { targtCacheConfig.Status = BridgeCacheStateParam.Passive.ToString(); } ToolsUtil.VerifyBridgeConfigurations(bridgeConfig, BridgeId); List <TargetCacheCofiguration> previouslyAddedCaches = bridgeConfig.TargetCacheConfigList; if (previouslyAddedCaches.Count <= 1) { //checking validations regarding bridge foreach (TargetCacheCofiguration pCache in previouslyAddedCaches) { if (pCache.CacheID.ToLower().Equals(targtCacheConfig.CacheID.ToLower())) { OutputProvider.WriteErrorLine("Failed to Add Cache to bridge '{0}'. Error:No Same Cache Can be Added Twice ", BridgeId); return; } if (pCache.Status.Equals("passive")) { OutputProvider.WriteErrorLine("Failed to Add Cache to bridge '{0}'. Error:No both bridge caches can be passive ", BridgeId); return; } } } else { OutputProvider.WriteErrorLine("Failed to Add Cache to bridge '{0}'. Error:No More than 2 caches can be add at a time ", BridgeId); return; } // //Adding Bridge to config.ncconf BridgeConfig bridgeConf = new BridgeConfig(); bridgeConf.CacheAlias = Alias; bridgeConf.Id = BridgeId; if (config != null) { bridgeConf.Servers = bridgeConfig.BridgeNodes; bridgeConf.Port = bridgeConfig.BridgePort; bridgeConf.Status = State.ToString(); } config.Bridge = bridgeConf; byte[] userId = null; byte[] paswd = null; if (UserId != string.Empty && Password != string.Empty) { userId = EncryptionUtil.Encrypt(UserId); paswd = EncryptionUtil.Encrypt(Password); } //writing to config.ncconf config.ConfigVersion++; cacheServer.ConfigureBridgeToCache(config, userId, paswd, true); cacheServer.HotApplyBridgeReplicator(CacheName, false); Alachisoft.NCache.Config.NewDom.CacheServerConfig nConfig = cacheServer.GetNewConfiguration(CacheName); foreach (Address node in nConfig.CacheDeployment.Servers.GetAllConfiguredNodes()) { NCache.ServerName = node.IpAddress.ToString(); ICacheServer server = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30)); server.ConfigureBridgeToCache(config, userId, paswd, true); server.HotApplyBridgeReplicator(CacheName, false); } ConveyToRegisteredNodes(); char [] separater = { ',' }; bridgeConfig.TargetCacheConfigList.Add(targtCacheConfig); // write in all bridge nodes bridge.nconnf file bridgeConfig.DeploymentVersion++; foreach (string bridgeIp in bridgeConfig.BridgeNodes.Split(separater).ToList()) { _bridgeService = new NCBridgeRPCService(bridgeIp); _bridgeServer = _bridgeService.GetBridgeServer(TimeSpan.FromSeconds(30)); _bridgeServer.RegisterBridge(bridgeConfig, true, true); } OutputProvider.WriteLine("{0} successfully added to BridgeID {1}", CacheName, BridgeId); } catch (SecurityException e) { OutputProvider.WriteErrorLine("Failed to Add Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message); } catch (Exception e) { OutputProvider.WriteErrorLine("Failed to Add Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message); } } } catch (Exception e) { OutputProvider.WriteErrorLine("Error: {0}", e.Message); } finally { if (_bridgeService != null) { _bridgeService.Dispose(); } if (NCache != null) { NCache.Dispose(); } } }
private static string GetProps(CacheServerConfig[] configs) { Hashtable table = ConfigConverter.ToHashtable(configs); string props = ConfigReader.ToPropertiesString(table); return props; }
private static void GetCluster(Hashtable settings, CacheServerConfig cache) { settings.Add("type", cache.Cluster.Topology); settings.Add("stats-repl-interval", cache.Cluster.StatsRepInterval.ToString()); settings.Add("op-timeout", cache.Cluster.OpTimeout.ToString()); settings.Add("use-heart-beat", cache.Cluster.UseHeartbeat.ToString().ToLower()); if (cache.Cleanup != null) settings.Add("clean-interval", cache.Cleanup.Interval.ToString()); settings.Add("internal-cache", new Hashtable()); GetInternalCache((Hashtable)settings["internal-cache"], cache, false); Hashtable cluster = new Hashtable(); cluster.Add("group-id", cache.Name); cluster.Add("class", "tcp"); cluster.Add("channel", GetChannel(cache.Cluster.Channel, cache.Cluster.UseHeartbeat)); settings.Add("cluster", cluster); }
public static Hashtable GetCache(CacheServerConfig cache) { Hashtable settings = new Hashtable(); settings.Add("name", cache.Name); if (cache.Log != null) settings.Add("log", GetLog(cache.Log)); settings.Add("config-id", cache.ConfigID); if (cache.LastModified != null) settings.Add("last-modified", cache.LastModified); settings.Add("cache-classes", GetCacheClasses(cache)); settings.Add("class", cache.Name); if (cache.PerfCounters != null) settings.Add("perf-counters", cache.PerfCounters.Enabled); return settings; }
private static void GetInternalCache(Hashtable source, CacheServerConfig cache, bool localCache) { if (cache.QueryIndices != null) source.Add("indexes", GetIndexes(cache.QueryIndices)); if (cache.Storage != null) source.Add("storage", GetStorage(cache.Storage)); if (!localCache) { source.Add("type", "local-cache"); source.Add("id", "internal-cache"); } if (cache.EvictionPolicy != null) source.Add("scavenging-policy", GetEvictionPolicy(cache.EvictionPolicy)); if (cache.Cleanup != null) source.Add("clean-interval", cache.Cleanup.Interval.ToString()); }
/// <summary> /// Internal method that actually creates the cache. A HashMap containing the config parameters /// is passed to this method. /// </summary> /// <param name="propertyTable">contains the properties provided by the user in the for of Hashtable</param> /// <param name="itemAdded">item added handler</param> /// <param name="itemRemoved">item removed handler</param> /// <param name="itemUpdated">item updated handler</param> /// <param name="cacheMiss">cache miss handler</param> /// <param name="cacheCleared">cache cleared handler</param> /// <returns>return the Cache object</returns> static private Cache CreateFromProperties(IDictionary properties, CacheServerConfig config, CustomRemoveCallback customRemove, CustomUpdateCallback customUpdate, bool isStartingAsMirror, bool twoPhaseInitialization) { Cache cache = new Cache(); cache.Configuration = config; if (customRemove != null) cache.CustomRemoveCallbackNotif += customRemove; if (customUpdate != null) cache.CustomUpdateCallbackNotif += customUpdate; cache.Initialize(properties, true, isStartingAsMirror,twoPhaseInitialization); return cache; }
public static Hashtable GetConfig(CacheServerConfig cache) { return(GetCacheConfiguration(cache)); }
/// <summary> /// This overload is used to call the Internal method that actually creates the cache. /// </summary> /// <param name="propertyString"></param> /// <returns></returns> static public Cache CreateFromPropertyString(string propertyString,CacheServerConfig config, bool isStartedAsMirror, bool twoPhaseInitialization) { ConfigReader propReader = new PropsConfigReader(propertyString); return CreateFromProperties(propReader.Properties,config, null, null, isStartedAsMirror,twoPhaseInitialization); }
public static Dictionary <Runtime.CacheManagement.ServerNode, List <Runtime.CacheManagement.CacheClient> > GetCacheClients(string cacheName, string initialNodeName, Runtime.CacheManagement.CacheContext context, int port) { CacheService cacheService = GetCacheService(context); if (port != 0) { cacheService.Port = port; } string startingNode = initialNodeName; Alachisoft.NCache.Config.Dom.CacheServerConfig cacheServerConfig = null; Alachisoft.NCache.Management.ICacheServer cacheServer = null; Dictionary <Runtime.CacheManagement.ServerNode, List <Runtime.CacheManagement.CacheClient> > clientList = new Dictionary <Runtime.CacheManagement.ServerNode, List <Runtime.CacheManagement.CacheClient> >(); try { if (initialNodeName.Equals(string.Empty)) { cacheServerConfig = GetCacheConfigThroughClientConfig(cacheName, port, context); if (cacheServerConfig == null) { throw new ManagementException("cache with name " + cacheName + " not found in " + config); } } else { cacheService.ServerName = initialNodeName; cacheServer = cacheService.GetCacheServer(new TimeSpan(0, 0, 0, 30)); if (cacheServer == null) { throw new ManagementException("provided initial node not available"); } cacheServerConfig = cacheServer.GetCacheConfiguration(cacheName); if (cacheServerConfig == null) { throw new ManagementException("cache with name " + cacheName + " not registered on specified node"); } } //For Local Cache if (cacheServerConfig.CacheType.Equals(LOCALCACHE, StringComparison.OrdinalIgnoreCase)) { if (cacheServerConfig.InProc) { throw new ArgumentException("API is not supported for Local Inproc Cache"); } cacheService.ServerName = Environment.MachineName; cacheServer = cacheService.GetCacheServer(new TimeSpan(0, 0, 0, 30)); if (cacheServer != null) { if (cacheServer.IsRunning(cacheName)) { Runtime.CacheManagement.ServerNode serverNode = new Runtime.CacheManagement.ServerNode(); serverNode.ServerIP = Environment.MachineName; List <Alachisoft.NCache.Common.Monitoring.ClientProcessStats> clients = cacheServer.GetClientProcessStats(cacheServerConfig.Name); List <Runtime.CacheManagement.CacheClient> list = new List <Runtime.CacheManagement.CacheClient>(); foreach (Alachisoft.NCache.Common.Monitoring.ClientProcessStats clientNode in clients) { Runtime.CacheManagement.CacheClient cacheClient = new Runtime.CacheManagement.CacheClient(); cacheClient.ClientIP = clientNode.Address.IpAddress.ToString(); cacheClient.Port = clientNode.Address.Port; cacheClient.ProcessID = clientNode.ProcessID; list.Add(cacheClient); } clientList.Add(serverNode, list); } } return(clientList); } //For Clustered Cache else { ArrayList initialHost = InitialHostList(cacheServerConfig.Cluster.Channel.InitialHosts); foreach (object host in initialHost) { try { cacheService.ServerName = (string)host; cacheServer = cacheService.GetCacheServer(new TimeSpan(0, 0, 0, 30)); if (cacheServer.IsRunning(cacheName)) { Runtime.CacheManagement.ServerNode serverNode = new Runtime.CacheManagement.ServerNode(); serverNode.ServerIP = host as string; serverNode.Port = cacheServerConfig.Cluster.Channel.TcpPort; List <Alachisoft.NCache.Common.Monitoring.ClientProcessStats> clients = cacheServer.GetClientProcessStats(cacheServerConfig.Name); List <Runtime.CacheManagement.CacheClient> list = new List <Runtime.CacheManagement.CacheClient>(); foreach (Alachisoft.NCache.Common.Monitoring.ClientProcessStats clientNode in clients) { Runtime.CacheManagement.CacheClient cacheClient = new Runtime.CacheManagement.CacheClient(); cacheClient.ClientIP = clientNode.Address.IpAddress.ToString(); cacheClient.Port = clientNode.Address.Port; cacheClient.ProcessID = clientNode.ProcessID; list.Add(cacheClient); } clientList.Add(serverNode, list); } } catch (Exception e) { } } return(clientList); } } catch (Exception ex) { throw new ManagementException(ex.Message); } finally { if (cacheServer != null) { cacheServer.Dispose(); } cacheService.Dispose(); } return(null); }
public static Hashtable ToHashtable(CacheServerConfig config) { return(DomToHashtable.GetConfig(config)); }
public bool RegisterCache(string cacheId, CacheServerConfig config, string partId, bool overwrite, bool hotApply, bool isLocalNode) { if (cacheId == null) throw new ArgumentNullException("cacheId"); //We load configuration before applying the new changes to preserve some old values in the config. cacheId = cacheId.ToLower(); CacheInfo cacheInfo = null; _rwLock.AcquireWriterLock(Timeout.Infinite); try { if (s_partitionedCaches.Contains(cacheId.ToLower())) throw new Runtime.Exceptions.ManagementException("A cache with same cacheId already exists"); if (s_caches.Contains(cacheId.ToLower())) { if (!overwrite) { return false; } cacheInfo = (CacheInfo)s_caches[cacheId.ToLower()]; //(WARNING) This code is here to save the old value of connection-retries //in the cluster configuration to avoid override by NCManager. //This code should be removed after these options appears on UI. //props = GetChangedConfigForTemp(cacheId.ToLower(), cacheInfo.CacheProps, props); } else { ///This is until we change the use of properties in Cache ///from props stirng or hashtable to Dom /// string props = GetProps(config); ClientConfigManager.LocalCacheId = this.LocalCacheIP; ClientConfigManager.AddCache(cacheId, config); cacheInfo = new CacheInfo(); cacheInfo.Cache = new LeasedCache(props); s_caches[cacheId.ToLower()] = cacheInfo; } cacheInfo.CacheProps = config; if (hotApply && cacheInfo != null && cacheInfo.Cache != null && cacheInfo.Cache.IsRunning) { CacheConfig cc = CacheConfig.FromConfiguration(config); Alachisoft.NCache.Caching.Util.HotConfig hotConfig = new Alachisoft.NCache.Caching.Util.HotConfig(); hotConfig.IsErrorLogsEnabled = cc.IsErrorLogsEnabled; hotConfig.IsDetailedLogsEnabled = cc.IsDetailedLogsEnabled; hotConfig.CacheMaxSize = cc.CacheMaxSize; hotConfig.CleanInterval = cc.CleanInterval; hotConfig.EvictRatio = cc.EvictRatio; cacheInfo.Cache.ApplyHotConfiguration(hotConfig); } SaveConfiguration(); } catch (Exception) { throw; } finally { _rwLock.ReleaseWriterLock(); } return true; }
private static void GetInternalCache(CacheServerConfig cache, Hashtable settings) { if (settings.ContainsKey("indexes")) cache.QueryIndices = GetIndexes((Hashtable)settings["indexes"]); if (settings.ContainsKey("storage")) cache.Storage = GetStorage((Hashtable)settings["storage"]); if (settings.ContainsKey("scavenging-policy")) cache.EvictionPolicy = GetEvictionPolicy((Hashtable)settings["scavenging-policy"]); if (settings.ContainsKey("clean-interval")) cache.Cleanup = GetCleanup(settings); }
public bool ApplyCacheConfiguration(string cacheId, CacheServerConfig props, bool hotApply) { if (cacheId == null) throw new ArgumentNullException("cacheId"); cacheId = cacheId.ToLower(); if (s_caches.Contains(cacheId)) { _rwLock.AcquireWriterLock(Timeout.Infinite); try { CacheInfo cacheInfo = (CacheInfo)s_caches[cacheId.ToLower()]; if (cacheInfo != null) { cacheInfo.CacheProps = props; SaveConfiguration(); } } finally { _rwLock.ReleaseWriterLock(); } return true; } return false; }
public static Hashtable GetConfig(CacheServerConfig[] caches) { Hashtable settings = new Hashtable(); foreach (CacheServerConfig cache in caches) settings.Add(cache.Name, GetCacheConfiguration(cache)); return settings; }
private static Hashtable GetCacheClasses(CacheServerConfig cache) { Hashtable settings = new Hashtable(); settings.Add(cache.Name, GetClassifiedCache(cache)); return settings; }
/// <summary> /// Adds Server Node /// </summary> /// <param name="cacheId"></param> /// <param name="config"></param> /// <param name="partId"></param> /// <param name="overwrite"></param> /// <param name="hotApply"></param> /// <returns></returns> public bool RegisterCache(string cacheId, CacheServerConfig config, string partId, bool overwrite, bool hotApply, bool isLocalNode) { //overload 1 ManagementCommand command = GetManagementCommand(ManagementUtil.MethodName.RegisterCache, 1); command.Parameters.AddParameter(cacheId); command.Parameters.AddParameter(config); command.Parameters.AddParameter(partId); command.Parameters.AddParameter(overwrite); command.Parameters.AddParameter(hotApply); command.Parameters.AddParameter(isLocalNode); return (bool)ExecuteCommandOnCacehServer(command); }
public string CanApplyHotConfiguration(string cacheId, CacheServerConfig config) { ManagementCommand command = GetManagementCommand(ManagementUtil.MethodName.CanApplyHotConfig); command.Parameters.AddParameter(cacheId); command.Parameters.AddParameter(config); return ExecuteCommandOnCacehServer(command) as string; }
public static Alachisoft.NCache.Config.Dom.CacheServerConfig convertToOldDom(Alachisoft.NCache.Config.NewDom.CacheServerConfig newDom) { Alachisoft.NCache.Config.Dom.CacheServerConfig oldDom = null; try { if (newDom != null) { oldDom = new Alachisoft.NCache.Config.Dom.CacheServerConfig(); if (newDom.CacheSettings != null) { oldDom.Name = newDom.Name; oldDom.InProc = newDom.CacheSettings.InProc; oldDom.ConfigVersion = newDom.ConfigVersion; oldDom.ConfigID = newDom.ConfigID; oldDom.LastModified = newDom.CacheSettings.LastModified; oldDom.DataFormat = newDom.CacheSettings.DataFormat; if (newDom.CacheSettings.Log != null) { oldDom.Log = newDom.CacheSettings.Log; } else { oldDom.Log = new Alachisoft.NCache.Config.Dom.Log(); } if (newDom.CacheSettings.PerfCounters != null) { oldDom.PerfCounters = newDom.CacheSettings.PerfCounters; } else { oldDom.PerfCounters = new Alachisoft.NCache.Config.Dom.PerfCounters(); } if (newDom.CacheSettings.ClientDeathDetection != null) { oldDom.ClientDeathDetection = newDom.CacheSettings.ClientDeathDetection; } else { oldDom.ClientDeathDetection = new Alachisoft.NCache.Config.Dom.ClientDeathDetection(); } if (newDom.CacheSettings.BackingSource != null) { oldDom.BackingSource = newDom.CacheSettings.BackingSource; } if (newDom.CacheSettings.Notifications != null) { oldDom.Notifications = newDom.CacheSettings.Notifications; } else { oldDom.Notifications = new Alachisoft.NCache.Config.Dom.Notifications(); } if (newDom.CacheSettings.Cleanup != null) { oldDom.Cleanup = newDom.CacheSettings.Cleanup; } else { oldDom.Cleanup = new Alachisoft.NCache.Config.Dom.Cleanup(); } if (newDom.CacheSettings.Storage != null) { oldDom.Storage = newDom.CacheSettings.Storage; } else { oldDom.Storage = new Alachisoft.NCache.Config.Dom.Storage(); } if (newDom.CacheSettings.EvictionPolicy != null) { oldDom.EvictionPolicy = newDom.CacheSettings.EvictionPolicy; } else { oldDom.EvictionPolicy = new Alachisoft.NCache.Config.Dom.EvictionPolicy(); } if (newDom.CacheSettings.SynchronizationStrategy != null) { oldDom.SynchronizationStrategy = newDom.CacheSettings.SynchronizationStrategy; } if (newDom.CacheSettings.CacheTopology != null) { oldDom.CacheType = newDom.CacheSettings.CacheType; } if (oldDom.CacheType.Equals("clustered-cache")) { if (newDom.CacheDeployment != null) { if (oldDom.Cluster == null) { oldDom.Cluster = new Alachisoft.NCache.Config.Dom.Cluster(); } string topology = newDom.CacheSettings.CacheTopology.Topology; if (topology != null) { topology = topology.ToLower(); if (topology.Equals("replicated")) { topology = "replicated-server"; } else if (topology.Equals("partitioned")) { topology = "partitioned-server"; } else if (topology.Equals("partitioned-replica")) { topology = "partitioned-replicas-server"; } else if (topology.Equals("mirrored")) { topology = "mirror-server"; } else if (topology.Equals("local")) { topology = "local-cache"; } else if (topology.Equals("client-cache")) { topology = "client-cache"; } } oldDom.Cluster.Topology = topology; oldDom.Cluster.OpTimeout = newDom.CacheSettings.CacheTopology.ClusterSettings.OpTimeout; oldDom.Cluster.StatsRepInterval = newDom.CacheSettings.CacheTopology.ClusterSettings.StatsRepInterval; if (oldDom.Cluster.Channel == null) { oldDom.Cluster.Channel = new Alachisoft.NCache.Config.Dom.Channel(); } oldDom.Cluster.Channel.TcpPort = newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.TcpPort; oldDom.Cluster.Channel.PortRange = newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.PortRange; oldDom.Cluster.Channel.ConnectionRetries = newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.ConnectionRetries; oldDom.Cluster.Channel.ConnectionRetryInterval = newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.ConnectionRetryInterval; if (newDom.CacheSettings.CacheTopology.ClusterSettings.ReplicationStrategy != null) { oldDom.ReplicationStrategy = newDom.CacheSettings.CacheTopology.ClusterSettings.ReplicationStrategy; } else { oldDom.ReplicationStrategy = new Alachisoft.NCache.Config.Dom.ReplicationStrategy(); } oldDom.Cluster.Channel.InitialHosts = createInitialHosts(newDom.CacheDeployment.Servers.NodesList, newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.TcpPort); oldDom.Cluster.Channel.NumInitHosts = newDom.CacheDeployment.Servers.NodesList.Count; oldDom.Cluster.ActiveMirrorNode = newDom.CacheDeployment.Servers.ActiveMirrorNode; if (newDom.CacheDeployment.ClientNodes != null) { if (oldDom.ClientNodes == null) { oldDom.ClientNodes = new Alachisoft.NCache.Config.Dom.ClientNodes(); } oldDom.ClientNodes = newDom.CacheDeployment.ClientNodes; } oldDom.DeploymentVersion = newDom.CacheDeployment.DeploymentVersion; } } if (newDom.CacheSettings.Security != null) { oldDom.Security = newDom.CacheSettings.Security; } if (newDom.CacheSettings.AutoLoadBalancing != null) { oldDom.AutoLoadBalancing = newDom.CacheSettings.AutoLoadBalancing; } if (newDom.CacheSettings.ClientActivityNotification != null) { oldDom.ClientActivityNotification = newDom.CacheSettings.ClientActivityNotification; } oldDom.IsRunning = newDom.IsRunning; oldDom.IsRegistered = newDom.IsRegistered; oldDom.IsExpired = newDom.IsExpired; oldDom.DataFormat = newDom.CacheSettings.DataFormat; } } } catch (Exception ex) { throw new Exception("DomHelper.convertToOldDom" + ex.Message); } return(oldDom); }
/// <summary> /// Update TCP cache settings that includes updated list of TCP members /// </summary> /// <param name="cacheId"></param> /// <param name="props"></param> /// <exception cref="ArgumentNullException">cacheId is a null reference (Nothing in Visual Basic).</exception> public bool ApplyCacheConfiguration(string cacheId, CacheServerConfig props, bool hotApply) { ManagementCommand command = GetManagementCommand(ManagementUtil.MethodName.ApplyCacheConfiguration); command.Parameters.AddParameter(cacheId); command.Parameters.AddParameter(props); command.Parameters.AddParameter(hotApply); return (bool)ExecuteCommandOnCacehServer(command); }
/// <summary> /// The main entry point for the tool. /// </summary> public void RemoveBridgeCache() { try { _bridgeService = new NCBridgeRPCService(BridgeServer); _bridgeServer = _bridgeService.GetBridgeServer(TimeSpan.FromSeconds(30)); NCacheRPCService nService = new NCacheRPCService(CacheServer); cacheServer = nService.GetCacheServer(new TimeSpan(0, 0, 0, 30)); if (!ValidateParameters()) { return; } //********************************** config = cacheServer.GetCacheConfiguration(CacheName); if (config == null) { OutputProvider.WriteErrorLine("Error : The cache'{0}' does not exist on server {1}:{2} .", CacheName, NCache.ServerName, NCache.Port); return; } { //OutputProvider.WriteErrorLine("Error : The Bidge {0} is running on {1} , please stop Bridge and try again .", BridgeId, NCache.ServerName); //return; } if (config.CacheType.ToLower().Equals("local-cache")) { OutputProvider.WriteLine("Local Cache cannot be added as a bridge cache"); return; } //cacheServer = GetCacheServers(config.Cluster.GetAllConfiguredNodes()); if (_bridgeServer != null) { try { OutputProvider.WriteLine("Removing Cache To Bridge '{0}' on {1}:{2}.", BridgeId, _bridgeService.ServerName, _bridgeService.Port); Alachisoft.NCache.Bridging.Configuration.BridgeConfiguration bridgeConfig = _bridgeServer.GetBridgeConfiguration(BridgeId); ToolsUtil.VerifyBridgeConfigurations(bridgeConfig, BridgeId); if (bridgeConfig == null) { OutputProvider.WriteErrorLine("No Bridge with Bridge ID '{0} exists' on Server {1}:{2}.", BridgeId, _bridgeService.ServerName, _bridgeService.Port); return; } TargetCacheCofiguration targtCacheConfig = new TargetCacheCofiguration(); targtCacheConfig.CacheID = CacheName; targtCacheConfig.Servers = cacheServer.GetHostName(); targtCacheConfig.IsConnected = true; { if (!VerifyBridgeMasterCache(BridgeId, false, bridgeConfig)) { targtCacheConfig.IsMaster = true; } targtCacheConfig.Status = BridgeCacheStateParam.Active.ToString(); } List <TargetCacheCofiguration> previouslyAddedCaches = bridgeConfig.TargetCacheConfigList; int removedCacheIndex = -1; if (previouslyAddedCaches.Count >= 1) { int iteration = 0; //checking validations regarding bridge foreach (TargetCacheCofiguration pCache in previouslyAddedCaches) { //if exists than remove if (pCache.CacheID.ToLower().Equals(CacheName.ToLower())) { if (pCache.CacheAlias.ToLower().Equals(Alias.ToLower()) || string.IsNullOrEmpty(Alias)) { removedCacheIndex = iteration; if (pCache.IsMaster) { OutputProvider.WriteErrorLine("Failed to Remove Cache to bridge '{0}'. Error: Master cache cannot be removed ", BridgeId); return; } } } if (pCache.Status.Equals("passive")) { OutputProvider.WriteErrorLine("Failed to Remove Cache to bridge '{0}'. Error: No both bridge caches can be passive ", BridgeId); return; } iteration++; } } else { OutputProvider.WriteErrorLine("Failed to Remove Cache There is currently no Cache Added in Bridge {0} ", BridgeId); return; } // if (removedCacheIndex >= 0) { bridgeConfig.TargetCacheConfigList.RemoveAt(removedCacheIndex); } else { OutputProvider.WriteErrorLine("Bridge Cache Does not exists with name{0} in Bridge '{1}'", CacheName, BridgeId); return; } //Adding Bridge to config.ncconf BridgeConfig bridgeConf = config.Bridge; config.Bridge = null; byte[] userId = null; byte[] paswd = null; if (UserId != string.Empty && Password != string.Empty) { userId = EncryptionUtil.Encrypt(UserId); paswd = EncryptionUtil.Encrypt(Password); } //writing to config.ncconf config.ConfigVersion++; cacheServer.ConfigureBridgeToCache(config, userId, paswd, true); cacheServer.HotApplyBridgeReplicator(CacheName, false); ConveyToRegisteredNodes(); char[] separater = { ',' }; // write in all bridge nodes bridge.nconnf file bool write = false; foreach (string bridgeIp in bridgeConfig.BridgeNodes.Split(separater).ToList()) { try{ _bridgeService = new NCBridgeRPCService(bridgeIp); _bridgeServer = _bridgeService.GetBridgeServer(TimeSpan.FromSeconds(30)); _bridgeServer.RegisterBridge(bridgeConfig, true, true); write = true; OutputProvider.WriteLine("Removed Bridge Cache {0} From Bridge {1}", CacheName, BridgeId); } catch (Exception e) { OutputProvider.WriteErrorLine("Removing Bridge Cache {0} From Bridge Server{1} Gives Error: {2}", bridgeConf, bridgeIp, e.Message); } } } catch (SecurityException e) { OutputProvider.WriteErrorLine("Failed to Remove Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message); } catch (Exception e) { OutputProvider.WriteErrorLine("Failed to Remove Cache to bridge '{0}'. Error: {1} ", BridgeId, e.Message); } } } catch (Exception e) { OutputProvider.WriteErrorLine("Error: {0}", e.Message); } finally { if (_bridgeService != null) { _bridgeService.Dispose(); } if (NCache != null) { NCache.Dispose(); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private static Alachisoft.NCache.Config.Dom.CacheServerConfig[] convertToOldDom(Alachisoft.NCache.Config.NewDom.CacheServerConfig[] newCacheConfigsList) throws Exception private static Alachisoft.NCache.Config.Dom.CacheServerConfig[] convertToOldDom(Alachisoft.NCache.Config.NewDom.CacheServerConfig[] newCacheConfigsList) { Alachisoft.NCache.Config.Dom.CacheServerConfig[] oldCacheConfigsList = new CacheServerConfig[newCacheConfigsList.Length]; for (int index = 0; index < newCacheConfigsList.Length; index++) { try { oldCacheConfigsList[index] = Alachisoft.NCache.Config.NewDom.DomHelper.convertToOldDom(newCacheConfigsList[index]); } catch (Exception ex) { } } return oldCacheConfigsList; }
public Exception CanApplyHotConfig(string cacheId, CacheServerConfig config) { CacheInfo cacheInfo = null; cacheId = cacheId.ToLower(); Hashtable result = new Hashtable(); Alachisoft.NCache.Caching.Util.HotConfig hotConfig = new Alachisoft.NCache.Caching.Util.HotConfig(); hotConfig.IsErrorLogsEnabled = config.Log.TraceErrors; hotConfig.IsDetailedLogsEnabled = config.Log.TraceNotices; hotConfig.CacheMaxSize = config.Storage.Size * 1024 * 1024; //from MBs to bytes hotConfig.CleanInterval = config.Cleanup.Interval; hotConfig.EvictRatio = (float)config.EvictionPolicy.EvictionRatio; if (s_caches.Contains(cacheId)) { cacheInfo = (CacheInfo)s_caches[cacheId]; return cacheInfo.Cache.CanApplyHotConfig(hotConfig); } return null; }
//Method for converting New Dom into Old Dom for Passing to back to LoadConfig Method private static Alachisoft.NCache.Config.Dom.CacheServerConfig[] convertToOldDom(Alachisoft.NCache.Config.NewDom.CacheServerConfig[] newCacheConfigsList) { IList<Alachisoft.NCache.Config.Dom.CacheServerConfig> oldCacheConfigsList = new List<Alachisoft.NCache.Config.Dom.CacheServerConfig>(); for (int index = 0; index < newCacheConfigsList.Length; index++) { try { oldCacheConfigsList.Add(Alachisoft.NCache.Config.NewDom.DomHelper.convertToOldDom(newCacheConfigsList[index])); } catch (Exception) { } } Alachisoft.NCache.Config.Dom.CacheServerConfig[] oldCacheConfigsArray = new CacheServerConfig[oldCacheConfigsList.Count]; oldCacheConfigsList.CopyTo(oldCacheConfigsArray,0); return oldCacheConfigsArray; }
/// <summary> /// Get string props representation of config /// </summary> /// <param name="config"></param> /// <returns></returns> private static string GetProps(CacheServerConfig config) { ///[Ata] This is until we change the use of properties in Cache ///from props stirng or hashtable to Dom /// Hashtable table = ConfigConverter.ToHashtable(config); string props = ConfigReader.ToPropertiesString(table); return props; }
public static Alachisoft.NCache.Config.NewDom.CacheServerConfig convertToNewDom(Alachisoft.NCache.Config.Dom.CacheServerConfig oldDom) { Alachisoft.NCache.Config.NewDom.CacheServerConfig newDom = null; try { if (oldDom != null) { newDom = new CacheServerConfig(); if (newDom.CacheSettings == null) { newDom.CacheSettings = new CacheServerConfigSetting(); } newDom.Name = oldDom.Name; newDom.CacheSettings.InProc = oldDom.InProc; newDom.CacheSettings.DataFormat = oldDom.DataFormat; if (oldDom.Log != null) { newDom.CacheSettings.Log = oldDom.Log; } else { newDom.CacheSettings.Log = new Alachisoft.NCache.Config.Dom.Log(); } if (oldDom.PerfCounters != null) { newDom.CacheSettings.PerfCounters = oldDom.PerfCounters; } else { newDom.CacheSettings.PerfCounters = new Alachisoft.NCache.Config.Dom.PerfCounters(); } if (oldDom.QueryIndices != null) { newDom.CacheSettings.QueryIndices = oldDom.QueryIndices; } if (oldDom.BackingSource != null) { newDom.CacheSettings.BackingSource = oldDom.BackingSource; } if (oldDom.Notifications != null) { newDom.CacheSettings.Notifications = oldDom.Notifications; } else { newDom.CacheSettings.Notifications = new Alachisoft.NCache.Config.Dom.Notifications(); } if (oldDom.Cleanup != null) { newDom.CacheSettings.Cleanup = oldDom.Cleanup; } else { newDom.CacheSettings.Cleanup = new Alachisoft.NCache.Config.Dom.Cleanup(); } if (oldDom.Storage != null) { newDom.CacheSettings.Storage = oldDom.Storage; } else { newDom.CacheSettings.Storage = new Alachisoft.NCache.Config.Dom.Storage(); } if (oldDom.EvictionPolicy != null) { newDom.CacheSettings.EvictionPolicy = oldDom.EvictionPolicy; } else { newDom.CacheSettings.EvictionPolicy = oldDom.EvictionPolicy; } if (oldDom.ExpirationPolicy != null) { newDom.CacheSettings.ExpirationPolicy = oldDom.ExpirationPolicy; } else { newDom.CacheSettings.ExpirationPolicy = oldDom.ExpirationPolicy; } if (oldDom.TaskConfiguration != null) { newDom.CacheSettings.TaskConfiguration = oldDom.TaskConfiguration; } else { newDom.CacheSettings.TaskConfiguration = oldDom.TaskConfiguration; } if (newDom.CacheSettings.CacheTopology == null) { newDom.CacheSettings.CacheTopology = new CacheTopology(); } if (oldDom.ClientActivityNotification != null) { newDom.CacheSettings.ClientActivityNotification = oldDom.ClientActivityNotification; } newDom.CacheSettings.CacheType = oldDom.CacheType; if (oldDom.Cluster != null) { string topology = oldDom.Cluster.Topology; if (topology != null) { topology = topology.ToLower(); if (topology.Equals("replicated-server")) { topology = "replicated"; } else if (topology.Equals("partitioned-server")) { topology = "partitioned"; } else if (topology.Equals("local-cache")) { topology = "local-cache"; } } newDom.CacheSettings.CacheTopology.Topology = topology; if (oldDom.CacheType.Equals("clustered-cache")) { if (newDom.CacheDeployment == null) { newDom.CacheDeployment = new CacheDeployment(); } if (newDom.CacheSettings.CacheTopology.ClusterSettings == null) { newDom.CacheSettings.CacheTopology.ClusterSettings = new Cluster(); } newDom.CacheSettings.CacheTopology.ClusterSettings.OpTimeout = oldDom.Cluster.OpTimeout; newDom.CacheSettings.CacheTopology.ClusterSettings.StatsRepInterval = oldDom.Cluster.StatsRepInterval; newDom.CacheSettings.CacheTopology.ClusterSettings.UseHeartbeat = oldDom.Cluster.UseHeartbeat; if (newDom.CacheSettings.CacheTopology.ClusterSettings.Channel == null) { newDom.CacheSettings.CacheTopology.ClusterSettings.Channel = new Channel(); } if (oldDom.Cluster.Channel != null) { newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.TcpPort = oldDom.Cluster.Channel.TcpPort; newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.PortRange = oldDom.Cluster.Channel.PortRange; newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.ConnectionRetries = oldDom.Cluster.Channel.ConnectionRetries; newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.ConnectionRetryInterval = oldDom.Cluster.Channel.ConnectionRetryInterval; } if (oldDom.ReplicationStrategy != null) { newDom.CacheSettings.CacheTopology.ClusterSettings.ReplicationStrategy = oldDom.ReplicationStrategy; } else { newDom.CacheSettings.CacheTopology.ClusterSettings.ReplicationStrategy = new Alachisoft.NCache.Config.Dom.ReplicationStrategy(); } if (newDom.CacheDeployment.Servers == null) { newDom.CacheDeployment.Servers = new ServersNodes(); } newDom.CacheDeployment.Servers.NodesList = createServers(oldDom.Cluster.Channel.InitialHosts, oldDom.Cluster.ActiveMirrorNode); if (oldDom.ClientNodes != null) { if (newDom.CacheDeployment.ClientNodes == null) { newDom.CacheDeployment.ClientNodes = new Alachisoft.NCache.Config.Dom.ClientNodes(); } newDom.CacheDeployment.ClientNodes = oldDom.ClientNodes; } } } else { if (oldDom.CacheType != null) { if (oldDom.CacheType.Equals("local-cache")) { newDom.CacheSettings.CacheTopology.Topology = oldDom.CacheType; } newDom.CacheSettings.CacheTopology.ClusterSettings = null; } } if (oldDom.SQLDependencyConfig != null) { newDom.CacheSettings.SQLDependencyConfig = oldDom.SQLDependencyConfig; } newDom.IsRunning = oldDom.IsRunning; newDom.IsRegistered = oldDom.IsRegistered; newDom.IsExpired = oldDom.IsExpired; } } catch (Exception ex) { throw new Exception("DomHelper.convertToNewDom" + ex.Message); } return(newDom); }
public string CanApplyHotConfiguration(string cacheId, CacheServerConfig config) { Exception e = CanApplyHotConfig(cacheId, config); if (e != null) return e.Message; return null; }
public static Hashtable GetConfig(CacheServerConfig cache) { return GetCacheConfiguration(cache); }