Permalink
Browse files

Add executors to Listeners

Handle shutdown properly in LogbackService
Renamed API for clustering to ClusterEvents
Implemented ClusterEvents
Added ClusterDiscovery API
Updated settings for HA
Change HA to use URI more than URL
  • Loading branch information...
1 parent f06460f commit 938380aba4ee13970743d7c14662de9fe8d38822 @rickardoberg rickardoberg committed Jun 29, 2012
View
39 kernel/src/main/java/org/neo4j/helpers/Listeners.java
@@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
+import java.util.concurrent.Executor;
/**
* Helper class for dealing with listeners
@@ -57,14 +58,42 @@
{
for( T listener : listeners )
{
- try
+ synchronized( listener )
{
- notification.notify( listener );
+ try
+ {
+ notification.notify( listener );
+ }
+ catch( Throwable e )
+ {
+ e.printStackTrace();
+ }
}
- catch( Exception e )
+ }
+ }
+
+ public static <T> void notifyListeners(Iterable<T> listeners, Executor executor, final Notification<T> notification)
+ {
+ for( final T listener : listeners )
+ {
+ executor.execute( new Runnable()
{
- // Ignore
- }
+ @Override
+ public void run()
+ {
+ synchronized( listener )
+ {
+ try
+ {
+ notification.notify( listener );
+ }
+ catch( Throwable e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+ });
}
}
}
View
76 kernel/src/main/java/org/neo4j/kernel/logging/LogbackService.java
@@ -59,55 +59,59 @@ public void init()
throws Throwable
{
final String storeDir = config.get( InternalAbstractGraphDatabase.Configuration.store_dir );
-
- File file = new File( storeDir ).getAbsoluteFile();
- if (!file.exists())
- file.mkdirs();
-
- loggerContext = (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory();
-
- // Neo4j specific log config
- loggingLife.add( new LifecycleAdapter()
+
+ if (storeDir != null)
{
- @Override
- public void start()
- throws Throwable
+ File file = new File( storeDir ).getAbsoluteFile();
+ if (!file.exists())
+ file.mkdirs();
+
+ loggerContext = (LoggerContext) StaticLoggerBinder.getSingleton().getLoggerFactory();
+
+ // Neo4j specific log config
+ loggingLife.add( new LifecycleAdapter()
{
- JoranConfigurator configurator = new JoranConfigurator();
- configurator.setContext( loggerContext );
- loggerContext.putProperty( "neo_store", storeDir );
- loggerContext.putProperty( "remote_logging_enabled", config.get( GraphDatabaseSettings.remote_logging_enabled ).toString() );
- loggerContext.putProperty( "remote_logging_host", config.get( GraphDatabaseSettings.remote_logging_host ) );
- loggerContext.putProperty( "remote_logging_port", config.get( GraphDatabaseSettings.remote_logging_port ).toString() );
- try
+ @Override
+ public void start()
+ throws Throwable
{
- configurator.doConfigure( getClass().getResource( "/neo4j-logback.xml" ) );
+ JoranConfigurator configurator = new JoranConfigurator();
+ configurator.setContext( loggerContext );
+ loggerContext.putProperty( "neo_store", storeDir );
+ loggerContext.putProperty( "remote_logging_enabled", config.get( GraphDatabaseSettings.remote_logging_enabled ).toString() );
+ loggerContext.putProperty( "remote_logging_host", config.get( GraphDatabaseSettings.remote_logging_host ) );
+ loggerContext.putProperty( "remote_logging_port", config.get( GraphDatabaseSettings.remote_logging_port ).toString() );
+ try
+ {
+ configurator.doConfigure( getClass().getResource( "/neo4j-logback.xml" ) );
+ }
+ catch( JoranException e )
+ {
+ throw new IllegalStateException("Failed to configure logging", e );
+ }
}
- catch( JoranException e )
+
+ @Override
+ public void stop()
+ throws Throwable
{
- throw new IllegalStateException("Failed to configure logging", e );
+ loggerContext.getLogger( Loggers.NEO4J ).detachAndStopAllAppenders();
}
- }
-
- @Override
- public void stop()
- throws Throwable
- {
- loggerContext.getLogger( Loggers.NEO4J ).detachAndStopAllAppenders();
- }
- });
- loggingLife.start();
-
- restartOnChange = new RestartOnChange( "remote_logging_", loggingLife );
- config.addConfigurationChangeListener( restartOnChange );
+ });
+ loggingLife.start();
+
+ restartOnChange = new RestartOnChange( "remote_logging_", loggingLife );
+ config.addConfigurationChangeListener( restartOnChange );
+ }
}
@Override
public void shutdown()
throws Throwable
{
loggingLife.shutdown();
- config.removeConfigurationChangeListener( restartOnChange );
+ if (restartOnChange != null)
+ config.removeConfigurationChangeListener( restartOnChange );
}
@Override

0 comments on commit 938380a

Please sign in to comment.