//internal static List<MongodbServerStateInfo> GetState() //{ // lock (submitDataMemoryQueueServices) // { // var state = new List<MongodbServerStateInfo>() // { // new MongodbServerStateInfo // { // MemoryQueueServiceStates = submitDataMemoryQueueServices.ToDictionary(s=>s.Key, s=>s.Value.GetState()), // } // }; // return state; // } //} private static MongoServer CreateMasterMongoServer(string typeName) { if (!masterServerCache.ContainsKey(typeName)) { lock (masterServerCache) { if (!masterServerCache.ContainsKey(typeName)) { var config = MongodbServerConfiguration.GetMongodbServerConfigurationItem(typeName); if (config == null) { LocalLoggingService.Warning("{0} {1} {2} {3}", MongodbServerConfiguration.ModuleName, "MongodbServer_Master", "CreateMasterMongoServer", string.Format("没取到服务器配置项,参数:{0}", typeName)); return(null); } var server = MongodbServerConfiguration.GetMongodbServerUrl(config.MongodbServerUrlName); if (server == null) { LocalLoggingService.Warning("{0} {1} {2} {3}", MongodbServerConfiguration.ModuleName, "MongodbServer_Master", "CreateMasterMongoServer", string.Format("没取到服务器地址,参数:{0}", config.MongodbServerUrlName)); return(null); } masterServerCache.Add(typeName, MongoServer.Create(server.Master)); } } } return(masterServerCache[typeName]); }
private static MongodbServerUrl GetMongodbServerUrl(string typeName) { var config = MongodbServerConfiguration.GetMongodbServerConfigurationItem(typeName); if (config == null) { return(null); } var server = MongodbServerConfiguration.GetMongodbServerUrl(config.MongodbServerUrlName); if (server == null) { return(null); } return(server); }
private static MongoServer CreateSlaveMongoServer(string typeName) { try { if (!slaveServerCache.ContainsKey(typeName)) { lock (slaveServerCache) { if (!slaveServerCache.ContainsKey(typeName)) { var config = MongodbServerConfiguration.GetMongodbServerConfigurationItem(typeName); if (config == null) { LocalLoggingService.Warning("{0} {1} {2} {3}", MongodbServerConfiguration.ModuleName, "MongodbServer_Slave", "CreateSlaveMongoServer", string.Format("没取到服务器配置项,参数:{0}", typeName)); return(null); } var server = MongodbServerConfiguration.GetMongodbServerUrl(config.MongodbServerUrlName); if (server == null) { LocalLoggingService.Warning("{0} {1} {2} {3}", MongodbServerConfiguration.ModuleName, "MongodbServer_Slave", "CreateSlaveMongoServer", string.Format("没取到服务器地址,参数:{0}", config.MongodbServerUrlName)); return(null); } slaveServerCache.Add(typeName, MongoServer.Create(server.Slave)); } } } return(slaveServerCache[typeName]); } catch (Exception ex) { LocalLoggingService.Error("{0} {1} {2} {3} {4}", MongodbServerConfiguration.ModuleName, "MongodbServer_Slave", "CreateSlaveMongoServer", string.Format("创建服务器链接出错,参数:{0}", typeName), ex.Message); throw; } }