Skip to content

Commit

Permalink
Update default file system usage in lucene index, tools, server and e…
Browse files Browse the repository at this point in the history
…nt.server.
  • Loading branch information
MishaDemianenko committed Nov 21, 2016
1 parent 8729be3 commit dc1c9dd
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 84 deletions.
Expand Up @@ -22,7 +22,6 @@
import java.io.File;
import java.util.Objects;

import org.neo4j.io.fs.DefaultFileSystemAbstraction;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
import org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage;
Expand All @@ -35,7 +34,7 @@
public class LuceneIndexStorageBuilder
{
private DirectoryFactory directoryFactory = DirectoryFactory.PERSISTENT;
private FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
private FileSystemAbstraction fileSystem;
private File indexRootFolder;
private String indexIdentifier;
private PartitionedIndexStorage indexStorage;
Expand Down
Expand Up @@ -33,6 +33,7 @@
import org.neo4j.kernel.api.impl.index.storage.PartitionedIndexStorage;
import org.neo4j.test.TestGraphDatabaseFactory;
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.DefaultFileSystemRule;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.core.IsEqual.equalTo;
Expand All @@ -44,6 +45,8 @@ public class ConstraintIndexFailureIT
{
@Rule
public final TestDirectory storeDir = TestDirectory.testDirectory();
@Rule
public final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule();

@Test
public void shouldFailToValidateConstraintsIfUnderlyingIndexIsFailed() throws Exception
Expand Down Expand Up @@ -102,6 +105,7 @@ private void storeIndexFailure( String failure ) throws IOException
{
File luceneRootDirectory = new File( storeDir.directory(), "schema/index/lucene" );
PartitionedIndexStorage indexStorage = LuceneIndexStorageBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( luceneRootDirectory )
.withIndexIdentifier( "1" ).build();
indexStorage.storeIndexFailure( failure );
Expand Down
Expand Up @@ -42,6 +42,7 @@
import org.neo4j.storageengine.api.schema.IndexSample;
import org.neo4j.storageengine.api.schema.IndexSampler;
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.DefaultFileSystemRule;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand All @@ -53,6 +54,9 @@ public class LuceneSchemaIndexPopulationIT

@Rule
public TestDirectory testDir = TestDirectory.testDirectory();
@Rule
public final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule();

private int affectedNodes;

@Before
Expand Down Expand Up @@ -82,6 +86,7 @@ public LuceneSchemaIndexPopulationIT( int affectedNodes )
public void partitionedIndexPopulation() throws Exception
{
try ( SchemaIndex uniqueIndex = LuceneSchemaIndexBuilder.create().uniqueIndex()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( testDir.directory( "partitionIndex" + affectedNodes ) )
.withIndexIdentifier( "uniqueIndex" + affectedNodes )
.build() )
Expand Down
Expand Up @@ -53,6 +53,7 @@
import org.neo4j.kernel.api.properties.Property;
import org.neo4j.test.Randoms;
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.DefaultFileSystemRule;

import static java.util.stream.Collectors.toSet;
import static org.hamcrest.Matchers.instanceOf;
Expand All @@ -67,6 +68,8 @@ public class LuceneSchemaIndexUniquenessVerificationIT

@Rule
public TestDirectory testDir = TestDirectory.testDirectory();
@Rule
public final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule();

@Parameter
public int nodesToCreate;
Expand Down Expand Up @@ -95,6 +98,7 @@ public void setPartitionSize() throws Exception

index = LuceneSchemaIndexBuilder.create()
.uniqueIndex()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( testDir.directory( "uniquenessVerification" ) )
.withIndexIdentifier( "index" )
.build();
Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.kernel.impl.factory.OperationalMode;
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.DefaultFileSystemRule;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand All @@ -37,11 +38,14 @@ public class LuceneLabelScanIndexBuilderTest

@Rule
public final TestDirectory testDir = TestDirectory.testDirectory( getClass() );
@Rule
public final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule();

@Test
public void readOnlyIndexCreation() throws Exception
{
try ( LabelScanIndex index = LuceneLabelScanIndexBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( testDir.graphDbDir() )
.withConfig( getReadOnlyConfig() )
.withOperationalMode( OperationalMode.single )
Expand All @@ -55,6 +59,7 @@ public void readOnlyIndexCreation() throws Exception
public void writableIndexCreation() throws Exception
{
try ( LabelScanIndex index = LuceneLabelScanIndexBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( testDir.graphDbDir() )
.withConfig( getDefaultConfig() )
.withOperationalMode( OperationalMode.single )
Expand Down
Expand Up @@ -35,6 +35,7 @@
import org.neo4j.kernel.api.labelscan.NodeLabelUpdate;
import org.neo4j.storageengine.api.schema.LabelScanReader;
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.DefaultFileSystemRule;

import static org.junit.Assert.assertEquals;

Expand All @@ -44,6 +45,9 @@ public class LuceneLabelScanIndexIT

@Rule
public TestDirectory testDir = TestDirectory.testDirectory();
@Rule
public final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule();

private int affectedNodes;

@Before
Expand Down Expand Up @@ -73,6 +77,7 @@ public LuceneLabelScanIndexIT( int affectedNodes )
public void readFromPartitionedIndex() throws IOException
{
try ( LabelScanIndex labelScanIndex = LuceneLabelScanIndexBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withIndexIdentifier( "partitionedIndex" + affectedNodes )
.withIndexRootFolder( testDir.directory( "partitionedIndexFolder" + affectedNodes ) )
.build() )
Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.kernel.impl.factory.OperationalMode;
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.DefaultFileSystemRule;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand All @@ -36,11 +37,14 @@ public class LuceneSchemaIndexBuilderTest
{
@Rule
public final TestDirectory testDir = TestDirectory.testDirectory();
@Rule
public final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule();

@Test
public void readOnlyIndexCreation() throws Exception
{
try ( SchemaIndex schemaIndex = LuceneSchemaIndexBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withConfig( getReadOnlyConfig() )
.withOperationalMode( OperationalMode.single )
.withIndexRootFolder( testDir.graphDbDir() )
Expand All @@ -56,6 +60,7 @@ public void writableIndexCreation() throws Exception
{
try ( SchemaIndex schemaIndex = LuceneSchemaIndexBuilder.create()
.withConfig( getDefaultConfig() )
.withFileSystem( fileSystemRule.get() )
.withOperationalMode( OperationalMode.single )
.withIndexRootFolder( testDir.graphDbDir() )
.withIndexIdentifier( "b" )
Expand Down
Expand Up @@ -43,6 +43,7 @@
import org.neo4j.kernel.api.index.NodePropertyUpdate;
import org.neo4j.kernel.impl.api.index.IndexUpdateMode;
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.DefaultFileSystemRule;

import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertEquals;
Expand All @@ -57,6 +58,8 @@ public class LuceneSchemaIndexIT

@Rule
public TestDirectory testDir = TestDirectory.testDirectory();
@Rule
public final DefaultFileSystemRule fileSystemRule = new DefaultFileSystemRule();

@Before
public void before() throws Exception
Expand Down Expand Up @@ -118,6 +121,7 @@ public void snapshotForIndexWithNoCommits() throws Exception
public void updateMultiplePartitionedIndex() throws IOException, IndexEntryConflictException
{
try ( SchemaIndex index = LuceneSchemaIndexBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( testDir.directory() )
.withIndexIdentifier( "partitionedIndexForUpdates" )
.build() )
Expand All @@ -140,6 +144,7 @@ public void createPopulateDropIndex() throws Exception
{
File crudOperation = testDir.directory( "indexCRUDOperation" );
try ( SchemaIndex crudIndex = LuceneSchemaIndexBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( crudOperation )
.withIndexIdentifier( "crudIndex" )
.build() )
Expand All @@ -163,6 +168,7 @@ public void createPopulateDropIndex() throws Exception
public void createFailPartitionedIndex() throws Exception
{
try ( SchemaIndex failedIndex = LuceneSchemaIndexBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( testDir.directory( "failedIndexFolder" ) )
.withIndexIdentifier( "failedIndex" )
.build() )
Expand All @@ -187,6 +193,7 @@ public void openClosePartitionedIndex() throws IOException
try
{
reopenIndex = LuceneSchemaIndexBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( testDir.directory( "reopenIndexFolder" ) )
.withIndexIdentifier( "reopenIndex" )
.build();
Expand Down Expand Up @@ -239,6 +246,7 @@ private void addDocumentToIndex( SchemaIndex index, int documents ) throws IOExc
private LuceneIndexAccessor createDefaultIndexAccessor() throws IOException
{
SchemaIndex index = LuceneSchemaIndexBuilder.create()
.withFileSystem( fileSystemRule.get() )
.withIndexRootFolder( testDir.directory() )
.withIndexIdentifier( "testIndex" )
.build();
Expand Down
Expand Up @@ -19,7 +19,6 @@
*/
package org.neo4j.server;

import com.sun.jersey.api.core.HttpContext;
import org.apache.commons.configuration.Configuration;
import org.bouncycastle.operator.OperatorCreationException;

Expand All @@ -43,7 +42,7 @@
import org.neo4j.helpers.AdvertisedSocketAddress;
import org.neo4j.helpers.ListenSocketAddress;
import org.neo4j.helpers.RunCarefully;
import org.neo4j.io.fs.DefaultFileSystemAbstraction;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.kernel.GraphDatabaseQueryService;
import org.neo4j.kernel.api.security.AuthManager;
import org.neo4j.kernel.configuration.Config;
Expand All @@ -56,8 +55,8 @@
import org.neo4j.logging.Log;
import org.neo4j.logging.LogProvider;
import org.neo4j.server.configuration.ClientConnectorSettings;
import org.neo4j.server.configuration.ServerSettings;
import org.neo4j.server.configuration.ClientConnectorSettings.HttpConnector;
import org.neo4j.server.configuration.ServerSettings;
import org.neo4j.server.database.CypherExecutor;
import org.neo4j.server.database.CypherExecutorProvider;
import org.neo4j.server.database.Database;
Expand Down Expand Up @@ -91,7 +90,6 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.neo4j.helpers.collection.Iterables.map;
import static org.neo4j.kernel.impl.util.JobScheduler.Groups.serverTransactionTimeout;
import static org.neo4j.server.configuration.ClientConnectorSettings.httpConnector;
import static org.neo4j.server.configuration.ServerSettings.http_logging_enabled;
import static org.neo4j.server.configuration.ServerSettings.http_logging_rotation_keep_number;
import static org.neo4j.server.configuration.ServerSettings.http_logging_rotation_size;
Expand Down Expand Up @@ -340,7 +338,7 @@ private void setUpHttpLogging() throws IOException {
}

AsyncRequestLog requestLog = new AsyncRequestLog(
new DefaultFileSystemAbstraction(),
dependencyResolver.resolveDependency( FileSystemAbstraction.class ),
new File( config.get( GraphDatabaseSettings.logs_directory ), "http.log" ).toString(),
config.get( http_logging_rotation_size ),
config.get( http_logging_rotation_keep_number ) );
Expand Down

0 comments on commit dc1c9dd

Please sign in to comment.