[12969] | 1 | /* HeuristicLab
|
---|
| 2 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 3 | *
|
---|
| 4 | * This file is part of HeuristicLab.
|
---|
| 5 | *
|
---|
| 6 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 7 | * it under the terms of the GNU General Public License as published by
|
---|
| 8 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 9 | * (at your option) any later version.
|
---|
| 10 | *
|
---|
| 11 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | * GNU General Public License for more details.
|
---|
| 15 | *
|
---|
| 16 | * You should have received a copy of the GNU General Public License
|
---|
| 17 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 18 | */
|
---|
| 19 | USE [HeuristicLab.Hive-3.3]
|
---|
[6983] | 20 |
|
---|
[9665] | 21 | EXEC sp_configure filestream_access_level, 2
|
---|
| 22 | GO
|
---|
| 23 | RECONFIGURE
|
---|
| 24 | GO
|
---|
| 25 |
|
---|
[6983] | 26 | SET ARITHABORT ON
|
---|
| 27 | CREATE TABLE [dbo].[AssignedResources](
|
---|
| 28 | [ResourceId] UniqueIdentifier NOT NULL,
|
---|
[7847] | 29 | [TaskId] UniqueIdentifier NOT NULL,
|
---|
[6983] | 30 | CONSTRAINT [PK_dbo.ResourceIdTaskId] PRIMARY KEY ([ResourceId], [TaskId])
|
---|
| 31 | )
|
---|
| 32 | CREATE TABLE [dbo].[Plugin](
|
---|
[7847] | 33 | [PluginId] UniqueIdentifier NOT NULL,
|
---|
| 34 | [Name] VarChar(MAX) NOT NULL,
|
---|
| 35 | [Version] VarChar(MAX) NOT NULL,
|
---|
| 36 | [UserId] UniqueIdentifier NOT NULL,
|
---|
| 37 | [DateCreated] DateTime NOT NULL,
|
---|
| 38 | [Hash] VarBinary(20) NOT NULL,
|
---|
[6983] | 39 | CONSTRAINT [PK_dbo.Plugin] PRIMARY KEY ([PluginId])
|
---|
| 40 | )
|
---|
| 41 | CREATE TABLE [dbo].[RequiredPlugins](
|
---|
[7847] | 42 | [RequiredPluginId] UniqueIdentifier NOT NULL,
|
---|
| 43 | [TaskId] UniqueIdentifier NOT NULL,
|
---|
| 44 | [PluginId] UniqueIdentifier NOT NULL,
|
---|
[6983] | 45 | CONSTRAINT [PK_dbo.RequiredPlugins] PRIMARY KEY ([RequiredPluginId])
|
---|
| 46 | )
|
---|
| 47 | CREATE TABLE [dbo].[Resource](
|
---|
[7847] | 48 | [ResourceId] UniqueIdentifier NOT NULL,
|
---|
| 49 | [Name] VarChar(MAX) NOT NULL,
|
---|
| 50 | [ResourceType] NVarChar(4000) NOT NULL,
|
---|
| 51 | [ParentResourceId] UniqueIdentifier,
|
---|
| 52 | [CpuSpeed] Int,
|
---|
| 53 | [Memory] Int,
|
---|
| 54 | [Login] DateTime,
|
---|
| 55 | [SlaveState] VarChar(15),
|
---|
| 56 | [Cores] Int,
|
---|
| 57 | [FreeCores] Int,
|
---|
| 58 | [FreeMemory] Int,
|
---|
| 59 | [IsAllowedToCalculate] Bit,
|
---|
| 60 | [CpuArchitecture] VarChar(3),
|
---|
| 61 | [OperatingSystem] VarChar(MAX),
|
---|
| 62 | [LastHeartbeat] DateTime,
|
---|
| 63 | [CpuUtilization] float,
|
---|
| 64 | [HbInterval] int NOT NULL,
|
---|
[7857] | 65 | [IsDisposable] Bit,
|
---|
[7916] | 66 | [OwnerUserId] UniqueIdentifier,
|
---|
[6983] | 67 | CONSTRAINT [PK_dbo.Resource] PRIMARY KEY ([ResourceId])
|
---|
| 68 | )
|
---|
[7916] | 69 | CREATE TABLE [dbo].[ResourcePermission](
|
---|
| 70 | [ResourceId] UniqueIdentifier NOT NULL,
|
---|
| 71 | [GrantedUserId] UniqueIdentifier NOT NULL,
|
---|
| 72 | [GrantedByUserId] UniqueIdentifier NOT NULL,
|
---|
| 73 | CONSTRAINT [PK_dbo.ResourcePermission] PRIMARY KEY ([ResourceId], [GrantedUserId])
|
---|
| 74 | )
|
---|
[6983] | 75 | CREATE TABLE [dbo].[Task](
|
---|
[7847] | 76 | [TaskId] UniqueIdentifier NOT NULL,
|
---|
| 77 | [TaskState] VarChar(30) NOT NULL,
|
---|
| 78 | [ExecutionTimeMs] float NOT NULL,
|
---|
| 79 | [LastHeartbeat] DateTime,
|
---|
| 80 | [ParentTaskId] UniqueIdentifier,
|
---|
| 81 | [Priority] Int NOT NULL,
|
---|
| 82 | [CoresNeeded] Int NOT NULL,
|
---|
| 83 | [MemoryNeeded] Int NOT NULL,
|
---|
| 84 | [IsParentTask] Bit NOT NULL,
|
---|
| 85 | [FinishWhenChildJobsFinished] Bit NOT NULL,
|
---|
| 86 | [Command] VarChar(30),
|
---|
| 87 | [JobId] UniqueIdentifier NOT NULL,
|
---|
[6983] | 88 | CONSTRAINT [PK_dbo.Task] PRIMARY KEY ([TaskId])
|
---|
| 89 | )
|
---|
| 90 | CREATE TABLE [dbo].[Downtime](
|
---|
[7847] | 91 | [DowntimeId] UniqueIdentifier NOT NULL,
|
---|
| 92 | [ResourceId] UniqueIdentifier NOT NULL,
|
---|
| 93 | [StartDate] DateTime NOT NULL,
|
---|
| 94 | [EndDate] DateTime NOT NULL,
|
---|
| 95 | [AllDayEvent] Bit NOT NULL,
|
---|
| 96 | [Recurring] Bit NOT NULL,
|
---|
| 97 | [RecurringId] UniqueIdentifier NOT NULL,
|
---|
[8957] | 98 | [DowntimeType] VarChar(MAX) NOT NULL,
|
---|
[6983] | 99 | CONSTRAINT [PK_dbo.Downtime] PRIMARY KEY ([DowntimeId])
|
---|
| 100 | )
|
---|
| 101 | CREATE TABLE [dbo].[Job](
|
---|
[7847] | 102 | [JobId] UniqueIdentifier NOT NULL,
|
---|
| 103 | [Name] VarChar(MAX) NOT NULL,
|
---|
| 104 | [Description] VarChar(MAX),
|
---|
| 105 | [ResourceIds] VarChar(MAX),
|
---|
| 106 | [OwnerUserId] UniqueIdentifier NOT NULL,
|
---|
| 107 | [DateCreated] DateTime NOT NULL,
|
---|
[6983] | 108 | CONSTRAINT [PK_dbo.Job] PRIMARY KEY ([JobId])
|
---|
| 109 | )
|
---|
| 110 | CREATE TABLE [dbo].[TaskData](
|
---|
[9665] | 111 | [TaskId] UniqueIdentifier RowGuidCol NOT NULL,
|
---|
| 112 | [Data] VarBinary(MAX) Filestream NOT NULL,
|
---|
[7847] | 113 | [LastUpdate] DateTime NOT NULL,
|
---|
[6983] | 114 | CONSTRAINT [PK_dbo.TaskData] PRIMARY KEY ([TaskId])
|
---|
| 115 | )
|
---|
| 116 | CREATE TABLE [dbo].[PluginData](
|
---|
[9665] | 117 | [PluginDataId] UniqueIdentifier RowGuidCol NOT NULL,
|
---|
[7847] | 118 | [PluginId] UniqueIdentifier NOT NULL,
|
---|
[9665] | 119 | [Data] VarBinary(MAX) FileStream NOT NULL,
|
---|
[7847] | 120 | [FileName] VarChar(MAX) NOT NULL,
|
---|
[6983] | 121 | CONSTRAINT [PK_dbo.PluginData] PRIMARY KEY ([PluginDataId])
|
---|
| 122 | )
|
---|
| 123 | CREATE TABLE [dbo].[StateLog](
|
---|
[7847] | 124 | [StateLogId] UniqueIdentifier NOT NULL,
|
---|
| 125 | [State] VarChar(30) NOT NULL,
|
---|
| 126 | [DateTime] DateTime NOT NULL,
|
---|
| 127 | [TaskId] UniqueIdentifier NOT NULL,
|
---|
| 128 | [UserId] UniqueIdentifier,
|
---|
| 129 | [SlaveId] UniqueIdentifier,
|
---|
| 130 | [Exception] VarChar(MAX),
|
---|
[6983] | 131 | CONSTRAINT [PK_dbo.StateLog] PRIMARY KEY ([StateLogId])
|
---|
| 132 | )
|
---|
| 133 | CREATE TABLE [dbo].[JobPermission](
|
---|
[7847] | 134 | [JobId] UniqueIdentifier NOT NULL,
|
---|
| 135 | [GrantedUserId] UniqueIdentifier NOT NULL,
|
---|
| 136 | [GrantedByUserId] UniqueIdentifier NOT NULL,
|
---|
| 137 | [Permission] VarChar(15) NOT NULL,
|
---|
[6983] | 138 | CONSTRAINT [PK_dbo.JobPermission] PRIMARY KEY ([JobId], [GrantedUserId])
|
---|
| 139 | )
|
---|
| 140 | CREATE TABLE [Lifecycle](
|
---|
[7847] | 141 | [LifecycleId] Int NOT NULL,
|
---|
| 142 | [LastCleanup] DateTime NOT NULL,
|
---|
[6983] | 143 | CONSTRAINT [PK_Lifecycle] PRIMARY KEY ([LifecycleId])
|
---|
| 144 | )
|
---|
[9123] | 145 | CREATE TABLE [UserPriority](
|
---|
| 146 | [UserId] UniqueIdentifier NOT NULL,
|
---|
| 147 | [DateEnqueued] DateTime NOT NULL,
|
---|
| 148 | CONSTRAINT [PK_UserPriority] PRIMARY KEY ([UserId])
|
---|
| 149 | )
|
---|
[6983] | 150 | ALTER TABLE [dbo].[AssignedResources]
|
---|
| 151 | ADD CONSTRAINT [Resource_AssignedResource] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
| 152 | ALTER TABLE [dbo].[AssignedResources]
|
---|
| 153 | ADD CONSTRAINT [Task_AssignedResource] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 154 | ALTER TABLE [dbo].[RequiredPlugins]
|
---|
| 155 | ADD CONSTRAINT [Plugin_RequiredPlugin] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
|
---|
| 156 | ALTER TABLE [dbo].[RequiredPlugins]
|
---|
| 157 | ADD CONSTRAINT [Task_RequiredPlugin] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 158 | ALTER TABLE [dbo].[Resource]
|
---|
| 159 | ADD CONSTRAINT [Resource_Resource] FOREIGN KEY ([ParentResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
[7916] | 160 | ALTER TABLE [dbo].[ResourcePermission]
|
---|
| 161 | ADD CONSTRAINT [Resource_ResourcePermission] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
[6983] | 162 | ALTER TABLE [dbo].[Task]
|
---|
| 163 | ADD CONSTRAINT [Task_Task] FOREIGN KEY ([ParentTaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 164 | ALTER TABLE [dbo].[Task]
|
---|
| 165 | ADD CONSTRAINT [Job_Job] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
|
---|
| 166 | ALTER TABLE [dbo].[Downtime]
|
---|
| 167 | ADD CONSTRAINT [Resource_Downtime] FOREIGN KEY ([ResourceId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
| 168 | ALTER TABLE [dbo].[TaskData]
|
---|
| 169 | ADD CONSTRAINT [Task_TaskData] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 170 | ALTER TABLE [dbo].[PluginData]
|
---|
| 171 | ADD CONSTRAINT [Plugin_PluginData] FOREIGN KEY ([PluginId]) REFERENCES [dbo].[Plugin]([PluginId])
|
---|
| 172 | ALTER TABLE [dbo].[StateLog]
|
---|
| 173 | ADD CONSTRAINT [Task_StateLog] FOREIGN KEY ([TaskId]) REFERENCES [dbo].[Task]([TaskId])
|
---|
| 174 | ALTER TABLE [dbo].[StateLog]
|
---|
| 175 | ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY ([SlaveId]) REFERENCES [dbo].[Resource]([ResourceId])
|
---|
| 176 | ALTER TABLE [dbo].[JobPermission]
|
---|
| 177 | ADD CONSTRAINT [Job_JobPermission] FOREIGN KEY ([JobId]) REFERENCES [dbo].[Job]([JobId])
|
---|
[12969] | 178 |
|
---|
| 179 | GO
|
---|
| 180 | CREATE SCHEMA [statistics]
|
---|
| 181 | GO
|
---|
| 182 |
|
---|
| 183 | CREATE TABLE [statistics].[DimTime] (
|
---|
| 184 | [Time] DATETIME NOT NULL,
|
---|
| 185 | [Minute] DATETIME NOT NULL,
|
---|
| 186 | [Hour] DATETIME NOT NULL,
|
---|
| 187 | [Day] DATE NOT NULL,
|
---|
| 188 | [Month] DATE NOT NULL,
|
---|
| 189 | [Year] DATE NOT NULL,
|
---|
| 190 | CONSTRAINT [PK_DimTime] PRIMARY KEY CLUSTERED ([Time] ASC)
|
---|
| 191 | );
|
---|
| 192 | CREATE TABLE [statistics].[DimClient] (
|
---|
| 193 | [Id] UNIQUEIDENTIFIER CONSTRAINT [DF_DimClient_Id] DEFAULT (newsequentialid()) NOT NULL,
|
---|
| 194 | [Name] VARCHAR (MAX) NOT NULL,
|
---|
| 195 | [ResourceId] UNIQUEIDENTIFIER NOT NULL,
|
---|
| 196 | [ExpirationTime] DATETIME NULL,
|
---|
| 197 | [ResourceGroupId] UNIQUEIDENTIFIER NULL,
|
---|
| 198 | [ResourceGroup2Id] UNIQUEIDENTIFIER NULL,
|
---|
| 199 | [GroupName] VARCHAR (MAX) NULL,
|
---|
| 200 | [GroupName2] VARCHAR (MAX) NULL,
|
---|
| 201 | CONSTRAINT [PK_DimClient] PRIMARY KEY CLUSTERED ([Id] ASC)
|
---|
| 202 | );
|
---|
| 203 | CREATE TABLE [statistics].[DimJob] (
|
---|
| 204 | [JobId] UNIQUEIDENTIFIER NOT NULL,
|
---|
| 205 | [UserId] UNIQUEIDENTIFIER NOT NULL,
|
---|
| 206 | [JobName] VARCHAR (MAX) NOT NULL,
|
---|
| 207 | [UserName] VARCHAR (MAX) NOT NULL,
|
---|
| 208 | [DateCreated] DATETIME NOT NULL,
|
---|
| 209 | [TotalTasks] INT NOT NULL,
|
---|
| 210 | [CompletedTasks] INT NOT NULL,
|
---|
| 211 | [DateCompleted] DATETIME NULL,
|
---|
| 212 | CONSTRAINT [PK_DimJob] PRIMARY KEY CLUSTERED ([JobId] ASC)
|
---|
| 213 | );
|
---|
| 214 | CREATE TABLE [statistics].[DimUser] (
|
---|
| 215 | [UserId] UNIQUEIDENTIFIER NOT NULL,
|
---|
| 216 | [Name] VARCHAR (MAX) NOT NULL,
|
---|
| 217 | CONSTRAINT [PK_DimUser] PRIMARY KEY CLUSTERED ([UserId] ASC)
|
---|
| 218 | );
|
---|
| 219 | CREATE TABLE [statistics].[FactClientInfo] (
|
---|
| 220 | [ClientId] UNIQUEIDENTIFIER NOT NULL,
|
---|
| 221 | [Time] DATETIME NOT NULL,
|
---|
| 222 | [UserId] UNIQUEIDENTIFIER NOT NULL,
|
---|
| 223 | [NumUsedCores] INT NOT NULL,
|
---|
| 224 | [NumTotalCores] INT NOT NULL,
|
---|
| 225 | [UsedMemory] INT NOT NULL,
|
---|
| 226 | [TotalMemory] INT NOT NULL,
|
---|
| 227 | [CpuUtilization] FLOAT (53) NOT NULL,
|
---|
| 228 | [SlaveState] VarChar(15) NOT NULL,
|
---|
| 229 | [IdleTime] INT NOT NULL,
|
---|
| 230 | [OfflineTime] INT NOT NULL,
|
---|
| 231 | [UnavailableTime] INT NOT NULL,
|
---|
| 232 | [IsAllowedToCalculate] BIT NOT NULL,
|
---|
| 233 | CONSTRAINT [PK_FactClientInfo] PRIMARY KEY CLUSTERED ([ClientId] ASC, [Time] ASC, [UserId] ASC),
|
---|
| 234 | CONSTRAINT [FK_FactClientInfo_DimTime] FOREIGN KEY ([Time]) REFERENCES [statistics].[DimTime] ([Time]),
|
---|
| 235 | CONSTRAINT [FK_FactClientInfo_DimClient] FOREIGN KEY ([ClientId]) REFERENCES [statistics].[DimClient] ([Id]),
|
---|
| 236 | CONSTRAINT [FK_FactClientInfo_DimUser] FOREIGN KEY ([UserId]) REFERENCES [statistics].[DimUser] ([UserId])
|
---|
| 237 | );
|
---|
| 238 | CREATE TABLE [statistics].[FactTask] (
|
---|
| 239 | [TaskId] UNIQUEIDENTIFIER NOT NULL,
|
---|
| 240 | [CalculatingTime] INT NOT NULL,
|
---|
| 241 | [WaitingTime] INT NOT NULL,
|
---|
| 242 | [TransferTime] INT NOT NULL,
|
---|
| 243 | [NumCalculationRuns] INT NOT NULL,
|
---|
| 244 | [NumRetries] INT NOT NULL,
|
---|
| 245 | [CoresRequired] INT NOT NULL,
|
---|
| 246 | [MemoryRequired] INT NOT NULL,
|
---|
| 247 | [Priority] INT NOT NULL,
|
---|
| 248 | [LastClientId] UNIQUEIDENTIFIER NULL,
|
---|
| 249 | [JobId] UNIQUEIDENTIFIER NOT NULL,
|
---|
| 250 | [StartTime] DATETIME NULL,
|
---|
| 251 | [EndTime] DATETIME NULL,
|
---|
| 252 | [TaskState] VARCHAR (30) NOT NULL,
|
---|
| 253 | [Exception] VARCHAR (MAX) NULL,
|
---|
| 254 | [InitialWaitingTime] INT NULL,
|
---|
| 255 | CONSTRAINT [PK_FactTask] PRIMARY KEY CLUSTERED ([TaskId] ASC),
|
---|
| 256 | CONSTRAINT [FK_FactTask_DimClient] FOREIGN KEY ([LastClientId]) REFERENCES [statistics].[DimClient] ([Id]),
|
---|
| 257 | CONSTRAINT [FK_FactTask_DimJob] FOREIGN KEY ([JobId]) REFERENCES [statistics].[DimJob] ([JobId])
|
---|
| 258 | );
|
---|
| 259 |
|
---|
| 260 | /* dummy for nullable userIds in FactClientInfo */
|
---|
| 261 | INSERT INTO [statistics].[DimUser] ([UserId], [Name])
|
---|
| 262 | VALUES ('00000000-0000-0000-0000-000000000000', 'NULL'); |
---|