Skip to content

Commit

Permalink
Modified UDC to run one thread per DB, and to shut down background th…
Browse files Browse the repository at this point in the history
…read on unload. Closes #279
  • Loading branch information
jakewins committed Apr 2, 2012
1 parent 4d496fd commit 536ba13
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions udc/src/main/java/org/neo4j/ext/udc/impl/UdcExtensionImpl.java
Expand Up @@ -28,6 +28,7 @@
import java.util.Map;
import java.util.Properties;
import java.util.Timer;

import org.neo4j.ext.udc.UdcSettings;
import org.neo4j.helpers.Service;
import org.neo4j.kernel.KernelData;
Expand Down Expand Up @@ -57,7 +58,7 @@ public UdcExtensionImpl()
super( KEY );
}

private static Timer timer = new Timer( "Neo4j UDC Timer", /*isDeamon=*/true );
private Timer timer;

@Override
public Class getSettingsClass()
Expand All @@ -68,6 +69,10 @@ public Class getSettingsClass()
@Override
protected UdcTimerTask load( KernelData kernel )
{
if(timer != null) {
timer.cancel();
}

Map<String, String> conf = loadSystemProperties();
conf.putAll( kernel.getConfigParams());
Config config = new Config( conf );
Expand All @@ -86,14 +91,19 @@ protected UdcTimerTask load( KernelData kernel )
String version = kernel.version().getRevision();
if ( version.equals( "" ) ) version = kernel.version().getVersion();
UdcTimerTask task = new UdcTimerTask( hostAddress, version, storeId, source, crashPing, registration, formattedMacAddy() );

timer = new Timer( "Neo4j UDC Timer", /*isDeamon=*/true );
timer.scheduleAtFixedRate( task, firstDelay, interval );

return task;
}

@Override
protected void unload( UdcTimerTask task )
{
task.cancel();
if(timer != null) {
timer.cancel();
}
}

private Map<String,String> loadSystemProperties()
Expand Down

0 comments on commit 536ba13

Please sign in to comment.