Beispiel #1
0
        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.CacheSettings.Name;
                        oldDom.InProc       = newDom.CacheSettings.InProc;
                        oldDom.ConfigID     = newDom.ConfigID;
                        oldDom.LastModified = newDom.CacheSettings.LastModified;

                        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.QueryIndices != null)
                        {
                            oldDom.QueryIndices = newDom.CacheSettings.QueryIndices;
                        }



                        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.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("partitioned"))
                                    {
                                        topology = "partitioned-server";
                                    }

                                    else if (topology.Equals("replicated"))
                                    {
                                        topology = "replicated-server";
                                    }
                                    else if (topology.Equals("local"))
                                    {
                                        topology = "local-cache";
                                    }
                                }

                                oldDom.Cluster.Topology         = topology;
                                oldDom.Cluster.OpTimeout        = newDom.CacheSettings.CacheTopology.ClusterSettings.OpTimeout;
                                oldDom.Cluster.StatsRepInterval = newDom.CacheSettings.CacheTopology.ClusterSettings.StatsRepInterval;
                                oldDom.Cluster.UseHeartbeat     = newDom.CacheSettings.CacheTopology.ClusterSettings.UseHeartbeat;

                                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;
                                oldDom.Cluster.Channel.InitialHosts            = createInitialHosts(newDom.CacheDeployment.Servers.NodesList, newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.TcpPort);
                                oldDom.Cluster.Channel.NumInitHosts            = newDom.CacheDeployment.Servers.NodesList.Count;

                                if (newDom.CacheDeployment.ClientNodes != null)
                                {
                                    if (oldDom.ClientNodes == null)
                                    {
                                        oldDom.ClientNodes = new Alachisoft.NCache.Config.Dom.ClientNodes();
                                    }

                                    oldDom.ClientNodes = newDom.CacheDeployment.ClientNodes;
                                }
                            }
                        }

                        if (newDom.CacheSettings.AutoLoadBalancing != null)
                        {
                            oldDom.AutoLoadBalancing = newDom.CacheSettings.AutoLoadBalancing;
                        }
                        oldDom.IsRunning    = newDom.IsRunning;
                        oldDom.IsRegistered = newDom.IsRegistered;
                        oldDom.IsExpired    = newDom.IsExpired;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("DomHelper.convertToOldDom" + ex.Message);
            }
            return(oldDom);
        }
Beispiel #2
0
		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.CacheSettings.Name;
				oldDom.InProc = newDom.CacheSettings.InProc;
				oldDom.ConfigID = newDom.ConfigID;
				oldDom.LastModified = newDom.CacheSettings.LastModified;

				 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.QueryIndices != null)
				{
					oldDom.QueryIndices = newDom.CacheSettings.QueryIndices;
				}



				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.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("partitioned"))
				{
				topology = "partitioned-server";
				}

				else if (topology.Equals("replicated"))
				{
				topology = "replicated-server";
				}
				else if (topology.Equals("local"))
				{
				topology = "local-cache";
				}

				
			}

					oldDom.Cluster.Topology = topology;
					oldDom.Cluster.OpTimeout = newDom.CacheSettings.CacheTopology.ClusterSettings.OpTimeout;
					oldDom.Cluster.StatsRepInterval = newDom.CacheSettings.CacheTopology.ClusterSettings.StatsRepInterval;
					oldDom.Cluster.UseHeartbeat = newDom.CacheSettings.CacheTopology.ClusterSettings.UseHeartbeat;

					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;
					oldDom.Cluster.Channel.InitialHosts = createInitialHosts(newDom.CacheDeployment.Servers.NodesList,newDom.CacheSettings.CacheTopology.ClusterSettings.Channel.TcpPort);
					oldDom.Cluster.Channel.NumInitHosts = newDom.CacheDeployment.Servers.NodesList.Count;

					if (newDom.CacheDeployment.ClientNodes != null)
					{
						if (oldDom.ClientNodes == null)
						{
                            oldDom.ClientNodes = new Alachisoft.NCache.Config.Dom.ClientNodes();
						}

						oldDom.ClientNodes = newDom.CacheDeployment.ClientNodes;
					}

				  }

				}

				 if (newDom.CacheSettings.AutoLoadBalancing != null)
				 {
					oldDom.AutoLoadBalancing = newDom.CacheSettings.AutoLoadBalancing;
				 }
				oldDom.IsRunning = newDom.IsRunning;
				oldDom.IsRegistered = newDom.IsRegistered;
				oldDom.IsExpired = newDom.IsExpired;
	        }
		  }
	    }
		catch (Exception ex)
		{
		   throw new Exception("DomHelper.convertToOldDom" + ex.Message);
		}
			return oldDom;

		}