forked from lyft/presto-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gateway-ha-persistence.sql
78 lines (64 loc) · 2.3 KB
/
gateway-ha-persistence.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
CREATE TABLE IF NOT EXISTS gateway_backend (
name VARCHAR(256) PRIMARY KEY,
routing_group VARCHAR (256),
backend_url VARCHAR (256),
external_url VARCHAR (256),
active BOOLEAN
);
CREATE TABLE IF NOT EXISTS query_history (
query_id VARCHAR(256) PRIMARY KEY,
query_text VARCHAR (256),
created bigint,
backend_url VARCHAR (256),
user_name VARCHAR(256),
source VARCHAR(256)
);
CREATE INDEX query_history_created_idx ON query_history(created);
CREATE TABLE IF NOT EXISTS resource_groups (
resource_group_id BIGINT NOT NULL AUTO_INCREMENT,
name VARCHAR(250) NOT NULL UNIQUE,
-- OPTIONAL POLICY CONTROLS
parent BIGINT NULL,
jmx_export BOOLEAN NULL,
scheduling_policy VARCHAR(128) NULL,
scheduling_weight INT NULL,
-- REQUIRED QUOTAS
soft_memory_limit VARCHAR(128) NOT NULL,
max_queued INT NOT NULL,
hard_concurrency_limit INT NOT NULL,
-- OPTIONAL QUOTAS
soft_concurrency_limit INT NULL,
soft_cpu_limit VARCHAR(128) NULL,
hard_cpu_limit VARCHAR(128) NULL,
environment VARCHAR(128) NULL,
PRIMARY KEY(resource_group_id),
FOREIGN KEY (parent) REFERENCES resource_groups (resource_group_id)
);
CREATE TABLE IF NOT EXISTS selectors (
resource_group_id BIGINT NOT NULL,
priority BIGINT NOT NULL,
-- Regex fields -- these will be used as a regular expression pattern to
-- match against the field of the same name on queries
user_regex VARCHAR(512),
source_regex VARCHAR(512),
-- Selector fields -- these must match exactly.
query_type VARCHAR(512),
client_tags VARCHAR(512),
selector_resource_estimate VARCHAR(1024),
FOREIGN KEY (resource_group_id) REFERENCES resource_groups(resource_group_id)
);
CREATE TABLE IF NOT EXISTS resource_groups_global_properties (
name VARCHAR(128) NOT NULL PRIMARY KEY,
value VARCHAR(512) NULL,
CHECK (name in ('cpu_quota_period'))
);
CREATE TABLE IF NOT EXISTS exact_match_source_selectors (
resource_group_id VARCHAR(256) NOT NULL, -- WTF varchar?!
update_time DATETIME NOT NULL,
-- Selector fields which must exactly match a query
source VARCHAR(512) NOT NULL,
environment VARCHAR(128),
query_type VARCHAR(128), -- (reduced from 512)
PRIMARY KEY (environment, source, query_type),
UNIQUE (source, environment, query_type, resource_group_id)
);