Esempio n. 1
0
        private ConfigurationManager()
        {


            string appID = System.Configuration.ConfigurationManager.AppSettings["ncache.application_id"];
            if(string.IsNullOrEmpty(appID))
                throw new ConfigurationException("ncache.application-id not specified in app.config/web.config file");

            string configFilePath = this.GetFilePath("NCacheNHibernate.xml");



            ConfigurationBuilder configBuilder = new ConfigurationBuilder(configFilePath);
            configBuilder.RegisterRootConfigurationObject(typeof(ApplicationConfiguration));
            configBuilder.ReadConfiguration();

            Object[] configuration = configBuilder.Configuration;

            bool appConfigFound = false;
            if (configuration != null && configuration.Length > 0)
            {
                for (int i = 0; i < configuration.Length; i++)
                {
                    _appConfig = configuration[i] as ApplicationConfiguration;
                    if(_appConfig!=null)
                    if (!string.IsNullOrEmpty(_appConfig.ApplicationID) && _appConfig.ApplicationID.ToLower() == appID.ToLower())
                    {
                        appConfigFound = true;
                        break;
                    }
                }
            }
            
            if (!appConfigFound)
                throw new ConfigurationException("Invalid value of NCache.application_id. Applicaion configuration not found for application-id = " + appID);
            if (string.IsNullOrEmpty(_appConfig.DefaultRegion))
                throw new Alachisoft.NCache.Runtime.Exceptions.ConfigurationException("default-region cannot be null for application-id = " + _appConfig.ApplicationID);
            
            _regionConfigManager = new RegionConfigurationManager(_appConfig.CacheRegions);
            if (!_regionConfigManager.Contains(_appConfig.DefaultRegion))

                throw new Alachisoft.NCache.Runtime.Exceptions.ConfigurationException("Region's configuration not specified for default-region : "+_appConfig.DefaultRegion);

        }
        private static MappingConfiguration.Dom.MappingConfiguration LoadXml()
        {
            MappingConfiguration.Dom.MappingConfiguration config= null;
            lock (_syncRoot)
            {
                if (String.IsNullOrEmpty(m_configFileName))
                    CombinePath();
                try
                {
                    ConfigurationBuilder configBuilder = new ConfigurationBuilder(m_configFileName);
                    configBuilder.RegisterRootConfigurationObject(typeof(Alachisoft.NCache.Management.MappingConfiguration.Dom.MappingConfiguration));
                    configBuilder.ReadConfiguration();

                    MappingConfiguration.Dom.MappingConfiguration mappingConfiguration = null;
                    Object[] configuration = configBuilder.Configuration;

                    if (configuration != null && configuration.Length > 0)
                    {
                        for (int i = 0; i < configuration.Length; i++)
                        {
                            mappingConfiguration = configuration[i] as MappingConfiguration.Dom.MappingConfiguration;
                            break;
                        }
                    }

                    config = mappingConfiguration;
                }
                catch (Exception)
                { }

                if (config == null)
                    config = new Alachisoft.NCache.Management.MappingConfiguration.Dom.MappingConfiguration();

                if (config.ManagementIPMapping == null)
                    config.ManagementIPMapping = new ServerMapping();

                if (config.ClientIPMapping == null)
                    config.ClientIPMapping = new ServerMapping();
            }
            return config;
        }
 private static string ToXml(MappingConfiguration.Dom.MappingConfiguration config)
 {
     StringBuilder sb = new StringBuilder();
     object[] configuration = new object[1];
     configuration[0] = config;
     ConfigurationBuilder cfgBuilder = new ConfigurationBuilder(configuration);
     cfgBuilder.RegisterRootConfigurationObject(typeof(ClientConfiguration.Dom.ClientConfiguration));
     sb.Append(cfgBuilder.GetXmlString());
     return sb.ToString();
 }
Esempio n. 4
0
 /// <summary>
 /// Save the configuration
 /// </summary>
 /// <param name="configuration"></param>
 public static void SaveConfiguration(object[] configuration)
 {
     StringBuilder xml = new StringBuilder();
     xml.Append("<configuration>\r\n");
     if (configuration != null && configuration.Length > 0)
     {
         ConfigurationBuilder builder = new ConfigurationBuilder(configuration);
         builder.RegisterRootConfigurationObject(typeof(Alachisoft.NCache.Config.NewDom.CacheServerConfig));
         xml.Append(builder.GetXmlString());
     }
     xml.Append("\r\n</configuration>");
     WriteXmlToFile(xml.ToString());
 }
Esempio n. 5
0
        /// <summary>
        /// Loads and returns all cache configurations from the configuration file.
        /// </summary>
        static public CacheServerConfig[] GetConfiguredCaches()
        {
            if (FileName.Length == 0)
            {
                throw new ManagementException("Can not locate cache configuration file. Installation might be corrupt.");
            }
            try
            {
                ConfigurationBuilder builder = new ConfigurationBuilder(FileName);
                builder.RegisterRootConfigurationObject(typeof(Alachisoft.NCache.Config.NewDom.CacheServerConfig));
                builder.ReadConfiguration();
                Alachisoft.NCache.Config.NewDom.CacheServerConfig[] newCaches = new Alachisoft.NCache.Config.NewDom.CacheServerConfig[builder.Configuration.Length];
                builder.Configuration.CopyTo(newCaches, 0);

                return convertToOldDom(newCaches);
            }
            catch (ManagementException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new ManagementException(e.Message, e);
            }
        }
Esempio n. 6
0
 private static void LoadConfig(string fileName, ref Hashtable properties)
 {
     ConfigurationBuilder builder = new ConfigurationBuilder(fileName);
     builder.RegisterRootConfigurationObject(typeof(Alachisoft.NCache.Config.NewDom.CacheServerConfig));
     builder.ReadConfiguration();
     Alachisoft.NCache.Config.NewDom.CacheServerConfig[] newCaches = new NewDom.CacheServerConfig[builder.Configuration.Length];
     builder.Configuration.CopyTo(newCaches, 0);
     properties = ConfigConverter.ToHashtable(convertToOldDom(newCaches));
 }
Esempio n. 7
0
        private static CacheServerConfig[] LoadConfig(string fileName)
        {
            ConfigurationBuilder builder = new ConfigurationBuilder(fileName);
            builder.RegisterRootConfigurationObject(typeof(Alachisoft.NCache.Config.NewDom.CacheServerConfig));
            builder.ReadConfiguration();
            Alachisoft.NCache.Config.NewDom.CacheServerConfig[] newCaches = new Alachisoft.NCache.Config.NewDom.CacheServerConfig[builder.Configuration.Length];
            builder.Configuration.CopyTo(newCaches, 0);

            return convertToOldDom(newCaches);
        }
Esempio n. 8
0
        private static string ToXml()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

                sb.Append(ENDSTRING + "<!-- Client configuration file is used by client to connect to out-proc caches. " +
                    ENDSTRING + "This file is automatically generated each time a new cache/cluster is created or " +
                    ENDSTRING + "cache/cluster configuration settings are applied." +
                    ENDSTRING + "-->");


            sb.Append("\n");

            object[] configuration = new object[1];
            configuration[0] = _configuration;
            ConfigurationBuilder cfgBuilder = new ConfigurationBuilder(configuration);
            cfgBuilder.RegisterRootConfigurationObject(typeof(ClientConfiguration.Dom.ClientConfiguration));
            sb.Append(cfgBuilder.GetXmlString());

            return sb.ToString();
        }
Esempio n. 9
0
        private static void LoadXml()
        {
            if (String.IsNullOrEmpty(c_configFileName))
                CombinePath();

            ConfigurationBuilder configBuilder = new ConfigurationBuilder(c_configFileName);
            configBuilder.RegisterRootConfigurationObject(typeof(Alachisoft.NCache.Management.ClientConfiguration.Dom.ClientConfiguration));
            configBuilder.ReadConfiguration();

            ClientConfiguration.Dom.ClientConfiguration clientConfiguration = null;
            Object[] configuration = configBuilder.Configuration;

            if (configuration != null && configuration.Length > 0)
            {
                for (int i = 0; i < configuration.Length; i++)
                {
                    clientConfiguration = configuration[i] as ClientConfiguration.Dom.ClientConfiguration;
                    break;
                }
            }

            _configuration = clientConfiguration;

            if (_configuration == null)
                _configuration = new Alachisoft.NCache.Management.ClientConfiguration.Dom.ClientConfiguration();

            if (_configuration.NodeConfiguration == null)
                _configuration.NodeConfiguration = new NodeConfiguration();



            _configuration.BindIp = BindIP;
        }
        public static void CommandLineParser(ref object obj, string[] args)
        {
            Type type;
            PropertyInfo[] objProps;
            ConfigurationBuilder configBuilder = new ConfigurationBuilder();
            type = obj.GetType();
            objProps = type.GetProperties();
            ArgumentAttribute orphanAttribute = null;
            PropertyInfo orphanPropInfo = null;

            if (objProps != null)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    PropertyInfo propInfo;
                    Object[] customParams;
                    int propLoc = i;
                    bool isAssigned = false;
                    for (int j = 0; j < objProps.Length; j++)
                    {
                        propInfo = objProps[j];
                        customParams = propInfo.GetCustomAttributes(typeof(ArgumentAttribute), false);

                        if (customParams != null && customParams.Length > 0)
                        {
                            ArgumentAttribute param = customParams[0] as ArgumentAttribute;
                            try
                            {
                                if (param != null && (param.ShortNotation == args[i] || param.FullName.ToLower() == args[i].ToLower()))
                                {

                                    if (propInfo.PropertyType.FullName == "System.Boolean")
                                    {
                                        bool value = (bool)param.DefaultValue;

                                        if (value)
                                            propInfo.SetValue(obj, false, null);
                                        else
                                            propInfo.SetValue(obj, true, null);
                                        isAssigned = true;
                                        break;
                                    }
                                    else
                                    {
                                        int index = i + 1;
                                        if (index <= (args.Length - 1))
                                        {
                                            object value = configBuilder.ConvertToPrimitive(propInfo.PropertyType, args[++i], null);
                                            if (propInfo.PropertyType.IsAssignableFrom(value.GetType()))
                                            {
                                                propInfo.SetValue(obj, value, null);
                                                isAssigned = true;
                                                break;
                                            }
                                        }
                                    }
                                }
                                else if (param != null && (string.IsNullOrEmpty(param.ShortNotation) && string.IsNullOrEmpty(param.FullName)))
                                {
                                    if (orphanAttribute == null && !isAssigned)
                                    {
                                        orphanAttribute = param;
                                        orphanPropInfo = propInfo;
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                throw new Exception("Can not set the value for attribute " + param.ShortNotation + " Error :" + e.Message.ToString());
                            }

                        }
                    }
                    if (!isAssigned)
                    {
                        if (orphanAttribute != null && orphanPropInfo != null)
                        {
                            if (orphanPropInfo.GetValue(obj, null) != null)
                            {
                                object value = configBuilder.ConvertToPrimitive(orphanPropInfo.PropertyType, args[i], null);
                                if (orphanPropInfo.PropertyType.IsAssignableFrom(value.GetType()))
                                {
                                    orphanPropInfo.SetValue(obj, value, null);
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 11
0
        /// <summary>
        /// The main entry point for the tool.
        /// </summary>
        public static void Run(string[] args)
        {
            string failedNodes = string.Empty;
            ICacheServer cacheServer = null;

            try
            {
                object param = new GetCacheConfigurationParam();
                CommandLineArgumentParser.CommandLineParser(ref param, args);
                ccParam = (GetCacheConfigurationParam)param;

                if (ccParam.IsUsage)
                {
                    AssemblyUsage.PrintLogo(ccParam.IsLogo);
                    AssemblyUsage.PrintUsage();
                    return;
                }

                if (!ValidateParameters()) return;

                string _filename = null;
                string _path = null;
                if (ccParam.Path != null && ccParam.Path != string.Empty)
                {
                    if (!Path.HasExtension(ccParam.Path))
                    {

                        _filename = ccParam.CacheId + ".ncconf";
                        ccParam.Path = ccParam.Path + "\\" + _filename;
                    }
                }
                else
                {
                    ccParam.Path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                    _filename = ccParam.CacheId + ".ncconf";
                    ccParam.Path = ccParam.Path + "\\" + _filename;
                }

                if (ccParam.Port == -1) NCache.Port = NCache.UseTcp ? CacheConfigManager.NCacheTcpPort : CacheConfigManager.HttpPort;
                if (!string.IsNullOrEmpty(ccParam.Server))
                {
                    NCache.ServerName = ccParam.Server;
                }
                else
                    NCache.ServerName = System.Environment.MachineName;

                if (ccParam.Port != -1)
                {
                    NCache.Port = ccParam.Port;
                }

                cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));

                if (cacheServer != null)
                {
                    Alachisoft.NCache.Config.NewDom.CacheServerConfig serverConfig = cacheServer.GetNewConfiguration(ccParam.CacheId);

                    if (serverConfig == null) throw new Exception("Specified cache is not registered on given server.");

                    serverConfig.CacheDeployment = null;

                    Console.WriteLine("Creating configuration for cache '{0}' registered on server '{1}:{2}'.", ccParam.CacheId, NCache.ServerName, NCache.Port);

                    StringBuilder xml = new StringBuilder();
                    List<Alachisoft.NCache.Config.NewDom.CacheServerConfig> configurations = new List<Alachisoft.NCache.Config.NewDom.CacheServerConfig>();
                    configurations.Add(serverConfig);
                    ConfigurationBuilder builder = new ConfigurationBuilder(configurations.ToArray());
                    builder.RegisterRootConfigurationObject(typeof(Alachisoft.NCache.Config.NewDom.CacheServerConfig));
                    xml.Append(builder.GetXmlString());
                    WriteXmlToFile(xml.ToString());

                    Console.WriteLine("Cache configuration saved successfully at " + ccParam.Path + ".");
                }

            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error : {0}", e.Message);
            }
            finally
            {
                NCache.Dispose();
                if ( cacheServer != null )
                    cacheServer.Dispose();
            }
        }
Esempio n. 12
0
        /// <summary>
        /// The main entry point for the tool.
        /// </summary>
        public static void Run(string[] args)
        {
            string failedNodes = string.Empty;
            NCache.Port = NCache.UseTcp ? CacheConfigManager.NCacheTcpPort : CacheConfigManager.HttpPort;
            Alachisoft.NCache.Config.NewDom.CacheServerConfig[] caches = null;
            ICacheServer cacheServer = null;
            Alachisoft.NCache.Config.NewDom.CacheServerConfig _cacheConfig = null;

            try
            {
                object param = new ConfigureCacheParam();
                CommandLineArgumentParser.CommandLineParser(ref param, args);
                ccParam = (ConfigureCacheParam)param;

                if (ccParam.IsUsage)
                {
                    AssemblyUsage.PrintLogo(ccParam.IsLogo);
                    AssemblyUsage.PrintUsage();
                    return;
                }

                if (!ValidateParameters()) return;

                if (ccParam.Port != -1)
                {
                    NCache.Port = ccParam.Port;
                }

                if (ccParam.Port == -1) NCache.Port = NCache.UseTcp ? CacheConfigManager.NCacheTcpPort : CacheConfigManager.HttpPort;

                if (ccParam.Path != null && ccParam.Path != string.Empty)
                {
                    if (Path.HasExtension(ccParam.Path))
                    {
                        string extension = Path.GetExtension(ccParam.Path);

                        if (!extension.Equals(".ncconf") && !extension.Equals(".xml"))
                        {
                            throw new Exception("Incorrect file format. Only .ncconf and .xml are supported.");
                        }
                    }
                    else
                        throw new Exception("Incorrect configuration file path specified.");

                    ConfigurationBuilder builder = new ConfigurationBuilder(ccParam.Path);
                    builder.RegisterRootConfigurationObject(typeof(Alachisoft.NCache.Config.NewDom.CacheServerConfig));
                    builder.ReadConfiguration();

                    if (builder.Configuration != null)
                    {
                        caches = new Alachisoft.NCache.Config.NewDom.CacheServerConfig[builder.Configuration.Length];
                        builder.Configuration.CopyTo(caches, 0);
                    }
                    else
                        throw new Exception("Configuration cannot be loaded.");
                    ConfigurationValidator validator = new ConfigurationValidator();
                    bool _isConfigValidated = validator.ValidateConfiguration(caches);

                    _cacheConfig = caches[0];

                    if (_cacheConfig.CacheSettings.Name == null)
                        _cacheConfig.CacheSettings.Name = ccParam.CacheId;

                    if (_cacheConfig.CacheSettings.Storage == null || _cacheConfig.CacheSettings.Storage.Size == -1)
                    {
                        throw new Exception("Cache size is not specified.");
                    }

                    if (_cacheConfig.CacheSettings.EvictionPolicy == null)
                    {
                        _cacheConfig.CacheSettings.EvictionPolicy = new EvictionPolicy();
                        _cacheConfig.CacheSettings.EvictionPolicy.Policy = "priority";
                        _cacheConfig.CacheSettings.EvictionPolicy.DefaultPriority = "normal";
                        _cacheConfig.CacheSettings.EvictionPolicy.EvictionRatio = 5;
                        _cacheConfig.CacheSettings.EvictionPolicy.Enabled = true;
                    }

                    if (_cacheConfig.CacheSettings.Cleanup == null)
                    {
                        _cacheConfig.CacheSettings.Cleanup = new Cleanup();
                        _cacheConfig.CacheSettings.Cleanup.Interval = 15;
                    }

                    if (_cacheConfig.CacheSettings.Log == null)
                    {
                        _cacheConfig.CacheSettings.Log = new Log();
                    }

                    if (_cacheConfig.CacheSettings.PerfCounters == null)
                    {
                        _cacheConfig.CacheSettings.PerfCounters = new PerfCounters();
                        _cacheConfig.CacheSettings.PerfCounters.Enabled = true;
                    }

                    if (_cacheConfig.CacheSettings.CacheType == "clustered-cache")
                    {
                        if (_cacheConfig.CacheSettings.CacheTopology.ClusterSettings == null)
                        {
                            throw new Exception("Cluster settings not specified for the cluster cache.");
                        }

                        if (_cacheConfig.CacheSettings.CacheTopology.ClusterSettings.Channel == null)
                        {
                            throw new Exception("Cluster channel related settings not specified for cluster cache.");
                        }

                        if (_cacheConfig.CacheSettings.CacheTopology.ClusterSettings.Channel.TcpPort == -1)
                        {
                            throw new Exception("Cluster port not specified for cluster cache.");
                        }
                    }
                }
                else
                {
                    _SimpleCacheConfig.CacheSettings = new Alachisoft.NCache.Config.NewDom.CacheServerConfigSetting();
                    _SimpleCacheConfig.CacheSettings.Name = ccParam.CacheId;
                    _SimpleCacheConfig.CacheSettings.Storage = new Alachisoft.NCache.Config.Dom.Storage();
                    _SimpleCacheConfig.CacheSettings.EvictionPolicy = new EvictionPolicy();
                    _SimpleCacheConfig.CacheSettings.Cleanup = new Cleanup();
                    _SimpleCacheConfig.CacheSettings.Log = new Log();
                    _SimpleCacheConfig.CacheSettings.PerfCounters = new PerfCounters();
                    _SimpleCacheConfig.CacheSettings.PerfCounters.Enabled = true;
                    _SimpleCacheConfig.CacheSettings.Storage.Type = "heap";
                    _SimpleCacheConfig.CacheSettings.Storage.Size = ccParam.CacheSize;
                    _SimpleCacheConfig.CacheSettings.EvictionPolicy.Policy = "priority";
                    _SimpleCacheConfig.CacheSettings.EvictionPolicy.DefaultPriority = "normal";
                    _SimpleCacheConfig.CacheSettings.EvictionPolicy.EvictionRatio = 5;
                    _SimpleCacheConfig.CacheSettings.EvictionPolicy.Enabled = false;
                    _SimpleCacheConfig.CacheSettings.Cleanup.Interval = 15;
                    _SimpleCacheConfig.CacheSettings.CacheTopology = new Alachisoft.NCache.Config.NewDom.CacheTopology();

                    if (string.IsNullOrEmpty(ccParam.Topology))
                    {
                        _SimpleCacheConfig.CacheSettings.CacheTopology.Topology = "Local";
                    }
                    else
                    {
                        _SimpleCacheConfig.CacheSettings.CacheTopology.Topology = ccParam.Topology;
                    }

                    if (ccParam.IsInProc && _SimpleCacheConfig.CacheSettings.CacheTopology.Topology.Equals("local-cache"))
                        _SimpleCacheConfig.CacheSettings.InProc = true;

                    if (_SimpleCacheConfig.CacheSettings.CacheType == "clustered-cache")
                    {
                        _SimpleCacheConfig.CacheSettings.CacheTopology.ClusterSettings = new Alachisoft.NCache.Config.NewDom.Cluster();
                        _SimpleCacheConfig.CacheSettings.CacheTopology.ClusterSettings.Channel = new Alachisoft.NCache.Config.NewDom.Channel();

                        _SimpleCacheConfig.CacheSettings.CacheTopology.ClusterSettings.Channel.TcpPort = ccParam.ClusterPort;
                        _SimpleCacheConfig.CacheSettings.CacheTopology.ClusterSettings.StatsRepInterval = 600;
                        if (_SimpleCacheConfig.CacheSettings.CacheTopology.Topology == "partitioned-replica")
                            _SimpleCacheConfig.CacheSettings.CacheTopology.ClusterSettings.Channel.PortRange = 2;

                    }

                    if (ccParam.EvictionPolicy != null && ccParam.EvictionPolicy != string.Empty)
                    {
                        _SimpleCacheConfig.CacheSettings.EvictionPolicy.Policy = ccParam.EvictionPolicy;
                        _SimpleCacheConfig.CacheSettings.EvictionPolicy.Enabled = true;
                    }

                    if (ccParam.Ratio != -1)
                    {
                        _SimpleCacheConfig.CacheSettings.EvictionPolicy.EvictionRatio = ccParam.Ratio;
                    }

                    if (ccParam.CleanupInterval != -1)
                    {
                        _SimpleCacheConfig.CacheSettings.Cleanup.Interval = ccParam.CleanupInterval;
                    }

                    if (ccParam.DefaultPriority != null && ccParam.DefaultPriority != string.Empty)
                    {
                        _SimpleCacheConfig.CacheSettings.EvictionPolicy.DefaultPriority = ccParam.DefaultPriority;
                        _SimpleCacheConfig.CacheSettings.EvictionPolicy.Enabled = true;
                    }
                    _cacheConfig = _SimpleCacheConfig;
                }
                try
                {
                    _cacheConfig.CacheSettings.Name = ccParam.CacheId;

                    if (_cacheConfig.CacheSettings.CacheType == "clustered-cache")
                    {
                        if (_cacheConfig.CacheDeployment == null)
                        {
                            _cacheConfig.CacheDeployment = new Alachisoft.NCache.Config.NewDom.CacheDeployment();
                            _cacheConfig.CacheDeployment.Servers = new Alachisoft.NCache.Config.NewDom.ServersNodes();

                        }
                        _cacheConfig.CacheDeployment.Servers.NodesList = GetServers(ccParam.Server);
                    }

                    Dictionary<int, Management.ClientConfiguration.Dom.CacheServer> serverList = new Dictionary<int, Management.ClientConfiguration.Dom.CacheServer>();
                    int serverCount = 0;
                    foreach (Alachisoft.NCache.Config.NewDom.ServerNode node in GetServers(ccParam.Server))
                    {
                        Management.ClientConfiguration.Dom.CacheServer tempServer = new Management.ClientConfiguration.Dom.CacheServer();
                        tempServer.ServerName = node.IP;
                        serverList.Add(serverCount, tempServer);
                        serverCount++;
                    }
                    Management.ClientConfiguration.CacheServerList servers = new Management.ClientConfiguration.CacheServerList(serverList);
                    List<string> serversToUpdate = new List<string>();
                    foreach (Alachisoft.NCache.Config.NewDom.ServerNode node in GetServers(ccParam.Server))
                    {
                        NCache.ServerName = node.IP;

                        Console.WriteLine(AppendBlankLine("\nCreating cache") + " '{0}' on server '{1}' ", _cacheConfig.CacheSettings.Name, NCache.ServerName);
                        try
                        {
                            cacheServer = NCache.GetCacheServer(new TimeSpan(0, 0, 0, 30));
                            if (cacheServer != null)
                            {
                                Alachisoft.NCache.Config.NewDom.CacheServerConfig serverConfig = cacheServer.GetNewConfiguration(_cacheConfig.CacheSettings.Name);

                                if (serverConfig != null)
                                {
                                    throw new Exception("Specified cache already exists.");

                                }

                                else if (serverConfig != null && ccParam.IsOverWrite)
                                {
                                    NCache.ServerName = node.IP;

                                    if (serverConfig.CacheDeployment != null)
                                    {
                                        if (serverConfig.CacheDeployment.ClientNodes != null)
                                            _cacheConfig.CacheDeployment.ClientNodes = serverConfig.CacheDeployment.ClientNodes;
                                    }

                                }

                                cacheServer.RegisterCache(_cacheConfig.CacheSettings.Name, _cacheConfig, "", ccParam.IsOverWrite, ccParam.IsHotApply);
                                cacheServer.UpdateClientServersList(_cacheConfig.CacheSettings.Name, servers, "NCACHE");
                                serversToUpdate.Add(node.IP);

                                Console.WriteLine("Cache '{0}' successfully created on server {1}:{2} .", _cacheConfig.CacheSettings.Name, NCache.ServerName, NCache.Port);
                            }

                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                    Management.Management.Util.ManagementWorkFlow.UpdateServerMappingConfig(serversToUpdate.ToArray());

                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (cacheServer != null)
                        cacheServer.Dispose();
                }

            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(AppendBlankLine("Failed") + " to create cache on server '{0}'. ", ccParam.Server);
                Console.Error.WriteLine("Error Detail: '{0}'. ", ex.Message);
                LogEvent(ex.Message);
            }
            finally
            {
                NCache.Dispose();
            }
        }