Skip to content

Commit

Permalink
Merge pull request #7709 from davidegrohmann/3.1-cleanups
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
davidegrohmann committed Aug 12, 2016
2 parents 57e5e43 + 9e95898 commit d3d9103
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 89 deletions.
Expand Up @@ -58,7 +58,6 @@
*/
public class SegmentedRaftLog extends LifecycleAdapter implements RaftLog
{
public static final String SEGMENTED_LOG_DIRECTORY_NAME = "raft-log";
private final int READER_POOL_MAX_AGE = 1; // minutes

private final FileSystemAbstraction fileSystem;
Expand Down

This file was deleted.

Expand Up @@ -45,9 +45,9 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.neo4j.coreedge.core.consensus.ReplicatedInteger.valueOf;
import static org.neo4j.coreedge.core.consensus.log.RaftLog.PHYSICAL_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.consensus.log.RaftLogHelper.hasNoContent;
import static org.neo4j.coreedge.core.consensus.log.RaftLogHelper.readLogEntry;
import static org.neo4j.coreedge.core.consensus.log.segmented.SegmentedRaftLog.SEGMENTED_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.EnterpriseCoreEditionModule.RaftLogImplementation.SEGMENTED;

@RunWith(Parameterized.class)
Expand All @@ -67,7 +67,7 @@ public RaftLogDurabilityTest( RaftLogImplementation ignored, RaftLogFactory logF
public static Collection<Object[]> data()
{
RaftLogFactory segmented = ( fileSystem ) -> {
File directory = new File( SEGMENTED_LOG_DIRECTORY_NAME );
File directory = new File( PHYSICAL_LOG_DIRECTORY_NAME );
fileSystem.mkdir( directory );

long rotateAtSizeBytes = 128;
Expand Down
Expand Up @@ -19,52 +19,39 @@
*/
package org.neo4j.coreedge.core.consensus.log.segmented;

import org.junit.After;
import org.junit.Rule;
import org.junit.rules.RuleChain;

import java.io.File;

import org.neo4j.coreedge.core.consensus.log.DummyRaftableContentSerializer;
import org.neo4j.coreedge.core.consensus.log.RaftLog;
import org.neo4j.coreedge.core.consensus.log.RaftLogContractTest;
import org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.lifecycle.LifeSupport;
import org.neo4j.kernel.lifecycle.LifeRule;
import org.neo4j.logging.NullLogProvider;
import org.neo4j.test.OnDemandJobScheduler;
import org.neo4j.test.rule.fs.EphemeralFileSystemRule;
import org.neo4j.time.FakeClock;

import static org.neo4j.coreedge.core.consensus.log.segmented.SegmentedRaftLog.SEGMENTED_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.consensus.log.RaftLog.PHYSICAL_LOG_DIRECTORY_NAME;

public class SegmentedRaftLogContractTest extends RaftLogContractTest
{
private LifeSupport life = new LifeSupport();
private FileSystemAbstraction fileSystem;
private final EphemeralFileSystemRule fsRule = new EphemeralFileSystemRule();
private final LifeRule life = new LifeRule( true );

@After
public void tearDown() throws Throwable
{
life.stop();
life.shutdown();
}
@Rule
public RuleChain chain = RuleChain.outerRule( fsRule ).around( life );

@Override
public RaftLog createRaftLog()
{
if ( fileSystem == null )
{
fileSystem = new EphemeralFileSystemAbstraction();
}

File directory = new File( SEGMENTED_LOG_DIRECTORY_NAME );
File directory = new File( PHYSICAL_LOG_DIRECTORY_NAME );
FileSystemAbstraction fileSystem = fsRule.get();
fileSystem.mkdir( directory );

SegmentedRaftLog newRaftLog = new SegmentedRaftLog( fileSystem, directory, 1024,
new DummyRaftableContentSerializer(),
NullLogProvider.getInstance(), "1 entries", 8, new FakeClock(), new OnDemandJobScheduler() );

life.add( newRaftLog );
life.init();
life.start();
return newRaftLog;
return life.add( new SegmentedRaftLog( fileSystem, directory, 1024, new DummyRaftableContentSerializer(),
NullLogProvider.getInstance(), "1 entries", 8, new FakeClock(), new OnDemandJobScheduler() ) );
}
}
Expand Up @@ -37,8 +37,8 @@

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.neo4j.coreedge.core.consensus.log.segmented.SegmentedRaftLog.SEGMENTED_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.CoreEdgeClusterSettings.raft_log_pruning_strategy;
import static org.neo4j.coreedge.core.consensus.log.RaftLog.PHYSICAL_LOG_DIRECTORY_NAME;

public class SegmentedRaftLogCursorIT
{
Expand All @@ -59,7 +59,7 @@ private SegmentedRaftLog createRaftLog( long rotateAtSize, String pruneStrategy
fileSystem = new EphemeralFileSystemAbstraction();
}

File directory = new File( SEGMENTED_LOG_DIRECTORY_NAME );
File directory = new File( PHYSICAL_LOG_DIRECTORY_NAME );
fileSystem.mkdir( directory );

SegmentedRaftLog newRaftLog =
Expand Down
Expand Up @@ -34,7 +34,7 @@

import static org.junit.Assert.assertEquals;
import static org.neo4j.coreedge.core.consensus.ReplicatedInteger.valueOf;
import static org.neo4j.coreedge.core.consensus.log.segmented.SegmentedRaftLog.SEGMENTED_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.consensus.log.RaftLog.PHYSICAL_LOG_DIRECTORY_NAME;

public class SegmentedRaftLogRotationTruncationPruneTest
{
Expand Down Expand Up @@ -118,7 +118,7 @@ private RaftLog createRaftLog() throws Exception
{
FileSystemAbstraction fileSystem = new EphemeralFileSystemAbstraction();

File directory = new File( SEGMENTED_LOG_DIRECTORY_NAME );
File directory = new File( PHYSICAL_LOG_DIRECTORY_NAME );
fileSystem.mkdir( directory );

SegmentedRaftLog newRaftLog = new SegmentedRaftLog( fileSystem, directory, 1,
Expand Down
Expand Up @@ -29,8 +29,8 @@
import org.neo4j.logging.NullLogProvider;
import org.neo4j.test.OnDemandJobScheduler;

import static org.neo4j.coreedge.core.consensus.log.segmented.SegmentedRaftLog.SEGMENTED_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.CoreEdgeClusterSettings.raft_log_pruning_strategy;
import static org.neo4j.coreedge.core.consensus.log.RaftLog.PHYSICAL_LOG_DIRECTORY_NAME;

public class SegmentedRaftLogVerificationIT extends RaftLogVerificationIT
{
Expand All @@ -39,7 +39,7 @@ protected RaftLog createRaftLog() throws Throwable
{
FileSystemAbstraction fsa = fsRule.get();

File directory = new File( SEGMENTED_LOG_DIRECTORY_NAME );
File directory = new File( PHYSICAL_LOG_DIRECTORY_NAME );
fsa.mkdir( directory );

long rotateAtSizeBytes = 128;
Expand Down
Expand Up @@ -40,8 +40,8 @@
import static java.lang.String.format;
import static java.util.stream.Collectors.joining;

import static org.neo4j.coreedge.core.consensus.log.segmented.SegmentedRaftLog.SEGMENTED_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.EnterpriseCoreEditionModule.CLUSTER_STATE_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.consensus.log.RaftLog.PHYSICAL_LOG_DIRECTORY_NAME;
import static org.neo4j.helpers.collection.MapUtil.stringMap;

public class CoreClusterMember
Expand Down Expand Up @@ -144,7 +144,7 @@ public MemberId id()
public SortedMap<Long,File> getLogFileNames( )
{
File clusterStateDir = new File( storeDir, CLUSTER_STATE_DIRECTORY_NAME );
File logFilesDir = new File( clusterStateDir, SEGMENTED_LOG_DIRECTORY_NAME );
File logFilesDir = new File( clusterStateDir, PHYSICAL_LOG_DIRECTORY_NAME );
return new FileNames( logFilesDir ).getAllFiles( new DefaultFileSystemAbstraction(), null );
}

Expand Down
Expand Up @@ -32,7 +32,7 @@
import org.neo4j.test.coreedge.ClusterRule;

import static org.hamcrest.Matchers.equalTo;
import static org.neo4j.coreedge.core.consensus.log.segmented.SegmentedRaftLog.SEGMENTED_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.consensus.log.RaftLog.PHYSICAL_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.scenarios.SampleData.createData;
import static org.neo4j.coreedge.core.CoreEdgeClusterSettings.raft_log_pruning_strategy;
import static org.neo4j.test.assertion.Assert.assertEventually;
Expand Down Expand Up @@ -95,7 +95,7 @@ public void shouldNotPruneUncommittedEntries() throws Exception
private int numberOfFiles( File storeDir ) throws RuntimeException
{
File clusterDir = new File( storeDir, EnterpriseCoreEditionModule.CLUSTER_STATE_DIRECTORY_NAME );
File raftLogDir = new File( clusterDir, SEGMENTED_LOG_DIRECTORY_NAME );
File raftLogDir = new File( clusterDir, PHYSICAL_LOG_DIRECTORY_NAME );
return raftLogDir.list().length;
}
}
Expand Up @@ -76,8 +76,8 @@
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;

import static org.neo4j.coreedge.core.consensus.log.segmented.SegmentedRaftLog.SEGMENTED_LOG_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.EnterpriseCoreEditionModule.CLUSTER_STATE_DIRECTORY_NAME;
import static org.neo4j.coreedge.core.consensus.log.RaftLog.PHYSICAL_LOG_DIRECTORY_NAME;
import static org.neo4j.function.Predicates.awaitEx;
import static org.neo4j.helpers.collection.Iterables.count;
import static org.neo4j.helpers.collection.MapUtil.stringMap;
Expand Down Expand Up @@ -335,7 +335,7 @@ public void shouldBeAbleToCopyStoresFromCoreToEdge() throws Exception

private long versionBy( File storeDir, BinaryOperator<Long> operator )
{
File raftLogDir = new File( new File( storeDir, CLUSTER_STATE_DIRECTORY_NAME ), SEGMENTED_LOG_DIRECTORY_NAME );
File raftLogDir = new File( new File( storeDir, CLUSTER_STATE_DIRECTORY_NAME ), PHYSICAL_LOG_DIRECTORY_NAME );
SortedMap<Long,File> logs =
new FileNames( raftLogDir ).getAllFiles( new DefaultFileSystemAbstraction(), mock( Log.class ) );
return logs.keySet().stream().reduce( operator ).orElseThrow( IllegalStateException::new );
Expand Down

0 comments on commit d3d9103

Please sign in to comment.