Skip to content

Commit

Permalink
Merge pull request #25 from sjones4/topic-cluster-backends
Browse files Browse the repository at this point in the history
Cluster controller backends
  • Loading branch information
sjones4 authored Aug 15, 2018
2 parents 03cf994 + 911effb commit f13f90f
Show file tree
Hide file tree
Showing 42 changed files with 1,638 additions and 1,426 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,6 @@ protected Cluster( final ClusterProvider clusterProvider, final ServiceConfigura
clusterProvider.init( this );
}

@Deprecated
public ClusterProvider getClusterProvider( ) {
return clusterProvider;
}

@Override
public String getName( ) {
return this.configuration.getName();
Expand Down Expand Up @@ -210,21 +205,21 @@ public void start( ) throws ServiceRegistrationException {
}
}

public void enable( ) throws ServiceRegistrationException {
public void enable( ) {
clusterProvider.enable( );
}

public void disable( ) throws ServiceRegistrationException {
public void disable( ) {
try {
clusterProvider.disable();
} finally {
try {
ClusterRegistry.getInstance( ).disable(this.getName());
} catch ( Exception ex ) {}
ClusterRegistry.getInstance( ).disable( this.getName( ) );
} catch ( Exception ignore ) {}
}
}

public void stop( ) throws ServiceRegistrationException {
public void stop( ) {
try {
clusterProvider.stop();
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,7 @@ public class ResourceStateCallback extends StateUpdateMessageCallback<Cluster, D
private static Logger LOG = Logger.getLogger( ResourceStateCallback.class );

public ResourceStateCallback( ) {
super( new DescribeResourcesType( ) {
{
regarding( );
for ( VmType arg0 : new VmTypesSupplier( ).get( ) ) {
getInstanceTypes( ).add( new VmTypeInfo( arg0.getName( ), arg0.getMemory( ), arg0.getDisk( ), arg0.getCpu( ), "sda1" ) {
{
this.setSwap( "sda2", 512 * 1024l * 1024l, "none" );
}
} );
}
}
} );
super( describeResources( ) );
}

/**
Expand Down Expand Up @@ -92,4 +81,20 @@ public void fireException( FailedRequestException t ) {
LOG.debug( "Request to " + this.getSubject( ).getName( ) + " failed: " + t.getMessage( ) );
}

private static DescribeResourcesType describeResources( ) {
final DescribeResourcesType describeResourcesType = new DescribeResourcesType( ).regarding( );
for ( final VmType vmType : new VmTypesSupplier( ).get( ) ) {
describeResourcesType.getInstanceTypes( ).add( new VmTypeInfo(
vmType.getName( ),
vmType.getMemory( ),
vmType.getDisk( ),
vmType.getCpu( ),
"sda1" ) {
{
this.setSwap( "sda2", 512 * 1024l * 1024l, "none" );
}
} );
}
return describeResourcesType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.eucalyptus.cluster.common.msgs.NodeType;
import com.eucalyptus.component.Partition;
import com.eucalyptus.component.ServiceConfiguration;
import com.eucalyptus.component.ServiceRegistrationException;

/**
* ClusterProvider is an internal API for providing cluster functionality.
Expand All @@ -49,10 +48,10 @@ public interface ClusterProvider {
void init( Cluster cluster );
void refreshResources( );
void check( );
void start( ) throws ServiceRegistrationException;
void stop( ) throws ServiceRegistrationException;
void enable( ) throws ServiceRegistrationException;
void disable( ) throws ServiceRegistrationException;
void start( );
void stop( );
void enable( );
void disable( );
void updateNodeInfo( long time, List<NodeType> nodes );
boolean hasNode( String sourceHost );
void cleanup( Cluster cluster, Exception ex );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.eucalyptus.cluster.common.msgs.NodeType;
import com.eucalyptus.component.Partition;
import com.eucalyptus.component.ServiceConfiguration;
import com.eucalyptus.component.ServiceRegistrationException;

/**
*
Expand All @@ -44,9 +43,6 @@ public class TestClusterProvider implements ClusterProvider {
private String partition;
private String hostname;

public TestClusterProvider( ) {
}

@Override
public String getName( ) {
return name;
Expand Down Expand Up @@ -96,19 +92,19 @@ public void check( ) {
}

@Override
public void start( ) throws ServiceRegistrationException {
public void start( ) {
}

@Override
public void stop( ) throws ServiceRegistrationException {
public void stop( ) {
}

@Override
public void enable( ) throws ServiceRegistrationException {
public void enable( ) {
}

@Override
public void disable( ) throws ServiceRegistrationException {
public void disable( ) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
* NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
************************************************************************/

package com.eucalyptus.cluster.proxy.node;
package com.eucalyptus.cluster.node;

import com.eucalyptus.cluster.common.ClusterController;
import com.eucalyptus.component.ComponentId;
import com.eucalyptus.component.annotation.InternalService;
import com.eucalyptus.component.annotation.Partition;
import com.eucalyptus.cluster.proxy.ProxyClusterController;

@Partition( value = { ProxyClusterController.class }, manyToOne = true )
@Partition( value = ClusterController.class, manyToOne = true )
@InternalService
public class ProxyNodeController extends ComponentId {
public class NodeController extends ComponentId {

public ProxyNodeController( ) {
public NodeController( ) {
super( "node" );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
************************************************************************/

package com.eucalyptus.cluster.proxy.node;
package com.eucalyptus.cluster.node;

import java.io.Serializable;
import javax.persistence.Entity;
Expand All @@ -56,13 +56,13 @@
*/
@Entity
@PersistenceContext( name = "eucalyptus_config" )
@ComponentPart( ProxyNodeController.class )
@ComponentPart( NodeController.class )
@ConfigurableClass( root = "node",
alias = "basic",
description = "Node Controller Configuration.",
singleton = false,
deferred = true )
public class ProxyNodeConfiguration extends ComponentConfiguration implements Serializable {
public class NodeControllerConfiguration extends ComponentConfiguration implements Serializable {
@Transient
private static String DEFAULT_SERVICE_PATH = "/axis2/services/EucalyptusNC";
@Transient
Expand All @@ -72,11 +72,11 @@ public class ProxyNodeConfiguration extends ComponentConfiguration implements Se
@ConfigurableIdentifier
private String propertyPrefix;

public ProxyNodeConfiguration( ) {
public NodeControllerConfiguration( ) {
super( );
}

public ProxyNodeConfiguration( String partition, String hostName ) {
public NodeControllerConfiguration( String partition, String hostName ) {
super( partition, hostName, hostName, DEFAULT_SERVICE_PORT, DEFAULT_SERVICE_PATH );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
************************************************************************/

package com.eucalyptus.cluster.proxy.node;
package com.eucalyptus.cluster.node;

import org.apache.log4j.Logger;

Expand All @@ -54,13 +54,13 @@
* @author chris grzegorczyk <[email protected]>
* @todo doc
*/
@ComponentPart(ProxyNodeController.class)
public class ProxyNodeServiceBuilder implements ServiceBuilder<ProxyNodeConfiguration> {
private static Logger LOG = Logger.getLogger( ProxyNodeServiceBuilder.class );
@ComponentPart(NodeController.class)
public class NodeControllerServiceBuilder implements ServiceBuilder<NodeControllerConfiguration> {
private static Logger LOG = Logger.getLogger( NodeControllerServiceBuilder.class );

@Override
public ComponentId getComponentId() {
return ComponentIds.lookup( ProxyNodeController.class );
return ComponentIds.lookup( NodeController.class );
}

@Override
Expand Down Expand Up @@ -141,13 +141,13 @@ public void fireCheck( ServiceConfiguration config ) throws ServiceRegistrationE
}

@Override
public ProxyNodeConfiguration newInstance( String partition, String name, String host, Integer port ) {
return new ProxyNodeConfiguration( partition, host );
public NodeControllerConfiguration newInstance( String partition, String name, String host, Integer port ) {
return new NodeControllerConfiguration( partition, host );
}

@Override
public ProxyNodeConfiguration newInstance() {
return new ProxyNodeConfiguration();
public NodeControllerConfiguration newInstance() {
return new NodeControllerConfiguration();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* NEEDED TO COMPLY WITH ANY SUCH LICENSES OR RIGHTS.
************************************************************************/

package com.eucalyptus.cluster.proxy.node;
package com.eucalyptus.cluster.node;

import java.net.URI;
import java.util.*;
Expand All @@ -56,7 +56,7 @@
import com.eucalyptus.util.async.AsyncRequests;
import com.eucalyptus.util.fsm.TransitionRecord;
import com.google.common.base.*;
import com.google.common.base.Objects;
import com.google.common.base.MoreObjects;
import com.google.common.collect.*;
import edu.ucsb.eucalyptus.msgs.BaseMessage;
import org.apache.log4j.Logger;
Expand Down Expand Up @@ -94,7 +94,7 @@ static Function<NodeInfo, ServiceConfiguration> transformNodeInfo( final Service

@Override
public ServiceConfiguration apply( @Nullable NodeInfo input ) {
ProxyNodeController compId = ComponentIds.lookup( ProxyNodeController.class );
NodeController compId = ComponentIds.lookup( NodeController.class );
Component comp = Components.lookup( compId );
try {
return comp.lookup( input.getName( ) );
Expand Down Expand Up @@ -133,7 +133,7 @@ public static void updateNodeInfo( final long now, final ServiceConfiguration cc
for ( String unreportedTag : unreportedTags ) {
NodeInfo unreportedNode = clusterNodeMap.get( unreportedTag );
if ( unreportedNode != null && ( now - unreportedNode.getLastSeen( ).getTime( ) ) > Nodes.REFRESH_TIMEOUT ) {
Topology.destroy( Components.lookup( ProxyNodeController.class ).lookup( unreportedNode.getName() ) );
Topology.destroy( Components.lookup( NodeController.class ).lookup( unreportedNode.getName() ) );
NodeInfo removed = clusterNodeMap.remove( unreportedTag );
nodeLog.append( "GONE:" ).append( removed.getName() ).append( ":" ).append( removed.getLastState() ).append( " " );
}
Expand Down Expand Up @@ -183,7 +183,7 @@ private static void updateServiceConfiguration( final ServiceConfiguration ccCon
public ServiceConfiguration apply( @Nullable NodeInfo input ) {
if ( Component.State.ENABLED.apply( ccConfig ) && !ccConfig.lookupStateMachine( ).isBusy( ) ) {
ServiceConfiguration ncConfig = Nodes.lookup( ccConfig, input.getName( ) );
Component component = Components.lookup( ProxyNodeController.class );
Component component = Components.lookup( NodeController.class );
if ( !component.hasService( ncConfig ) ) {
component.setup( ncConfig );
try {
Expand Down Expand Up @@ -271,11 +271,11 @@ public String apply( @Nullable NodeInfo nodeInfo ) {
if ( checkException != null ) {
LOG.debug( checkException );
}
checkException = Faults.failure( ncConfig, e, Objects.firstNonNull( checkException, Faults.advisory( ncConfig, lastMessage ) ) );
checkException = Faults.failure( ncConfig, e, MoreObjects.firstNonNull( checkException, Faults.advisory( ncConfig, lastMessage ) ) );
}
}
} finally {
checkException = Objects.firstNonNull( checkException, Faults.advisory( ncConfig, lastMessage ) );
checkException = MoreObjects.firstNonNull( checkException, Faults.advisory( ncConfig, lastMessage ) );
nodeInfo.touch( reportedState, lastMessage, checkException );
Faults.submit( ncConfig, tr, checkException );
}
Expand Down Expand Up @@ -308,7 +308,7 @@ static ServiceConfiguration lookupClusterController( ServiceConfiguration config
}

public static void clusterCleanup( Cluster cluster, Exception e ) {
Threads.enqueue( ProxyNodeController.class, CleanupNodes.class, new CleanupNodes( cluster, e ) );
Threads.enqueue( cluster.getConfiguration( ), CleanupNodes.class, new CleanupNodes( cluster, e ) );
}

public static class CleanupNodes implements Callable<Collection<NodeInfo>> {
Expand Down
Loading

0 comments on commit f13f90f

Please sign in to comment.