Skip to content

Commit

Permalink
Moved UdcSettings out from UDC, so the server can start without the u…
Browse files Browse the repository at this point in the history
…dc-jar in place
  • Loading branch information
systay committed Jul 2, 2012
1 parent b632e23 commit c1ec3ef
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,47 @@ public abstract class GraphDatabaseSettings
@Description( "The minimal time that must pass in between logging statistics from the cache (when using the 'gcr' cache)." )
@Default( "60s" )
public static final TimeSpanSetting gcr_cache_min_log_interval = new TimeSpanSetting( "gcr_cache_min_log_interval");


/**
* Configuration key for enabling the UDC extension. Set to "false"
* to disable; any other value is considered false.
*/
@Default( TRUE)
public static final GraphDatabaseSetting.BooleanSetting udc_enabled = new GraphDatabaseSetting.BooleanSetting("neo4j.ext.udc.enabled");

/**
* Configuration key for the first delay, expressed
* in milliseconds.
*/
@Default( ""+10 * 1000 * 60 )
public static final GraphDatabaseSetting.IntegerSetting first_delay = new GraphDatabaseSetting.IntegerSetting("neo4j.ext.udc.first_delay", "Must be nr of milliseconds to delay", 1, null);

/**
* Configuration key for the interval for regular updates,
* expressed in milliseconds.
*/
@Default(""+1000 * 60 * 60 * 24)
public static final GraphDatabaseSetting.IntegerSetting interval = new GraphDatabaseSetting.IntegerSetting("neo4j.ext.udc.interval", "Must be nr of milliseconds of the interval for checking", 1, null);

/**
* The host address to which UDC updates will be sent.
* Should be of the form hostname[:port].
*/
@Default( "udc.neo4j.org" )
public static final GraphDatabaseSetting.StringSetting udc_host = new GraphDatabaseSetting.StringSetting( "neo4j.ext.udc.host", ANY, "Must be a valid hostname");

/**
* Configuration key for overriding the source parameter in UDC
*/
public static final GraphDatabaseSetting.StringSetting udc_source = new GraphDatabaseSetting.StringSetting("neo4j.ext.udc.source", ANY, "Must be a valid source");

/**
* Unique registration id
*/
@Default( "unreg" )
public static final GraphDatabaseSetting.StringSetting udc_registration_key = new GraphDatabaseSetting.StringSetting( "neo4j.ext.udc.reg", ANY, "Must be a valid registration id" );


// Specialized settings
public static class CacheTypeSetting
extends OptionsSetting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.util.Map;

import org.apache.commons.configuration.Configuration;
import org.neo4j.ext.udc.UdcSettings;
import org.neo4j.graphdb.factory.GraphDatabaseSetting;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.collection.MapUtil;
Expand Down Expand Up @@ -98,7 +97,7 @@ protected Map<String, String> loadNeo4jProperties() {

putIfAbsent( neo4jProperties, ShellSettings.remote_shell_enabled.name(), GraphDatabaseSetting.TRUE );
putIfAbsent( neo4jProperties, GraphDatabaseSettings.keep_logical_logs.name(), GraphDatabaseSetting.TRUE );
neo4jProperties.put( UdcSettings.udc_source.name(), "server" );
neo4jProperties.put( GraphDatabaseSettings.udc_source.name(), "server" );

return neo4jProperties;
}
Expand Down
3 changes: 1 addition & 2 deletions server/src/main/java/org/neo4j/server/database/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.HashMap;
import java.util.Map;

import org.neo4j.ext.udc.UdcSettings;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.factory.GraphDatabaseSetting;
Expand Down Expand Up @@ -117,7 +116,7 @@ private static GraphDatabaseAPI createDatabase( GraphDatabaseFactory factory, St

putIfAbsent( databaseProperties, ShellSettings.remote_shell_enabled.name(), GraphDatabaseSetting.TRUE );
putIfAbsent( databaseProperties, GraphDatabaseSettings.keep_logical_logs.name(), GraphDatabaseSetting.TRUE );
databaseProperties.put( UdcSettings.udc_source.name(), "server" );
databaseProperties.put( GraphDatabaseSettings.udc_source.name(), "server" );

return factory.createDatabase( databaseStoreDirectory, databaseProperties );
}
Expand Down
72 changes: 0 additions & 72 deletions udc/src/main/java/org/neo4j/ext/udc/UdcSettings.java

This file was deleted.

16 changes: 8 additions & 8 deletions udc/src/main/java/org/neo4j/ext/udc/impl/UdcExtensionImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import java.util.regex.Pattern;

import org.neo4j.ext.udc.Edition;
import org.neo4j.ext.udc.UdcSettings;
import org.neo4j.graphdb.factory.GraphDatabaseSetting;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.helpers.Service;
import org.neo4j.helpers.collection.MapUtil;
import org.neo4j.kernel.KernelData;
Expand Down Expand Up @@ -69,7 +69,7 @@ public UdcExtensionImpl()
@Override
public Class getSettingsClass()
{
return UdcSettings.class;
return GraphDatabaseSettings.class;
}

@Override
Expand All @@ -81,13 +81,13 @@ protected UdcTimerTask load( KernelData kernel )

Config config = loadConfig(kernel);

if ( !config.getBoolean( UdcSettings.udc_enabled )) return null;
if ( !config.getBoolean( GraphDatabaseSettings.udc_enabled )) return null;

int firstDelay = config.getInteger( UdcSettings.first_delay);
int interval = config.getInteger( UdcSettings.interval );
String hostAddress = config.get( UdcSettings.udc_host );
String source = config.get( UdcSettings.udc_source );
String registration = config.get( UdcSettings.udc_registration_key );
int firstDelay = config.getInteger( GraphDatabaseSettings.first_delay);
int interval = config.getInteger( GraphDatabaseSettings.interval );
String hostAddress = config.get( GraphDatabaseSettings.udc_host );
String source = config.get( GraphDatabaseSettings.udc_source );
String registration = config.get( GraphDatabaseSettings.udc_registration_key );
Integer clusterNameHash = determineClusterNameHash(config);
NeoStoreXaDataSource ds = kernel.graphDatabase().getXaDataSourceManager().getNeoStoreDataSource();
boolean crashPing = ds.getXaContainer().getLogicalLog().wasNonClean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
import org.junit.Before;
import org.junit.Test;
import org.neo4j.ext.udc.Edition;
import org.neo4j.ext.udc.UdcSettings;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.GraphDatabaseAPI;
// import org.neo4j.kernel.ha.HaSettings;

Expand Down Expand Up @@ -114,8 +114,8 @@ public void shouldRecordFailuresWhenThereIsNoServer() throws Exception
{
GraphDatabaseService graphdb = new GraphDatabaseFactory().
newEmbeddedDatabaseBuilder( "should-record-failures").
setConfig( UdcSettings.first_delay, "100" ).
setConfig( UdcSettings.udc_host, "127.0.0.1:1" ).
setConfig( GraphDatabaseSettings.first_delay, "100" ).
setConfig( GraphDatabaseSettings.udc_host, "127.0.0.1:1" ).
newGraphDatabase();
assertGotFailureWithRetry( IS_GREATER_THAN_ZERO );
destroy( graphdb );
Expand Down Expand Up @@ -154,8 +154,8 @@ private void setupServer() throws Exception {
serverAddress = hostname + ":" + server.getServicePort();

config = new HashMap<String, String>();
config.put(UdcSettings.first_delay.name(), "100");
config.put(UdcSettings.udc_host.name(), serverAddress);
config.put(GraphDatabaseSettings.first_delay.name(), "100");
config.put(GraphDatabaseSettings.udc_host.name(), serverAddress);
}

@Test
Expand All @@ -164,7 +164,7 @@ public void shouldNotBeAbleToSpecifyRegistrationIdWithConfig() throws Exception

setupServer();

config.put( UdcSettings.udc_registration_key.name(), "marketoid" );
config.put( GraphDatabaseSettings.udc_registration_key.name(), "marketoid" );

GraphDatabaseService graphdb = createTempDatabase( config );
assertGotSuccessWithRetry( IS_GREATER_THAN_ZERO );
Expand Down

0 comments on commit c1ec3ef

Please sign in to comment.