public DBObjectDistributedTable GetDistributedTable(DBObjectTableSchemaAdapter schemaAdapter, string tableName)//DBConnection connection, string tableName) { if (schemaAdapter == null) { throw new ArgumentNullException("schemaAdapter"); } if (String.IsNullOrEmpty(tableName)) { throw new ArgumentNullException("tableName"); } DBConnection connection = schemaAdapter.PrimaryDatabaseConnection; string tableKey = string.Format("{0}.{1}.{2}", connection.DisplayName.ToLower(), schemaAdapter.ClassDefinition.TypeUniqueKey, tableName); this.Logger.WriteFormatMessage("Получение распределенной таблицы. Ключ: '{0}'", tableKey); DBObjectDistributedTable table = null; if (DBObjectTableActivator.TablesByKey.ContainsKey(tableKey)) { table = DBObjectTableActivator.TablesByKey[tableKey]; } else { if (!DBObjectTableActivator.LockObjects.ContainsKey(tableKey)) { lock (DBObjectTableActivator.LokersLocker) { if (!DBObjectTableActivator.LockObjects.ContainsKey(tableKey)) { DBObjectTableActivator.LockObjects.Add(tableKey, new object()); } } } lock (DBObjectTableActivator.LockObjects[tableKey]) { if (!DBObjectTableActivator.TablesByKey.ContainsKey(tableKey)) { this.Logger.WriteFormatMessage("Вызов конструктора объекта таблицы. Ключ: '{0}'", tableKey); table = new DBObjectDistributedTable(schemaAdapter, tableName); if (!table.TablePartition.Table.Exists) { throw new DistributedTableNotFoundException(connection.DisplayName, tableName); } } else { table = DBObjectTableActivator.TablesByKey[tableKey]; } } } this.Logger.WriteFormatMessage("Получение распределенной таблицы завершено. Ключ: '{0}'", tableKey); return(table); }
internal DBObjectPrincipalTableSchema(DBObjectTableSchemaAdapter objectSchemaAdapter) : base(objectSchemaAdapter) { if (objectSchemaAdapter == null) { throw new ArgumentNullException("objectSchemaAdapter"); } this.ObjectSchemaAdapter = objectSchemaAdapter; }
internal DBObjectDistributedTablePartition(DBObjectTableSchemaAdapter adapter, string tableName) : base(adapter) { if (String.IsNullOrEmpty(tableName)) { throw new ArgumentNullException("tableName"); } this.Name = tableName; }
/// <summary> /// /// </summary> /// <param name="adapter"></param> /// <param name="tableName"></param> internal DBObjectDistributedTable(DBObjectTableSchemaAdapter adapter, string tableName) { if (adapter == null) { throw new ArgumentNullException("adapter"); } if (String.IsNullOrEmpty(tableName)) { throw new ArgumentNullException("tableName"); } this.SchemaAdapter = adapter; this.TableName = tableName; }
internal DBObjectIndexSchema(MetadataIndexDefinition indexDefinition, DBObjectTableSchemaAdapter objectSchemaAdapter) : base(objectSchemaAdapter) { if (indexDefinition == null) { throw new ArgumentNullException("indexDefinition"); } if (objectSchemaAdapter == null) { throw new ArgumentNullException("objectSchemaAdapter"); } this.IndexDefinition = indexDefinition; this.ObjectSchemaAdapter = objectSchemaAdapter; }
internal DBObjectColumnSchema(MetadataPropertyDefinition propertyDefinition, DBObjectTableSchemaAdapter objectSchemaAdapter) : base(objectSchemaAdapter) { if (propertyDefinition == null) { throw new ArgumentNullException("propertyDefinition"); } if (objectSchemaAdapter == null) { throw new ArgumentNullException("objectSchemaAdapter"); } this.PropertyDefinition = propertyDefinition; this.ObjectSchemaAdapter = objectSchemaAdapter; }
public DBObjectDistributedTable EnsureDistributedTable(DBObjectTableSchemaAdapter schemaAdapter, string tableName) { if (schemaAdapter == null) { throw new ArgumentNullException("schemaAdapter"); } if (String.IsNullOrEmpty(tableName)) { throw new ArgumentNullException("tableName"); } DBConnection connection = schemaAdapter.PrimaryDatabaseConnection; string tableKey = string.Format("{0}.{1}.{2}", connection.DisplayName.ToLower(), schemaAdapter.ClassDefinition.TypeUniqueKey, tableName); DBObjectDistributedTable table = null; this.Logger.WriteFormatMessage("Получение/создание распределенной таблицы. Ключ: '{0}'", tableKey); if (!DBObjectTableActivator.TablesByKey.ContainsKey(tableKey)) { if (!DBObjectTableActivator.LockObjects.ContainsKey(tableKey)) { lock (DBObjectTableActivator.LokersLocker) { if (!DBObjectTableActivator.LockObjects.ContainsKey(tableKey)) { DBObjectTableActivator.LockObjects.Add(tableKey, new object()); } } } lock (DBObjectTableActivator.LockObjects[tableKey]) { if (!DBObjectTableActivator.TablesByKey.ContainsKey(tableKey)) { this.Logger.WriteFormatMessage("Вызов конструктора объекта таблицы. Ключ: '{0}'", tableKey); table = new DBObjectDistributedTable(schemaAdapter, tableName); this.Logger.WriteFormatMessage("Инициализация объекта таблицы. Ключ: '{0}'", tableKey); table.TablePartition.Table.Init(); this.Logger.WriteFormatMessage("Инициализация объекта таблицы завершена. Ключ: '{0}'", tableKey); lock (DBObjectTableActivator.LokersLocker) { DBObjectTableActivator.TablesByKey.Add(tableKey, table); } } else { table = DBObjectTableActivator.TablesByKey[tableKey]; } } } else { table = DBObjectTableActivator.TablesByKey[tableKey]; } if (table == null) { throw new Exception(string.Format("Не удалось получить таблицу файлов, с названием {0}.", tableName)); } this.Logger.WriteFormatMessage("Получение/создание распределенной таблицы завершено. Ключ: '{0}'", tableKey); return(table); }