Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' into 4bplus

Conflicts:
	kernel/src/main/java/org/neo4j/kernel/Config.java
	kernel/src/test/java/org/neo4j/kernel/impl/nioneo/store/TestXa.java
  • Loading branch information...
commit d16080b27be71ac90507fbd7121cad321825c067 2 parents 9641404 + 2363559
Mattias Persson tinwelint authored

Showing 50 changed files with 1,234 additions and 204 deletions. Show diff stats Hide diff stats

  1. +8 0 com/src/main/java/org/neo4j/com/MasterUtil.java
  2. +3 1 com/src/main/java/org/neo4j/com/backup/OnlineBackupExtension.java
  3. +7 4 com/src/test/java/org/neo4j/com/backup/TestBackup.java
  4. +6 1 com/src/test/java/org/neo4j/com/backup/TestConfiguration.java
  5. +44 0 com/src/test/java/org/neo4j/com/backup/TestOnlineBackupExtension.java
  6. +6 0 graph-algo/src/main/java/org/neo4j/graphalgo/CommonEvaluators.java
  7. +42 0 graph-algo/src/main/java/org/neo4j/graphalgo/impl/util/DoubleEvaluatorWithDefault.java
  8. +24 1 graph-algo/src/test/java/common/Neo4jAlgoTestCase.java
  9. +45 7 graph-algo/src/test/java/org/neo4j/graphalgo/path/TestDijkstra.java
  10. +5 1 ha/src/test/java/org/neo4j/ha/LocalhostZooKeeperCluster.java
  11. +19 0 ha/src/test/java/slavetest/AbstractHaTest.java
  12. +2 0  ha/src/test/java/slavetest/MultiJvmTest.java
  13. +3 0  ha/src/test/java/slavetest/MultiJvmWithZooKeeperTest.java
  14. +3 0  ha/src/test/java/slavetest/SingleJvmTest.java
  15. +2 0  ha/src/test/java/slavetest/SingleJvmWithNettyTest.java
  16. +4 13 integration-test/pom.xml
  17. +173 0 kernel/src/docs/ops/cache.txt
  18. +17 0 kernel/src/docs/ops/index.txt
  19. +38 0 kernel/src/docs/ops/jvm.txt
  20. +1 0  kernel/src/docs/{dev → ops}/short-strings.txt
  21. +10 4 kernel/src/main/java/org/neo4j/kernel/Config.java
  22. +25 17 kernel/src/main/java/org/neo4j/kernel/EmbeddedGraphDbImpl.java
  23. +3 2 kernel/src/main/java/org/neo4j/kernel/KernelData.java
  24. +30 10 kernel/src/main/java/org/neo4j/kernel/KernelExtension.java
  25. +21 0 kernel/src/main/java/org/neo4j/kernel/KernelExtensionLoader.java
  26. +1 1  kernel/src/main/java/org/neo4j/kernel/Version.java
  27. +18 0 kernel/src/main/java/org/neo4j/kernel/impl/nioneo/store/CommonAbstractStore.java
  28. +6 1 kernel/src/main/java/org/neo4j/kernel/impl/nioneo/store/PersistenceWindowPool.java
  29. +0 2  kernel/src/main/java/org/neo4j/kernel/impl/nioneo/xa/NeoStoreXaDataSource.java
  30. +9 10 kernel/src/main/java/org/neo4j/kernel/impl/transaction/xaframework/XaLogicalLog.java
  31. +47 0 kernel/src/test/java/org/neo4j/kernel/DummyExtension.java
  32. +282 0 kernel/src/test/java/org/neo4j/kernel/KernelExtensionContractTest.java
  33. +54 0 kernel/src/test/java/org/neo4j/kernel/TestKernelExtension.java
  34. +8 2 kernel/src/test/java/org/neo4j/kernel/impl/AbstractNeo4jTestCase.java
  35. +1 1  kernel/src/test/java/org/neo4j/kernel/impl/core/TestCacheTypes.java
  36. +1 1  kernel/src/test/java/org/neo4j/kernel/impl/core/TestChangingOfLogFormat.java
  37. +39 14 kernel/src/test/java/org/neo4j/kernel/impl/core/TestExceptionTypeOnInvalidIds.java
  38. +48 41 kernel/src/test/java/org/neo4j/kernel/impl/core/TestReadOnlyNeo4j.java
  39. +53 32 kernel/src/test/java/org/neo4j/kernel/impl/nioneo/store/TestXa.java
  40. +1 0  kernel/src/test/resources/META-INF/services/org.neo4j.kernel.KernelExtension
  41. +4 3 lucene-index/src/main/java/org/neo4j/index/impl/lucene/LuceneBatchInserterIndex.java
  42. +18 11 lucene-index/src/test/java/org/neo4j/index/impl/lucene/BaseWorker.java
  43. +19 13 lucene-index/src/test/java/org/neo4j/index/impl/lucene/TestLuceneBatchInsert.java
  44. +0 5 lucene-index/src/test/java/org/neo4j/index/impl/lucene/WorkThread.java
  45. +13 4 management/pom.xml
  46. +2 1  management/src/main/java/org/neo4j/management/impl/JmxExtension.java
  47. +30 0 management/src/test/java/org/neo4j/management/impl/TestJmxExtension.java
  48. +7 0 udc/pom.xml
  49. +2 1  udc/src/main/java/org/neo4j/ext/udc/impl/UdcExtensionImpl.java
  50. +30 0 udc/src/test/java/org/neo4j/ext/udc/impl/TestUdcExtensionImpl.java
8 com/src/main/java/org/neo4j/com/MasterUtil.java
@@ -74,11 +74,19 @@ private static String relativePath( File baseDir, File storeFile ) throws FileNo
74 74
75 75 public static SlaveContext rotateLogsAndStreamStoreFiles( GraphDatabaseService graphDb, StoreWriter writer )
76 76 {
  77 + if ( Config.osIsWindows() )
  78 + {
  79 + throw new UnsupportedOperationException(
  80 + "Streaming store files live (as used in HA and backup) "
  81 + + "isn't supported on Windows due to limitations in OS/filesystem" );
  82 + }
  83 +
77 84 File baseDir = getBaseDir( graphDb );
78 85 XaDataSourceManager dsManager =
79 86 ((AbstractGraphDatabase) graphDb).getConfig().getTxModule().getXaDataSourceManager();
80 87 Collection<XaDataSource> sources = dsManager.getAllRegisteredDataSources();
81 88
  89 + @SuppressWarnings( "unchecked" )
82 90 Pair<String, Long>[] appliedTransactions = new Pair[sources.size()];
83 91 int i = 0;
84 92 for ( XaDataSource ds : sources )
4 com/src/main/java/org/neo4j/com/backup/OnlineBackupExtension.java
@@ -32,9 +32,11 @@
32 32 @Service.Implementation( KernelExtension.class )
33 33 public class OnlineBackupExtension extends KernelExtension<BackupServer>
34 34 {
  35 + static final String KEY = "online backup";
  36 +
35 37 public OnlineBackupExtension()
36 38 {
37   - super( "online backup" );
  39 + super( KEY );
38 40 }
39 41
40 42 @Override
11 com/src/test/java/org/neo4j/com/backup/TestBackup.java
@@ -40,12 +40,14 @@
40 40 public class TestBackup
41 41 {
42 42 private String serverPath = "target/var/serverdb";
  43 + private String otherServerPath = serverPath + "2";
43 44 private String backupPath = "target/var/backuedup-serverdb";
44 45
45 46 @Before
46 47 public void before() throws Exception
47 48 {
48 49 FileUtils.deleteDirectory( new File( serverPath ) );
  50 + FileUtils.deleteDirectory( new File( otherServerPath ) );
49 51 FileUtils.deleteDirectory( new File( backupPath ) );
50 52 }
51 53
@@ -89,6 +91,7 @@ public void makeSureIncrementalFailsWhenNoDb() throws Exception
89 91 @Test
90 92 public void fullThenIncremental() throws Exception
91 93 {
  94 + if ( Config.osIsWindows() ) return;
92 95 DbRepresentation initialDataSetRepresentation = createInitialDataSet( serverPath );
93 96 ServerInterface server = startServer( serverPath );
94 97 OnlineBackup backup = OnlineBackup.from( "localhost" );
@@ -106,6 +109,7 @@ public void fullThenIncremental() throws Exception
106 109 @Test
107 110 public void makeSureStoreIdIsEnforced() throws Exception
108 111 {
  112 + if ( Config.osIsWindows() ) return;
109 113 // Create data set X on server A
110 114 DbRepresentation initialDataSetRepresentation = createInitialDataSet( serverPath );
111 115 ServerInterface server = startServer( serverPath );
@@ -117,10 +121,9 @@ public void makeSureStoreIdIsEnforced() throws Exception
117 121 shutdownServer( server );
118 122
119 123 // Create data set X+Y on server B
120   - String serverPath2 = serverPath + "2";
121   - createInitialDataSet( serverPath2 );
122   - addMoreData( serverPath2 );
123   - server = startServer( serverPath2 );
  124 + createInitialDataSet( otherServerPath );
  125 + addMoreData( otherServerPath );
  126 + server = startServer( otherServerPath );
124 127
125 128 // Try to grab incremental backup from server B.
126 129 // Data should be OK, but store id check should prevent that.
7 com/src/test/java/org/neo4j/com/backup/TestConfiguration.java
@@ -29,21 +29,24 @@
29 29 import org.junit.Before;
30 30 import org.junit.Test;
31 31 import org.neo4j.graphdb.GraphDatabaseService;
  32 +import org.neo4j.kernel.Config;
32 33 import org.neo4j.kernel.EmbeddedGraphDatabase;
33 34
34 35 public class TestConfiguration
35 36 {
  37 + private static final String SOURCE_DIR = "target/db";
36 38 private static final String BACKUP_DIR = "target/full-backup";
37 39
38 40 @Before
39 41 public void before() throws Exception
40 42 {
  43 + FileUtils.deleteDirectory( new File( SOURCE_DIR ) );
41 44 FileUtils.deleteDirectory( new File( BACKUP_DIR ) );
42 45 }
43 46
44 47 private GraphDatabaseService newDb( String onlineBackupConfig )
45 48 {
46   - String path = "target/db";
  49 + String path = SOURCE_DIR;
47 50 return onlineBackupConfig == null ?
48 51 new EmbeddedGraphDatabase( path ) :
49 52 new EmbeddedGraphDatabase( path, stringMap( ENABLE_ONLINE_BACKUP, onlineBackupConfig ) );
@@ -82,6 +85,7 @@ public void testOffByConfig() throws Exception
82 85 @Test
83 86 public void testEnableDefaultsInConfig() throws Exception
84 87 {
  88 + if ( Config.osIsWindows() ) return;
85 89 GraphDatabaseService db = newDb( "true" );
86 90 OnlineBackup.from( "localhost" ).full( BACKUP_DIR );
87 91 db.shutdown();
@@ -90,6 +94,7 @@ public void testEnableDefaultsInConfig() throws Exception
90 94 @Test
91 95 public void testEnableCustomPortInConfig() throws Exception
92 96 {
  97 + if ( Config.osIsWindows() ) return;
93 98 int customPort = 12345;
94 99 GraphDatabaseService db = newDb( "port=" + customPort );
95 100 try
44 com/src/test/java/org/neo4j/com/backup/TestOnlineBackupExtension.java
... ... @@ -0,0 +1,44 @@
  1 +/**
  2 + * Copyright (c) 2002-2011 "Neo Technology,"
  3 + * Network Engine for Objects in Lund AB [http://neotechnology.com]
  4 + *
  5 + * This file is part of Neo4j.
  6 + *
  7 + * Neo4j is free software: you can redistribute it and/or modify
  8 + * it under the terms of the GNU Affero General Public License as
  9 + * published by the Free Software Foundation, either version 3 of the
  10 + * License, or (at your option) any later version.
  11 + *
  12 + * This program is distributed in the hope that it will be useful,
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15 + * GNU Affero General Public License for more details.
  16 + *
  17 + * You should have received a copy of the GNU Affero General Public License
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19 + */
  20 +package org.neo4j.com.backup;
  21 +
  22 +import java.util.Map;
  23 +
  24 +import org.neo4j.kernel.Config;
  25 +import org.neo4j.kernel.KernelExtensionContractTest;
  26 +
  27 +public class TestOnlineBackupExtension extends KernelExtensionContractTest<BackupServer, OnlineBackupExtension>
  28 +{
  29 + public TestOnlineBackupExtension()
  30 + {
  31 + super( OnlineBackupExtension.KEY, OnlineBackupExtension.class );
  32 + }
  33 +
  34 + @Override
  35 + protected Map<String, String> configuration( boolean shouldLoad, int instance )
  36 + {
  37 + Map<String, String> configuration = super.configuration( shouldLoad, instance );
  38 + if ( shouldLoad )
  39 + {
  40 + configuration.put( Config.ENABLE_ONLINE_BACKUP, "port=" + ( BackupServer.DEFAULT_PORT + instance ) );
  41 + }
  42 + return configuration;
  43 + }
  44 +}
6 graph-algo/src/main/java/org/neo4j/graphalgo/CommonEvaluators.java
@@ -20,6 +20,7 @@
20 20 package org.neo4j.graphalgo;
21 21
22 22 import org.neo4j.graphalgo.impl.util.DoubleEvaluator;
  23 +import org.neo4j.graphalgo.impl.util.DoubleEvaluatorWithDefault;
23 24 import org.neo4j.graphalgo.impl.util.GeoEstimateEvaluator;
24 25 import org.neo4j.graphalgo.impl.util.IntegerEvaluator;
25 26
@@ -36,6 +37,11 @@
36 37 return new DoubleEvaluator( relationshipCostPropertyKey );
37 38 }
38 39
  40 + public static CostEvaluator<Double> doubleCostEvaluator( String relationshipCostPropertyKey, double defaultCost )
  41 + {
  42 + return new DoubleEvaluatorWithDefault( relationshipCostPropertyKey, defaultCost );
  43 + }
  44 +
39 45 public static CostEvaluator<Integer> intCostEvaluator( String relationshipCostPropertyKey )
40 46 {
41 47 return new IntegerEvaluator( relationshipCostPropertyKey );
42 graph-algo/src/main/java/org/neo4j/graphalgo/impl/util/DoubleEvaluatorWithDefault.java
... ... @@ -0,0 +1,42 @@
  1 +/**
  2 + * Copyright (c) 2002-2011 "Neo Technology,"
  3 + * Network Engine for Objects in Lund AB [http://neotechnology.com]
  4 + *
  5 + * This file is part of Neo4j.
  6 + *
  7 + * Neo4j is free software: you can redistribute it and/or modify
  8 + * it under the terms of the GNU Affero General Public License as
  9 + * published by the Free Software Foundation, either version 3 of the
  10 + * License, or (at your option) any later version.
  11 + *
  12 + * This program is distributed in the hope that it will be useful,
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15 + * GNU Affero General Public License for more details.
  16 + *
  17 + * You should have received a copy of the GNU Affero General Public License
  18 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19 + */
  20 +package org.neo4j.graphalgo.impl.util;
  21 +
  22 +import org.neo4j.graphalgo.CostEvaluator;
  23 +import org.neo4j.graphdb.Direction;
  24 +import org.neo4j.graphdb.Relationship;
  25 +
  26 +public class DoubleEvaluatorWithDefault implements CostEvaluator<Double>
  27 +{
  28 + private String costPropertyName;
  29 + private final double defaultCost;
  30 +
  31 + public DoubleEvaluatorWithDefault( String costPropertyName, double defaultCost )
  32 + {
  33 + super();
  34 + this.costPropertyName = costPropertyName;
  35 + this.defaultCost = defaultCost;
  36 + }
  37 +
  38 + public Double getCost( Relationship relationship, Direction direction )
  39 + {
  40 + return (Double) relationship.getProperty( costPropertyName, defaultCost );
  41 + }
  42 +}
25 graph-algo/src/test/java/common/Neo4jAlgoTestCase.java
@@ -23,6 +23,7 @@
23 23 import static org.junit.Assert.assertTrue;
24 24 import static org.junit.Assert.fail;
25 25
  26 +import java.io.File;
26 27 import java.util.ArrayList;
27 28 import java.util.Arrays;
28 29 import java.util.HashSet;
@@ -59,7 +60,9 @@
59 60 @BeforeClass
60 61 public static void setUpGraphDb() throws Exception
61 62 {
62   - graphDb = new EmbeddedGraphDatabase( "target/var/algotest" );
  63 + String storeDir = "target/var/algotest";
  64 + deleteFileOrDirectory( new File( storeDir ) );
  65 + graphDb = new EmbeddedGraphDatabase( storeDir );
63 66 graph = new SimpleGraphBuilder( graphDb, MyRelTypes.R1 );
64 67 }
65 68
@@ -90,6 +93,26 @@ protected void restartTx()
90 93 tx = graphDb.beginTx();
91 94 }
92 95
  96 + public static void deleteFileOrDirectory( File file )
  97 + {
  98 + if ( !file.exists() )
  99 + {
  100 + return;
  101 + }
  102 +
  103 + if ( file.isDirectory() )
  104 + {
  105 + for ( File child : file.listFiles() )
  106 + {
  107 + deleteFileOrDirectory( child );
  108 + }
  109 + }
  110 + else
  111 + {
  112 + file.delete();
  113 + }
  114 + }
  115 +
93 116 protected void assertPathDef( Path path, String... names )
94 117 {
95 118 int i = 0;
52 graph-algo/src/test/java/org/neo4j/graphalgo/path/TestDijkstra.java
@@ -20,6 +20,9 @@
20 20 package org.neo4j.graphalgo.path;
21 21
22 22 import static org.junit.Assert.fail;
  23 +import static org.neo4j.helpers.collection.MapUtil.map;
  24 +
  25 +import java.util.Map;
23 26
24 27 import org.junit.Test;
25 28 import org.neo4j.graphalgo.CommonEvaluators;
@@ -35,8 +38,7 @@
35 38
36 39 public class TestDijkstra extends Neo4jAlgoTestCase
37 40 {
38   - @Test
39   - public void testSmallGraph()
  41 + private Relationship createGraph( boolean includeOnes )
40 42 {
41 43 /* Layout:
42 44 * (y)
@@ -49,19 +51,29 @@ public void testSmallGraph()
49 51 * v / | / \ /
50 52 * (b)--[1]-->(c)--[1]->(d)
51 53 */
  54 +
  55 + Map<String, Object> propertiesForOnes = includeOnes ? map( "cost", (double) 1 ) : map();
  56 +
52 57 graph.makeEdge( "start", "a", "cost", (double) 1 );
53 58 graph.makeEdge( "a", "x", "cost", (double) 9 );
54   - graph.makeEdge( "a", "b", "cost", (double) 1 );
  59 + graph.makeEdge( "a", "b", propertiesForOnes );
55 60 graph.makeEdge( "b", "x", "cost", (double) 7 );
56   - graph.makeEdge( "b", "c", "cost", (double) 1 );
  61 + graph.makeEdge( "b", "c", propertiesForOnes );
57 62 graph.makeEdge( "c", "x", "cost", (double) 5 );
58 63 Relationship shortCTOXRelationship = graph.makeEdge( "c", "x", "cost", (double) 3 );
59   - graph.makeEdge( "c", "d", "cost", (double) 1 );
  64 + graph.makeEdge( "c", "d", propertiesForOnes );
60 65 graph.makeEdge( "d", "x", "cost", (double) 3 );
61   - graph.makeEdge( "d", "e", "cost", (double) 1 );
62   - graph.makeEdge( "e", "x", "cost", (double) 1 );
  66 + graph.makeEdge( "d", "e", propertiesForOnes );
  67 + graph.makeEdge( "e", "x", propertiesForOnes );
63 68 graph.makeEdge( "e", "f", "cost", (double) 2 );
64 69 graph.makeEdge( "x", "y", "cost", (double) 2 );
  70 + return shortCTOXRelationship;
  71 + }
  72 +
  73 + @Test
  74 + public void testSmallGraph()
  75 + {
  76 + Relationship shortCTOXRelationship = createGraph( true );
65 77
66 78 PathFinder<WeightedPath> finder = GraphAlgoFactory.dijkstra(
67 79 Traversal.expanderForTypes( MyRelTypes.R1, Direction.OUTGOING ), "cost" );
@@ -88,6 +100,32 @@ public void testSmallGraph()
88 100 }
89 101 }
90 102
  103 + @Test
  104 + public void testSmallGraphWithDefaults()
  105 + {
  106 + Relationship shortCTOXRelationship = createGraph( true );
  107 +
  108 + PathFinder<WeightedPath> finder = GraphAlgoFactory.dijkstra(
  109 + Traversal.expanderForTypes( MyRelTypes.R1, Direction.OUTGOING ),
  110 + CommonEvaluators.doubleCostEvaluator( "cost", 1.0d ) );
  111 +
  112 + // Assert that there are two matching paths
  113 + Node startNode = graph.getNode( "start" );
  114 + Node endNode = graph.getNode( "x" );
  115 + assertPaths( finder.findAllPaths( startNode, endNode ),
  116 + "start,a,b,c,x", "start,a,b,c,d,e,x" );
  117 +
  118 + // Assert that for the shorter one it picked the correct relationship
  119 + // of the two from (c) --> (x)
  120 + for ( WeightedPath path : finder.findAllPaths( startNode, endNode ) )
  121 + {
  122 + if ( getPathDef( path ).equals( "start,a,b,c,x" ) )
  123 + {
  124 + assertContainsRelationship( path, shortCTOXRelationship );
  125 + }
  126 + }
  127 + }
  128 +
91 129 private void assertContainsRelationship( WeightedPath path,
92 130 Relationship relationship )
93 131 {
6 ha/src/test/java/org/neo4j/ha/LocalhostZooKeeperCluster.java
@@ -136,7 +136,11 @@ private String config( TargetDirectory target, int id, int port )
136 136 conf.println( "tickTime=2000" );
137 137 conf.println( "initLimit=10" );
138 138 conf.println( "syncLimit=5" );
139   - conf.println( "dataDir=" + dataDir.getAbsolutePath() );
  139 +
  140 + // On Windows the backslashes will have to be escaped for
  141 + // ZooKeeper to interpret them correctly.
  142 + conf.println( "dataDir=" + dataDir.getAbsolutePath().replaceAll( "\\\\", "\\\\\\\\" ) );
  143 +
140 144 conf.println( "clientPort=" + port );
141 145 for ( int j = 0; j < keeper.length; j++ )
142 146 {
19 ha/src/test/java/slavetest/AbstractHaTest.java
@@ -46,6 +46,7 @@
46 46 import org.neo4j.graphdb.RelationshipType;
47 47 import org.neo4j.helpers.collection.IteratorUtil;
48 48 import org.neo4j.helpers.collection.MapUtil;
  49 +import org.neo4j.kernel.Config;
49 50 import org.neo4j.kernel.ha.Broker;
50 51 import org.neo4j.kernel.ha.BrokerFactory;
51 52
@@ -392,6 +393,7 @@ protected void setExpectedResults( int nodeCount, int relCount,
392 393 @Test
393 394 public void slaveCreateNode() throws Exception
394 395 {
  396 + if ( Config.osIsWindows() ) return;
395 397 setExpectedResults( 3, 2, 2, 2, 0, 0 );
396 398 initializeDbs( 1 );
397 399 executeJob( new CommonJobs.CreateSomeEntitiesJob(), 0 );
@@ -400,6 +402,7 @@ public void slaveCreateNode() throws Exception
400 402 @Test
401 403 public void testMultipleSlaves() throws Exception
402 404 {
  405 + if ( Config.osIsWindows() ) return;
403 406 setExpectedResults( 2, 1, 1, 1, 0, 0 );
404 407 initializeDbs( 3 );
405 408 executeJob( new CommonJobs.CreateSubRefNodeJob( CommonJobs.REL_TYPE.name(), null, null ), 0 );
@@ -412,6 +415,7 @@ public void testMultipleSlaves() throws Exception
412 415 @Test
413 416 public void testMasterFailure() throws Exception
414 417 {
  418 + if ( Config.osIsWindows() ) return;
415 419 initializeDbs( 1 );
416 420 Serializable[] result = executeJob( new CommonJobs.CreateSubRefNodeMasterFailJob(
417 421 getMasterShutdownDispatcher() ), 0 );
@@ -425,6 +429,7 @@ public void testMasterFailure() throws Exception
425 429 @Test
426 430 public void testSlaveConstraintViolation() throws Exception
427 431 {
  432 + if ( Config.osIsWindows() ) return;
428 433 setExpectedResults( 2, 1, 0, 1, 0, 0 );
429 434 initializeDbs( 1 );
430 435
@@ -438,6 +443,7 @@ public void testSlaveConstraintViolation() throws Exception
438 443 @Test
439 444 public void testMasterConstraintViolation() throws Exception
440 445 {
  446 + if ( Config.osIsWindows() ) return;
441 447 setExpectedResults( 2, 1, 1, 1, 0, 0 );
442 448 initializeDbs( 1 );
443 449
@@ -452,6 +458,7 @@ public void testMasterConstraintViolation() throws Exception
452 458 @Test
453 459 public void testGetRelationships() throws Exception
454 460 {
  461 + if ( Config.osIsWindows() ) return;
455 462 setExpectedResults( 3, 2, 0, 0, 0, 0 );
456 463 initializeDbs( 1 );
457 464
@@ -468,6 +475,7 @@ public void testGetRelationships() throws Exception
468 475 @Test
469 476 public void testNoTransaction() throws Exception
470 477 {
  478 + if ( Config.osIsWindows() ) return;
471 479 setExpectedResults( 2, 1, 0, 1, 0, 0 );
472 480 initializeDbs( 1 );
473 481
@@ -480,6 +488,7 @@ public void testNoTransaction() throws Exception
480 488 @Test
481 489 public void testNodeDeleted() throws Exception
482 490 {
  491 + if ( Config.osIsWindows() ) return;
483 492 setExpectedResults( 1, 0, 0, 0, 0, 0 );
484 493 initializeDbs( 1 );
485 494
@@ -494,6 +503,7 @@ public void testNodeDeleted() throws Exception
494 503 @Test
495 504 public void testDeadlock() throws Exception
496 505 {
  506 + if ( Config.osIsWindows() ) return;
497 507 initializeDbs( 2 );
498 508
499 509 Long[] nodes = executeJobOnMaster( new CommonJobs.CreateNodesJob( 2 ) );
@@ -516,6 +526,7 @@ public void testDeadlock() throws Exception
516 526 @Test
517 527 public void createNodeAndIndex() throws Exception
518 528 {
  529 + if ( Config.osIsWindows() ) return;
519 530 setExpectedResults( 2, 0, 1, 0, 1, 0 );
520 531 initializeDbs( 1 );
521 532 executeJob( new CommonJobs.CreateNodeAndIndexJob( "name", "Neo" ), 0 );
@@ -524,6 +535,7 @@ public void createNodeAndIndex() throws Exception
524 535 @Test
525 536 public void indexingAndTwoSlaves() throws Exception
526 537 {
  538 + if ( Config.osIsWindows() ) return;
527 539 initializeDbs( 2 );
528 540 long id = executeJobOnMaster( new CommonJobs.CreateNodeAndIndexJob( "name", "Morpheus" ) );
529 541 pullUpdates();
@@ -536,6 +548,7 @@ public void indexingAndTwoSlaves() throws Exception
536 548 @Test
537 549 public void testNewIndexFramework() throws Exception
538 550 {
  551 + if ( Config.osIsWindows() ) return;
539 552 setExpectedResults( 2, 0, 2, 0, 0, 2 );
540 553 initializeDbs( 2 );
541 554 long id = executeJobOnMaster( new CommonJobs.CreateNodeAndNewIndexJob( "users",
@@ -546,6 +559,7 @@ public void testNewIndexFramework() throws Exception
546 559 @Test
547 560 public void testLargeTransaction() throws Exception
548 561 {
  562 + if ( Config.osIsWindows() ) return;
549 563 initializeDbs( 1 );
550 564 executeJob( new CommonJobs.LargeTransactionJob( 20, 1 ), 0 );
551 565 }
@@ -553,6 +567,7 @@ public void testLargeTransaction() throws Exception
553 567 @Test
554 568 public void testPullLargeTransaction() throws Exception
555 569 {
  570 + if ( Config.osIsWindows() ) return;
556 571 initializeDbs( 1 );
557 572 executeJobOnMaster( new CommonJobs.LargeTransactionJob( 20, 1 ) );
558 573 pullUpdates();
@@ -561,6 +576,7 @@ public void testPullLargeTransaction() throws Exception
561 576 @Test
562 577 public void testLargeTransactionData() throws Exception
563 578 {
  579 + if ( Config.osIsWindows() ) return;
564 580 initializeDbs( 1 );
565 581 executeJob( new CommonJobs.LargeTransactionJob( 1, 20 ), 0 );
566 582 }
@@ -568,6 +584,7 @@ public void testLargeTransactionData() throws Exception
568 584 @Test
569 585 public void testPullLargeTransactionData() throws Exception
570 586 {
  587 + if ( Config.osIsWindows() ) return;
571 588 initializeDbs( 1 );
572 589 executeJobOnMaster( new CommonJobs.LargeTransactionJob( 1, 20 ) );
573 590 pullUpdates();
@@ -576,6 +593,7 @@ public void testPullLargeTransactionData() throws Exception
576 593 @Test
577 594 public void makeSureSlaveCanCopyLargeInitialDatabase() throws Exception
578 595 {
  596 + if ( Config.osIsWindows() ) return;
579 597 startUpMaster( MapUtil.stringMap() );
580 598 executeJobOnMaster( new CommonJobs.LargeTransactionJob( 1, 60 ) );
581 599 addDb( MapUtil.stringMap() );
@@ -586,6 +604,7 @@ public void makeSureSlaveCanCopyLargeInitialDatabase() throws Exception
586 604 @Test
587 605 public void canCopyInitialDbWithLuceneIndexes() throws Exception
588 606 {
  607 + if ( Config.osIsWindows() ) return;
589 608 int additionalNodeCount = 50;
590 609 setExpectedResults( 1+additionalNodeCount, 0, additionalNodeCount*2, 0, 0, additionalNodeCount*2 );
591 610 startUpMaster( MapUtil.stringMap() );
2  ha/src/test/java/slavetest/MultiJvmTest.java
@@ -29,6 +29,7 @@
29 29 import org.junit.After;
30 30 import org.neo4j.graphdb.GraphDatabaseService;
31 31 import org.neo4j.ha.StandaloneDatabase;
  32 +import org.neo4j.kernel.Config;
32 33 import org.neo4j.kernel.EmbeddedGraphDatabase;
33 34
34 35 public class MultiJvmTest extends AbstractHaTest
@@ -67,6 +68,7 @@ protected void awaitAllStarted() throws Exception
67 68 @After
68 69 public void shutdownDbsAndVerify() throws Exception
69 70 {
  71 + if ( Config.osIsWindows() ) return;
70 72 shutdownDbs();
71 73
72 74 GraphDatabaseService masterDb = new EmbeddedGraphDatabase( dbPath( 0 ).getAbsolutePath() );
3  ha/src/test/java/slavetest/MultiJvmWithZooKeeperTest.java
@@ -28,6 +28,7 @@
28 28 import org.junit.Before;
29 29 import org.neo4j.ha.LocalhostZooKeeperCluster;
30 30 import org.neo4j.ha.StandaloneDatabase;
  31 +import org.neo4j.kernel.Config;
31 32
32 33 public class MultiJvmWithZooKeeperTest extends MultiJvmTest
33 34 {
@@ -42,6 +43,7 @@
42 43 @Before
43 44 public void startZooKeeperCluster() throws Exception
44 45 {
  46 + if ( Config.osIsWindows() ) return;
45 47 FileUtils.deleteDirectory( BASE_ZOO_KEEPER_DATA_DIR );
46 48 zooKeeperCluster = new LocalhostZooKeeperCluster( getClass(), /*ports:*/2181, 2182, 2183 );
47 49 }
@@ -82,6 +84,7 @@ private static String buildHaServerConfigValue( int machineId )
82 84 @After
83 85 public void shutdownZooKeeperCluster()
84 86 {
  87 + if ( Config.osIsWindows() ) return;
85 88 zooKeeperCluster.shutdown();
86 89 }
87 90 }
3  ha/src/test/java/slavetest/SingleJvmTest.java
@@ -119,6 +119,7 @@ protected void shutdownDbs()
119 119 @After
120 120 public void verifyAndShutdownDbs()
121 121 {
  122 + if ( Config.osIsWindows() ) return;
122 123 try
123 124 {
124 125 verify( master.getGraphDb(), haDbs.toArray( new GraphDatabaseService[haDbs.size()] ) );
@@ -183,6 +184,8 @@ protected void pullUpdates( int... ids )
183 184 @Test
184 185 public void testMixingEntitiesFromWrongDbs() throws Exception
185 186 {
  187 + if ( Config.osIsWindows() ) return;
  188 +
186 189 initializeDbs( 1 );
187 190 GraphDatabaseService haDb1 = haDbs.get( 0 );
188 191 GraphDatabaseService mDb = master.getGraphDb();
2  ha/src/test/java/slavetest/SingleJvmWithNettyTest.java
@@ -25,6 +25,7 @@
25 25 import org.neo4j.com.Protocol;
26 26 import org.neo4j.graphdb.GraphDatabaseService;
27 27 import org.neo4j.helpers.Pair;
  28 +import org.neo4j.kernel.Config;
28 29 import org.neo4j.kernel.HighlyAvailableGraphDatabase;
29 30 import org.neo4j.kernel.ha.AbstractBroker;
30 31 import org.neo4j.kernel.ha.Broker;
@@ -38,6 +39,7 @@
38 39 @Test
39 40 public void assertThatNettyIsUsed() throws Exception
40 41 {
  42 + if ( Config.osIsWindows() ) return;
41 43 initializeDbs( 1 );
42 44 assertTrue(
43 45 "Slave Broker is not a client",
17 integration-test/pom.xml
... ... @@ -1,11 +1,6 @@
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3 3 <modelVersion>4.0.0</modelVersion>
4   - <parent>
5   - <groupId>org.neo4j</groupId>
6   - <artifactId>parent-pom</artifactId>
7   - <version>17</version>
8   - </parent>
9 4
10 5 <organization>
11 6 <name>Neo4j</name>
@@ -36,7 +31,7 @@
36 31 </modules>
37 32
38 33 <properties>
39   - <neo4j-release.version>1.3-SNAPSHOT</neo4j-release.version>
  34 + <neo4j-release.version>1.3.M02</neo4j-release.version>
40 35 <!--
41 36 <neo4j-kernel.version>1.2-${neo4j-release.version}</neo4j-kernel.version>
42 37 <neo4j-index.version>1.2-${neo4j-release.version}</neo4j-index.version>
@@ -48,15 +43,11 @@
48 43 </properties>
49 44
50 45 <!-- Staging repository URLs change... -->
51   - <!-- repositories>
  46 + <repositories>
52 47 <repository>
53 48 <id>staging-1</id>
54   - <url>https://oss.sonatype.org/content/repositories/orgneo4j-636/</url>
  49 + <url>https://oss.sonatype.org/content/repositories/orgneo4j-049/</url>
55 50 </repository>
56   - <repository>
57   - <id>staging-2</id>
58   - <url>https://oss.sonatype.org/content/repositories/orgneo4j-637/</url>
59   - </repository>
60   - </repositories -->
  51 + </repositories>
61 52
62 53 </project>
173 kernel/src/docs/ops/cache.txt
... ... @@ -0,0 +1,173 @@
  1 +[[configuration-caches]]
  2 +Caches in Neo4j
  3 +===============
  4 +
  5 +Neo4j utilizes two different types of caches.
  6 +A file buffer cache and an object cache.
  7 +The file buffer cache caches the storage file data in the same format as it is stored on the durable storage media.
  8 +The object cache caches the nodes, relationships and properties in a format that is optimized for high traversal speeds and transactional mutation.
  9 +
  10 +
  11 +File buffer cache
  12 +-----------------
  13 +
  14 +.Quick info
  15 +***********
  16 +* The file buffer cache is sometimes called _low level cache_ or _file system cache_.
  17 +* It caches the Neo4j data as stored on the durable media.
  18 +* It uses the operating system memory mapping features when possible.
  19 +* Neo4j will configure the cache automatically as long as the heap size of the JVM is configured properly.
  20 +***********
  21 +
  22 +The file buffer cache caches the Neo4j data in the same format as it is represented on the durable storage media.
  23 +The purpose of this cache layer is to improve both read and write performance.
  24 +The file buffer cache improves write performance by writing to the cache and deferring durable write until the logical log is rotated.
  25 +This behavior is safe since all transactions are always durably written to the logical log, which can be used to recover the store files in the event of a crash.
  26 +
  27 +Since the operation of the cache is tightly related to the data it stores, a short description of the Neo4j durable representation format is necessary background.
  28 +Neo4j stores data in multiple files and relies on the underlying file system to handle this efficiently.
  29 +Each Neo4j storage file contains uniform fixed size records of a particular type:
  30 +
  31 +[options="header",grid="none",frame="none",cols="<,>m,<", width="50%"]
  32 +|============================================
  33 +| Store file | Record size | Contents
  34 +| nodestore | 9 B | Nodes
  35 +| relstore | 33 B | Relationships
  36 +| propstore | 25 B | Properties for nodes and relationships
  37 +| stringstore | 133 B | Values of string properties
  38 +| arraystore | 133 B | Values of array properties
  39 +|============================================
  40 +
  41 +For strings and arrays, where data can be of variable length, data is stored in one or more 120B chunks, with 13B record overhead.
  42 +The sizes of these blocks can actually be configured when the store is created using the `string_block_size` and `array_block_size` parameters.
  43 +The size of each record type can also be used to calculate the storage requirements of a Neo4j graph or the appropriate cache size for each file buffer cache.
  44 +
  45 +Neo4j uses multiple file buffer caches, one for each different storage file.
  46 +Each file buffer cache divides its storage file into a number of equally sized windows.
  47 +Each cache window contains an even number of storage records.
  48 +The cache holds the most active cache windows in memory and tracks hit vs. miss ratio for the windows.
  49 +When the hit ratio of an uncached window gets higher than the miss ratio of a cached window, the cached window gets evicted and the previously uncached window is cached instead.
  50 +
  51 +Configuration
  52 +~~~~~~~~~~~~~
  53 +
  54 +[options="header",frame="none",cols="<35m,<30,<35"]
  55 +|========================================================
  56 +| Parameter | Possible values | Effect
  57 +| use_memory_mapped_buffers | `true` or `false` |
  58 + If set to `true` Neo4j will use the operating systems memory mapping functionality for the file buffer cache windows.
  59 + If set to `false` Neo4j will use its own buffer implementation.
  60 + In this case the buffers will reside in the JVM heap which needs to be increased accordingly.
  61 + The default value for this parameter is `true`, except on Windows.
  62 +| neostore.nodestore.db.mapped_memory .7+^.^|
  63 + The maximum amount of memory to use for memory mapped buffers for this file buffer cache.
  64 + The default unit is `MiB`, for other units use any of the following suffixes: `B`, `k`, `M` or `G`.
  65 + |
  66 + The maximum amount of memory to use for the file buffer cache of the node storage file.
  67 +| neostore.relationshipstore.db.mapped_memory |
  68 + The maximum amount of memory to use for the file buffer cache of the relationship store file.
  69 +| neostore.propertystore.db.index.keys.mapped_memory |
  70 + The maximum amount of memory to use for the file buffer cache of the something-something file.
  71 +| neostore.propertystore.db.index.mapped_memory |
  72 + The maximum amount of memory to use for the file buffer cache of the something-something file.
  73 +| neostore.propertystore.db.mapped_memory |
  74 + The maximum amount of memory to use for the file buffer cache of the property storage file.
  75 +| neostore.propertystore.db.strings.mapped_memory |
  76 + The maximum amount of memory to use for the file buffer cache of the string property storage file.
  77 +| neostore.propertystore.db.arrays.mapped_memory |
  78 + The maximum amount of memory to use for the file buffer cache of the array property storage file.
  79 +| string_block_size .2+^.^| The number of bytes per block. |
  80 + Specifies the block size for storing strings.
  81 + This parameter is only honored when the store is created, otherwise it is ignored.
  82 + Note that each character in a string occupies two bytes, meaning that a block size of 120 (the default size) will hold a 60 character long string before overflowing into a second block.
  83 + Also note that each block carries an overhead of 13 bytes.
  84 + This means that if the block size is 120, the size of the stored records will be 133 bytes.
  85 +| array_block_size |
  86 + Specifies the block size for storing arrays.
  87 + This parameter is only honored when the store is created, otherwise it is ignored.
  88 + The default block size is 120 bytes, and the overhead of each block is the same as for string blocks, i.e., 13 bytes.
  89 +| dump_configuration | `true` or `false` | If set to `true` the current configuration settings will be written to the default system output, mostly the console or the logfiles.
  90 +|========================================================
  91 +
  92 +When memory mapped buffers are used (`use_memory_mapped_buffers = true`) the heap size of the JVM must be smaller than the total available memory of the computer, minus the total amount of memory used for the buffers.
  93 +When heap buffers are used (`use_memory_mapped_buffers = false`) the heap size of the JVM must be large enough to contain all the buffers, plus the runtime heap memory requirements of the application and the object cache.
  94 +
  95 +When reading the configuration parameters on startup Neo4j will automatically configure the parameters that are not specified.
  96 +The cache sizes will be configured based on the available memory on the computer, how much is used by the JVM heap, and how large the storage files are.
  97 +
  98 +Object cache
  99 +------------
  100 +
  101 +.Quick info
  102 +***********
  103 +* The object cache is sometimes called _high level cache_.
  104 +* It caches the Neo4j data in a form optimized for fast traversal.
  105 +***********
  106 +
  107 +The object cache caches individual nodes and relationships and their properties in a form that is optimized for fast traversal of the graph.
  108 +The content of this cache are objects with a representation geared towards supporting the Neo4j object API and graph traversals.
  109 +Reading from this cache is 5 to 10 times faster than reading from the file buffer cache.
  110 +This cache is contained in the heap of the JVM and the size is adapted to the current amount of available heap memory.
  111 +
  112 +Nodes and relationships are added to the object cache as soon as they are accessed.
  113 +The cached objects are however populated lazily.
  114 +The properties for a node or relationship are not loaded until properties are accessed for that node or relationship.
  115 +String (and array) properties are not loaded until that particular property is accessed.
  116 +The relationships for a particular node is also not loaded until the relationships are accessed for that node.
  117 +Eviction from the cache happens in an LRU manner when the memory is needed.
  118 +
  119 +
  120 +Configuration
  121 +~~~~~~~~~~~~~
  122 +
  123 +The main configuration parameter for the object cache is the `cache_type` parameter.
  124 +This specifies which cache implementation to use for the object cache.
  125 +The available cache types are:
  126 +
  127 +[options="header",frame="none",cols="<15m,<85"]
  128 +|==========================================
  129 +| `cache_type` | Description
  130 +| none | Do not use a high level cache. No objects will be cached.
  131 +| soft | Provides optimal utilization of the available memory.
  132 + Suitable for high performance traversal.
  133 + May run into GC issues under high load if the frequently accessed parts of the graph does not fit in the cache.
  134 +
  135 + This is the default cache implementation.
  136 +| weak | Provides short life span for cached objects.
  137 + Suitable for high throughput applications where a larger portion of the graph than what can fit into memory is frequently accessed.
  138 +| strong | This cache will cache *all data* in the *entire graph*.
  139 + It will never release memory held by the cache.
  140 + Provides optimal performance if your graph is small enough to fit in memory.
  141 +|==========================================
  142 +
  143 +
  144 +Heap memory usage
  145 +~~~~~~~~~~~~~~~~~
  146 +
  147 +This table can be used to calculate how much memory the data in the object cache will occupy on a 64bit JVM:
  148 +
  149 +[options="header",frame="none",cols="<15,<15e,<70e"]
  150 +|================================
  151 +| Object | Size | Comment
  152 +.5+| Node .+>m| 344 B | Size for each node (not counting its relationships or properties).
  153 + .+>m| 48 B | Object overhead.
  154 + .+>m| 136 B | Property storage (ArrayMap `48B`, HashMap `88B`).
  155 + .+>m| 136 B | Relationship storage (ArrayMap `48B`, HashMap `88B`).
  156 + .+>m| 24 B | Location of first / next set of relationships.
  157 +.3+| Relationship .+>m| 208 B | Size for each relationship (not counting its properties).
  158 + .+>m| 48 B | Object overhead.
  159 + .+>m| 136 B | Property storage (ArrayMap `48B`, HashMap `88B`).
  160 +.5+| Property .+>m| 116 B | Size for each property of a node or relationship.
  161 + .+>m| 32 B | Data element - allows for transactional modification and keeps track of on disk location.
  162 + .+>m| 48 B | Entry in the hash table where it is stored.
  163 + .+>m| 12 B | Space used in hash table, accounts for normal fill ratio.
  164 + .+>m| 24 B | Property key index.
  165 +.4+| Relationships .+>m| 108 B | Size for each relationship type for a node that has a relationship of that type.
  166 + .+>m| 48 B | Collection of the relationships of this type.
  167 + .+>m| 48 B | Entry in the hash table where it is stored.
  168 + .+>m| 12 B | Space used in hash table, accounts for normal fill ratio.
  169 +| Relationships .+>m| 8 B | Space used by each relationship related to a particular node (both incoming and outgoing).
  170 +| Primitive .+>m| 24 B | Size of a primitive property value.
  171 +| String .+>m| 64+B | Size of a string property value. `64 + 2*len(string) B` (64 bytes, plus two bytes for each character in the string).
  172 +|================================
  173 +
17 kernel/src/docs/ops/index.txt
... ... @@ -0,0 +1,17 @@
  1 +[[configuration]]
  2 +Configuration & Performance
  3 +===========================
  4 +
  5 +In order to get optimum performance out of Neo4j for your application there are a few parameters that can be tweaked.
  6 +The two main components that can be configured are the Neo4j caches and the JVM that Neo4j runs in.
  7 +The following sections describe how to tune these.
  8 +
  9 +
  10 +:leveloffset: 2
  11 +
  12 +include::cache.txt[]
  13 +
  14 +include::jvm.txt[]
  15 +
  16 +include::short-strings.txt[]
  17 +
38 kernel/src/docs/ops/jvm.txt
... ... @@ -0,0 +1,38 @@
  1 +[[configuration-jvm]]
  2 +JVM Settings
  3 +============
  4 +
  5 +Properly configuring memory utilization of the JVM is crucial for optimal performance.
  6 +As an example, a poorly configured JVM could spend all CPU time performing garbage collection (blocking all threads from performing any work).
  7 +Requirements such as latency, total throughput and available hardware have to be considered to find the right setup.
  8 +In production, Neo4j should run on a multi core/CPU platform with the JVM in server mode.
  9 +
  10 +== Configuring heap size and GC ==
  11 +
  12 +A large heap allows for larger node and relationship caches -- which is a good thing -- but large heaps can also lead to latency problems caused by full garbage collection.
  13 +The different high level cache implementations available in Neo4j together with a suitable JVM configuration of heap size and garbage collection (GC) should be able to handle most workloads.
  14 +
  15 +The default cache (soft reference based LRU cache) works best with a heap that never gets full: a graph where the most used nodes and relationships can be cached.
  16 +If the heap gets too full there is a risk that a full GC will be triggered; the larger the heap, the longer it can take to determine what soft references should be cleared.
  17 +
  18 +Using the strong reference cache means 'all' the nodes and relationships being used must fit in available heap.
  19 +Otherwise there is a risk of getting out-of-memory exceptions.
  20 +The soft reference and strong reference caches are well suited for applications were the overal throughput is important.
  21 +
  22 +The weak reference cache basically needs enough heap to handle the peak load of the application -- peak load multiplied by the average memory required per request.
  23 +It is well suited for low latency requirements were GC interuptions are not acceptable.
  24 +
  25 +When running Neo4j on Windows, keep in mind that the memory mapped buffers are allocated on heap by default, so need to be taken into consideration when determining heap size.
  26 +
  27 +.Guidelines for heap size
  28 +[format="csv",width="75%",cols="4"]
  29 +[frame="topbot",grid="none",options="header"]
  30 +|======================================================================================================
  31 +Number of primitives,RAM size,Heap configuration,Reserved RAM for the OS
  32 +10M,2GB,512MB,the rest
  33 +100M,8GB+,1-4GB,1-2GB
  34 +1B+,16GB-32GB+,4GB+,1-2GB
  35 +|======================================================================================================
  36 +
  37 +The recommended garbage collector to use when running Neo4j in production is the Concurrent Mark and Sweep Compactor turned on by supplying -XX:+UseConcMarkSweepGC as a JVM parameter.
  38 +
1  kernel/src/docs/dev/short-strings.txt → kernel/src/docs/ops/short-strings.txt
... ... @@ -1,3 +1,4 @@
  1 +[[short-strings]]
1 2 Compressed storage of short strings
2 3 ===================================
3 4
14 kernel/src/main/java/org/neo4j/kernel/Config.java
@@ -78,6 +78,7 @@
78 78 public static final String CACHE_TYPE = "cache_type";
79 79 public static final String TXMANAGER_IMPLEMENTATION = "tx_manager_impl";
80 80 public static final String ALLOW_STORE_UPGRADE = "allow_store_upgrade";
  81 + static final String LOAD_EXTENSIONS = "load_kernel_extensions";
81 82
82 83 private final AdaptiveCacheManager cacheManager;
83 84 private final TxModule txModule;
@@ -137,7 +138,7 @@
137 138 params.put( GraphDbModule.class, graphDbModule );
138 139 }
139 140
140   - private static Map<Object, Object> getDefaultParams()
  141 + public static Map<Object, Object> getDefaultParams()
141 142 {
142 143 Map<Object, Object> params = new HashMap<Object, Object>();
143 144 params.put( "neostore.nodestore.db.mapped_memory", "20M" );
@@ -148,14 +149,19 @@
148 149 params.put( "neostore.propertystore.db.arrays.mapped_memory", "130M" );
149 150 params.put( "neostore.relationshipstore.db.mapped_memory", "100M" );
150 151 // if on windows, default no memory mapping
151   - String nameOs = System.getProperty( "os.name" );
152   - if ( nameOs.startsWith( "Windows" ) )
  152 + if ( osIsWindows() )
153 153 {
154 154 params.put( Config.USE_MEMORY_MAPPED_BUFFERS, "false" );
155 155 }
156 156 return params;
157 157 }
158 158
  159 + public static boolean osIsWindows()
  160 + {
  161 + String nameOs = System.getProperty( "os.name" );
  162 + return nameOs.startsWith( "Windows" );
  163 + }
  164 +
159 165 void setPersistenceSource( String name, boolean create )
160 166 {
161 167 persistenceSourceName = name;
@@ -261,7 +267,7 @@ public static void dumpConfiguration( Map<?, ?> config )
261 267 }
262 268 }
263 269 }
264   -
  270 +
265 271 public static Map<String, String> parseMapFromConfigValue( String name, String configValue )
266 272 {
267 273 Map<String, String> result = new HashMap<String, String>();
42 kernel/src/main/java/org/neo4j/kernel/EmbeddedGraphDbImpl.java
@@ -146,25 +146,33 @@ public GraphDatabaseService graphDatabase()
146 146 boolean started = false;
147 147 try
148 148 {
149   - KernelExtensionLoader extensionLoader = new KernelExtensionLoader()
  149 + final KernelExtensionLoader extensionLoader;
  150 + if ( "false".equalsIgnoreCase( inputParams.get( Config.LOAD_EXTENSIONS ) ) )
150 151 {
151   - private Collection<KernelExtension<?>> loaded;
152   -
153   - public void configureKernelExtensions()
154   - {
155   - loaded = extensions.loadExtensionConfigurations( msgLog );
156   - }
157   -
158   - public void initializeIndexProviders()
159   - {
160   - extensions.loadIndexImplementations( indexManager, msgLog );
161   - }
162   -
163   - public void load()
  152 + extensionLoader = KernelExtensionLoader.DONT_LOAD;
  153 + }
  154 + else
  155 + {
  156 + extensionLoader = new KernelExtensionLoader()
164 157 {
165   - extensions.loadExtensions( loaded, msgLog );
166   - }
167   - };
  158 + private Collection<KernelExtension<?>> loaded;
  159 +
  160 + public void configureKernelExtensions()
  161 + {
  162 + loaded = extensions.loadExtensionConfigurations( msgLog );
  163 + }
  164 +
  165 + public void initializeIndexProviders()
  166 + {
  167 + extensions.loadIndexImplementations( indexManager, msgLog );
  168 + }
  169 +
  170 + public void load()
  171 + {
  172 + extensions.loadExtensions( loaded, msgLog );
  173 + }
  174 + };
  175 + }
168 176 graphDbInstance.start( graphDbService, extensionLoader );
169 177 nodeManager = config.getGraphDbModule().getNodeManager();
170 178 extensionLoader.load();
5 kernel/src/main/java/org/neo4j/kernel/KernelData.java
@@ -201,9 +201,10 @@ synchronized void shutdown( StringLogger msgLog )
201 201 extension.unload( (S) state );
202 202 }
203 203
204   - final Object getState( KernelExtension<?> extension )
  204 + @SuppressWarnings( "unchecked" )
  205 + final <S> S getState( KernelExtension<S> extension )
205 206 {
206   - return state.get( extension );
  207 + return (S) state.get( extension );
207 208 }
208 209
209 210 private Object setState( KernelExtension<?> extension, Object value )
40 kernel/src/main/java/org/neo4j/kernel/KernelExtension.java
@@ -28,14 +28,37 @@
28 28 /**
29 29 * Hook for providing extended functionality to the Neo4j Graph Database kernel.
30 30 *
31   - * @author Tobias Ivarsson
  31 + * Implementations of {@link KernelExtension} must fulfill the following
  32 + * contract:
  33 + * <ul>
  34 + * <li>Must have a public no-arg constructor.</li>
  35 + * <li>The same instance must be able to load with multiple GraphDatabase
  36 + * kernels.</li>
  37 + * <li>Different instances should be able to access the same state from the same
  38 + * kernel. <br/>
  39 + * To achieve this, different instances of the same class should have the same
  40 + * {@link #hashCode()} and be {@link #equals(Object)}. This is enforced by this
  41 + * base class by delegating {@link #hashCode()} and {@link #equals(Object)} to
  42 + * the same methods on the {@link #getClass() class object}.</li>
  43 + * </ul>
  44 + * The simplest way to implement an {@link KernelExtension extension} that
  45 + * fulfills this contract is if the {@link KernelExtension extension}
  46 + * implementation is stateless, and all state is kept in the state object
  47 + * returned by {@link #load(KernelData) the load method}.
  48 + *
  49