Skip to content

Commit

Permalink
Create Id Allocation Chunk Size config option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Sumrall committed Aug 24, 2016
1 parent 9eac189 commit 43592cb
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 9 deletions.
Expand Up @@ -29,7 +29,7 @@
public class IdTypeConfiguration
{
static final int DEFAULT_GRAB_SIZE = 1024;
static final int AGGRESIVE_GRAB_SIZE = 50000;
static final int AGGRESSIVE_GRAB_SIZE = 50000;

private final boolean allowAggressiveReuse;

Expand All @@ -45,6 +45,6 @@ public boolean allowAggressiveReuse()

public int getGrabSize()
{
return allowAggressiveReuse ? AGGRESIVE_GRAB_SIZE : DEFAULT_GRAB_SIZE;
return allowAggressiveReuse ? AGGRESSIVE_GRAB_SIZE : DEFAULT_GRAB_SIZE;
}
}
Expand Up @@ -64,7 +64,7 @@ public void reusableTypeConfiguration()
IdTypeConfigurationProvider provider = createIdTypeProvider();
IdTypeConfiguration typeConfiguration = provider.getIdTypeConfiguration( reusableType );
assertTrue( typeConfiguration.allowAggressiveReuse() );
assertEquals( IdTypeConfiguration.AGGRESIVE_GRAB_SIZE, typeConfiguration.getGrabSize() );
assertEquals( IdTypeConfiguration.AGGRESSIVE_GRAB_SIZE, typeConfiguration.getGrabSize() );
}

private IdTypeConfigurationProvider createIdTypeProvider()
Expand Down
Expand Up @@ -67,7 +67,8 @@ public StoreId after()

public String getConversionId()
{
ByteBuffer buffer = ByteBuffer.allocate( 88 );
int bytesNeeded = 88;
ByteBuffer buffer = ByteBuffer.allocate( bytesNeeded );

buffer.putLong( lastTxId );

Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.neo4j.helpers.ArrayUtil;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.util.Converters;
import org.neo4j.logging.NullLog;
import org.neo4j.server.configuration.ConfigLoader;

import static org.neo4j.helpers.collection.MapUtil.stringMap;
Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.neo4j.helpers.ArrayUtil;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.impl.util.Converters;
import org.neo4j.logging.NullLog;
import org.neo4j.server.configuration.ConfigLoader;

import static org.neo4j.dbms.DatabaseManagementSystemSettings.database_path;
Expand Down
Expand Up @@ -223,4 +223,8 @@ public String toString()
@Description( "Edge server 'call home' frequency" )
public static final Setting<Long> edge_refresh_rate =
setting( "core_edge.edge_refresh_rate", DURATION, "5s", min(5_000L) );

@Description( "Id range allocation chunk size" )
public static final Setting<Integer> allocation_chunk_size =
setting( "core_edge.allocation_chunk_size", INTEGER, "1024" );
}
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;
import java.io.PrintStream;

import org.neo4j.coreedge.core.CoreEdgeClusterSettings;
import org.neo4j.coreedge.core.consensus.membership.RaftMembershipState;
import org.neo4j.coreedge.core.consensus.term.TermState;
import org.neo4j.coreedge.core.consensus.vote.VoteState;
Expand All @@ -36,6 +37,7 @@
import org.neo4j.coreedge.identity.MemberId.Marshal;
import org.neo4j.io.fs.DefaultFileSystemAbstraction;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.lifecycle.Lifespan;
import org.neo4j.logging.NullLogProvider;

Expand Down Expand Up @@ -105,8 +107,10 @@ void dump() throws IOException

private void dumpState( String name, StateMarshal<?> marshal ) throws IOException
{
DurableStateStorage<?> storage = new DurableStateStorage<>(
fs, clusterStateDirectory, name, marshal, 1024, NullLogProvider.getInstance() );
int rotationSize = Config.defaults().get( CoreEdgeClusterSettings.replicated_lock_token_state_size );
DurableStateStorage<?> storage =
new DurableStateStorage<>( fs, clusterStateDirectory, name, marshal, rotationSize,
NullLogProvider.getInstance() );

if ( storage.exists() )
{
Expand Down
Expand Up @@ -111,7 +111,7 @@ public CoreStateMachinesModule( MemberId myself, PlatformModule platformModule,
ReplicatedIdAllocationStateMachine idAllocationStateMachine =
new ReplicatedIdAllocationStateMachine( idAllocationState );

int allocationChunk = 1024; // TODO: AllocationChunk should be configurable and per type.
int allocationChunk = config.get( CoreEdgeClusterSettings.allocation_chunk_size );
ReplicatedIdRangeAcquirer idRangeAcquirer =
new ReplicatedIdRangeAcquirer( replicator, idAllocationStateMachine, allocationChunk, myself,
logProvider );
Expand Down

0 comments on commit 43592cb

Please sign in to comment.