Skip to content

Commit df814d9

Browse files
Merge pull request #7 from yiiyama/production
Express partition
2 parents 4db770e + 43c4081 commit df814d9

4 files changed

Lines changed: 121 additions & 7 deletions

File tree

etc/db/dynamoregister.sql

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
--
33
-- Host: localhost Database: dynamoregister
44
-- ------------------------------------------------------
5-
-- Server version 5.1.73
5+
-- Server version 5.1.73-log
66

77
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
88
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -55,10 +55,11 @@ DROP TABLE IF EXISTS `deletion_queue`;
5555
/*!40101 SET @saved_cs_client = @@character_set_client */;
5656
/*!40101 SET character_set_client = utf8 */;
5757
CREATE TABLE `deletion_queue` (
58+
`reqid` int(10) unsigned NOT NULL DEFAULT '0',
5859
`file` varchar(512) COLLATE latin1_general_cs NOT NULL,
59-
`target` varchar(64) COLLATE latin1_general_cs NOT NULL,
60-
`created` datetime NOT NULL,
61-
UNIQUE KEY `files` (`file`,`target`)
60+
`site` varchar(32) COLLATE latin1_general_cs NOT NULL,
61+
`status` enum('new','done','failed') COLLATE latin1_general_cs NOT NULL,
62+
UNIQUE KEY `file` (`file`,`site`)
6263
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
6364
/*!40101 SET character_set_client = @saved_cs_client */;
6465

@@ -103,6 +104,57 @@ CREATE TABLE `domains` (
103104
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
104105
/*!40101 SET character_set_client = @saved_cs_client */;
105106

107+
--
108+
-- Table structure for table `invalidations`
109+
--
110+
111+
DROP TABLE IF EXISTS `invalidations`;
112+
/*!40101 SET @saved_cs_client = @@character_set_client */;
113+
/*!40101 SET character_set_client = utf8 */;
114+
CREATE TABLE `invalidations` (
115+
`item` varchar(512) CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
116+
`user_id` int(10) unsigned NOT NULL DEFAULT '0',
117+
`timestamp` datetime NOT NULL
118+
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
119+
/*!40101 SET character_set_client = @saved_cs_client */;
120+
121+
--
122+
-- Table structure for table `requests`
123+
--
124+
125+
DROP TABLE IF EXISTS `requests`;
126+
/*!40101 SET @saved_cs_client = @@character_set_client */;
127+
/*!40101 SET character_set_client = utf8 */;
128+
CREATE TABLE `requests` (
129+
`item` varchar(512) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
130+
`datatype` enum('dataset','block') CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
131+
`site` varchar(32) NOT NULL,
132+
`reqtype` enum('copy','delete') NOT NULL,
133+
`created` datetime NOT NULL
134+
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
135+
/*!40101 SET character_set_client = @saved_cs_client */;
136+
137+
--
138+
-- Table structure for table `requests_unified`
139+
--
140+
141+
DROP TABLE IF EXISTS `requests_unified`;
142+
/*!40101 SET @saved_cs_client = @@character_set_client */;
143+
/*!40101 SET character_set_client = utf8 */;
144+
CREATE TABLE `requests_unified` (
145+
`reqid` int(10) unsigned NOT NULL AUTO_INCREMENT,
146+
`item` varchar(512) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
147+
`datatype` enum('dataset','block') CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
148+
`site` varchar(32) NOT NULL,
149+
`reqtype` enum('copy','delete') NOT NULL,
150+
`rank` int(10) unsigned DEFAULT '0',
151+
`status` enum('new','queued') NOT NULL,
152+
`created` datetime NOT NULL,
153+
`updated` datetime DEFAULT NULL,
154+
PRIMARY KEY (`reqid`)
155+
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
156+
/*!40101 SET character_set_client = @saved_cs_client */;
157+
106158
--
107159
-- Table structure for table `services`
108160
--
@@ -162,4 +214,4 @@ CREATE TABLE `users` (
162214
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
163215
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
164216

165-
-- Dump completed on 2017-06-26 15:52:45
217+
-- Dump completed on 2017-10-07 11:12:50

etc/policies.tag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v49
1+
v50

lib/common/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
('IB RelVal', lambda r: r.group is not None and r.group.name == 'IB RelVal'),
185185
('Tape', lambda r: r.site.storage_type == Site.TYPE_MSS),
186186
('Unsubscribed', lambda r: r.group is None),
187-
('Express', lambda r: r.group is not None and r.group.name == 'express' and re.match('/.*Express.*/.+/.+$', r.block.dataset.name)),
187+
('Express', lambda r: r.group is not None and r.group.name == 'express' and re.match('/(?:.*Express.*/.+|.+/.*Express.*)/.+$', r.block.dataset.name)),
188188
('Physics', ['AnalysisOps', 'DataOps']),
189189
],
190190
# list of conditions for a PRODUCTION state dataset to become IGNORED (will still be reset to PRODUCTION if a new block replica is found)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
date_default_timezone_set('UTC');
4+
5+
$command = substr($_SERVER['PATH_INFO'], 1); # dynamo.mit.edu/registry/invalidate/command -> /command
6+
7+
if ($command == "") {
8+
# show webpage
9+
exit(0);
10+
}
11+
12+
if ($command == 'help') {
13+
# echo file_get_contents(__DIR__ . '/html/invalidate_help.html');
14+
exit(0);
15+
}
16+
17+
include_once(__DIR__ . '/../dynamo/common/db_conf.php');
18+
include_once(__DIR__ . '/common.php');
19+
20+
/* if ($_SERVER['SSL_CLIENT_VERIFY'] != 'SUCCESS') */
21+
/* send_response(401, 'AuthFailed', 'SSL authentication failed.'); */
22+
23+
if ($command == 'invalidate' || $command == 'clear') {
24+
if (!isset($_REQUEST['item']))
25+
send_response(400, 'BadRequest', '\'item\' field is required', NULL, 'json');
26+
27+
$item = $_REQUEST['item'];
28+
29+
$db = new mysqli($db_conf['host'], $db_conf['user'], $db_conf['password'], 'dynamoregister');
30+
31+
if ($command == 'invalidate') {
32+
$stmt = $db->prepare('INSERT INTO `invalidations` (`item`, `timestamp`) VALUES (?, NOW())');
33+
$message = 'Item added';
34+
}
35+
else {
36+
$stmt = $db->prepare('DELETE FROM `invalidations` WHERE `item` = ?');
37+
$message = 'Item removed';
38+
}
39+
40+
$return_data = array();
41+
42+
if (is_array($item)) {
43+
foreach ($item as $t) {
44+
$stmt->bind_param('s', $t);
45+
$stmt->execute();
46+
$return_data[] = array('item' => $t);
47+
}
48+
}
49+
else {
50+
$stmt->bind_param('s', $item);
51+
$stmt->execute();
52+
$return_data[] = array('item' => $item);
53+
}
54+
$stmt->close();
55+
56+
send_response(200, 'OK', $message, $return_data, 'json');
57+
}
58+
else {
59+
send_response(400, 'BadRequest', 'Invalid command (possible values: help, invalidate)');
60+
}
61+
62+
?>

0 commit comments

Comments
 (0)