Beispiel #1
0
        public override BaseMessage ToMessage()
        {
            var msg = new HubInfoMessage();

            msg.Name              = Name;
            msg.Id                = Id;
            msg.ExternalEndpoint  = ExternalEndpoint?.ToString();
            msg.InternalEndpoint  = InternalEndpoint?.ToString();
            msg.ConnectionType    = ConnectionType.ToString();
            msg.InternalAddresses = InternalAddresses.Select(a => a.ToString()).ToList();

            return(msg);
        }
Beispiel #2
0
        /// <summary>
        /// Applies required configuration for enabling cache in SDK 1.8.0 version by:
        /// * Add MemcacheShim runtime installation.
        /// * Add startup task to install memcache shim on the client side.
        /// * Add default memcache internal endpoint.
        /// * Add cache diagnostic to local resources.
        /// * Add ClientDiagnosticLevel setting to service configuration.
        /// * Adjust web.config to enable auto discovery for the caching role.
        /// </summary>
        /// <param name="azureService">The azure service instance</param>
        /// <param name="webRole">The web role to enable caching on</param>
        /// <param name="isWebRole">Flag indicating if the provided role is web or not</param>
        /// <param name="cacheWorkerRole">The memcache worker role name</param>
        /// <param name="startup">The role startup</param>
        /// <param name="endpoints">The role endpoints</param>
        /// <param name="localResources">The role local resources</param>
        /// <param name="configurationSettings">The role configuration settings</param>
        private void Version180Configuration(
            AzureService azureService,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefinitionConfigurationSetting[] configurationSettings)
        {
            if (isWebRole)
            {
                // Generate cache scaffolding for web role
                azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WebRole.ToString()),
                                                 roleName, new Dictionary <string, object>());

                // Adjust web.config to enable auto discovery for the caching role.
                string webCloudConfigPath = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebCloudConfig);
                string webConfigPath      = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebConfigTemplateFileName);

                UpdateWebConfig(roleName, cacheWorkerRole, webCloudConfigPath);
                UpdateWebConfig(roleName, cacheWorkerRole, webConfigPath);
            }
            else
            {
                // Generate cache scaffolding for worker role
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                parameters[ScaffoldParams.RoleName] = cacheWorkerRole;

                azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WorkerRole.ToString()),
                                                 roleName, parameters);
            }

            // Add startup task to install memcache shim on the client side.
            string cacheRuntimeUri = CloudRuntimeCollection.GetRuntimeUrl(Resources.CacheRuntimeValue, CacheRuntimeVersion);

            Debug.Assert(!string.IsNullOrEmpty(cacheRuntimeUri));
            Variable emulated = new Variable {
                name = Resources.EmulatedKey, RoleInstanceValue = new RoleInstanceValueElement {
                    xpath = "/RoleEnvironment/Deployment/@emulated"
                }
            };

            Variable[] env = { emulated, new Variable {
                                   name = Resources.CacheRuntimeUrl,value = cacheRuntimeUri
                               } };
            Task       shimStartupTask = new Task {
                Environment = env, commandLine = Resources.CacheStartupCommand, executionContext = ExecutionContext.elevated
            };

            startup.Task = General.ExtendArray <Task>(startup.Task, shimStartupTask);

            // Add default memcache internal endpoint.
            InternalEndpoint memcacheEndpoint = new InternalEndpoint
            {
                name     = Resources.MemcacheEndpointName,
                protocol = InternalProtocol.tcp,
                port     = Resources.MemcacheEndpointPort
            };

            endpoints.InternalEndpoint = General.ExtendArray <InternalEndpoint>(endpoints.InternalEndpoint, memcacheEndpoint);

            // Enable cache diagnostic
            LocalStore localStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };

            localResources.LocalStorage = General.ExtendArray <LocalStore>(localResources.LocalStorage, localStore);

            DefinitionConfigurationSetting diagnosticLevel = new DefinitionConfigurationSetting {
                name = Resources.CacheClientDiagnosticLevelAssemblyName
            };

            configurationSettings = General.ExtendArray <DefinitionConfigurationSetting>(configurationSettings, diagnosticLevel);

            // Add ClientDiagnosticLevel setting to service configuration.
            AddClientDiagnosticLevelToConfig(azureService.Components.GetCloudConfigRole(roleName));
            AddClientDiagnosticLevelToConfig(azureService.Components.GetLocalConfigRole(roleName));
        }
        /// <summary>
        /// Applies required configuration for enabling cache in SDK 1.8.0 version by:
        /// * Add MemcacheShim runtime installation.
        /// * Add startup task to install memcache shim on the client side.
        /// * Add default memcache internal endpoint.
        /// * Add cache diagnostic to local resources.
        /// * Add ClientDiagnosticLevel setting to service configuration.
        /// * Adjust web.config to enable auto discovery for the caching role.
        /// </summary>
        /// <param name="azureService">The azure service instance</param>
        /// <param name="webRole">The web role to enable caching on</param>
        /// <param name="isWebRole">Flag indicating if the provided role is web or not</param>
        /// <param name="cacheWorkerRole">The memcache worker role name</param>
        /// <param name="startup">The role startup</param>
        /// <param name="endpoints">The role endpoints</param>
        /// <param name="localResources">The role local resources</param>
        /// <param name="configurationSettings">The role configuration settings</param>
        private void Version180Configuration(
            AzureService azureService,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefConfigurationSetting[] configurationSettings)
        {
            if (isWebRole)
            {
                // Generate cache scaffolding for web role
                azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WebRole.ToString()),
                    roleName, new Dictionary<string, object>());

                // Adjust web.config to enable auto discovery for the caching role.
                string webCloudConfigPath = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebCloudConfig);
                string webConfigPath = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebConfigTemplateFileName);

                UpdateWebConfig(roleName, cacheWorkerRole, webCloudConfigPath);
                UpdateWebConfig(roleName, cacheWorkerRole, webConfigPath);
            }
            else
            {
                // Generate cache scaffolding for worker role
                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters[ScaffoldParams.RoleName] = cacheWorkerRole;

                azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WorkerRole.ToString()),
                    roleName, parameters);
            }

            // Add startup task to install memcache shim on the client side.
            string cacheRuntimeUri = CloudRuntimeCollection.GetRuntimeUrl(Resources.CacheRuntimeValue, CacheRuntimeVersion);
            Debug.Assert(!string.IsNullOrEmpty(cacheRuntimeUri));
            Variable emulated = new Variable { name = Resources.EmulatedKey, RoleInstanceValue = new RoleInstanceValueElement { xpath = "/RoleEnvironment/Deployment/@emulated" } };
            Variable[] env = { emulated, new Variable { name = Resources.CacheRuntimeUrl, value = cacheRuntimeUri } };
            Task shimStartupTask = new Task { Environment = env, commandLine = Resources.CacheStartupCommand, executionContext = ExecutionContext.elevated };
            startup.Task = CloudServiceUtilities.ExtendArray<Task>(startup.Task, shimStartupTask);

            // Add default memcache internal endpoint.
            InternalEndpoint memcacheEndpoint = new InternalEndpoint
            {
                name = Resources.MemcacheEndpointName,
                protocol = InternalProtocol.tcp,
                port = Resources.MemcacheEndpointPort
            };
            endpoints.InternalEndpoint = CloudServiceUtilities.ExtendArray<InternalEndpoint>(endpoints.InternalEndpoint, memcacheEndpoint);

            // Enable cache diagnostic
            LocalStore localStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };
            localResources.LocalStorage = CloudServiceUtilities.ExtendArray<LocalStore>(localResources.LocalStorage, localStore);

            DefConfigurationSetting diagnosticLevel = new DefConfigurationSetting { name = Resources.CacheClientDiagnosticLevelAssemblyName };
            configurationSettings = CloudServiceUtilities.ExtendArray<DefConfigurationSetting>(configurationSettings, diagnosticLevel);

            // Add ClientDiagnosticLevel setting to service configuration.
            AddClientDiagnosticLevelToConfig(azureService.Components.GetCloudConfigRole(roleName));
            AddClientDiagnosticLevelToConfig(azureService.Components.GetLocalConfigRole(roleName));
        }
        private static void CacheClientCommonConfiguration(
            CloudServiceProject cloudServiceProject,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefinitionConfigurationSetting[] configurationSettings)
        {
            if (isWebRole)
            {
                // Generate cache scaffolding for web role
                cloudServiceProject.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WebRole.ToString()),
                    roleName, new Dictionary<string, object>());

                // Adjust web.config to enable auto discovery for the caching role.
                string webCloudConfigPath = Path.Combine(cloudServiceProject.Paths.RootPath, roleName, Resources.WebCloudConfig);
                string webConfigPath = Path.Combine(cloudServiceProject.Paths.RootPath, roleName, Resources.WebConfigTemplateFileName);

                UpdateWebConfig(roleName, cacheWorkerRole, webCloudConfigPath);
                UpdateWebConfig(roleName, cacheWorkerRole, webConfigPath);
            }
            else
            {
                // Generate cache scaffolding for worker role
                Dictionary<string, object> parameters = new Dictionary<string, object>();
                parameters[ScaffoldParams.RoleName] = cacheWorkerRole;

                cloudServiceProject.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WorkerRole.ToString()),
                    roleName, parameters);
            }

            // Add default memcache internal endpoint.
            InternalEndpoint memcacheEndpoint = new InternalEndpoint
            {
                name = Resources.MemcacheEndpointName,
                protocol = InternalProtocol.tcp,
                port = Resources.MemcacheEndpointPort
            };
            endpoints.InternalEndpoint = GeneralUtilities.ExtendArray<InternalEndpoint>(endpoints.InternalEndpoint, memcacheEndpoint);

            // Enable cache diagnostic
            LocalStore localStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };
            localResources.LocalStorage = GeneralUtilities.ExtendArray<LocalStore>(localResources.LocalStorage, localStore);

            DefinitionConfigurationSetting diagnosticLevel = new DefinitionConfigurationSetting { name = Resources.CacheClientDiagnosticLevelAssemblyName };
            configurationSettings = GeneralUtilities.ExtendArray<DefinitionConfigurationSetting>(configurationSettings, diagnosticLevel);

            // Add ClientDiagnosticLevel setting to service configuration.
            AddClientDiagnosticLevelToConfig(cloudServiceProject.Components.GetCloudConfigRole(roleName));
            AddClientDiagnosticLevelToConfig(cloudServiceProject.Components.GetLocalConfigRole(roleName));
        }
Beispiel #5
0
 public static void InternalEndpointExists(InternalEndpoint[] internalEndpoints, InternalEndpoint internalEndpoint)
 {
     Assert.IsTrue(Array.Exists <InternalEndpoint>(internalEndpoints, i => i.name == internalEndpoint.name &&
                                                   i.port == internalEndpoint.port && i.protocol == internalEndpoint.protocol));
 }
 public static void InternalEndpointExists(InternalEndpoint[] internalEndpoints, InternalEndpoint internalEndpoint)
 {
     Assert.IsTrue(Array.Exists<InternalEndpoint>(internalEndpoints, i => i.name == internalEndpoint.name &&
         i.port == internalEndpoint.port && i.protocol == internalEndpoint.protocol));
 }
Beispiel #7
0
        /// <summary>
        /// Applies required configuration for enabling cache in SDK 1.8.0 version by:
        /// * Add MemcacheShim runtime installation.
        /// * Add startup task to install memcache shim on the client side.
        /// * Add default memcache internal endpoint.
        /// * Add cache diagnostic to local resources.
        /// * Add ClientDiagnosticLevel setting to service configuration.
        /// * Adjust web.config to enable auto discovery for the caching role.
        /// </summary>
        /// <param name="cloudServiceProject">The azure service instance</param>
        /// <param name="webRole">The web role to enable caching on</param>
        /// <param name="isWebRole">Flag indicating if the provided role is web or not</param>
        /// <param name="cacheWorkerRole">The memcache worker role name</param>
        /// <param name="startup">The role startup</param>
        /// <param name="endpoints">The role endpoints</param>
        /// <param name="localResources">The role local resources</param>
        /// <param name="configurationSettings">The role configuration settings</param>
        private void Version180Configuration(
            CloudServiceProject cloudServiceProject,
            string roleName,
            bool isWebRole,
            string cacheWorkerRole,
            Startup startup,
            Endpoints endpoints,
            LocalResources localResources,
            ref DefinitionConfigurationSetting[] configurationSettings)
        {
            if (isWebRole)
            {
                // Generate cache scaffolding for web role
                cloudServiceProject.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WebRole.ToString()),
                                                        roleName, new Dictionary <string, object>());

                // Adjust web.config to enable auto discovery for the caching role.
                string webCloudConfigPath = Path.Combine(cloudServiceProject.Paths.RootPath, roleName, Resources.WebCloudConfig);
                string webConfigPath      = Path.Combine(cloudServiceProject.Paths.RootPath, roleName, Resources.WebConfigTemplateFileName);

                UpdateWebConfig(roleName, cacheWorkerRole, webCloudConfigPath);
                UpdateWebConfig(roleName, cacheWorkerRole, webConfigPath);
            }
            else
            {
                // Generate cache scaffolding for worker role
                Dictionary <string, object> parameters = new Dictionary <string, object>();
                parameters[ScaffoldParams.RoleName] = cacheWorkerRole;

                cloudServiceProject.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WorkerRole.ToString()),
                                                        roleName, parameters);
            }

            // Add default memcache internal endpoint.
            InternalEndpoint memcacheEndpoint = new InternalEndpoint
            {
                name     = Resources.MemcacheEndpointName,
                protocol = InternalProtocol.tcp,
                port     = Resources.MemcacheEndpointPort
            };

            endpoints.InternalEndpoint = General.ExtendArray <InternalEndpoint>(endpoints.InternalEndpoint, memcacheEndpoint);

            // Enable cache diagnostic
            LocalStore localStore = new LocalStore
            {
                name = Resources.CacheDiagnosticStoreName,
                cleanOnRoleRecycle = false
            };

            localResources.LocalStorage = General.ExtendArray <LocalStore>(localResources.LocalStorage, localStore);

            DefinitionConfigurationSetting diagnosticLevel = new DefinitionConfigurationSetting {
                name = Resources.CacheClientDiagnosticLevelAssemblyName
            };

            configurationSettings = General.ExtendArray <DefinitionConfigurationSetting>(configurationSettings, diagnosticLevel);

            // Add ClientDiagnosticLevel setting to service configuration.
            AddClientDiagnosticLevelToConfig(cloudServiceProject.Components.GetCloudConfigRole(roleName));
            AddClientDiagnosticLevelToConfig(cloudServiceProject.Components.GetLocalConfigRole(roleName));
        }