Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Dev/grze/euca 5133 #20

Closed
wants to merge 11 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static void register( ) {

@Override
public void fireEvent( ClockTick event ) {
if ( Hosts.isCoordinator( ) && ready.compareAndSet( true, false ) ) {
if ( Topology.isEnabledLocally( Eucalyptus.class ) && ready.compareAndSet( true, false ) ) {
try {
Threads.enqueue( Eucalyptus.class, Snapshots.class, this );
} catch ( Exception ex ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public static void register( ) {

@Override
public void fireEvent( final ClockTick event ) {
if ( Hosts.isCoordinator( ) && ready.compareAndSet( true, false ) ) {
if ( Topology.isEnabledLocally( Eucalyptus.class ) && ready.compareAndSet( true, false ) ) {
try {
Threads.enqueue( Eucalyptus.class, Volumes.class, this );
} catch ( final Exception ex ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NaturalId;
import org.hibernate.annotations.Type;
import org.hibernate.type.StringClobType;
import org.jboss.netty.util.internal.LinkedTransferQueue;
import com.eucalyptus.bootstrap.Bootstrap;
import com.eucalyptus.bootstrap.BootstrapArgs;
Expand All @@ -111,8 +110,8 @@
import com.eucalyptus.configurable.ConfigurableField;
import com.eucalyptus.empyrean.ServiceStatusDetail;
import com.eucalyptus.empyrean.ServiceStatusType;
import com.eucalyptus.event.ClockTick;
import com.eucalyptus.event.EventListener;
import com.eucalyptus.event.Hertz;
import com.eucalyptus.event.Listeners;
import com.eucalyptus.records.Logs;
import com.eucalyptus.scripting.Groovyness;
Expand Down Expand Up @@ -634,17 +633,17 @@ public static void submit( final ServiceConfiguration parent, TransitionRecord<S
}
}

public static class FaultNotificationHandler implements EventListener<ClockTick>, Callable<Boolean> {
public static class FaultNotificationHandler implements EventListener<Hertz>, Callable<Boolean> {
private static final AtomicBoolean ready = new AtomicBoolean( true );
private static final AtomicLong lastDigest = new AtomicLong( System.currentTimeMillis( ) );

public static void register( ) {
Listeners.register( ClockTick.class, new FaultNotificationHandler( ) );
Listeners.register( Hertz.class, new FaultNotificationHandler( ) );
}

@Override
public void fireEvent( final ClockTick event ) {
if ( BootstrapArgs.isCloudController( ) && ready.compareAndSet( true, false ) ) {
public void fireEvent( final Hertz event ) {
if ( Bootstrap.isOperational( ) && event.isAsserted( Faults.BATCH_DELAY_SECONDS ) && ready.compareAndSet( true, false ) ) {
try {
Threads.enqueue( Eucalyptus.class, Faults.class, this );
} catch ( final Exception ex ) {
Expand All @@ -656,7 +655,6 @@ public void fireEvent( final ClockTick event ) {
@Override
public Boolean call( ) throws Exception {
try {
TimeUnit.SECONDS.sleep( Faults.BATCH_DELAY_SECONDS );
sendFaults( );
sendDigest( );
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
package com.eucalyptus.reporting.modules.backend;

import org.apache.log4j.Logger;

import com.eucalyptus.bootstrap.Bootstrap;
import com.eucalyptus.bootstrap.BootstrapArgs;
import com.eucalyptus.bootstrap.Hosts;
import com.eucalyptus.cluster.callback.DescribeSensorCallback;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -56,16 +55,18 @@ public class DescribeSensorsListener implements EventListener<Hertz> {
private Integer HISTORY_SIZE = 5;
private Integer MAX_WRITE_INTERVAL_MS = 86400000;
private Integer SENSOR_QUERY_BATCH_SIZE = 10;

private static final Logger LOG = Logger.getLogger(DescribeSensorsListener.class);

public static void register() {
Listeners.register( Hertz.class, new DescribeSensorsListener() );
}

@Override
public void fireEvent( Hertz event ) {

if ( !Bootstrap.isOperational( ) || !BootstrapArgs.isCloudController( ) || !event.isAsserted( DEFAULT_POLL_INTERVAL_MINS ) ) {
return;
} else {
if (DEFAULT_POLL_INTERVAL_MINS >= 1) {
COLLECTION_INTERVAL_TIME_MS = ((int) TimeUnit.MINUTES
.toMillis(DEFAULT_POLL_INTERVAL_MINS) / 2);
Expand Down Expand Up @@ -118,6 +119,6 @@ public void fireEvent( Hertz event ) {
+ DEFAULT_POLL_INTERVAL_MINS
+ " must be less than 1440 minutes");
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.eucalyptus.bootstrap.Bootstrap;
import com.eucalyptus.bootstrap.Hosts;
import com.eucalyptus.cluster.Clusters;
import com.eucalyptus.component.Topology;
import com.eucalyptus.component.id.Storage;
import com.eucalyptus.entities.TransactionException;
import com.eucalyptus.entities.Transactions;
import com.eucalyptus.event.ClockTick;
Expand All @@ -45,15 +47,15 @@
* Event listener that fires resource availability events for block storage.
*/
public class BlockStorageAvailabilityEventListener implements EventListener<ClockTick> {
private static Logger logger = Logger.getLogger( WalrusAvailabilityEventListener.class );
private static Logger logger = Logger.getLogger( BlockStorageAvailabilityEventListener.class );

public static void register( ) {
Listeners.register( ClockTick.class, new BlockStorageAvailabilityEventListener() );
}

@Override
public void fireEvent( final ClockTick event ) {
if ( Bootstrap.isFinished() && Hosts.isCoordinator() ) {
if ( Topology.isEnabledLocally( Storage.class ) && Bootstrap.isFinished() ) {
final List<Availability> resourceAvailability = Lists.newArrayList();
final Set<String> partitions =
Sets.newHashSet( Iterables.transform( Clusters.getInstance().listValues(), HasFullName.GET_PARTITION ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.logicalcobwebs.proxool.ProxoolException;
import org.logicalcobwebs.proxool.ProxoolFacade;

import com.eucalyptus.bootstrap.OrderedShutdown;
import com.eucalyptus.component.ComponentId;
import com.eucalyptus.component.ComponentIds;
import com.eucalyptus.component.Faults;
Expand All @@ -57,6 +58,16 @@
public class DBResourceCheck extends Thread {
private final static Logger LOG = Logger.getLogger(DBResourceCheck.class);
private static final ScheduledExecutorService pool = Executors.newSingleThreadScheduledExecutor();
private static final Runnable shutdownHook = new Runnable( ) {

@Override
public void run( ) {
if ( !pool.isShutdown( ) ) {
pool.shutdownNow( );
}
}

};
private static final int OUT_OF_DB_CONNECTIONS_FAULT_ID = 1006;
private final static long DEFAULT_POLL_INTERVAL = 60 * 1000;
private static final Class<? extends ComponentId> DEFAULT_COMPONENT_ID_CLASS = Eucalyptus.class;
Expand All @@ -65,6 +76,7 @@ public class DBResourceCheck extends Thread {
* Marking the constructor private on purpose, so that no code can instantiate an object this class
*/
private DBResourceCheck() {}

/**
* <p>
* Kicks off an infinite series of disk resource checks with a delay in between consecutive checks. {@link ScheduledExecutorService#scheduleWithFixedDelay
Expand All @@ -81,6 +93,7 @@ private DBResourceCheck() {}
* @return ScheduledFuture
*/
public static ScheduledFuture<?> start(DBChecker checker) {
OrderedShutdown.registerPreShutdownHook( shutdownHook );
return pool.scheduleWithFixedDelay(checker, 0, checker.pollInterval, TimeUnit.MILLISECONDS);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import org.apache.log4j.Logger;
import com.eucalyptus.bootstrap.Bootstrap;
import com.eucalyptus.bootstrap.Hosts;
import com.eucalyptus.component.Topology;
import com.eucalyptus.component.id.Walrus;
import com.eucalyptus.event.ClockTick;
import com.eucalyptus.event.EventListener;
import com.eucalyptus.event.ListenerRegistry;
Expand All @@ -45,7 +47,7 @@ public static void register( ) {

@Override
public void fireEvent( final ClockTick event ) {
if ( Bootstrap.isFinished() && Hosts.isCoordinator() ) {
if ( Topology.isEnabledLocally( Walrus.class ) && Bootstrap.isFinished() ) {
try {

WalrusInfo wInfo = WalrusInfo.getWalrusInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public boolean enable( ) throws Exception {
*/
@Override
public boolean stop( ) throws Exception {
jettyServer.stop( );
return true;
}

Expand Down