private ConfigurationKeyValues refreshBSL(out ConfigurationKeyValues thisOldbusinessServiceKey, string fieldName, ServiceUsers csUser) { Trade.StockTraderWebApplicationConfigurationImplementation.ConfigurationService configService = new ConfigurationService(); List<TraverseNode> traversePath; ConfigurationKeyValues businessServiceKey = new ConfigurationKeyValues(); businessServiceKey.ConfigurationKeyFieldName = fieldName; businessServiceKey.OriginatingConfigServiceName = StockTraderUtility.BUSINESS_SERVICES_CONFIG; traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser); businessServiceKey = configService.getServiceConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, businessServiceKey.ConfigurationKeyFieldName, traversePath, csUser); thisOldbusinessServiceKey = businessServiceKey; return businessServiceKey; }
/// <summary> /// This is where you could implemement any additional validation logic for any config key. For OPS, there are a few /// app-specific settings we need to validate. If a setting update from ConfigWeb fails validation, the update to /// the repository (and other nodes) will be rejected automatically. MAKE SURE TO CALL THE BASE VALIDATION FIRST. /// </summary> /// <param name="settingsInstance">Instance of this host's Settings class.</param> /// <param name="configurationKey">Key to be validated.</param> /// <returns>Bool return code, true if passes validation.</returns> public override bool validateConfigurationKey(object settingsInstance, ConfigurationKeyValues configurationKey) { //First call base validate, this validates inherited settings, and integral type validaiton is also performed. bool success = base.validateConfigurationKey(settingsInstance,configurationKey); if (success) { switch (configurationKey.ConfigurationKeyFieldName) { default: { return true; } } } return success; }
/// <summary> /// This is where you could implemement any additional validation logic for any config key. For BSL, there are a few /// app-specific settings we need to validate. If a setting update from ConfigWeb fails validation, the update to /// the repository (and other nodes) will be rejected automatically. MAKE SURE TO CALL THE BASE VALIDATION FIRST. /// </summary> /// <param name="settingsInstance">Instance of this host's Settings class.</param> /// <param name="configurationKey">Key to be validated.</param> /// <returns>Bool return code, true if passes validation.</returns> public override bool validateConfigurationKey(object settingsInstance, ConfigurationKeyValues configurationKey) { //call base method first! bool success = base.validateConfigurationKey(settingsInstance,configurationKey); if (success) { switch (configurationKey.ConfigurationKeyFieldName) { case "ORDER_PROCESSING_MODE": { if (configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_SOAP && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_AZURE_HTTP_TMSEC_CLIENTCERT && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_AZURE_HTTP_TMSEC_USERNAME && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_AZURE_TCP_TMSEC_CLIENTCERT && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_AZURE_TCP_TMSEC_USERNAME && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_INPROCESS && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_SELF_HOST_HTTP && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_CLIENTCERT && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_USERNAME && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_SELF_HOST_MSMQ && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_SELF_HOST_TCP && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_CLIENTCERT && configurationKey.ConfigurationKeyValue != StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_USERNAME) success= false; else success= true; break; } default: { success= true; break; } } } return success; }
/// <summary> /// Refreshes the Config of the OPS when running in-process with BSL. /// </summary> /// <param name="key"></param> /// <param name="configService"></param> /// <param name="csUser"></param> /// <returns>Int success code.</returns> public int refreshOPSConfig(ConfigurationKeyValues key, ConfigurationService configService, bool notifyNodes, ServiceUsers csUser) { int returnCode= ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS; string value = key.ConfigurationKeyValue; string targetHostID = null; if (ConfigUtility.onAzure) targetHostID = Trade.Utility.StockTraderUtility.ORDER_PROCESSOR_SERVICE_AZURE; else targetHostID = Trade.Utility.StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST; List<TraverseNode> traversePath = configService.getTraversePath(null, targetHostID, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, csUser); key = configService.getServiceConfigurationKey(targetHostID, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, key.ConfigurationKeyFieldName, traversePath, csUser); if (key != null) { key.ConfigurationKeyValue = value; traversePath = configService.getTraversePath(null, targetHostID, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, csUser); if (traversePath!=null || Trade.BusinessServiceConfigurationSettings.Settings.ORDER_PROCESSING_MODE.Equals(StockTraderUtility.OPS_INPROCESS)) returnCode = configService.receiveConfigurationKey(targetHostID, StockTraderUtility.ORDER_PROCESSOR_SERVICE_CONFIG, key, key, notifyNodes, ConfigUtility.UPDATE_KEY_VALUE, traversePath, csUser); } return returnCode; }
/// <summary> /// Overrides the base method, performs app-specific logic on specific app-specific setting changes. For BSL, /// there are few app specific routines we need to run when OPS-specific app settings are changed in the repository. /// MAKE SURE TO CALL THE BASE checkChangedSetting method FIRST! /// </summary> /// <param name="settingsInstance">Instance of this host's Settings class.</param> /// <param name="updatedConfigurationKey">The key that has been updated.</param> /// <param name="block">True to block on any multi-threaded calls, typically the node receiving via /// Config Service endpoint blocks, nodes receiving via Node Service do not, if any threads are spun up.</param> /// <returns>bool as success code.</returns> public override bool checkChangedSetting(object settingsInstance, ConfigurationKeyValues updatedConfigurationKey, bool block, ServiceUsers csUser) { bool success = false; success = base.checkChangedSetting(settingsInstance, updatedConfigurationKey, block, csUser); if (success) { switch (updatedConfigurationKey.ConfigurationKeyFieldName) { case "ORDER_PROCESSING_MODE": { setOrderMode(updatedConfigurationKey.ConfigurationKeyValue); ConfigUtility.invokeGenericConsoleMethod("PostInitProcedure", new object[] { Settings.ORDER_PROCESSING_MODE }); ConfigurationKeyValues orderServiceKey = new ConfigurationKeyValues(); switch (Settings.ORDER_PROCESSING_MODE) { case StockTraderUtility.OPS_INPROCESS: { InitConfigInProcessOrderService.initConfigOrderProcessService(ConfigUtility.masterServiceWebHostSyncObject, true); break; } //********************* Self Host OPS case StockTraderUtility.OPS_SELF_HOST_MSMQ: { if (block) { orderServiceKey.ConfigurationKeyFieldName = "REFRESHCONFIG"; orderServiceKey.ConfigurationKeyValue = "RefreshConfig"; orderServiceKey.OriginatingConfigServiceName = "Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService"; refreshOPSConfig(orderServiceKey, new ConfigurationService(), block,csUser); } break; } case StockTraderUtility.OPS_SELF_HOST_TCP: { goto case StockTraderUtility.OPS_SELF_HOST_MSMQ; } case StockTraderUtility.OPS_SELF_HOST_HTTP: { goto case StockTraderUtility.OPS_SELF_HOST_MSMQ; } case StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_CLIENTCERT: { goto case StockTraderUtility.OPS_SELF_HOST_MSMQ; } case StockTraderUtility.OPS_SELF_HOST_TCP_TMSEC_USERNAME: { goto case StockTraderUtility.OPS_SELF_HOST_MSMQ; } case StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_CLIENTCERT: { goto case StockTraderUtility.OPS_SELF_HOST_MSMQ; } case StockTraderUtility.OPS_SELF_HOST_HTTP_TMSEC_USERNAME: { goto case StockTraderUtility.OPS_SELF_HOST_MSMQ; } case StockTraderUtility.OPS_SOAP: { goto case StockTraderUtility.OPS_SELF_HOST_MSMQ; } } success = true; break; } case "DAL": { buildConnString(); if (block) { ConfigurationKeyValues orderServiceKey = new ConfigurationKeyValues(); orderServiceKey.ConfigurationKeyFieldName = "DAL"; orderServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue; orderServiceKey.OriginatingConfigServiceName = "Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService"; refreshOPSConfig(orderServiceKey, new ConfigurationService(), block, csUser); } break; } case "DBServer": { buildConnString(); if (block) { ConfigurationKeyValues orderServiceKey = new ConfigurationKeyValues(); orderServiceKey.ConfigurationKeyFieldName = "DBServer"; orderServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue; orderServiceKey.OriginatingConfigServiceName = "Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService"; refreshOPSConfig(orderServiceKey, new ConfigurationService(), block, csUser); } break; } case "Database": { buildConnString(); if (block) { ConfigurationKeyValues orderServiceKey = new ConfigurationKeyValues(); orderServiceKey.ConfigurationKeyFieldName = "Database"; orderServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue; orderServiceKey.OriginatingConfigServiceName = "Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService"; refreshOPSConfig(orderServiceKey, new ConfigurationService(),block, csUser); } break; } case "UserID": { buildConnString(); break; } case "Password": { buildConnString(); break; } case "ENABLE_GLOBAL_SYSTEM_DOT_TRANSACTIONS_CONFIGSTRING": { Settings.setTxModel(); break; } default: { success = true; break; } } } return success; }
/// <summary> /// This method performs the logic required when a specific configuration settings key is changed. This includes /// potentially updating configuration database, notifying nodes, and performing configuration actions. /// </summary> /// <param name="targetHostNameIdentifier">The name of the target host we are seeking, as specified in the target's HOST_NAME_IDENTIFIER settings key.</param> /// <param name="targetConfigServiceName">The fully qualified name of the Configuration Service implementation class for the host we are seeking, used in /// conjunction with targetHostNameIdentifier to uniquely identify a target host.</param> /// <param name="oldKey">The key prior to update.</param> /// <param name="newKey">The updated key.</param> /// <param name="notifyNodes">If true, key update will be flowed to peer nodes.</param> /// <param name="action">Action to perform.</param> /// <param name="traversePath">Network path to the target host.</param> /// <param name="csUser">User to authenticate.</param> /// <returns>Int representing success code.</returns> public override int receiveConfigurationKey(string targetHostNameIdentifier, string targetConfigServiceNameIdentifier, ConfigurationKeyValues oldKey, ConfigurationKeyValues newKey, bool notifyNodes, string action, List<TraverseNode> traversePath, ServiceUsers csUser) { ServiceConfigHelper configHelper = new ServiceConfigHelper(settingsInstance); bool success = true; object theSettingsInstance = new Trade.BusinessServiceConfigurationSettings.Settings(); IConfigurationActions configActions; int returnCode = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS; try { if (!(configHelper.setServiceRights(ref csUser, ConfigUtility.CONFIG_ADMIN_RIGHTS)>=ConfigUtility.CONFIG_ADMIN_RIGHTS)) return ConfigUtility.CLUSTER_UPDATE_FAIL_AUTHENTICATION; configActions = (IConfigurationActions)ConfigUtility.reflectGetField(settingsInstance, "thisServiceConfigActions"); if ((action != ConfigUtility.ADD_KEY && action != ConfigUtility.REMOVE_KEY) && (traversePath == null || traversePath.Count <= 1 || traversePath[0] == null)) { if (targetHostNameIdentifier != StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST && targetHostNameIdentifier != StockTraderUtility.ORDER_PROCESSOR_SERVICE_AZURE) { if (!configActions.validateConfigurationKey(settingsInstance, newKey)) return ConfigUtility.CLUSTER_UPDATE_FAIL_VALIDATION; } } ConfigUtility.writeConfigConsoleMessage("\nReceived Request for Configuration Key Change, Action: " + action + ". Keyname: " + oldKey.ConfigurationKeyDisplayName + "\n", EventLogEntryType.Information, true, settingsInstance); ConfigUtility.writeConfigConsoleMessage("Value: " + newKey.ConfigurationKeyValue + "\n\n", EventLogEntryType.Information, true, settingsInstance); if (traversePath == null || traversePath.Count <= 1 || traversePath[0] == null) { bool SHARESERVICECONFIGURATIONDATA = (bool)ConfigUtility.reflectGetField(settingsInstance, "SHARESERVICECONFIGURATIONDATA"); if (!SHARESERVICECONFIGURATIONDATA) { List<ServiceUsers> thisServiceUsers = (List<ServiceUsers>)ConfigUtility.reflectGetField(settingsInstance, "thisServiceUsers"); ServiceUsers userLocalAdmin = thisServiceUsers.Find(delegate(ServiceUsers userExist) { return csUser.UserId.ToLower().Equals("localadmin") && userExist.Password.Equals(csUser.Password) && csUser.Rights == ConfigUtility.CONFIG_ADMIN_RIGHTS; }); if (userLocalAdmin == null) return ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS; } switch (targetHostNameIdentifier) { case StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST: { theSettingsInstance = new Trade.OrderProcessorServiceConfigurationSettings.Settings(); Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService configService = new Trade.OrderProcessorHostConfigurationImplementation.ConfigurationService(); int opsRetCode = configService.receiveConfigurationKey(targetHostNameIdentifier, targetConfigServiceNameIdentifier, oldKey, newKey, notifyNodes, action, traversePath, csUser); if (opsRetCode == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS) success = true; break; } case StockTraderUtility.ORDER_PROCESSOR_SERVICE_AZURE: { goto case StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST; } default: { if (notifyNodes) success = configHelper.sendConfigurationKeyUpdateLocal(oldKey, newKey, action, csUser); break; } } if (success) { if (targetHostNameIdentifier != StockTraderUtility.ORDER_PROCESSOR_SERVICE_SELFHOST) success = configActions.checkChangedSetting(theSettingsInstance, newKey, notifyNodes, csUser); if (notifyNodes && success) { RemoteNotifications remoteNotify = new RemoteNotifications(settingsInstance); return remoteNotify.sendKeyUpdateToClusterMembers(targetHostNameIdentifier, targetConfigServiceNameIdentifier, oldKey, newKey, action); } } else returnCode = ConfigUtility.CLUSTER_UPDATE_FAIL_PERSISTED; } else { if (traversePath != null && traversePath.Count > 1) { RemoteNotifications remoteKeyUpdate = new RemoteNotifications(settingsInstance); ConfigUtility.writeConfigConsoleMessage(" Forwarding Key to Remote Connected Service: " + traversePath[traversePath.Count - 1].MyNode.Address + "\n", EventLogEntryType.Information, true, settingsInstance); return (remoteKeyUpdate.sendConfigurationKeyUpdateRemote(targetHostNameIdentifier, targetConfigServiceNameIdentifier, oldKey, newKey, notifyNodes, action, traversePath, csUser)); } } } catch (Exception e) { ServiceConfigHelper.logServiceOperationException(csUser, e.ToString(), settingsInstance); throw; } return (returnCode); }
protected override void OnLoad(EventArgs e) { Page.Form.DefaultFocus = NewValue.ClientID; Input.getHostData(IsPostBack, ViewState, out userid, out address, out user, out binding, out hostNameIdentifier, out configName, out version, out platform, out hoster, false); string postback = "?name=" + hostNameIdentifier + "&cfgSvc=" + configName + "&version=" + version + "&platform=" + platform + "&hoster=" + hoster; if (IsPostBack) { theTargetContract = (string)ViewState["contract"]; level = (Int32)ViewState["level"]; compositeServiceData = (List<ServiceConfigurationData>)ViewState["CompositeServiceData"]; traversePath = (List<TraverseNode>)ViewState["traversePath"]; } else { theTargetContract = Request["contract"]; ViewState["contract"] = theTargetContract; string levelString = Request["level"]; if (!Int32.TryParse(levelString, out level)) level = ConfigUtility.CONFIG_LEVEL_BASIC; ViewState["level"] = level; traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, binding, user); compositeServiceData = configProxy.getServiceConfiguration(hostNameIdentifier, configName, level, true, traversePath, user); ViewState["CompositeServiceData"] = compositeServiceData; ViewState["traversePath"] = traversePath; } string keyName = null; thisData = findKeyValuesByContract(theTargetContract, 0); if (thisData == null) { Response.Redirect(ConfigSettings.PAGE_CONFIG + postback + "&contract=" + theTargetContract + "&level=1",true); } if (IsPostBack) { keyName = (string)ViewState["keyname"]; thisKey = (ConfigurationKeyValues)ViewState["thisKey"]; if (thisKey.ConfigurationKeyDataType.ToLower().Equals("radiobutton")) { NewValue.Text = RadioButtonListValidValues.SelectedValue; } if (thisKey.ConfigurationKeyDataType.ToLower().Equals("password") && NewValue.Text.Equals("NOT VIEWABLE")) updatedValue = thisKey.ConfigurationKeyValue; else updatedValue = NewValue.Text; } else { keyName = Request["keyname"]; ViewState["keyname"] = keyName; thisKey = getKey(thisData, keyName); ViewState["thisKey"] = thisKey; } if (thisKey == null) { Response.Redirect(ConfigSettings.PAGE_CONFIG + postback + "&contract=" + theTargetContract + "&level=1",true); } ViewState["keyName"] = thisKey.ConfigurationKeyFieldName; KeyName.Text =thisKey.ConfigurationKeyDisplayName; if (thisKey.ConfigurationKeyDataType.ToLower().Trim(new char[] { ' ' }) != "nodisplay" && thisKey.ConfigurationKeyDataType.ToLower().Trim(new char[] { ' ' }) != "password") Value.Text = ChunkText.chunkDot(thisKey.ConfigurationKeyValue, '.'); else Value.Text = "NOT VIEWABLE"; if (!Value.Text.Contains(" ")) { if (Value.Text.Length > 32) Value.Text = ChunkText.chunkDot(Value.Text, '_'); if (Value.Text.Length > 32) Value.Text = ChunkText.chunk(32, Value.Text); } string[] splitIt = Value.Text.Split(' '); for (int i = 0; i < splitIt.Length; i++) { if (splitIt[i].Length > 40) Value.Text = ChunkText.chunk(40, thisKey.ConfigurationKeyValue); } Description.Text = thisKey.ConfigurationKeyDescription; string[] format = thisKey.ConfigurationKeyValidValues.Split(new char[]{' '}); bool needChunk = false; for (int i = 0; i < format.Length; i++) { if (format[i].Length > 48) needChunk = true; } if (needChunk) ValidValues.Text = ChunkText.chunk(48,thisKey.ConfigurationKeyValidValues); else ValidValues.Text = thisKey.ConfigurationKeyValidValues; ValidValues.Text = thisKey.ConfigurationKeyValidValues; LastUpdated.Text = thisKey.ConfigurationKeyLastUpdate.ToString(); originalValue = thisKey.ConfigurationKeyValue; string keyreadonly = thisKey.ConfigurationKeyReadOnly.ToString(); if (keyreadonly.ToLower() == "false") { NewValue.Enabled = true; } if (thisKey.ConfigurationKeyDataType.ToLower().Equals("password")) NewValue.Text = "NOT VIEWABLE"; else NewValue.Text = thisKey.ConfigurationKeyValue; if (thisKey.ConfigurationKeyDataType.ToLower().Equals("radiobutton")) { NewValue.Visible = false; RadioButtonListValidValues.Visible = true; if (!IsPostBack) initradiobutton(); } else { NewValue.Visible = true; RadioButtonListValidValues.Visible = false; } TopNode.PostBackUrl = ConfigSettings.PAGE_NODES; ServiceVersion.Text = version; ServicePlatform.Text = platform; ServiceHoster.Text = hoster; TopNodeName.Text = hostNameIdentifier; ReturnLabel.Text = "<a class=\"Return\" href=\"" + ConfigSettings.PAGE_CONFIG + "?name=" + hostNameIdentifier + "&cfgSvc=" + configName + "&contract=" + theTargetContract + "&version=" + version + "&level=" + level.ToString() + "&platform=" + platform + "&hoster=" + hoster + "\">Return to Configuration Page</a>"; GetImageButton.runtimePoweredBy(platform, RuntimePlatform); if (IsPostBack) processUpdate(thisKey); }
private void processUpdate(ConfigurationKeyValues keyToUpdate) { int success = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS; ConfigurationKeyValues oldKey = getKey(thisData, keyToUpdate.ConfigurationKeyFieldName); if (oldKey.ConfigurationKeyDataType.ToLower().Trim(new char[] { ' ' }) != "nodisplay" && oldKey.ConfigurationKeyDataType.ToLower().Trim(new char[] { ' ' }) != "password") Value.Text = updatedValue; else Value.Text = "NOT VIEWABLE"; keyToUpdate.ConfigurationKeyValue = updatedValue; if (oldKey.ConfigurationKeyDataType.ToLower().Trim(new char[] { ' ' }) == "password") NewValue.Text = "NOT VIEWABLE"; else NewValue.Text = keyToUpdate.ConfigurationKeyValue; try { traversePath = DynamicTraversePath.getTraversePath(hostNameIdentifier, configName, ref configProxy, address, binding, user); success = configProxy.receiveConfigurationKey(hostNameIdentifier, configName, oldKey, keyToUpdate, true, ConfigUtility.UPDATE_KEY_VALUE, traversePath, user); if (success == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS) { UpdateMessage.Text = "<br/><span style=\"color:PaleGreen \">The configuration key was sucessfully updated.</span>"; if (keyToUpdate.ConfigurationKeyDataType.ToLower().Trim(new char[] { ' ' }) != "nodisplay" && keyToUpdate.ConfigurationKeyDataType.ToLower().Trim(new char[] { ' ' }) != "password") Value.Text = ChunkText.chunkDot(keyToUpdate.ConfigurationKeyValue, '.'); else Value.Text = "NOT VIEWABLE"; if (!Value.Text.Contains(" ")) { if (Value.Text.Length > 32) Value.Text = ChunkText.chunkDot(Value.Text, '_'); if (Value.Text.Length > 32) Value.Text = ChunkText.chunk(32, Value.Text); } string[] splitIt = Value.Text.Split(' '); for (int i = 0; i < splitIt.Length; i++) { if (splitIt[i].Length > 40) Value.Text = ChunkText.chunk(40, thisKey.ConfigurationKeyValue); } ViewState["thisKey"] = keyToUpdate; } else { string message = null; switch (success) { case ConfigUtility.CLUSTER_UPDATE_FAIL_PERSISTED: { message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_PERSISTED; break; } case ConfigUtility.CLUSTER_UPDATE_FAIL_VALIDATION: { message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_VALIDATION; break; } case ConfigUtility.CLUSTER_UPDATE_FAIL_AUTHENTICATION: { message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_AUTHORIZATION; break; } case ConfigUtility.CLUSTER_UPDATE_FAIL_REMOTE: { message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_REMOTE_UPDATE; break; } default: { message = ConfigSettings.EXCEPTION_MESSAGE_FAIL_REMOTE_PEER + success.ToString(); break; } } UpdateMessage.Text = "<br/><span style=\"color:Maroon\">" + message + "</span>"; keyToUpdate.ConfigurationKeyValue = originalValue; } } catch (Exception e) { keyToUpdate.ConfigurationKeyValue = originalValue; UpdateMessage.Text = "<br/><span style=\"color:Maroon\">An exception was encountered while updating the configuration key. The exception was: " + e.ToString() + "</span>"; } }
/// <summary> /// Overrides the base method, performs app-specific logic on specific app-specific setting changes. For the /// Web app there are few app specific routines we need to run when OPS-specific app settings are changed in the repository. /// MAKE SURE TO CALL THE BASE checkChangedSetting method FIRST! /// </summary> /// <param name="settingsInstance">Instance of this host's Settings class.</param> /// <param name="updatedConfigurationKey">The key that has been updated.</param> /// <param name="block">True to block on any multi-threaded calls, typically the node receiving via /// Config Service endpoint blocks, nodes receiving via Node Service do not, if any threads are spun up.</param> /// <returns>bool as success code.</returns> public override bool checkChangedSetting(object settingsInstance, ConfigurationKeyValues updatedConfigurationKey,bool block,ServiceUsers csUser) { bool success = false; Trade.StockTraderWebApplicationConfigurationImplementation.ConfigurationService configService = new ConfigurationService(); ServiceConfigHelper configHelper = new ServiceConfigHelper(settingsInstance); success = base.checkChangedSetting(settingsInstance, updatedConfigurationKey, block, csUser); if (success) { switch (updatedConfigurationKey.ConfigurationKeyFieldName) { case "ACCESS_MODE": { setAccessMode(updatedConfigurationKey.ConfigurationKeyValue); ConfigurationKeyValues businessServiceKey = new ConfigurationKeyValues(); switch (Settings.ACCESS_MODE) { case StockTraderUtility.BSL_IISHOST_BSL_HTTP: { if (block) { businessServiceKey.ConfigurationKeyFieldName = "REFRESHCONFIG"; businessServiceKey.ConfigurationKeyValue = "RefreshConfig"; businessServiceKey.OriginatingConfigServiceName = StockTraderUtility.BUSINESS_SERVICES_CONFIG; refreshBSLConfig(businessServiceKey, configService, block, csUser); } InitCommunicationChannels(settingsInstance, null, ConfigUtility.INIT_ALL_CONNECTED_INSTANCES); break; } case StockTraderUtility.BSL_IISHOST_BSL_TCP: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_IISHOST_TCP_TMSEC_CLIENTCERT: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_IISHOST_TCP_TMSEC_USERNAME: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_IISHOST_WSHTTP_MSEC_CLIENTCERT: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_IISHOST_WSHTTP_TMSEC_CLIENTCERT: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_IISHOST_WSHTTP_TMSEC_USERNAME: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_AZURE_TCP_TMSEC_CLIENTCERT: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_AZURE_TCP_TMSEC_USERNAME: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_AZURE_WSHTTP_TMSEC_CLIENTCERT: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_AZURE_WSHTTP_TMSEC_USERNAME: { goto case StockTraderUtility.BSL_IISHOST_BSL_HTTP; } case StockTraderUtility.BSL_INPROCESS: { InitConfigInProcessBusinessService.initConfigBusinessService(ConfigUtility.masterServiceWebHostSyncObject,true); break; } default: { break; } } success = true; break; } case "MAX_DISPLAY_ORDERS": { List<TraverseNode> traversePath=null; int successBSL = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS; if (Settings.ACCESS_MODE == StockTraderUtility.BSL_SOAP) { success = true; break; } ConfigurationKeyValues businessServiceKey = null; ConfigurationKeyValues thisOldbusinessServiceKey = null; businessServiceKey = refreshBSL(out thisOldbusinessServiceKey, "MAX_QUERY_ORDERS", csUser); if (businessServiceKey != null && block) { businessServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue; traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser); successBSL = configService.receiveConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER,StockTraderUtility.BUSINESS_SERVICES_CONFIG, thisOldbusinessServiceKey,businessServiceKey,block, ConfigUtility.UPDATE_KEY_VALUE,traversePath,csUser); if (successBSL == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS) success = true; } else success = false; break; } case "MAX_DISPLAY_TOP_ORDERS": { List<TraverseNode> traversePath = null; int successBSL = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS; if (Settings.ACCESS_MODE == StockTraderUtility.BSL_SOAP) { success = true; break; } ConfigurationKeyValues businessServiceKey = null; ConfigurationKeyValues thisOldbusinessServiceKey = null; businessServiceKey = refreshBSL(out thisOldbusinessServiceKey, "MAX_QUERY_TOP_ORDERS", csUser); if (businessServiceKey != null && block) { businessServiceKey.ConfigurationKeyValue = updatedConfigurationKey.ConfigurationKeyValue; traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser); successBSL = configService.receiveConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, thisOldbusinessServiceKey, businessServiceKey, block, ConfigUtility.UPDATE_KEY_VALUE, traversePath, csUser); if (successBSL == ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS) success = true; } else success = false; break; } default: { success = true; break; } } } return success; }
/// <summary> /// Refreshes the BSL from repository. /// </summary> /// <param name="key"></param> /// <param name="configService"></param> /// <param name="notifyNodes"></param> /// <param name="csUser"></param> /// <returns></returns> public int refreshBSLConfig(ConfigurationKeyValues key, ConfigurationService configService, bool notifyNodes,ServiceUsers csUser) { int returnCode = ConfigUtility.CLUSTER_UPDATE_FULL_SUCCESS; string value = key.ConfigurationKeyValue; List<TraverseNode> traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser); key = configService.getServiceConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, key.ConfigurationKeyFieldName, traversePath, csUser); if (key != null) { key.ConfigurationKeyValue = value; traversePath = configService.getTraversePath(null, Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, csUser); if (traversePath!=null) returnCode = configService.receiveConfigurationKey(Settings.BSL_CLIENT_ACTIVE_SERVICE_HOST_IDENTIFIER, StockTraderUtility.BUSINESS_SERVICES_CONFIG, key, key, notifyNodes, ConfigUtility.UPDATE_KEY_VALUE, traversePath, csUser); } return returnCode; }
/// <summary> /// Overrides the base method, performs app-specific logic on specific app-specific setting changes. For OPS, /// there are few app specific routines we need to run when OPS-specific app settings are changed in the repository. /// MAKE SURE TO CALL THE BASE checkChangedSetting method FIRST! /// </summary> /// <param name="settingsInstance">Instance of this host's Settings class.</param> /// <param name="updatedConfigurationKey">The key that has been updated.</param> /// <param name="block">True to block on any multi-threaded calls, typically the node receiving via /// Config Service endpoint blocks, nodes receiving via Node Service do not, if any threads are spun up.</param> /// <param name="csUser">The user making the requested configuration update.</param> /// <returns>bool as success code.</returns> public override bool checkChangedSetting(object settingsInstance, ConfigurationKeyValues updatedConfigurationKey, bool block, ServiceUsers csUser) { bool success = false; //First call the base method, this performs actions for required inherited global settings. success = base.checkChangedSetting(settingsInstance, updatedConfigurationKey, block, csUser); if (success) { switch (updatedConfigurationKey.ConfigurationKeyFieldName) { case "DAL": { buildConnString(); break; } case "DBServer": { buildConnString(); break; } case "Database": { buildConnString(); break; } case "UserID": { buildConnString(); break; } case "Password": { buildConnString(); break; } default: { success = true; break; } } } return success; }