001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
006: * Contact: sequoia@continuent.org
007: *
008: * Licensed under the Apache License, Version 2.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: * Initial developer(s): Nicolas Modrzyk.
021: * Contributor(s): Emmanuel Cecchet.
022: */package org.continuent.sequoia.common.util;
023:
024: import java.io.IOException;
025: import java.util.Properties;
026:
027: /**
028: * Constants that are common to the console, driver and controller modules
029: *
030: * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
031: * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
032: */
033: public class Constants {
034: static Properties getVersionProperties() {
035: Properties versionProperties = new Properties();
036: try {
037: versionProperties.load(Constants.class
038: .getResourceAsStream("version.properties"));
039: } catch (IOException e) { // ignored
040: }
041: return versionProperties;
042: }
043:
044: // the following default value "@VERSION@" is patched by build.xml
045: // target 'init-compile'.
046:
047: /** Sequoia version. */
048: public static final String VERSION = getVersionProperties()
049: .getProperty("sequoia.version", "@VERSION@");
050:
051: /**
052: * Sequoia major version
053: *
054: * @return major version
055: */
056: public static final int getMajorVersion() {
057: int ind = VERSION.indexOf('.');
058: if (ind > 0)
059: return Integer.parseInt(VERSION.substring(0, ind));
060: else
061: return 1;
062: }
063:
064: /**
065: * Sequoia minor version
066: *
067: * @return minor version
068: */
069: public static final int getMinorVersion() {
070: int ind = VERSION.indexOf('.');
071: if (ind > 0)
072: return Integer
073: .parseInt(VERSION.substring(ind + 1, ind + 2));
074: else
075: return 0;
076: }
077:
078: //
079: // Shutdown constants
080: //
081:
082: /** Shutdown Mode Wait: Wait for all clients to disconnect */
083: public static final int SHUTDOWN_WAIT = 1;
084:
085: /**
086: * Shutdown Mode Safe: Wait for all current transactions to complete before
087: * shutdown
088: */
089: public static final int SHUTDOWN_SAFE = 2;
090:
091: /**
092: * Shutdown Mode Force: Does not wait for the end of the current transactions
093: * and kill all connections. Recovery will be needed on restart.
094: */
095: public static final int SHUTDOWN_FORCE = 3;
096:
097: //
098: // Ping constant
099: /** Controller ping protocol version = byte that is sent/received as ping/pong */
100: public static final byte CONTROLLER_PING_VERSION = 0x01;
101: }
|