📄 server.java
字号:
// You can redistribute this software and/or modify it under the terms of// the Ozone Core License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-2000 by SMB GmbH. All rights reserved.//// $Id: Server.java,v 1.39 2000/11/06 15:44:27 daniela Exp $package org.ozoneDB.core;import java.io.*;import org.ozoneDB.DxLib.*;import org.ozoneDB.*;import org.ozoneDB.util.*;import org.ozoneDB.tools.*;/** * Main class to start the stand-alone server. * * @author <a href="http://www.softwarebuero.de/">SMB</a> * @version $Revision: 1.39 $Date: 2000/11/06 15:44:27 $ */public class Server { public static Env env; public static void main( String[] args ) throws Exception { String dir = File.separator + "tmp" + File.separator + "db"; int debugLevel = 0; boolean help = false; boolean verbose = false; boolean createDB = false; DxArrayBag users = new DxArrayBag(); System.out.println( "ozone server - version " + Env.VERSION ); for (int i = 0; i < args.length; i++) { if (args[i].equals( "-debug" ) || args[i].equals( "-debug1" )) { debugLevel = LogWriter.DEBUG; } else if (args[i].equals( "-debug2" )) { debugLevel = LogWriter.DEBUG | LogWriter.DEBUG2; } else if (args[i].equals( "-debug3" )) { debugLevel = LogWriter.DEBUG | LogWriter.DEBUG2 | LogWriter.DEBUG3; } else if (args[i].startsWith( "-d" )) { dir = args[i].substring( 2 ); } else if (args[i].startsWith( "-c" )) { createDB = true; } else if (args[i].startsWith( "-u" )) { String name = args[i].substring( 2 ); users.add( name ); } else if (args[i].startsWith( "-h" )) { help = true; } else { System.out.println( "illegal option: " + args[i] ); help = true; } } if (args.length == 0 || help) { System.out.println( "usage: ozone -d<dir> [-h] [-debug] [-v]" ); System.out.println( " -d<directory> database directory" ); System.out.println( " -debug<level> enable debug messages" ); System.out.println( " -v starts the ozonometer (broken)" ); System.out.println( " -c create a database if neccessary" ); System.out.println( " -u<name> add user <name>" ); System.out.println( " -h shows this help" ); System.exit( 0 ); } try { if (createDB) { // check to see if we have a config file in the database directory // if not, assume we need to make a new database, and do so. File testFile = new File( dir, Env.CONFIG_FILE ); if (!testFile.exists()) { System.out.println( "Installing new database in " + dir + "..." ); Setup defaults = new Setup( null ); defaults.addProperties( System.getProperties(), "ozoneDB." ); Install.createDB( dir, defaults, new PrintWriter( System.out, true ) ); System.out.println( "Edit " + dir + Env.CONFIG_FILE + " to change settings." ); System.out.println( "install complete\n" ); } } System.out.println( "initializing environment..." ); env = new Env( dir, debugLevel, verbose, false ); int freeSlot = 101; for (int i = 0; i < users.count(); i++) { String name = (String)users.elementAtIndex( i ); // don't insert a name twice if (env.userManager.userForName( name ) != null) { env.logWriter.newEntry( env, "User " + name + " already exists.", LogWriter.INFO ); continue; } // find a free id while (env.userManager.userForID( freeSlot ) != null) { freeSlot++; } // add the user env.userManager.newUser( name, freeSlot ); env.logWriter.newEntry( env, "user added: " + name + " ID: " + freeSlot, LogWriter.INFO ); } env.storeSetup(); env.startExternalEventProcessing(); env.startDeadlockRecognition(); System.out.println( "('q' to shutdown without admin tool)" ); InputStreamReader is = new InputStreamReader( System.in ); Thread.currentThread().setPriority( Env.SERVER_THREAD_PRIORITY ); int gcCount = 0; for (;;) { while (!is.ready() && !env.shuttingdown) { // this forces also task switches Thread.currentThread().sleep( 250 ); if (env.transactionManager.taTableCount() == 0) { gcCount++; } else { gcCount = 0; } if (gcCount >= 12) { gcCount = 0; System.gc(); } } // MEN 6/25/1999 - added a way to exit when the AdminTool // shuts us down if (env.shuttingdown) { break; } int c = is.read(); if (c == 'q') { env.shutdown(); break; } } } catch (Exception e) { if (env != null) { env.shutdown(); } // env.logWriter.newEntry (null, "", e, LogWriter.ERROR); System.out.println( "Unable to initialize server." ); e.printStackTrace(); } System.exit( 1 ); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -