22
22
23
23
/**
24
24
* This class is intended to store the configuration and catalog information for a Myria worker.
25
- *
26
- *
25
+ *
26
+ *
27
27
*/
28
28
public final class WorkerCatalog {
29
29
/** The logger for this class. */
@@ -33,7 +33,7 @@ public final class WorkerCatalog {
33
33
* @param filename the path to the SQLite database storing the worker catalog.
34
34
* @return a fresh WorkerCatalog fitting the specified description.
35
35
* @throws CatalogException if there is an error creating the database or the file already exists.
36
- *
36
+ *
37
37
* TODO add some sanity checks to the filename?
38
38
*/
39
39
public static WorkerCatalog create (final String filename ) throws CatalogException {
@@ -46,7 +46,7 @@ public static WorkerCatalog create(final String filename) throws CatalogExceptio
46
46
* @param overwrite specifies whether to overwrite an existing WorkerCatalog.
47
47
* @return a fresh WorkerCatalog fitting the specified description.
48
48
* @throws CatalogException if the database already exists, or there is an error creating it.
49
- *
49
+ *
50
50
* TODO add some sanity checks to the filename?
51
51
*/
52
52
public static WorkerCatalog create (final String filename , final boolean overwrite ) throws CatalogException {
@@ -61,12 +61,12 @@ public static WorkerCatalog create(final String filename, final boolean overwrit
61
61
}
62
62
63
63
/**
64
- *
64
+ *
65
65
* @param catalogFile a File object pointing to the SQLite database that will store the WorkerCatalog. If catalogFile
66
66
* is null, this creates an in-memory SQLite database.
67
67
* @return a fresh WorkerCatalog fitting the specified description.
68
68
* @throws CatalogException if there is an error opening the database.
69
- *
69
+ *
70
70
* TODO add some sanity checks to the filename?
71
71
*/
72
72
private static WorkerCatalog createFromFile (final File catalogFile ) throws CatalogException {
@@ -89,36 +89,36 @@ private static WorkerCatalog createFromFile(final File catalogFile) throws Catal
89
89
sqliteConnection .exec ("DROP TABLE IF EXISTS configuration" );
90
90
sqliteConnection .exec (
91
91
"CREATE TABLE configuration (\n "
92
- + " key STRING UNIQUE NOT NULL,\n "
93
- + " value STRING NOT NULL);" );
92
+ + " key STRING UNIQUE NOT NULL,\n "
93
+ + " value STRING NOT NULL);" );
94
94
sqliteConnection .exec ("DROP TABLE IF EXISTS masters" );
95
95
sqliteConnection .exec (
96
96
"CREATE TABLE masters (\n "
97
- + " master_id INTEGER PRIMARY KEY ASC,\n "
98
- + " host_port STRING NOT NULL);" );
97
+ + " master_id INTEGER PRIMARY KEY ASC,\n "
98
+ + " host_port STRING NOT NULL);" );
99
99
sqliteConnection .exec ("DROP TABLE IF EXISTS workers" );
100
100
sqliteConnection .exec (
101
101
"CREATE TABLE workers (\n "
102
- + " worker_id INTEGER PRIMARY KEY ASC,\n "
103
- + " host_port STRING NOT NULL);" );
102
+ + " worker_id INTEGER PRIMARY KEY ASC,\n "
103
+ + " host_port STRING NOT NULL);" );
104
104
sqliteConnection .exec ("DROP TABLE IF EXISTS relations" );
105
105
sqliteConnection .exec (
106
106
"CREATE TABLE relations (\n "
107
- + " relation_id INTEGER PRIMARY KEY ASC,\n "
108
- + " relation_name STRING NOT NULL UNIQUE);" );
107
+ + " relation_id INTEGER PRIMARY KEY ASC,\n "
108
+ + " relation_name STRING NOT NULL UNIQUE);" );
109
109
sqliteConnection .exec ("DROP TABLE IF EXISTS relation_schema" );
110
110
sqliteConnection .exec (
111
111
"CREATE TABLE relation_schema (\n "
112
- + " relation_id INTEGER NOT NULL REFERENCES relations(relation_id),\n "
113
- + " col_index INTEGER NOT NULL,\n "
114
- + " col_name STRING,\n "
115
- + " col_type STRING NOT NULL);" );
112
+ + " relation_id INTEGER NOT NULL REFERENCES relations(relation_id),\n "
113
+ + " col_index INTEGER NOT NULL,\n "
114
+ + " col_name STRING,\n "
115
+ + " col_type STRING NOT NULL);" );
116
116
sqliteConnection .exec ("DROP TABLE IF EXISTS shards" );
117
117
sqliteConnection .exec (
118
118
"CREATE TABLE shards (\n "
119
- + " stored_relation_id INTEGER NOT NULL REFERENCES stored_relations(stored_relation_id),\n "
120
- + " shard_index INTEGER NOT NULL,\n "
121
- + " location STRING NOT NULL);" );
119
+ + " stored_relation_id INTEGER NOT NULL REFERENCES stored_relations(stored_relation_id),\n "
120
+ + " shard_index INTEGER NOT NULL,\n "
121
+ + " location STRING NOT NULL);" );
122
122
sqliteConnection .exec ("COMMIT TRANSACTION" );
123
123
/* @formatter:on*/
124
124
} catch (final SQLiteException e ) {
@@ -147,7 +147,7 @@ private static WorkerCatalog createFromFile(final File catalogFile) throws Catal
147
147
/**
148
148
* @return a fresh WorkerCatalog fitting the specified description.
149
149
* @throws CatalogException if there is an error opening the database.
150
- *
150
+ *
151
151
* TODO add some sanity checks to the filename?
152
152
*/
153
153
public static WorkerCatalog createInMemory () throws CatalogException {
@@ -156,12 +156,12 @@ public static WorkerCatalog createInMemory() throws CatalogException {
156
156
157
157
/**
158
158
* Opens the worker catalog stored as a SQLite database in the specified file.
159
- *
159
+ *
160
160
* @param filename the path to the SQLite database storing the catalog.
161
161
* @return an initialized WorkerCatalog object ready to be used for experiments.
162
162
* @throws FileNotFoundException if the given file does not exist.
163
163
* @throws CatalogException if there is an error connecting to the database.
164
- *
164
+ *
165
165
* TODO add some sanity checks to the filename?
166
166
*/
167
167
public static WorkerCatalog open (final String filename ) throws FileNotFoundException , CatalogException {
@@ -195,7 +195,7 @@ public static WorkerCatalog open(final String filename) throws FileNotFoundExcep
195
195
196
196
/**
197
197
* Not publicly accessible.
198
- *
198
+ *
199
199
* @param sqliteConnection connection to the SQLite database that stores the WorkerCatalog.
200
200
* @throws SQLiteException if there is an error turning on foreign keys.
201
201
*/
@@ -208,7 +208,7 @@ private WorkerCatalog(final SQLiteConnection sqliteConnection) throws SQLiteExce
208
208
209
209
/**
210
210
* Adds a master using the specified host and port to the WorkerCatalog.
211
- *
211
+ *
212
212
* @param hostPortString specifies the path to the master in the format "host:port"
213
213
* @return this WorkerCatalog
214
214
* @throws CatalogException if the hostPortString is invalid or there is a database exception.
@@ -237,13 +237,13 @@ public WorkerCatalog addMaster(final String hostPortString) throws CatalogExcept
237
237
238
238
/**
239
239
* Adds the metadata for a relation into the WorkerCatalog.
240
- *
240
+ *
241
241
* @param name the name of the relation.
242
242
* @param schema the schema of the relation.
243
243
* @throws CatalogException if the relation is already in the WorkerCatalog or there is an error in the database.
244
- *
244
+ *
245
245
* TODO if we use SQLite in a multithreaded way this will need to be revisited.
246
- *
246
+ *
247
247
*/
248
248
public void addRelationMetadata (final String name , final Schema schema ) throws CatalogException {
249
249
Objects .requireNonNull (name );
@@ -291,7 +291,7 @@ public void addRelationMetadata(final String name, final Schema schema) throws C
291
291
292
292
/**
293
293
* Adds a worker using the specified host and port to the WorkerCatalog.
294
- *
294
+ *
295
295
* @param workerId specifies the global identifier of this worker.
296
296
* @param hostPortString specifies the path to the worker in the format "host:port".
297
297
* @return this WorkerCatalog.
@@ -333,7 +333,6 @@ public WorkerCatalog addWorkers(final Map<String, String> id2HostPortString) thr
333
333
throw new CatalogException ("WorkerCatalog is closed." );
334
334
}
335
335
try {
336
- /* Just used to verify that hostPortString is legal */
337
336
final SQLiteStatement statement =
338
337
sqliteConnection .prepare ("INSERT INTO workers(worker_id, host_port) VALUES(?,?);" , false );
339
338
sqliteConnection .exec ("BEGIN TRANSACTION" );
@@ -379,7 +378,7 @@ public void close() {
379
378
/**
380
379
* Extract the value of a particular configuration parameter from the database. Returns null if the parameter is not
381
380
* configured.
382
- *
381
+ *
383
382
* @param key the name of the configuration parameter.
384
383
* @return the value of the configuration parameter, or null if that configuration is not supported.
385
384
* @throws CatalogException if there is an error in the backing database.
@@ -489,7 +488,7 @@ public Map<Integer, SocketInfo> getWorkers() throws CatalogException {
489
488
/**
490
489
* Extract the value of a particular configuration parameter from the database. Returns null if the parameter is not
491
490
* configured.
492
- *
491
+ *
493
492
* @param key the name of the configuration parameter.
494
493
* @param value the value of the configuration parameter.
495
494
* @throws CatalogException if there is an error in the backing database.
@@ -515,7 +514,7 @@ public void setConfigurationValue(final String key, final String value) throws C
515
514
516
515
/**
517
516
* Set all the configuration values in the provided map in a single transaction.
518
- *
517
+ *
519
518
* @param entries the value of the configuration parameter.
520
519
* @throws CatalogException if there is an error in the backing database.
521
520
*/
0 commit comments