~davewalker/ubuntu/maverick/eucalyptus/lp611144

« back to all changes in this revision

Viewing changes to clc/modules/database/src/main/java/com/eucalyptus/bootstrap/LocalDatabaseBootstrapper.java

  • Committer: Dave Walker (Daviey)
  • Date: 2010-06-21 12:59:20 UTC
  • mfrom: (1048.1.14 ubuntu)
  • Revision ID: davewalker@ubuntu.com-20100621125920-60uhixwq174elnj1
* New major upstream version merge, 1.7 (r1200).
* debian/patches/:
  - 02-Makefile.patch: Updated to reflect new code layout.
  - 07-local_support_euca_conf-in.patch: Updated to reflect new code layout.
  - 08-ubuntu-default-networking.patch: Refreshed.
  - 09-small-128-192MB.patch: Updated to point to new location.
  - 10-disable-iscsi.patch: Refreshed.
  - 11-state-cleanup-memleakfix.patch: Refreshed.
  - 15-fix-default-ramdisk.patch: Updated to point to new location.
  - 16-kvm_libvirt_xml_default_use_kvm.patch: Updated to reflect changes.
  - 17-fix_walrus_OOM_errors.patch: Removed, fixed upstream.
  - 18-priv_security.patch: Updated to reflect upstream changes.
  - 20-brute-force-webui.patch: Updated to reflect upstream changes. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
package com.eucalyptus.bootstrap;
65
65
 
66
66
import java.util.concurrent.atomic.AtomicBoolean;
67
 
 
68
67
import org.apache.log4j.Logger;
69
68
import org.hsqldb.Server;
70
69
import org.hsqldb.persist.HsqlProperties;
71
 
 
 
70
import com.eucalyptus.bootstrap.Bootstrap.Stage;
72
71
import com.eucalyptus.event.ClockTick;
73
72
import com.eucalyptus.event.Event;
74
73
import com.eucalyptus.event.EventListener;
75
74
import com.eucalyptus.event.ListenerRegistry;
76
 
import com.eucalyptus.util.DatabaseUtil;
77
 
import com.eucalyptus.util.DebugUtil;
78
 
import com.eucalyptus.util.FailScriptFailException;
79
 
import com.eucalyptus.util.GroovyUtil;
 
75
import com.eucalyptus.scripting.ScriptExecutionFailedException;
 
76
import com.eucalyptus.scripting.groovy.GroovyUtil;
 
77
import com.eucalyptus.system.Threads;
80
78
import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
81
79
 
82
 
@Provides( resource = Resource.Database )
83
 
@Depends( resources = Resource.SystemCredentials, local = Component.eucalyptus )
 
80
@Provides(Component.db)
 
81
@RunDuring(Bootstrap.Stage.DatabaseInit)
 
82
@DependsLocal(Component.eucalyptus)
84
83
public class LocalDatabaseBootstrapper extends Bootstrapper implements EventListener, Runnable, DatabaseBootstrapper {
85
84
  private static Logger             LOG = Logger.getLogger( LocalDatabaseBootstrapper.class );
86
85
  private static DatabaseBootstrapper singleton;
89
88
    synchronized ( LocalDatabaseBootstrapper.class ) {
90
89
      if ( singleton == null ) {
91
90
        singleton = new LocalDatabaseBootstrapper( );
92
 
        SystemBootstrapper.setDatabaseBootstrapper( singleton );
93
91
      }
94
92
    }
95
93
    return singleton;
117
115
  }
118
116
 
119
117
  @Override
120
 
  public boolean load( Resource current ) throws Exception {
 
118
  public boolean load( Stage current ) throws Exception {
121
119
    try {
122
 
      LOG.debug( "Initializing SSL just in case: " + Class.forName( "com.eucalyptus.auth.util.SslSetup" ) );
 
120
      LOG.debug( "Initializing SSL just in case: " + ClassLoader.getSystemClassLoader().loadClass( "com.eucalyptus.auth.util.SslSetup" ) );
123
121
    } catch ( Throwable t ) {}
124
122
    try {
125
 
      LOG.debug( "Initializing db password: " + Class.forName( "com.eucalyptus.auth.util.Hashes" ) );
 
123
      LOG.debug( "Initializing db password: " + ClassLoader.getSystemClassLoader().loadClass( "com.eucalyptus.auth.util.Hashes" ) );
126
124
    } catch ( Throwable t ) {}
127
125
    createDatabase( );
128
126
    return true;
140
138
  private static AtomicBoolean hup = new AtomicBoolean( false );
141
139
  public void hup( ) {
142
140
    if( hup.compareAndSet( false, true ) ) {
143
 
      DebugUtil.printDebugDetails( );
144
141
      try {
145
142
        if ( this.db != null ) { 
146
143
          this.db.checkRunning( true );
159
156
  private void createDatabase( ) {    
160
157
    try {
161
158
      GroovyUtil.evaluateScript( "before_database.groovy" );//TODO: move this ASAP!
162
 
    } catch ( FailScriptFailException e ) {
 
159
    } catch ( ScriptExecutionFailedException e ) {
163
160
      LOG.fatal( e, e );
164
161
      LOG.fatal( "Failed to initialize the database layer." );
165
162
      System.exit( -1 );
166
163
    }
167
164
    this.db = new Server( );
168
165
    this.db.setProperties( new HsqlProperties( DatabaseConfig.getProperties( ) ) );
169
 
    SystemBootstrapper.makeSystemThread( this ).start( );
 
166
    Threads.newThread( this ).start( );
170
167
    try {
171
168
      GroovyUtil.evaluateScript( "after_database.groovy" );//TODO: move this ASAP!
172
 
    } catch ( FailScriptFailException e ) {
 
169
    } catch ( ScriptExecutionFailedException e ) {
173
170
      LOG.fatal( e, e );
174
171
      LOG.fatal( "Failed to initialize the persistence layer." );
175
172
      System.exit( -1 );
180
177
  public boolean start( ) throws Exception {
181
178
    this.waitForDatabase( );
182
179
    try {
183
 
      GroovyUtil.evaluateScript( "startup.groovy" );
184
 
    } catch ( Exception e ) {
185
 
      LOG.fatal( e, e );
186
 
      System.exit( -1 );
187
 
    }
188
 
    try {
189
180
      GroovyUtil.evaluateScript( "after_persistence.groovy" );//TODO: move this ASAP!
190
 
    } catch ( FailScriptFailException e ) {
 
181
    } catch ( ScriptExecutionFailedException e ) {
191
182
      LOG.fatal( e, e );
192
183
      LOG.fatal( "Failed to initialize the persistence layer." );
193
184
      System.exit( -1 );