示例#1
0
        public Cluster(Configuration.ClientConfiguration clientConfig)
        {
            // Initialize Things
            RegisteredContexts = new List <string>();
            contextsToRegister = new System.Collections.Concurrent.ConcurrentQueue <string>();
            ClientConfig       = clientConfig;

            // Initialize Timers
            registrationTimer = new Timer(RegistrationTimerCallback, this, Timeout.Infinite, Timeout.Infinite);
            statusCheckTimer  = new Timer(StatusCheckTimerCallback, null, Timeout.Infinite, Timeout.Infinite);
        }
示例#2
0
        private static Configuration.ClientConfiguration GetClientConfig()
        {
            Configuration.ClientConfiguration cfg = new Configuration.ClientConfiguration();

            // Set a few defaults that depend on a live IIS context
            if (HttpContext.Current != null && System.Web.Hosting.HostingEnvironment.ApplicationHost != null)
            {
                string siteName = System.Web.Hosting.HostingEnvironment.ApplicationHost.GetSiteName().Replace(" ", "");
                string siteID   = System.Web.Hosting.HostingEnvironment.ApplicationHost.GetSiteID();

                if (string.IsNullOrEmpty(cfg.JvmRoute))
                {
                    cfg.JvmRoute = siteName + (siteName + ":" + Environment.MachineName.ToLower()).GetHashCode();
                }

                // Get host, etc from site binding
                // TODO: Test with IP hosting and name based with multiple hostnames!
                if (string.IsNullOrEmpty(cfg.Host))
                {
                    var bindings = global::MCMP.Utilities.HostingEnvironment.GetBindings(HttpContext.Current);
                    if (bindings != null)
                    {
                        foreach (var binding in bindings)
                        {
                            switch (binding.Key)
                            {
                            case "http":
                            case "https":
                                cfg.Type = binding.Value.Scheme;
                                cfg.Host = binding.Value.Host;
                                cfg.Port = binding.Value.Port;
                                break;
                            }
                        }
                    }
                }

                cfg.Host  = (cfg.Host != "localhost" && cfg.Host != "*" && cfg.Host.IsNotNullOrEmpty() ? cfg.Host : Utilities.Networking.GetLocalIPAddress());
                cfg.Alias = (!string.IsNullOrEmpty(cfg.Alias) ? cfg.Alias : global::MCMP.Utilities.HostingEnvironment.GetServerAlias().Replace(" ", ""));
                if (cfg.Alias == "localhost" || cfg.Alias.IsNullOrEmpty())
                {
                    cfg.Alias = Utilities.Networking.GetFQDN();
                }
                cfg.AppRootPath = (!string.IsNullOrEmpty(cfg.AppRootPath) ? cfg.AppRootPath : global::MCMP.Utilities.HostingEnvironment.GetAppRootPath());
            }
            else
            {
                if (string.IsNullOrEmpty(cfg.JvmRoute))
                {
                    cfg.JvmRoute = (System.IO.Path.GetFileNameWithoutExtension(cfg.GetType().Assembly.Location).Replace(".", "_").TakeUpTo(10)
                                    + (System.IO.Path.GetFileNameWithoutExtension(cfg.GetType().Assembly.Location) + ":" + Environment.MachineName.ToLower()).GetHashCode().ToString()).TakeUpTo(20).ToLower();
                }
                cfg.Alias = (cfg.Alias.IsNotNullOrEmpty() ? cfg.Alias : cfg.Alias = Utilities.Networking.GetFQDN());

                if (log != null && log.IsDebugEnabled)
                {
                    log.Debug("GetClientConfig() has null HttpContext.Current or System.Web.Hosting.HostingEnvironment.ApplicationHost, skipping most autodetect stuff");
                }
            }
            return(cfg);
        }
示例#3
0
 public Client(Configuration.ClientConfiguration clientConfig)
 {
     this.clientConfig = clientConfig;
     Initialize();
 }