~ubuntu-branches/ubuntu/maverick/eucalyptus/maverick

« back to all changes in this revision

Viewing changes to clc/modules/wsstack/src/main/java/com/eucalyptus/ws/client/RemoteBootstrapperClient.java

  • Committer: Bazaar Package Importer
  • Author(s): Dave Walker (Daviey)
  • Date: 2010-07-21 17:27:10 UTC
  • mfrom: (1.1.38 upstream)
  • Revision ID: james.westby@ubuntu.com-20100721172710-7xv07dmdqgivc3t9
Tags: 2.0~bzr1211-0ubuntu1
* New major upstream version merge, 2.0 (r1211).
* debian/patches/:
  - 01-wsdl-stubs.patch, debian/wsdl.md5sums: wsdl stubs updated.
  - 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: Removed, fixed upstream.
  - 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. 
  - 21-eucalyptus-1.7-with-gwt-1.6.4.patch: New patch, allows 
    eucalyptus-1.7 to be built against gwt 1.6.4. Based on patch courtesy 
    of Dmitrii Zagorodnov, upstream. (LP: #597330)
* debian/eucalyptus-java-common.links: 
  - Changed symlink for groovy, point to groovy.all.jar, making compatiable 
    with groovy versions >1.7. (LP: #595421)
  - Added ant.jar & jetty-rewrite-handler.jar as they are now required.
* debian/control
  - & debian/build-jars: Added libjavassist-java and libjetty-extra-java as 
    build dependencies.
  - Added libjetty-extra-java as a dependency of eucalyptus-java-common
* The binary resulting jar's have been renamed from eucalyptus-*-1.6.2.jar
  to eucalyptus-*-main.jar:    
  - debian/eucalyptus-cc.upstart
  - debian/eucalyptus-cloud.install
  - debian/eucalyptus-common.eucalyptus.upstart
  - debian/eucalyptus-java-common.install
  - debian/eucalyptus-network.upstart
  - debian/eucalyptus-sc.install
  - debian/eucalyptus-walrus.install
* debian/eucalyptus-java-common.install: New upstream jars that have been
  installed:
  - eucalyptus-db-hsqldb-ext-main.jar
  - eucalyptus-component-main.jar
* debian/control:
  - Updated Standards Version to 3.8.4 (no change)
  - Updated the upstream Homepage to: http://open.eucalyptus.com/
  - Changed Vcs-Bzr to reflect new location of Ubuntu hosted development branch.
  - Made the Build Dependency of groovy and the binary eucalyptus-java-common
    package depend on version >=1.7.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
package com.eucalyptus.ws.client;
65
65
 
66
66
import java.security.GeneralSecurityException;
67
 
import java.util.Collection;
68
 
import java.util.Comparator;
69
 
import java.util.Map;
70
 
import java.util.Set;
71
 
import java.util.SortedMap;
72
 
import java.util.Map.Entry;
 
67
import java.util.List;
73
68
import java.util.concurrent.ConcurrentMap;
74
69
import java.util.concurrent.Executors;
75
 
 
76
70
import org.apache.log4j.Logger;
77
71
import org.jboss.netty.channel.ChannelDownstreamHandler;
78
72
import org.jboss.netty.channel.ChannelEvent;
88
82
import org.jboss.netty.handler.codec.http.HttpRequestEncoder;
89
83
import org.jboss.netty.handler.codec.http.HttpResponseDecoder;
90
84
import org.jboss.netty.handler.stream.ChunkedWriteHandler;
91
 
 
 
85
import com.eucalyptus.binding.BindingManager;
 
86
import com.eucalyptus.bootstrap.Bootstrap;
92
87
import com.eucalyptus.bootstrap.Bootstrapper;
93
88
import com.eucalyptus.bootstrap.Component;
94
 
import com.eucalyptus.bootstrap.Depends;
 
89
import com.eucalyptus.bootstrap.DependsLocal;
95
90
import com.eucalyptus.bootstrap.Provides;
96
 
import com.eucalyptus.bootstrap.Resource;
 
91
import com.eucalyptus.bootstrap.RunDuring;
 
92
import com.eucalyptus.bootstrap.Bootstrap.Stage;
 
93
import com.eucalyptus.component.ServiceConfiguration;
 
94
import com.eucalyptus.component.event.LifecycleEvent;
 
95
import com.eucalyptus.component.event.StartComponentEvent;
 
96
import com.eucalyptus.component.event.StopComponentEvent;
97
97
import com.eucalyptus.config.ComponentConfiguration;
 
98
import com.eucalyptus.config.Configuration;
98
99
import com.eucalyptus.event.ClockTick;
99
 
import com.eucalyptus.event.ComponentEvent;
100
100
import com.eucalyptus.event.Event;
101
101
import com.eucalyptus.event.EventListener;
102
 
import com.eucalyptus.event.StartComponentEvent;
103
 
import com.eucalyptus.event.StopComponentEvent;
104
102
import com.eucalyptus.util.LogUtil;
105
103
import com.eucalyptus.util.NetworkUtil;
106
 
import com.eucalyptus.ws.binding.BindingManager;
107
 
import com.eucalyptus.ws.client.pipeline.NioClientPipeline;
108
104
import com.eucalyptus.ws.handlers.BindingHandler;
109
105
import com.eucalyptus.ws.handlers.SoapMarshallingHandler;
110
106
import com.eucalyptus.ws.handlers.soap.AddressingHandler;
111
107
import com.eucalyptus.ws.handlers.soap.SoapHandler;
112
108
import com.eucalyptus.ws.handlers.wssecurity.InternalWsSecHandler;
 
109
import com.google.common.collect.Lists;
113
110
import com.google.common.collect.Maps;
114
111
import com.google.common.collect.Multimap;
115
112
import com.google.common.collect.Multimaps;
116
113
 
117
 
import edu.emory.mathcs.backport.java.util.NavigableMap;
118
 
import edu.emory.mathcs.backport.java.util.NavigableSet;
119
 
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentSkipListMap;
120
 
import edu.ucsb.eucalyptus.StartupChecks;
121
 
 
122
 
@Provides( resource = Resource.RemoteConfiguration )
123
 
@Depends( resources = Resource.Database, local = Component.eucalyptus )
 
114
@Provides(Component.eucalyptus)
 
115
@RunDuring(Bootstrap.Stage.RemoteConfiguration)
 
116
@DependsLocal(Component.eucalyptus)
124
117
public class RemoteBootstrapperClient extends Bootstrapper implements ChannelPipelineFactory, EventListener {
125
118
  private static Logger                            LOG    = Logger.getLogger( RemoteBootstrapperClient.class );
126
119
  private ConcurrentMap<String, HeartbeatClient>   heartbeatMap;
127
 
  private Multimap<String, ComponentConfiguration> componentMap;
 
120
  private Multimap<String, ServiceConfiguration> componentMap;
128
121
  private NioBootstrap                             clientBootstrap;
129
122
  private ChannelFactory                           channelFactory;
130
123
  private static RemoteBootstrapperClient          client = new RemoteBootstrapperClient( );
154
147
    }
155
148
    pipeline.addLast( "ws-addressing", new AddressingHandler( ) );
156
149
    pipeline.addLast( "build-soap-envelope", new SoapHandler( ) );
157
 
    pipeline.addLast( "binding", new BindingHandler( BindingManager.getBinding( "msgs_eucalyptus_ucsb_edu" ) ) );
 
150
    pipeline.addLast( "binding", new BindingHandler( BindingManager.getBinding( "msgs_eucalyptus_com" ) ) );
158
151
    pipeline.addLast( "handler", new HeartbeatHandler( ) );
159
152
    return pipeline;
160
153
  }
185
178
  }
186
179
 
187
180
  @Override
188
 
  public boolean load( Resource current ) throws Exception {
 
181
  public boolean load( Stage current ) throws Exception {
189
182
    return true;
190
183
  }
191
184
 
192
185
  @Override
193
186
  public boolean start( ) throws Exception {
 
187
    List<ServiceConfiguration> configs = Lists.newArrayList( );
 
188
    configs.addAll( Configuration.getStorageControllerConfigurations( ) );
 
189
    configs.addAll( Configuration.getWalrusConfigurations( ) );
 
190
    for( ServiceConfiguration c : configs ) {
 
191
      if( !c.isLocal( ) ) {
 
192
        this.addRemoteComponent( c );
 
193
        this.fireRemoteStartEvent( c );
 
194
      }
 
195
    }
194
196
    return true;
195
197
  }
196
198
 
199
201
 
200
202
  @Override
201
203
  public void fireEvent( Event event ) {
202
 
    if ( event instanceof ComponentEvent ) {
203
 
      ComponentEvent e = ( ComponentEvent ) event;
204
 
      if ( !Component.walrus.equals( e.getComponent( ) ) && !Component.storage.equals( e.getComponent( ) ) ) {
 
204
    if ( event instanceof LifecycleEvent ) {
 
205
      LifecycleEvent e = ( LifecycleEvent ) event;
 
206
      if ( !Component.walrus.equals( e.getPeer( ) ) && !Component.storage.equals( e.getPeer( ) ) ) {
205
207
        return;
206
208
      } else if ( e.getConfiguration( ).getPort( ) < 0 ) {
207
209
        return;
208
210
      } else {
209
 
        ComponentConfiguration config = e.getConfiguration( );
 
211
        ServiceConfiguration config = e.getConfiguration( );
210
212
        if ( event instanceof StartComponentEvent ) {
211
213
          if( !NetworkUtil.testLocal( e.getConfiguration( ).getHostName( ) ) ) {
212
214
            this.addRemoteComponent( config );
228
230
    }
229
231
  }
230
232
 
231
 
  private void fireRemoteStartEvent( ComponentConfiguration config ) {
 
233
  private void fireRemoteStartEvent( ServiceConfiguration config ) {
232
234
    for ( HeartbeatClient hb : this.heartbeatMap.values( ) ) {
233
235
      if ( hb.getHostName( ).equals( config.getHostName( ) ) ) {
234
236
        LOG.info( "--> Firing start event on target remote component: " + LogUtil.dumpObject( hb ) );
240
242
    }
241
243
  }
242
244
 
243
 
  private void fireRemoteStopEvent( ComponentConfiguration config ) {
 
245
  private void fireRemoteStopEvent( ServiceConfiguration config ) {
244
246
    for ( HeartbeatClient hb : this.heartbeatMap.values( ) ) {
245
247
      if ( hb.getHostName( ).equals( config.getHostName( ) ) ) {
246
248
        LOG.info( "--> Firing stop event on target remote component: " + LogUtil.dumpObject( hb ) );
252
254
    }
253
255
  }
254
256
 
255
 
  public void addRemoteComponent( ComponentConfiguration config ) {
 
257
  public void addRemoteComponent( ServiceConfiguration config ) {
256
258
    if ( !this.heartbeatMap.containsKey( config.getHostName( ) ) ) {
257
259
      LOG.debug( LogUtil.subheader( "-> Adding remote bootstrapper for host: " + config.getHostName( ) ) );
258
260
      this.heartbeatMap.put( config.getHostName( ), new HeartbeatClient( this.clientBootstrap, config.getHostName( ), config.getPort( ) ) );
263
265
    }
264
266
  }
265
267
 
266
 
  public void removeRemoteComponent( ComponentConfiguration config ) {
 
268
  public void removeRemoteComponent( ServiceConfiguration config ) {
267
269
    if ( this.componentMap.containsEntry( config.getHostName( ), config ) ) {
268
270
      LOG.debug( "-> Removing remote component bootstrapper: " + LogUtil.dumpObject( config ) );
269
271
      this.componentMap.remove( config.getHostName( ), config );