annotate src/main/java/org/monetdb/mcl/net/Parameter.java @ 806:f478317138d7 monetdbs

Change default reply size to 250 (I accidentally changed it to 200)
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Tue, 12 Dec 2023 11:56:58 +0100 (17 months ago)
parents 9dea0795a926
children 5aa19bbed0d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
789
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
1 package org.monetdb.mcl.net;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
2
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
3
791
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
4 import java.util.Calendar;
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
5
789
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
6 public enum Parameter {
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
7 TLS("tls", ParameterType.Bool, false, "secure the connection using TLS", true),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
8 HOST("host", ParameterType.Str, "", "IP number, domain name or one of the special values `localhost` and `localhost.`", true),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
9 PORT("port", ParameterType.Int, -1, "Port to connect to, 1..65535 or -1 for 'not set'", true),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
10 DATABASE("database", ParameterType.Str, "", "name of database to connect to", true),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
11 TABLESCHEMA("tableschema", ParameterType.Str, "", "only used for REMOTE TABLE, otherwise unused", true),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
12 TABLE("table", ParameterType.Str, "", "only used for REMOTE TABLE, otherwise unused", true),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
13 SOCK("sock", ParameterType.Path, "", "path to Unix domain socket to connect to", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
14 SOCKDIR("sockdir", ParameterType.Path, "/tmp", "Directory for implicit Unix domain sockets (.s.monetdb.PORT)", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
15 CERT("cert", ParameterType.Path, "", "path to TLS certificate to authenticate server with", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
16 CERTHASH("certhash", ParameterType.Str, "", "hash of server TLS certificate must start with these hex digits; overrides cert", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
17 CLIENTKEY("clientkey", ParameterType.Path, "", "path to TLS key (+certs) to authenticate with as client", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
18 CLIENTCERT("clientcert", ParameterType.Path, "", "path to TLS certs for 'clientkey', if not included there", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
19 USER("user", ParameterType.Str, "", "user name to authenticate as", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
20 PASSWORD("password", ParameterType.Str, "", "password to authenticate with", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
21 LANGUAGE("language", ParameterType.Str, "sql", "for example, \"sql\", \"mal\", \"msql\", \"profiler\"", false),
791
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
22 AUTOCOMMIT("autocommit", ParameterType.Bool, true, "initial value of autocommit", false),
789
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
23 SCHEMA("schema", ParameterType.Str, "", "initial schema", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
24 TIMEZONE("timezone", ParameterType.Int, null, "client time zone as minutes east of UTC", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
25 BINARY("binary", ParameterType.Str, "on", "whether to use binary result set format (number or bool)", false),
806
f478317138d7 Change default reply size to 250
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 792
diff changeset
26 REPLYSIZE("replysize", ParameterType.Int, 250, "rows beyond this limit are retrieved on demand, <1 means unlimited", false),
789
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
27 FETCHSIZE("fetchsize", ParameterType.Int, null, "alias for replysize, specific to jdbc", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
28 HASH("hash", ParameterType.Str, "", "specific to jdbc", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
29 DEBUG("debug", ParameterType.Bool, false, "specific to jdbc", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
30 LOGFILE("logfile", ParameterType.Str, "", "specific to jdbc", false),
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
31
792
9dea0795a926 Understand so_timeout, treat_clob_as_varchar and treat_blob_as_binary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 791
diff changeset
32 SO_TIMEOUT("so_timeout", ParameterType.Int, 0, "abort if network I/O does not complete in this many milliseconds", false),
9dea0795a926 Understand so_timeout, treat_clob_as_varchar and treat_blob_as_binary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 791
diff changeset
33 CLOB_AS_VARCHAR("treat_clob_as_varchar", ParameterType.Bool, true, "return CLOB/TEXT data as type VARCHAR instead of type CLOB", false),
9dea0795a926 Understand so_timeout, treat_clob_as_varchar and treat_blob_as_binary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 791
diff changeset
34 BLOB_AS_BINARY("treat_blob_as_binary", ParameterType.Bool, true, "return BLOB data as type BINARY instead of type BLOB", false),
789
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
35 ;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
36
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
37 public final String name;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
38 public final ParameterType type;
791
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
39 private final Object defaultValue;
789
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
40 public final String description;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
41 public final boolean isCore;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
42
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
43 Parameter(String name, ParameterType type, Object defaultValue, String description, boolean isCore) {
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
44 this.name = name;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
45 this.type = type;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
46 this.isCore = isCore;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
47 this.defaultValue = defaultValue;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
48 this.description = description;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
49 }
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
50
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
51 public static Parameter forName(String name) {
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
52 switch (name) {
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
53 case "tls": return TLS;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
54 case "host": return HOST;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
55 case "port": return PORT;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
56 case "database": return DATABASE;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
57 case "tableschema": return TABLESCHEMA;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
58 case "table": return TABLE;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
59 case "sock": return SOCK;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
60 case "sockdir": return SOCKDIR;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
61 case "cert": return CERT;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
62 case "certhash": return CERTHASH;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
63 case "clientkey": return CLIENTKEY;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
64 case "clientcert": return CLIENTCERT;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
65 case "user": return USER;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
66 case "password": return PASSWORD;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
67 case "language": return LANGUAGE;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
68 case "autocommit": return AUTOCOMMIT;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
69 case "schema": return SCHEMA;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
70 case "timezone": return TIMEZONE;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
71 case "binary": return BINARY;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
72 case "replysize": return REPLYSIZE;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
73 case "fetchsize": return FETCHSIZE;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
74 case "hash": return HASH;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
75 case "debug": return DEBUG;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
76 case "logfile": return LOGFILE;
792
9dea0795a926 Understand so_timeout, treat_clob_as_varchar and treat_blob_as_binary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 791
diff changeset
77 case "so_timeout": return SO_TIMEOUT;
9dea0795a926 Understand so_timeout, treat_clob_as_varchar and treat_blob_as_binary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 791
diff changeset
78 case "treat_clob_as_varchar": return CLOB_AS_VARCHAR;
9dea0795a926 Understand so_timeout, treat_clob_as_varchar and treat_blob_as_binary
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 791
diff changeset
79 case "treat_blob_as_binary": return BLOB_AS_BINARY;
789
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
80 default: return null;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
81 }
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
82 }
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
83
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
84 public static boolean isIgnored(String name) {
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
85 if (Parameter.forName(name) != null)
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
86 return false;
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
87 return name.contains("_");
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
88 }
791
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
89
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
90 public Object getDefault() {
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
91 switch (this) {
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
92 case TIMEZONE:
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
93 Calendar cal = Calendar.getInstance();
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
94 int offsetMillis = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
95 int offsetSeconds = offsetMillis / 1000;
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
96 return (Integer)offsetSeconds;
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
97 default:
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
98 return defaultValue;
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
99 }
4de810c22328 Refactor
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents: 789
diff changeset
100 }
789
88c5b678e974 URL parser passes the tests.
Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
parents:
diff changeset
101 }