Skip to content

Commit

Permalink
Update property description, remove maintenance method from NeoStoreD…
Browse files Browse the repository at this point in the history
…ataSource, introduce constants
  • Loading branch information
MishaDemianenko committed Jul 5, 2016
1 parent fc84c16 commit 907d06d
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 22 deletions.
Expand Up @@ -19,6 +19,7 @@
*/
package org.neo4j.kernel;

import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Map;
Expand All @@ -33,9 +34,11 @@
public class CommunityIdTypeConfigurationProvider implements IdTypeConfigurationProvider
{

private static final Set<IdType> TYPES_TO_ALLOW_REUSE =
Collections.unmodifiableSet( EnumSet.of( IdType.PROPERTY, IdType.STRING_BLOCK,
IdType.ARRAY_BLOCK, IdType.NODE_LABELS ) );

private final Map<IdType,IdTypeConfiguration> typeConfigurations = new EnumMap<>(IdType.class);
private final Set<IdType> typesToAllowReuse = EnumSet.of( IdType.PROPERTY, IdType.STRING_BLOCK,
IdType.ARRAY_BLOCK, IdType.NODE_LABELS);

@Override
public IdTypeConfiguration getIdTypeConfiguration( IdType idType )
Expand All @@ -51,6 +54,6 @@ public IdTypeConfiguration getIdTypeConfiguration( IdType idType )

protected Set<IdType> getTypesToReuse()
{
return typesToAllowReuse;
return TYPES_TO_ALLOW_REUSE;
}
}
Expand Up @@ -26,6 +26,9 @@
*/
public class IdTypeConfiguration
{
static final int DEFAULT_GRAB_SIZE = 1024;
static final int AGGRESIVE_GRAB_SIZE = 50000;

private final boolean allowAggressiveReuse;

public IdTypeConfiguration( boolean allowAggressiveReuse )
Expand All @@ -40,6 +43,6 @@ public boolean allowAggressiveReuse()

public int getGrabSize()
{
return allowAggressiveReuse ? 50000 : 1024;
return allowAggressiveReuse ? AGGRESIVE_GRAB_SIZE : DEFAULT_GRAB_SIZE;
}
}
Expand Up @@ -1368,14 +1368,6 @@ private StatementOperationParts buildStatementOperations(
return parts;
}

public void maintenance()
{
if ( bufferingIdGeneratorFactory != null )
{
bufferingIdGeneratorFactory.maintenance();
}
}

@Override
public void registerIndexProvider( String name, IndexImplementation index )
{
Expand Down
Expand Up @@ -19,6 +19,8 @@
*/
package org.neo4j.kernel.configuration;

import org.apache.commons.lang3.StringUtils;

import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -327,8 +329,10 @@ public List<String> apply( String value )
for( String item : list)
{
item = item.trim();
if( !item.equals( "" ) )
if( StringUtils.isNotEmpty( item ) )
{
result.add( item );
}
}
return result;
}
Expand Down
Expand Up @@ -56,7 +56,7 @@ public void nonReusableTypeConfiguration()
IdTypeConfigurationProvider provider = createIdTypeProvider();
IdTypeConfiguration typeConfiguration = provider.getIdTypeConfiguration( IdType.RELATIONSHIP );
assertFalse( "Relationship ids are not reusable.", typeConfiguration.allowAggressiveReuse() );
assertEquals( "Relationship ids are not reusable.", 1024, typeConfiguration.getGrabSize() );
assertEquals( "Relationship ids are not reusable.", IdTypeConfiguration.DEFAULT_GRAB_SIZE, typeConfiguration.getGrabSize() );
}

@Test
Expand All @@ -65,7 +65,7 @@ public void reusableTypeConfiguration()
IdTypeConfigurationProvider provider = createIdTypeProvider();
IdTypeConfiguration typeConfiguration = provider.getIdTypeConfiguration( reusableType );
assertTrue( typeConfiguration.allowAggressiveReuse() );
assertEquals( 50000, typeConfiguration.getGrabSize() );
assertEquals( IdTypeConfiguration.AGGRESIVE_GRAB_SIZE, typeConfiguration.getGrabSize() );
}

private IdTypeConfigurationProvider createIdTypeProvider()
Expand Down
Expand Up @@ -28,8 +28,8 @@
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Transaction;
import org.neo4j.kernel.GraphDatabaseAPI;
import org.neo4j.kernel.NeoStoreDataSource;
import org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster;
import org.neo4j.kernel.impl.transaction.state.DataSourceManager;
import org.neo4j.test.Barrier;
import org.neo4j.test.OtherThreadExecutor.WorkerCommand;
import org.neo4j.test.OtherThreadRule;
Expand Down Expand Up @@ -84,7 +84,9 @@ public void shouldNotSeeFreedIdsCrossRoleSwitch() throws Throwable

private void triggerIdMaintenance( GraphDatabaseAPI db )
{
db.getDependencyResolver().resolveDependency( DataSourceManager.class ).getDataSource().maintenance();
db.getDependencyResolver()
.resolveDependency( NeoStoreDataSource.BufferedIdMaintenanceController.class )
.maintenance();
}

private WorkerCommand<Void,Void> barrierControlledReadTransaction( final GraphDatabaseService slave,
Expand Down
Expand Up @@ -45,7 +45,6 @@
import org.neo4j.kernel.ha.HighlyAvailableGraphDatabase;
import org.neo4j.kernel.ha.UpdatePuller;
import org.neo4j.kernel.impl.ha.ClusterManager;
import org.neo4j.kernel.impl.transaction.state.DataSourceManager;
import org.neo4j.test.Race;
import org.neo4j.test.ha.ClusterRule;

Expand Down Expand Up @@ -409,9 +408,9 @@ private static String longString( char ch )

private void forceMaintenance( HighlyAvailableGraphDatabase master )
{
NeoStoreDataSource dataSource =
master.getDependencyResolver().resolveDependency( DataSourceManager.class ).getDataSource();
dataSource.maintenance();
master.getDependencyResolver()
.resolveDependency( NeoStoreDataSource.BufferedIdMaintenanceController.class )
.maintenance();
}

private static void assertPropertyValue( Object property, Object... candidates )
Expand Down
Expand Up @@ -31,7 +31,8 @@
*/
public class EnterpriseEditionSettings
{
@Description( "Specified names of id types that should be reused." )
@Description( "Specified names of id types (comma separated) that should be reused. " +
"Currently only 'RELATIONSHIP' type is supported. " )
public static Setting<List<String>> idTypesToReuse =
Settings.setting( "dbms.ids.reuse.types.override", Settings.STRING_LIST, "" );

Expand Down
Expand Up @@ -136,8 +136,12 @@ public void sequentialOperationRelationshipIdReuse()
assertEquals( "Ids should be sequential", relationship1 + 1, relationship2 );
assertEquals( "Ids should be sequential", relationship2 + 1, relationship3 );

final NeoStoreDataSource.BufferedIdMaintenanceController idMaintenanceController = getIdMaintenanceController();

deleteRelationshipByLabelAndRelationshipType( marker );

idMaintenanceController.maintenance();

assertEquals( "Relationships have reused id", relationship1, createRelationship( marker ) );
assertEquals( "Relationships have reused id", relationship2, createRelationship( marker ) );
assertEquals( "Relationships have reused id", relationship3, createRelationship( marker ) );
Expand All @@ -149,6 +153,8 @@ public void relationshipIdReusableOnlyAfterTransactionFinish()
Label testLabel = DynamicLabel.label( "testLabel" );
long relationshipId = createRelationship( testLabel );

final NeoStoreDataSource.BufferedIdMaintenanceController idMaintenanceController = getIdMaintenanceController();

try ( Transaction transaction = dbRule.beginTx();
ResourceIterator<Node> nodes = dbRule.findNodes( testLabel ) )
{
Expand All @@ -162,6 +168,8 @@ public void relationshipIdReusableOnlyAfterTransactionFinish()
}
}

idMaintenanceController.maintenance();

Node node1 = dbRule.createNode( testLabel );
Node node2 = dbRule.createNode( testLabel );

Expand Down

0 comments on commit 907d06d

Please sign in to comment.