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

« back to all changes in this revision

Viewing changes to clc/modules/cluster-manager/src/main/java/com/eucalyptus/cluster/handlers/VmStateHandler.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:
1
1
package com.eucalyptus.cluster.handlers;
2
2
 
3
 
import java.util.concurrent.atomic.AtomicBoolean;
4
 
 
 
3
import java.util.concurrent.atomic.AtomicInteger;
5
4
import org.apache.log4j.Logger;
6
5
import org.jboss.netty.channel.ChannelHandlerContext;
7
6
import org.jboss.netty.channel.ChannelPipelineCoverage;
8
7
import org.jboss.netty.channel.MessageEvent;
9
 
 
 
8
import com.eucalyptus.binding.BindingException;
10
9
import com.eucalyptus.bootstrap.Component;
11
10
import com.eucalyptus.cluster.Cluster;
 
11
import com.eucalyptus.cluster.VmTypes;
12
12
import com.eucalyptus.cluster.util.ClusterUtil;
 
13
import com.eucalyptus.entities.VmType;
13
14
import com.eucalyptus.event.Event;
 
15
import com.eucalyptus.http.MappingHttpResponse;
14
16
import com.eucalyptus.util.LogUtil;
15
 
import com.eucalyptus.ws.BindingException;
16
 
import com.eucalyptus.ws.MappingHttpResponse;
17
 
 
 
17
import com.eucalyptus.vm.SystemState;
18
18
import edu.ucsb.eucalyptus.cloud.VmDescribeResponseType;
19
19
import edu.ucsb.eucalyptus.cloud.VmDescribeType;
20
20
import edu.ucsb.eucalyptus.cloud.VmInfo;
21
 
import edu.ucsb.eucalyptus.cloud.cluster.VmTypes;
22
 
import edu.ucsb.eucalyptus.cloud.entities.VmType;
23
 
import edu.ucsb.eucalyptus.cloud.ws.SystemState;
24
21
import edu.ucsb.eucalyptus.msgs.VmTypeInfo;
25
22
 
26
 
@ChannelPipelineCoverage("one")
 
23
@ChannelPipelineCoverage( "one" )
27
24
public class VmStateHandler extends AbstractClusterMessageDispatcher {
28
 
  private static Logger LOG = Logger.getLogger( NetworkStateHandler.class );
29
 
  private AtomicBoolean init = new AtomicBoolean( false );
 
25
  private static Logger LOG  = Logger.getLogger( NetworkStateHandler.class );
 
26
  private AtomicInteger init = new AtomicInteger( 0 );
 
27
  
30
28
  public VmStateHandler( Cluster cluster ) throws BindingException {
31
29
    super( cluster );
32
30
  }
33
 
 
 
31
  
34
32
  @Override
35
33
  public void trigger( ) {
36
34
    VmDescribeType msg = new VmDescribeType( );
37
 
    msg.setUserId( Component.eucalyptus.name() );
38
 
    msg.setEffectiveUserId( Component.eucalyptus.name() );
 
35
    msg.setUserId( Component.eucalyptus.name( ) );
 
36
    msg.setEffectiveUserId( Component.eucalyptus.name( ) );
39
37
    this.write( msg );
40
38
  }
41
 
 
 
39
  
42
40
  @Override
43
41
  public void fireEvent( Event event ) {
44
42
    super.fireTimedStatefulTrigger( event );
45
43
  }
46
 
 
 
44
  
47
45
  @Override
48
46
  public void upstreamMessage( ChannelHandlerContext ctx, MessageEvent e ) {
49
47
    if ( e.getMessage( ) instanceof MappingHttpResponse ) {
50
48
      MappingHttpResponse resp = ( MappingHttpResponse ) e.getMessage( );
51
 
      VmDescribeResponseType reply = (VmDescribeResponseType) resp.getMessage( );
 
49
      VmDescribeResponseType reply = ( VmDescribeResponseType ) resp.getMessage( );
52
50
      if ( reply != null ) {
53
 
      reply.setOriginCluster( this.getCluster( ).getConfiguration( ).getName( ) );
54
 
      for ( VmInfo vmInfo : reply.getVms( ) ) {
55
 
        vmInfo.setPlacement( this.getCluster( ).getConfiguration( ).getName( ) );
56
 
        VmTypeInfo typeInfo = vmInfo.getInstanceType( );
57
 
        if ( typeInfo.getName( ) == null || "".equals( typeInfo.getName( ) ) ) {
58
 
          for ( VmType t : VmTypes.list( ) ) {
59
 
            if ( t.getCpu( ).equals( typeInfo.getCores( ) ) && t.getDisk( ).equals( typeInfo.getDisk( ) ) && t.getMemory( ).equals( typeInfo.getMemory( ) ) ) {
60
 
              typeInfo.setName( t.getName( ) );
 
51
        reply.setOriginCluster( this.getCluster( ).getConfiguration( ).getName( ) );
 
52
        for ( VmInfo vmInfo : reply.getVms( ) ) {
 
53
          vmInfo.setPlacement( this.getCluster( ).getConfiguration( ).getName( ) );
 
54
          VmTypeInfo typeInfo = vmInfo.getInstanceType( );
 
55
          if ( typeInfo.getName( ) == null || "".equals( typeInfo.getName( ) ) ) {
 
56
            for ( VmType t : VmTypes.list( ) ) {
 
57
              if ( t.getCpu( ).equals( typeInfo.getCores( ) ) && t.getDisk( ).equals( typeInfo.getDisk( ) ) && t.getMemory( ).equals( typeInfo.getMemory( ) ) ) {
 
58
                typeInfo.setName( t.getName( ) );
 
59
              }
61
60
            }
62
61
          }
63
62
        }
64
 
      }
65
 
      SystemState.handle( reply );
66
 
      }
67
 
      if( this.init.compareAndSet( false, true ) ) {
68
 
        try {
69
 
          ClusterUtil.registerClusterStateHandler( this.getCluster( ), new AddressStateHandler( this.getCluster( ) ) );
70
 
        } catch ( Exception e1 ) {
71
 
          LOG.error( e1, e1 );
 
63
        SystemState.handle( reply );
 
64
        if( this.init.addAndGet( 1 ) == 2 ) {
 
65
          try {
 
66
            ClusterUtil.registerClusterStateHandler( this.getCluster( ), new AddressStateHandler( this.getCluster( ) ) );
 
67
          } catch ( Exception e1 ) {
 
68
            LOG.error( e1, e1 );
 
69
          }
 
70
          this.getCluster( ).start( );
 
71
          LOG.info( LogUtil.header( "Starting threads for cluster: " + this.getCluster( ) ) );   
72
72
        }
73
 
        this.getCluster( ).start( );
74
 
        LOG.info( LogUtil.header( "Starting threads for cluster: " + this.getCluster( ) ) );
75
 
      }
 
73
      }      
76
74
    }
77
75
  }
78
 
 
 
76
  
79
77
  @Override
80
 
  public void advertiseEvent( Event event ) {
81
 
  }
 
78
  public void advertiseEvent( Event event ) {}
82
79
}