1 | /* |
2 | * Copyright 2004-2014 H2 Group. Multiple-Licensed under the MPL 2.0, |
3 | * and the EPL 1.0 (http://h2database.com/html/license.html). |
4 | * Initial Developer: H2 Group |
5 | */ |
6 | package org.h2.engine; |
7 | |
8 | import org.h2.util.MathUtils; |
9 | import org.h2.util.Utils; |
10 | |
11 | /** |
12 | * The constants defined in this class are initialized from system properties. |
13 | * Some system properties are per machine settings, and others are as a last |
14 | * resort and temporary solution to work around a problem in the application or |
15 | * database engine. Also, there are system properties to enable features that |
16 | * are not yet fully tested or that are not backward compatible. |
17 | * <p> |
18 | * System properties can be set when starting the virtual machine: |
19 | * </p> |
20 | * |
21 | * <pre> |
22 | * java -Dh2.baseDir=/temp |
23 | * </pre> |
24 | * |
25 | * They can be set within the application, but this must be done before loading |
26 | * any classes of this database (before loading the JDBC driver): |
27 | * |
28 | * <pre> |
29 | * System.setProperty("h2.baseDir", "/temp"); |
30 | * </pre> |
31 | */ |
32 | public class SysProperties { |
33 | |
34 | /** |
35 | * INTERNAL |
36 | */ |
37 | public static final String H2_SCRIPT_DIRECTORY = "h2.scriptDirectory"; |
38 | |
39 | /** |
40 | * INTERNAL |
41 | */ |
42 | public static final String H2_BROWSER = "h2.browser"; |
43 | |
44 | /** |
45 | * System property <code>file.encoding</code> (default: Cp1252).<br /> |
46 | * It is usually set by the system and is the default encoding used for the |
47 | * RunScript and CSV tool. |
48 | */ |
49 | public static final String FILE_ENCODING = |
50 | Utils.getProperty("file.encoding", "Cp1252"); |
51 | |
52 | /** |
53 | * System property <code>file.separator</code> (default: /).<br /> |
54 | * It is usually set by the system, and used to build absolute file names. |
55 | */ |
56 | public static final String FILE_SEPARATOR = |
57 | Utils.getProperty("file.separator", "/"); |
58 | |
59 | /** |
60 | * System property <code>java.specification.version</code>.<br /> |
61 | * It is set by the system. Examples: 1.4, 1.5, 1.6. |
62 | */ |
63 | public static final String JAVA_SPECIFICATION_VERSION = |
64 | Utils.getProperty("java.specification.version", "1.4"); |
65 | |
66 | /** |
67 | * System property <code>line.separator</code> (default: \n).<br /> |
68 | * It is usually set by the system, and used by the script and trace tools. |
69 | */ |
70 | public static final String LINE_SEPARATOR = |
71 | Utils.getProperty("line.separator", "\n"); |
72 | |
73 | /** |
74 | * System property <code>user.home</code> (empty string if not set).<br /> |
75 | * It is usually set by the system, and used as a replacement for ~ in file |
76 | * names. |
77 | */ |
78 | public static final String USER_HOME = |
79 | Utils.getProperty("user.home", ""); |
80 | |
81 | /** |
82 | * System property <code>h2.allowedClasses</code> (default: *).<br /> |
83 | * Comma separated list of class names or prefixes. |
84 | */ |
85 | public static final String ALLOWED_CLASSES = |
86 | Utils.getProperty("h2.allowedClasses", "*"); |
87 | |
88 | /** |
89 | * System property <code>h2.browser</code> (default: null).<br /> |
90 | * The preferred browser to use. If not set, the default browser is used. |
91 | * For Windows, to use the Internet Explorer, set this property to |
92 | * 'explorer'. For Mac OS, if the default browser is not Safari and you want |
93 | * to use Safari, use: |
94 | * <code>java -Dh2.browser="open,-a,Safari,%url" ...</code>. |
95 | */ |
96 | public static final String BROWSER = |
97 | Utils.getProperty(H2_BROWSER, null); |
98 | |
99 | /** |
100 | * System property <code>h2.enableAnonymousTLS</code> (default: true).<br /> |
101 | * When using TLS connection, the anonymous cipher suites should be enabled. |
102 | */ |
103 | public static final boolean ENABLE_ANONYMOUS_TLS = |
104 | Utils.getProperty("h2.enableAnonymousTLS", true); |
105 | |
106 | /** |
107 | * System property <code>h2.bindAddress</code> (default: null).<br /> |
108 | * The bind address to use. |
109 | */ |
110 | public static final String BIND_ADDRESS = |
111 | Utils.getProperty("h2.bindAddress", null); |
112 | |
113 | /** |
114 | * System property <code>h2.check</code> (default: true).<br /> |
115 | * Assertions in the database engine. |
116 | */ |
117 | //## CHECK ## |
118 | public static final boolean CHECK = |
119 | Utils.getProperty("h2.check", true); |
120 | /*/ |
121 | public static final boolean CHECK = false; |
122 | //*/ |
123 | |
124 | /** |
125 | * System property <code>h2.check2</code> (default: true).<br /> |
126 | * Additional assertions in the database engine. |
127 | */ |
128 | //## CHECK ## |
129 | public static final boolean CHECK2 = |
130 | Utils.getProperty("h2.check2", false); |
131 | /*/ |
132 | public static final boolean CHECK2 = false; |
133 | //*/ |
134 | |
135 | /** |
136 | * System property <code>h2.clientTraceDirectory</code> (default: |
137 | * trace.db/).<br /> |
138 | * Directory where the trace files of the JDBC client are stored (only for |
139 | * client / server). |
140 | */ |
141 | public static final String CLIENT_TRACE_DIRECTORY = |
142 | Utils.getProperty("h2.clientTraceDirectory", "trace.db/"); |
143 | |
144 | /** |
145 | * System property <code>h2.collatorCacheSize</code> (default: 32000).<br /> |
146 | * The cache size for collation keys (in elements). Used when a collator has |
147 | * been set for the database. |
148 | */ |
149 | public static final int COLLATOR_CACHE_SIZE = |
150 | Utils.getProperty("h2.collatorCacheSize", 32000); |
151 | |
152 | /** |
153 | * System property <code>h2.consoleTableIndexes</code> |
154 | * (default: 100).<br /> |
155 | * Up to this many tables, the column type and indexes are listed. |
156 | */ |
157 | public static final int CONSOLE_MAX_TABLES_LIST_INDEXES = |
158 | Utils.getProperty("h2.consoleTableIndexes", 100); |
159 | |
160 | /** |
161 | * System property <code>h2.consoleTableColumns</code> |
162 | * (default: 500).<br /> |
163 | * Up to this many tables, the column names are listed. |
164 | */ |
165 | public static final int CONSOLE_MAX_TABLES_LIST_COLUMNS = |
166 | Utils.getProperty("h2.consoleTableColumns", 300); |
167 | |
168 | /** |
169 | * System property <code>h2.consoleProcedureColumns</code> |
170 | * (default: 500).<br /> |
171 | * Up to this many procedures, the column names are listed. |
172 | */ |
173 | public static final int CONSOLE_MAX_PROCEDURES_LIST_COLUMNS = |
174 | Utils.getProperty("h2.consoleProcedureColumns", 300); |
175 | |
176 | /** |
177 | * System property <code>h2.consoleStream</code> (default: true).<br /> |
178 | * H2 Console: stream query results. |
179 | */ |
180 | public static final boolean CONSOLE_STREAM = |
181 | Utils.getProperty("h2.consoleStream", true); |
182 | |
183 | /** |
184 | * System property <code>h2.consoleTimeout</code> (default: 1800000).<br /> |
185 | * H2 Console: session timeout in milliseconds. The default is 30 minutes. |
186 | */ |
187 | public static final int CONSOLE_TIMEOUT = |
188 | Utils.getProperty("h2.consoleTimeout", 30 * 60 * 1000); |
189 | |
190 | /** |
191 | * System property <code>h2.dataSourceTraceLevel</code> (default: 1).<br /> |
192 | * The trace level of the data source implementation. Default is 1 for |
193 | * error. |
194 | */ |
195 | public static final int DATASOURCE_TRACE_LEVEL = |
196 | Utils.getProperty("h2.dataSourceTraceLevel", 1); |
197 | |
198 | /** |
199 | * System property <code>h2.delayWrongPasswordMin</code> |
200 | * (default: 250).<br /> |
201 | * The minimum delay in milliseconds before an exception is thrown for using |
202 | * the wrong user name or password. This slows down brute force attacks. The |
203 | * delay is reset to this value after a successful login. Unsuccessful |
204 | * logins will double the time until DELAY_WRONG_PASSWORD_MAX. |
205 | * To disable the delay, set this system property to 0. |
206 | */ |
207 | public static final int DELAY_WRONG_PASSWORD_MIN = |
208 | Utils.getProperty("h2.delayWrongPasswordMin", 250); |
209 | |
210 | /** |
211 | * System property <code>h2.delayWrongPasswordMax</code> |
212 | * (default: 4000).<br /> |
213 | * The maximum delay in milliseconds before an exception is thrown for using |
214 | * the wrong user name or password. This slows down brute force attacks. The |
215 | * delay is reset after a successful login. The value 0 means there is no |
216 | * maximum delay. |
217 | */ |
218 | public static final int DELAY_WRONG_PASSWORD_MAX = |
219 | Utils.getProperty("h2.delayWrongPasswordMax", 4000); |
220 | |
221 | /** |
222 | * System property <code>h2.javaSystemCompiler</code> (default: true).<br /> |
223 | * Whether to use the Java system compiler |
224 | * (ToolProvider.getSystemJavaCompiler()) if it is available to compile user |
225 | * defined functions. If disabled or if the system compiler is not |
226 | * available, the com.sun.tools.javac compiler is used if available, and |
227 | * "javac" (as an external process) is used if not. |
228 | */ |
229 | public static final boolean JAVA_SYSTEM_COMPILER = |
230 | Utils.getProperty("h2.javaSystemCompiler", true); |
231 | |
232 | /** |
233 | * System property <code>h2.lobCloseBetweenReads</code> |
234 | * (default: false).<br /> |
235 | * Close LOB files between read operations. |
236 | */ |
237 | public static boolean lobCloseBetweenReads = |
238 | Utils.getProperty("h2.lobCloseBetweenReads", false); |
239 | |
240 | /** |
241 | * System property <code>h2.lobFilesPerDirectory</code> |
242 | * (default: 256).<br /> |
243 | * Maximum number of LOB files per directory. |
244 | */ |
245 | public static final int LOB_FILES_PER_DIRECTORY = |
246 | Utils.getProperty("h2.lobFilesPerDirectory", 256); |
247 | |
248 | /** |
249 | * System property <code>h2.lobClientMaxSizeMemory</code> (default: |
250 | * 1048576).<br /> |
251 | * The maximum size of a LOB object to keep in memory on the client side |
252 | * when using the server mode. |
253 | */ |
254 | public static final int LOB_CLIENT_MAX_SIZE_MEMORY = |
255 | Utils.getProperty("h2.lobClientMaxSizeMemory", 1024 * 1024); |
256 | |
257 | /** |
258 | * System property <code>h2.maxFileRetry</code> (default: 16).<br /> |
259 | * Number of times to retry file delete and rename. in Windows, files can't |
260 | * be deleted if they are open. Waiting a bit can help (sometimes the |
261 | * Windows Explorer opens the files for a short time) may help. Sometimes, |
262 | * running garbage collection may close files if the user forgot to call |
263 | * Connection.close() or InputStream.close(). |
264 | */ |
265 | public static final int MAX_FILE_RETRY = |
266 | Math.max(1, Utils.getProperty("h2.maxFileRetry", 16)); |
267 | |
268 | /** |
269 | * System property <code>h2.maxReconnect</code> (default: 3).<br /> |
270 | * The maximum number of tries to reconnect in a row. |
271 | */ |
272 | public static final int MAX_RECONNECT = |
273 | Utils.getProperty("h2.maxReconnect", 3); |
274 | |
275 | /** |
276 | * System property <code>h2.maxMemoryRows</code> |
277 | * (default: 40000 per GB of available RAM).<br /> |
278 | * The default maximum number of rows to be kept in memory in a result set. |
279 | */ |
280 | public static final int MAX_MEMORY_ROWS = |
281 | getAutoScaledForMemoryProperty("h2.maxMemoryRows", 40000); |
282 | |
283 | /** |
284 | * System property <code>h2.maxTraceDataLength</code> |
285 | * (default: 65535).<br /> |
286 | * The maximum size of a LOB value that is written as data to the trace |
287 | * system. |
288 | */ |
289 | public static final long MAX_TRACE_DATA_LENGTH = |
290 | Utils.getProperty("h2.maxTraceDataLength", 65535); |
291 | |
292 | /** |
293 | * System property <code>h2.modifyOnWrite</code> (default: false).<br /> |
294 | * Only modify the database file when recovery is necessary, or when writing |
295 | * to the database. If disabled, opening the database always writes to the |
296 | * file (except if the database is read-only). When enabled, the serialized |
297 | * file lock is faster. |
298 | */ |
299 | public static final boolean MODIFY_ON_WRITE = |
300 | Utils.getProperty("h2.modifyOnWrite", false); |
301 | |
302 | /** |
303 | * System property <code>h2.nioLoadMapped</code> (default: false).<br /> |
304 | * If the mapped buffer should be loaded when the file is opened. |
305 | * This can improve performance. |
306 | */ |
307 | public static final boolean NIO_LOAD_MAPPED = |
308 | Utils.getProperty("h2.nioLoadMapped", false); |
309 | |
310 | /** |
311 | * System property <code>h2.nioCleanerHack</code> (default: false).<br /> |
312 | * If enabled, use the reflection hack to un-map the mapped file if |
313 | * possible. If disabled, System.gc() is called in a loop until the object |
314 | * is garbage collected. See also |
315 | * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4724038 |
316 | */ |
317 | public static final boolean NIO_CLEANER_HACK = |
318 | Utils.getProperty("h2.nioCleanerHack", false); |
319 | |
320 | /** |
321 | * System property <code>h2.objectCache</code> (default: true).<br /> |
322 | * Cache commonly used values (numbers, strings). There is a shared cache |
323 | * for all values. |
324 | */ |
325 | public static final boolean OBJECT_CACHE = |
326 | Utils.getProperty("h2.objectCache", true); |
327 | |
328 | /** |
329 | * System property <code>h2.objectCacheMaxPerElementSize</code> (default: |
330 | * 4096).<br /> |
331 | * The maximum size (precision) of an object in the cache. |
332 | */ |
333 | public static final int OBJECT_CACHE_MAX_PER_ELEMENT_SIZE = |
334 | Utils.getProperty("h2.objectCacheMaxPerElementSize", 4096); |
335 | |
336 | /** |
337 | * System property <code>h2.objectCacheSize</code> (default: 1024).<br /> |
338 | * The maximum number of objects in the cache. |
339 | * This value must be a power of 2. |
340 | */ |
341 | public static final int OBJECT_CACHE_SIZE = |
342 | MathUtils.nextPowerOf2(Utils.getProperty("h2.objectCacheSize", 1024)); |
343 | |
344 | /** |
345 | * System property <code>h2.oldStyleOuterJoin</code> |
346 | * (default: true for version 1.3, false for version 1.4).<br /> |
347 | * Limited support for the old-style Oracle outer join with "(+)". |
348 | */ |
349 | public static final boolean OLD_STYLE_OUTER_JOIN = |
350 | Utils.getProperty("h2.oldStyleOuterJoin", |
351 | Constants.VERSION_MINOR >= 4 ? false : true); |
352 | |
353 | /** |
354 | * System property <code>h2.pgClientEncoding</code> (default: UTF-8).<br /> |
355 | * Default client encoding for PG server. It is used if the client does not |
356 | * sends his encoding. |
357 | */ |
358 | public static final String PG_DEFAULT_CLIENT_ENCODING = |
359 | Utils.getProperty("h2.pgClientEncoding", "UTF-8"); |
360 | |
361 | /** |
362 | * System property <code>h2.prefixTempFile</code> (default: h2.temp).<br /> |
363 | * The prefix for temporary files in the temp directory. |
364 | */ |
365 | public static final String PREFIX_TEMP_FILE = |
366 | Utils.getProperty("h2.prefixTempFile", "h2.temp"); |
367 | |
368 | /** |
369 | * System property <code>h2.serverCachedObjects</code> (default: 64).<br /> |
370 | * TCP Server: number of cached objects per session. |
371 | */ |
372 | public static final int SERVER_CACHED_OBJECTS = |
373 | Utils.getProperty("h2.serverCachedObjects", 64); |
374 | |
375 | /** |
376 | * System property <code>h2.serverResultSetFetchSize</code> |
377 | * (default: 100).<br /> |
378 | * The default result set fetch size when using the server mode. |
379 | */ |
380 | public static final int SERVER_RESULT_SET_FETCH_SIZE = |
381 | Utils.getProperty("h2.serverResultSetFetchSize", 100); |
382 | |
383 | /** |
384 | * System property <code>h2.socketConnectRetry</code> (default: 16).<br /> |
385 | * The number of times to retry opening a socket. Windows sometimes fails |
386 | * to open a socket, see bug |
387 | * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6213296 |
388 | */ |
389 | public static final int SOCKET_CONNECT_RETRY = |
390 | Utils.getProperty("h2.socketConnectRetry", 16); |
391 | |
392 | /** |
393 | * System property <code>h2.socketConnectTimeout</code> |
394 | * (default: 2000).<br /> |
395 | * The timeout in milliseconds to connect to a server. |
396 | */ |
397 | public static final int SOCKET_CONNECT_TIMEOUT = |
398 | Utils.getProperty("h2.socketConnectTimeout", 2000); |
399 | |
400 | /** |
401 | * System property <code>h2.sortBinaryUnsigned</code> |
402 | * (default: false with version 1.3, true with version 1.4).<br /> |
403 | * Whether binary data should be sorted in unsigned mode |
404 | * (0xff is larger than 0x00). |
405 | */ |
406 | public static final boolean SORT_BINARY_UNSIGNED = |
407 | Utils.getProperty("h2.sortBinaryUnsigned", |
408 | Constants.VERSION_MINOR >= 4 ? true : false); |
409 | |
410 | /** |
411 | * System property <code>h2.sortNullsHigh</code> (default: false).<br /> |
412 | * Invert the default sorting behavior for NULL, such that NULL |
413 | * is at the end of a result set in an ascending sort and at |
414 | * the beginning of a result set in a descending sort. |
415 | */ |
416 | public static final boolean SORT_NULLS_HIGH = |
417 | Utils.getProperty("h2.sortNullsHigh", false); |
418 | |
419 | /** |
420 | * System property <code>h2.splitFileSizeShift</code> (default: 30).<br /> |
421 | * The maximum file size of a split file is 1L << x. |
422 | */ |
423 | public static final long SPLIT_FILE_SIZE_SHIFT = |
424 | Utils.getProperty("h2.splitFileSizeShift", 30); |
425 | |
426 | /** |
427 | * System property <code>h2.storeLocalTime</code> |
428 | * (default: false for version 1.3, true for version 1.4).<br /> |
429 | * Store the local time. If disabled, the daylight saving offset is not |
430 | * taken into account. |
431 | */ |
432 | public static final boolean STORE_LOCAL_TIME = |
433 | Utils.getProperty("h2.storeLocalTime", |
434 | Constants.VERSION_MINOR >= 4 ? true : false); |
435 | |
436 | /** |
437 | * System property <code>h2.syncMethod</code> (default: sync).<br /> |
438 | * What method to call when closing the database, on checkpoint, and on |
439 | * CHECKPOINT SYNC. The following options are supported: |
440 | * "sync" (default): RandomAccessFile.getFD().sync(); |
441 | * "force": RandomAccessFile.getChannel().force(true); |
442 | * "forceFalse": RandomAccessFile.getChannel().force(false); |
443 | * "": do not call a method (fast but there is a risk of data loss |
444 | * on power failure). |
445 | */ |
446 | public static final String SYNC_METHOD = |
447 | Utils.getProperty("h2.syncMethod", "sync"); |
448 | |
449 | /** |
450 | * System property <code>h2.traceIO</code> (default: false).<br /> |
451 | * Trace all I/O operations. |
452 | */ |
453 | public static final boolean TRACE_IO = |
454 | Utils.getProperty("h2.traceIO", false); |
455 | |
456 | /** |
457 | * System property <code>h2.implicitRelativePath</code> |
458 | * (default: true for version 1.3, false for version 1.4).<br /> |
459 | * If disabled, relative paths in database URLs need to be written as |
460 | * jdbc:h2:./test instead of jdbc:h2:test. |
461 | */ |
462 | public static final boolean IMPLICIT_RELATIVE_PATH = |
463 | Utils.getProperty("h2.implicitRelativePath", |
464 | Constants.VERSION_MINOR >= 4 ? false : true); |
465 | |
466 | /** |
467 | * System property <code>h2.urlMap</code> (default: null).<br /> |
468 | * A properties file that contains a mapping between database URLs. New |
469 | * connections are written into the file. An empty value in the map means no |
470 | * redirection is used for the given URL. |
471 | */ |
472 | public static final String URL_MAP = |
473 | Utils.getProperty("h2.urlMap", null); |
474 | |
475 | /** |
476 | * System property <code>h2.useThreadContextClassLoader</code> |
477 | * (default: false).<br /> |
478 | * Instead of using the default class loader when deserializing objects, the |
479 | * current thread-context class loader will be used. |
480 | */ |
481 | public static final boolean USE_THREAD_CONTEXT_CLASS_LOADER = |
482 | Utils.getProperty("h2.useThreadContextClassLoader", false); |
483 | |
484 | /** |
485 | * System property <code>h2.serializeJavaObject</code> |
486 | * (default: true).<br /> |
487 | * <b>If true</b>, values of type OTHER will be stored in serialized form |
488 | * and have the semantics of binary data for all operations (such as sorting |
489 | * and conversion to string). |
490 | * <br /> |
491 | * <b>If false</b>, the objects will be serialized only for I/O operations |
492 | * and a few other special cases (for example when someone tries to get the |
493 | * value in binary form or when comparing objects that are not comparable |
494 | * otherwise). |
495 | * <br /> |
496 | * If the object implements the Comparable interface, the method compareTo |
497 | * will be used for sorting (but only if objects being compared have a |
498 | * common comparable super type). Otherwise the objects will be compared by |
499 | * type, and if they are the same by hashCode, and if the hash codes are |
500 | * equal, but objects are not, the serialized forms (the byte arrays) are |
501 | * compared. |
502 | * <br /> |
503 | * The string representation of the values use the toString method of |
504 | * object. |
505 | * <br /> |
506 | * In client-server mode, the server must have all required classes in the |
507 | * class path. On the client side, this setting is required to be disabled |
508 | * as well, to have correct string representation and display size. |
509 | * <br /> |
510 | * In embedded mode, no data copying occurs, so the user has to make |
511 | * defensive copy himself before storing, or ensure that the value object is |
512 | * immutable. |
513 | */ |
514 | public static boolean serializeJavaObject = |
515 | Utils.getProperty("h2.serializeJavaObject", true); |
516 | |
517 | /** |
518 | * System property <code>h2.javaObjectSerializer</code> |
519 | * (default: null).<br /> |
520 | * The JavaObjectSerializer class name for java objects being stored in |
521 | * column of type OTHER. It must be the same on client and server to work |
522 | * correctly. |
523 | */ |
524 | public static final String JAVA_OBJECT_SERIALIZER = |
525 | Utils.getProperty("h2.javaObjectSerializer", null); |
526 | |
527 | private static final String H2_BASE_DIR = "h2.baseDir"; |
528 | |
529 | private SysProperties() { |
530 | // utility class |
531 | } |
532 | |
533 | /** |
534 | * INTERNAL |
535 | */ |
536 | public static void setBaseDir(String dir) { |
537 | if (!dir.endsWith("/")) { |
538 | dir += "/"; |
539 | } |
540 | System.setProperty(H2_BASE_DIR, dir); |
541 | } |
542 | |
543 | /** |
544 | * INTERNAL |
545 | */ |
546 | public static String getBaseDir() { |
547 | return Utils.getProperty(H2_BASE_DIR, null); |
548 | } |
549 | |
550 | /** |
551 | * System property <code>h2.scriptDirectory</code> (default: empty |
552 | * string).<br /> |
553 | * Relative or absolute directory where the script files are stored to or |
554 | * read from. |
555 | * |
556 | * @return the current value |
557 | */ |
558 | public static String getScriptDirectory() { |
559 | return Utils.getProperty(H2_SCRIPT_DIRECTORY, ""); |
560 | } |
561 | |
562 | /** |
563 | * This method attempts to auto-scale some of our properties to take |
564 | * advantage of more powerful machines out of the box. We assume that our |
565 | * default properties are set correctly for approx. 1G of memory, and scale |
566 | * them up if we have more. |
567 | */ |
568 | private static int getAutoScaledForMemoryProperty(String key, int defaultValue) { |
569 | String s = Utils.getProperty(key, null); |
570 | if (s != null) { |
571 | try { |
572 | return Integer.decode(s).intValue(); |
573 | } catch (NumberFormatException e) { |
574 | // ignore |
575 | } |
576 | } |
577 | return Utils.scaleForAvailableMemory(defaultValue); |
578 | } |
579 | |
580 | } |