53
53
* SOFTWARE, AND IF ANY SUCH MATERIAL IS DISCOVERED THE PARTY DISCOVERING
54
54
* IT MAY INFORM DR. RICH WOLSKI AT THE UNIVERSITY OF CALIFORNIA, SANTA
55
55
* BARBARA WHO WILL THEN ASCERTAIN THE MOST APPROPRIATE REMEDY, WHICH IN
56
* THE REGENTS’ DISCRETION MAY INCLUDE, WITHOUT LIMITATION, REPLACEMENT
56
* THE REGENTS' DISCRETION MAY INCLUDE, WITHOUT LIMITATION, REPLACEMENT
57
57
* OF THE CODE SO IDENTIFIED, LICENSING OF THE CODE SO IDENTIFIED, OR
58
58
* WITHDRAWAL OF THE CODE CAPABILITY TO THE EXTENT NEEDED TO COMPLY WITH
59
59
* ANY SUCH LICENSES OR RIGHTS.
60
60
*******************************************************************************/
61
61
package com.eucalyptus.bootstrap;
63
64
import java.net.URL;
64
65
import java.util.concurrent.ExecutorService;
65
66
import java.util.concurrent.Executors;
67
68
import org.mortbay.jetty.Server;
68
69
import org.mortbay.xml.XmlConfiguration;
69
70
import com.eucalyptus.bootstrap.Bootstrap.Stage;
71
import com.eucalyptus.component.id.Eucalyptus;
72
import com.eucalyptus.component.id.HttpService;
70
73
import com.eucalyptus.configurable.ConfigurableClass;
71
74
import com.eucalyptus.configurable.ConfigurableField;
72
75
import com.eucalyptus.configurable.ConfigurableProperty;
73
import com.eucalyptus.event.PassiveEventListener;
76
import com.eucalyptus.configurable.ConfigurablePropertyException;
77
import com.eucalyptus.configurable.PropertyChangeListener;
78
import com.eucalyptus.empyrean.Empyrean;
79
import com.eucalyptus.system.BaseDirectory;
74
80
import com.eucalyptus.system.Threads;
75
import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
81
import java.util.concurrent.TimeUnit;
82
import com.google.common.io.Files;
77
@Provides( Component.jetty )
78
@RunDuring( Bootstrap.Stage.CloudServiceInit )
79
@DependsLocal( Component.eucalyptus )
80
@ConfigurableClass( root = "www", description = "Parameters controlling the web UI's http server." )
81
public class HttpServerBootstrapper extends Bootstrapper {
84
@Provides( Empyrean.class )
85
@RunDuring( Bootstrap.Stage.UserCredentialsInit )
86
@DependsLocal( Eucalyptus.class )
87
@ConfigurableClass( root = "www",
88
description = "Parameters controlling the web UI's http server." )
89
public class HttpServerBootstrapper extends Bootstrapper {
82
90
private static Logger LOG = Logger.getLogger( HttpServerBootstrapper.class );
83
@ConfigurableField( description = "Listen to HTTPs on this port.", initial = "" + 8443, changeListener = PortChangeListener.class, displayName="euca.https.port" )
91
@ConfigurableField( description = "Listen to HTTPs on this port.",
93
changeListener = PortChangeListener.class,
94
displayName = "euca.https.port" )
84
95
public static Integer HTTPS_PORT = 8443;
85
@ConfigurableField( description = "Listen to HTTP on this port.", initial = "" + 8080, changeListener = PortChangeListener.class, displayName="euca.http.port" )
96
@ConfigurableField( description = "Listen to HTTP on this port.",
98
changeListener = PortChangeListener.class,
99
displayName = "euca.http.port" )
86
100
public static Integer HTTP_PORT = 8080;
87
101
private static Server jettyServer;
88
private static Thread serverThread;
89
@ConfigurableField( initial = "", description = "Http Proxy Host" )
90
public static String httpProxyHost;
91
@ConfigurableField( initial = "", description = "Http Proxy Port" )
92
public static String httpProxyPort;
102
@ConfigurableField( initial = "",
103
description = "Http Proxy Host" )
104
public static String httpProxyHost;
105
@ConfigurableField( initial = "",
106
description = "Http Proxy Port" )
107
public static String httpProxyPort;
94
109
private static void setupJettyServer( ) throws Exception {
95
110
//http proxy setup
96
if(System.getProperty("http.proxyHost") != null) {
97
httpProxyHost = System.getProperty("http.proxyHost");
99
if(System.getProperty("http.proxyPort") != null) {
100
httpProxyPort = System.getProperty("http.proxyPort");
102
jettyServer = new org.mortbay.jetty.Server( );
111
if ( System.getProperty( "http.proxyHost" ) != null ) {
112
httpProxyHost = System.getProperty( "http.proxyHost" );
114
if ( System.getProperty( "http.proxyPort" ) != null ) {
115
httpProxyPort = System.getProperty( "http.proxyPort" );
117
jettyServer = new org.mortbay.jetty.Server( );
103
118
System.setProperty( "euca.http.port", "" + HTTP_PORT );
104
119
System.setProperty( "euca.https.port", "" + HTTPS_PORT );
105
120
URL defaultConfig = ClassLoader.getSystemResource( "eucalyptus-jetty.xml" );
133
155
startJettyServer( );
136
public static class PortChangeListener extends PassiveEventListener<ConfigurableProperty> {
160
* @see com.eucalyptus.bootstrap.Bootstrapper#enable()
163
public boolean enable( ) throws Exception {
168
* @see com.eucalyptus.bootstrap.Bootstrapper#stop()
171
public boolean stop( ) throws Exception {
176
* @see com.eucalyptus.bootstrap.Bootstrapper#destroy()
179
public void destroy( ) throws Exception {}
182
* @see com.eucalyptus.bootstrap.Bootstrapper#disable()
185
public boolean disable( ) throws Exception {
190
* @see com.eucalyptus.bootstrap.Bootstrapper#check()
193
public boolean check( ) throws Exception {
197
public static class PortChangeListener implements PropertyChangeListener {
199
* @see com.eucalyptus.configurable.PropertyChangeListener#fireChange(com.eucalyptus.configurable.ConfigurableProperty,
138
public void firingEvent( ConfigurableProperty t ) {
139
LOG.info( "Change occurred to property " + t.getQualifiedName( ) + " which requires restarting the web server." );
140
if ( jettyServer == null ) {
203
public void fireChange( ConfigurableProperty t, Object newValue ) throws ConfigurablePropertyException {
204
LOG.warn( "Change occurred to property " + t.getQualifiedName( ) + " which will restart the servlet container." );
206
t.getField( ).set( null, t.getTypeParser( ).apply( newValue ) );
207
} catch ( IllegalArgumentException e1 ) {
208
throw new ConfigurablePropertyException( e1 );
209
} catch ( IllegalAccessException e1 ) {
210
throw new ConfigurablePropertyException( e1 );
212
if ( jettyServer == null || !Bootstrap.isFinished( ) ) {
142
214
} else if ( jettyServer.isRunning( ) ) {