Permalink
Browse files

latest grzemerge

  • Loading branch information...
2 parents 5b9b223 + 95cdfe4 commit 968b0c74a3654b4b4224e93bc741055d38fa66a6 root committed Apr 20, 2011
View
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>eee:clc</name>
+ <name>grze_eee:clc</name>
<comment></comment>
<projects>
</projects>
@@ -84,6 +84,7 @@
import com.eucalyptus.cluster.callback.NetworkStateCallback;
import com.eucalyptus.cluster.callback.PublicAddressStateCallback;
import com.eucalyptus.cluster.callback.ResourceStateCallback;
+import com.eucalyptus.cluster.callback.ServiceStateCallback;
import com.eucalyptus.cluster.callback.VmPendingCallback;
import com.eucalyptus.cluster.callback.VmStateCallback;
import com.eucalyptus.component.ComponentId;
@@ -147,7 +148,7 @@
public enum State {
DISABLED, /* just like down, but is explicitly requested */
DOWN, /* cluster either down, unreachable, or responds with errors */
- AUTHENTICATING, STARTING, STARTING_VMS2, STARTING_RESOURCES, STARTING_NET, STARTING_VMS, STARTING_ADDRS,
+ AUTHENTICATING, CHECKING_SERVICE, STARTING, STARTING_VMS2, STARTING_RESOURCES, STARTING_NET, STARTING_VMS, STARTING_ADDRS,
RUNNING_ADDRS, RUNNING_RSC, RUNNING_NET, RUNNING_VMS, /* available */
}
@@ -160,6 +161,7 @@
// NETWORK_ERROR, /* any -> DOWN: error reaching cluster host */
// CONFIG_ERROR, /* any -> DOWN: configuration error on the cluster */
INIT_CERTS, /* AUTHENTICATING -> STARTING */
+ INIT_SERVICES,
INIT_RESOURCES,
INIT_NET,
INIT_VMS,
@@ -204,8 +206,9 @@ public void fire( Cluster t ) {
//on input INIT_CERTS when in state AUTHENTICATING transition to STARTING on success or DOWN on failure with the transition listeners specified
on( Transition.INIT_CERTS )//
- .from( State.AUTHENTICATING ).to( State.STARTING ).error( State.DOWN ).run( newRefresh( ClusterCertsCallback.class ) );
+ .from( State.AUTHENTICATING ).to( State.CHECKING_SERVICE ).error( State.DOWN ).run( newRefresh( ClusterCertsCallback.class ) );
+ on( Transition.INIT_SERVICES ).from( State.CHECKING_SERVICE ).to( State.STARTING ).error( State.DOWN ).run( newRefresh( ServiceStateCallback.class ) );
on( Transition.INIT_RESOURCES ).from( State.STARTING ).to( State.STARTING_RESOURCES ).error( State.DOWN ).run( newRefresh( ResourceStateCallback.class ) );
on( Transition.INIT_NET ).from( State.STARTING_RESOURCES ).to( State.STARTING_NET ).error( State.DOWN ).run( newRefresh( NetworkStateCallback.class ) );
on( Transition.INIT_VMS ).from( State.STARTING_NET ).to( State.STARTING_VMS ).error( State.DOWN ).run( newRefresh( VmStateCallback.class ) );
@@ -591,6 +594,9 @@ private void nextState( ) {
case AUTHENTICATING:
this.stateMachine.startTransition( Transition.INIT_CERTS );
break;
+ case CHECKING_SERVICE:
+ this.stateMachine.startTransition( Transition.INIT_SERVICES );
+ break;
case STARTING:
this.stateMachine.startTransition( Transition.INIT_RESOURCES );
break;
@@ -14,6 +14,7 @@
import com.eucalyptus.component.ServiceConfiguration;
import com.eucalyptus.component.ServiceConfigurations;
import com.eucalyptus.component.ServiceRegistrationException;
+import com.eucalyptus.component.id.ClusterController;
import com.eucalyptus.component.id.Eucalyptus;
import com.eucalyptus.config.ClusterConfiguration;
import com.eucalyptus.config.DeregisterClusterType;
@@ -28,7 +29,7 @@
import com.eucalyptus.scripting.groovy.GroovyUtil;
import com.eucalyptus.system.SubDirectory;
-@DiscoverableServiceBuilder( com.eucalyptus.component.id.ClusterController.class )
+@DiscoverableServiceBuilder( ClusterController.class )
@Handles( { RegisterClusterType.class, DeregisterClusterType.class, DescribeClustersType.class, ClusterConfiguration.class, ModifyClusterAttributeType.class } )
public class ClusterBuilder extends DatabaseServiceBuilder<ClusterConfiguration> {
static Logger LOG = Logger.getLogger( ClusterBuilder.class );
@@ -84,7 +85,7 @@ public ClusterConfiguration newInstance( String partition, String name, String h
@Override
public Component getComponent( ) {
- return Components.lookup( com.eucalyptus.component.id.ClusterController.class );
+ return Components.lookup( ClusterController.class );
}
@Override
@@ -113,11 +114,14 @@ public Boolean checkRemove( String partition, String name ) throws ServiceRegist
@Override
public void fireStop( ServiceConfiguration config ) throws ServiceRegistrationException {
- LOG.info( "Tearing down cluster: " + config );
- Cluster cluster = Clusters.getInstance( ).lookup( config.getName( ) );
- EventRecord.here( ClusterBuilder.class, EventType.COMPONENT_SERVICE_STOPPED, config.getComponentId( ).name( ), config.getName( ), config.getUri( ).toASCIIString( ) ).info( );
- Cluster clusterInstance = Clusters.getInstance( ).lookup( config.getName( ) );
- clusterInstance.stop( );
+ try {
+ LOG.info( "Tearing down cluster: " + config );
+ Cluster cluster = Clusters.getInstance( ).lookup( config.getName( ) );
+ EventRecord.here( ClusterBuilder.class, EventType.COMPONENT_SERVICE_STOPPED, config.getComponentId( ).name( ), config.getName( ), config.getUri( ).toASCIIString( ) ).info( );
+ cluster.stop( );
+ } catch ( NoSuchElementException ex ) {
+ LOG.error( ex , ex );
+ }
super.fireStop( config );
}
@@ -52,13 +52,17 @@ public void fire( DescribeNetworksResponseType reply ) {
netToken = net.addTokenIfAbsent( netToken );
}
} catch ( NoSuchElementException e1 ) {
- AccountFullName accountFn = Accounts.lookupAccountFullNameById( netInfo.getAccountId( ) );
- if( accountFn != null ) {
- net = new Network( accountFn, netInfo.getNetworkName( ), netInfo.getUuid( ) );
- if ( net.getVlan( ).equals( Integer.valueOf( 0 ) ) && net.initVlan( netInfo.getVlan( ) ) ) {
- NetworkToken netToken = new NetworkToken( this.getSubject( ).getName( ), netInfo.getAccountId( ), netInfo.getNetworkName( ), netInfo.getUuid( ), netInfo.getVlan( ) );
- netToken = net.addTokenIfAbsent( netToken );
+ try {
+ AccountFullName accountFn = Accounts.lookupAccountFullNameById( netInfo.getAccountId( ) );
+ if( accountFn != null ) {
+ net = new Network( accountFn, netInfo.getNetworkName( ), netInfo.getUuid( ) );
+ if ( net.getVlan( ).equals( Integer.valueOf( 0 ) ) && net.initVlan( netInfo.getVlan( ) ) ) {
+ NetworkToken netToken = new NetworkToken( this.getSubject( ).getName( ), netInfo.getAccountId( ), netInfo.getNetworkName( ), netInfo.getUuid( ), netInfo.getVlan( ) );
+ netToken = net.addTokenIfAbsent( netToken );
+ }
}
+ } catch ( Exception ex ) {
+ LOG.error( ex );
}
}
}
@@ -0,0 +1,21 @@
+package com.eucalyptus.cluster.callback;
+
+import org.apache.log4j.Logger;
+import com.eucalyptus.cluster.Cluster;
+import com.eucalyptus.empyrean.DescribeServicesResponseType;
+import com.eucalyptus.empyrean.DescribeServicesType;
+import com.eucalyptus.util.async.SubjectMessageCallback;
+
+public class ServiceStateCallback extends SubjectMessageCallback<Cluster, DescribeServicesType, DescribeServicesResponseType> {
+ private static Logger LOG = Logger.getLogger( ServiceStateCallback.class );
+
+ public ServiceStateCallback( ) {
+ this.setRequest( new DescribeServicesType( ) );
+ }
+
+ @Override
+ public void fire( DescribeServicesResponseType msg ) {
+ LOG.debug( msg );
+ }
+
+}
@@ -358,12 +358,12 @@ private static String printBanner( ) {
}
banner += headerHeader + String.format( headerFormat, "Local Services" ) + headerFooter;
for ( Component c : Components.list( ) ) {
- if ( c.isAvailableLocally( ) ) {
+ if ( c.hasLocalService( ) ) {
ServiceConfiguration localConfig = c.getLocalService( ).getServiceConfiguration( );
banner += prefix + c.getName( ) + SEP + localConfig.toString( );
banner += prefix + c.getName( ) + SEP + localConfig.lookupBuilder( ).toString( );
banner += prefix + c.getName( ) + SEP + localConfig.getComponentId( ).toString( );
- banner += prefix + c.getName( ) + SEP + c.getLocalService( ).getState( ).toString( );
+ banner += prefix + c.getName( ) + SEP + localConfig.lookupService( ).getState( ).toString( );
}
}
banner += headerHeader + String.format( headerFormat, "Detected Interfaces" ) + headerFooter;
@@ -524,24 +524,36 @@ public boolean equals( Object obj ) {
Service lookupRegisteredService( final ServiceConfiguration config ) throws ServiceRegistrationException, NoSuchElementException {
Service service = null;
- if ( config.isLocal( ) && !this.serviceRegistry.hasLocalService( ) ) {
+ if ( ( config.isLocal( ) || Internets.testLocal( config.getHostName( ) ) ) && !this.serviceRegistry.hasLocalService( ) ) {
service = this.serviceRegistry.register( config );
try {
service.transition( State.INITIALIZED );
} catch ( IllegalStateException ex ) {
LOG.error( ex, ex );
- throw new ServiceRegistrationException( "Loading service " + config + " failed because of: " + ex.getMessage( ), ex );
+ throw new ServiceRegistrationException( "Initializing service " + config + " failed because of: " + ex.getMessage( ), ex );
} catch ( NoSuchElementException ex ) {
LOG.error( ex, ex );
- throw new ServiceRegistrationException( "Loading service " + config + " failed because of: " + ex.getMessage( ), ex );
+ throw new ServiceRegistrationException( "Initializing service " + config + " failed because of: " + ex.getMessage( ), ex );
} catch ( ExistingTransitionException ex ) {
LOG.error( ex, ex );
- throw new ServiceRegistrationException( "Loading service " + config + " failed because of: " + ex.getMessage( ), ex );
+ throw new ServiceRegistrationException( "Initializing service " + config + " failed because of: " + ex.getMessage( ), ex );
}
} else if ( this.serviceRegistry.hasService( config ) ) {
service = this.serviceRegistry.lookup( config );
} else {
service = this.serviceRegistry.register( config );
+ try {
+ service.transition( State.INITIALIZED );
+ } catch ( IllegalStateException ex ) {
+ LOG.error( ex, ex );
+ throw new ServiceRegistrationException( "Initializing service " + config + " failed because of: " + ex.getMessage( ), ex );
+ } catch ( NoSuchElementException ex ) {
+ LOG.error( ex, ex );
+ throw new ServiceRegistrationException( "Initializing service " + config + " failed because of: " + ex.getMessage( ), ex );
+ } catch ( ExistingTransitionException ex ) {
+ LOG.error( ex, ex );
+ throw new ServiceRegistrationException( "Initializing service " + config + " failed because of: " + ex.getMessage( ), ex );
+ }
}
return service;
}
@@ -239,7 +239,7 @@ public void leave( final ServiceConfiguration parent, final Completion transitio
try {
parent.lookupComponent( ).getBuilder( ).fireStart( parent );
transitionCallback.fire( );//TODO:GRZE: this is not complete.
- } catch ( ServiceRegistrationException ex ) {
+ } catch ( Throwable ex ) {
LOG.error( "Transition failed on "
+ parent.lookupComponent( ).getName( )
+ " due to "
@@ -275,7 +275,7 @@ public void leave( ServiceConfiguration parent, Completion transitionCallback )
try {
parent.lookupComponent( ).getBuilder( ).fireEnable( parent );
transitionCallback.fire( );//TODO:GRZE: this is not complete.
- } catch ( ServiceRegistrationException ex ) {
+ } catch ( Throwable ex ) {
LOG.error( "Transition failed on "
+ parent.lookupComponent( ).getName( )
+ " due to "
@@ -307,7 +307,7 @@ public void leave( ServiceConfiguration parent, Completion transitionCallback )
try {
parent.lookupComponent( ).getBuilder( ).fireDisable( parent );
transitionCallback.fire( );//TODO:GRZE: this is not complete.
- } catch ( ServiceRegistrationException ex ) {
+ } catch ( Throwable ex ) {
LOG.error( "Transition failed on "
+ parent.lookupComponent( ).getName( )
+ " due to "
@@ -339,7 +339,7 @@ public void leave( ServiceConfiguration parent, Completion transitionCallback )
try {
parent.lookupComponent( ).getBuilder( ).fireStop( parent );
transitionCallback.fire( );//TODO:GRZE: this is not complete.
- } catch ( ServiceRegistrationException ex ) {
+ } catch ( Throwable ex ) {
LOG.error( "Transition failed on "
+ parent.lookupComponent( ).getName( )
+ " due to "
@@ -395,7 +395,7 @@ public void leave( ServiceConfiguration parent, Completion transitionCallback )
if ( parent.lookupComponent( ).hasLocalService( ) ) {
parent.lookupComponent( ).getBuilder( ).fireDisable( parent );
}
- } catch ( ServiceRegistrationException ex1 ) {
+ } catch ( Throwable ex1 ) {
LOG.error( "Transition failed on "
+ parent.lookupComponent( ).getName( )
+ " due to "
@@ -20,6 +20,10 @@
private static ConcurrentMap<String, Context> uuidContexts = new ConcurrentHashMap<String, Context>( MAX, THRESHOLD, CONCUR );
private static ConcurrentMap<Channel, Context> channelContexts = new ConcurrentHashMap<Channel, Context>( MAX, THRESHOLD, CONCUR );
+ static boolean hasOutstandingRequests( ) {
+ return uuidContexts.keySet( ).size( ) > 0;
+ }
+
public static Context create( MappingHttpRequest request, Channel channel ) {
Context ctx = new Context( request, channel );
request.setCorrelationId( ctx.getCorrelationId( ) );
@@ -70,6 +70,7 @@
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -129,7 +130,7 @@ public void fireEvent( Event event ) {
doUpdate( );
}
}
-
+
private Future<?> doUpdate( ) {
if ( Bootstrap.isFinished( ) && this.canHasWrite.tryLock( ) ) {
try {
@@ -145,11 +146,13 @@ public void run( ) {
}
}
} );
- }
+ }
if ( this.shouldReload( ) ) {
this.pendingCount.incrementAndGet( );
}
- return ret != null ? ret : Futures.predestinedFuture( null );
+ return ret != null
+ ? ret
+ : Futures.predestinedFuture( null );
} finally {
this.canHasWrite.unlock( );
}
@@ -171,18 +174,18 @@ private boolean shouldReload( ) {
return false;
}
}
-
+
public static final void restartSync( ) {
singleton.pendingCount.incrementAndGet( );
try {
singleton.doUpdate( ).get( );
} catch ( InterruptedException ex ) {
- LOG.error( ex , ex );
+ LOG.error( ex, ex );
} catch ( ExecutionException ex ) {
- LOG.error( ex , ex );
+ LOG.error( ex, ex );
}
}
-
+
public static final void restart( ) {
singleton.pendingCount.incrementAndGet( );
}
@@ -297,6 +300,13 @@ private void stop( ) {
try {
if ( this.context != null ) {
try {
+ for ( int i = 0; i < 10 && Contexts.hasOutstandingRequests( ); i++ ) {
+ try {
+ TimeUnit.SECONDS.sleep( 1 );
+ } catch ( InterruptedException ex ) {
+ Thread.currentThread( ).interrupt( );
+ }
+ }
this.context.stop( );
this.context.dispose( );
} catch ( MuleException ex ) {
Oops, something went wrong.

0 comments on commit 968b0c7

Please sign in to comment.