private Exceptional<Boolean> CreateTypeOnFS_internal(GraphDBType myGraphType) { #region Data var typeName = myGraphType.Name; var typeDir = myGraphType.ObjectLocation; #endregion #region Change the database instance settings containing the StorageLocation paths (Object Schemes) lock (_ObjectLocationsOfAllUserDefinedDatabaseTypes) { _ObjectLocationsOfAllUserDefinedDatabaseTypes.Add(typeDir.ToString()); _ObjectLocationsOfAllUserDefinedDatabaseTypes.Save(); } #endregion #region Store the new type on the file system var isDirExcept = _IGraphFSSession.isIDirectoryObject(typeDir); if(isDirExcept.Failed()) return new Exceptional<bool>(isDirExcept); if (isDirExcept.Value == Trinary.TRUE) return new Exceptional<Boolean>(new Error_UnknownDBError("Default directory for the new type " + typeName + " could not be created, cause it already exists.")); #region Get blocksize of the TypeDirectory from "TYPEDIRBLOCKSIZE" setting UInt64 TypeDirBlockSize = 0; var blocksizeSetting = new SettingTypeDirBlocksize(); var _TypeDireBlockSizeExceptional = blocksizeSetting.Get(_DBContext, TypesSettingScope.DB); if (!_TypeDireBlockSizeExceptional.Success()) { return new Exceptional<Boolean>(_TypeDireBlockSizeExceptional); //throw new GraphDBException(new Error_SettingDoesNotExist("TYPEDIRBLOCKSIZE")); } if (_TypeDireBlockSizeExceptional.Value == null) { TypeDirBlockSize = (UInt64)(Int64)blocksizeSetting.Default.Value; } else { TypeDirBlockSize = (UInt64)(Int64)_TypeDireBlockSizeExceptional.Value.Value.Value; } #endregion // Create the directory for the new type var CreateDirExcept = _IGraphFSSession.CreateDirectoryObject(typeDir, TypeDirBlockSize); if (CreateDirExcept.Failed()) return new Exceptional<bool>(CreateDirExcept); // Create a subdirectory for the objects of this new type CreateDirExcept = _IGraphFSSession.CreateDirectoryObject(new ObjectLocation(typeDir, DBConstants.DBObjectsLocation)); if (CreateDirExcept.Failed()) return new Exceptional<bool>(CreateDirExcept); // Create a subdirectory for the indices of this new type CreateDirExcept = _IGraphFSSession.CreateDirectoryObject(new ObjectLocation(typeDir, DBConstants.DBIndicesLocation)); if (CreateDirExcept.Failed()) return new Exceptional<bool>(CreateDirExcept); #endregion var FlushExcept = FlushType(myGraphType); if (FlushExcept.Failed()) return new Exceptional<bool>(FlushExcept); #region create Objects directory shards Exceptional<IDirectoryObject> createObjectsDirectoryShard = null; for (int i = 0; i < myGraphType.ObjectDirectoryShards; i++) { //create object directory shards createObjectsDirectoryShard = _IGraphFSSession.CreateDirectoryObject(new ObjectLocation(typeDir, DBConstants.DBObjectsLocation, i.ToString())); if (createObjectsDirectoryShard.Failed()) return new Exceptional<bool>(createObjectsDirectoryShard); } #endregion return new Exceptional<bool>(true); }
private Exceptional AddType_CreateDefaultDirectories(GraphDBType aType) { var typeDir = aType.ObjectLocation; var isDirExcept = _IGraphFSSession.isIDirectoryObject(typeDir); if (isDirExcept.Failed()) return isDirExcept; if (isDirExcept.Value == Trinary.TRUE) return new Exceptional(new Error_UnknownDBError("Default directory for the new type " + aType.Name + " could not be created, cause it already exists.")); #region Get blocksize of the TypeDirectory from "TYPEDIRBLOCKSIZE" setting UInt64 TypeDirBlockSize = 0; var blocksizeSetting = new SettingTypeDirBlocksize(); var _TypeDireBlockSizeExceptional = blocksizeSetting.Get(_DBContext, TypesSettingScope.DB); if (!_TypeDireBlockSizeExceptional.Success()) { return _TypeDireBlockSizeExceptional; //throw new GraphDBException(new Error_SettingDoesNotExist("TYPEDIRBLOCKSIZE")); } if (_TypeDireBlockSizeExceptional.Value == null) { TypeDirBlockSize = (UInt64)(Int64)blocksizeSetting.Default.Value; } else { TypeDirBlockSize = (UInt64)(Int64)_TypeDireBlockSizeExceptional.Value.Value.Value; } #endregion // Create the directory for the new type var CreateDirExcept = _IGraphFSSession.CreateDirectoryObject(typeDir, TypeDirBlockSize); if (CreateDirExcept.Failed()) return new Exceptional(CreateDirExcept); // Create a subdirectory for the objects of this new type CreateDirExcept = _IGraphFSSession.CreateDirectoryObject(new ObjectLocation(typeDir, DBConstants.DBObjectsLocation)); if (CreateDirExcept.Failed()) return CreateDirExcept; // Create a subdirectory for the indices of this new type CreateDirExcept = _IGraphFSSession.CreateDirectoryObject(new ObjectLocation(typeDir, DBConstants.DBIndicesLocation)); if (CreateDirExcept.Failed()) return CreateDirExcept; return Exceptional.OK; }