Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR comment: Extract shared code in index provider factories into Abst…
…ractIndexProviderFactory
- Loading branch information
Showing
6 changed files
with
149 additions
and
135 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
...kernel/src/main/java/org/neo4j/kernel/impl/index/schema/AbstractIndexProviderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,91 @@ | |||
/* | |||
* Copyright (c) 2002-2018 "Neo4j," | |||
* Neo4j Sweden AB [http://neo4j.com] | |||
* | |||
* This file is part of Neo4j. | |||
* | |||
* Neo4j is free software: you can redistribute it and/or modify | |||
* it under the terms of the GNU General Public License as published by | |||
* the Free Software Foundation, either version 3 of the License, or | |||
* (at your option) any later version. | |||
* | |||
* This program is distributed in the hope that it will be useful, | |||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
* GNU General Public License for more details. | |||
* | |||
* You should have received a copy of the GNU General Public License | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
package org.neo4j.kernel.impl.index.schema; | |||
|
|||
import java.io.File; | |||
|
|||
import org.neo4j.graphdb.factory.GraphDatabaseSettings; | |||
import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector; | |||
import org.neo4j.io.fs.FileSystemAbstraction; | |||
import org.neo4j.io.pagecache.PageCache; | |||
import org.neo4j.kernel.api.index.IndexProvider; | |||
import org.neo4j.kernel.api.index.LoggingMonitor; | |||
import org.neo4j.kernel.configuration.Config; | |||
import org.neo4j.kernel.extension.ExtensionType; | |||
import org.neo4j.kernel.extension.KernelExtensionFactory; | |||
import org.neo4j.kernel.impl.factory.OperationalMode; | |||
import org.neo4j.kernel.impl.logging.LogService; | |||
import org.neo4j.kernel.impl.spi.KernelContext; | |||
import org.neo4j.kernel.lifecycle.Lifecycle; | |||
import org.neo4j.kernel.monitoring.Monitors; | |||
import org.neo4j.logging.Log; | |||
|
|||
public abstract class AbstractIndexProviderFactory extends KernelExtensionFactory<GenericNativeIndexProviderFactory.Dependencies> | |||
{ | |||
protected AbstractIndexProviderFactory( String key ) | |||
{ | |||
super( ExtensionType.DATABASE, key ); | |||
} | |||
|
|||
@Override | |||
public Lifecycle newInstance( KernelContext context, Dependencies dependencies ) | |||
{ | |||
PageCache pageCache = dependencies.pageCache(); | |||
File databaseDir = context.directory(); | |||
FileSystemAbstraction fs = dependencies.fileSystem(); | |||
Log log = dependencies.getLogService().getInternalLogProvider().getLog( loggingClass() ); | |||
Monitors monitors = dependencies.monitors(); | |||
monitors.addMonitorListener( new LoggingMonitor( log ), descriptorString() ); | |||
IndexProvider.Monitor monitor = monitors.newMonitor( IndexProvider.Monitor.class, descriptorString() ); | |||
Config config = dependencies.getConfig(); | |||
OperationalMode operationalMode = context.databaseInfo().operationalMode; | |||
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector = dependencies.recoveryCleanupWorkCollector(); | |||
return internalCreate( pageCache, databaseDir, fs, monitor, config, operationalMode, recoveryCleanupWorkCollector ); | |||
} | |||
|
|||
protected static int adjustPriorityForConfig( int basePriority, GraphDatabaseSettings.SchemaIndex target, Config config ) | |||
{ | |||
String defaultSchemaProvider = config.get( GraphDatabaseSettings.default_schema_provider ); | |||
return target.providerIdentifier().equals( defaultSchemaProvider ) ? 100 : basePriority; | |||
} | |||
|
|||
protected abstract Class loggingClass(); | |||
|
|||
protected abstract String descriptorString(); | |||
|
|||
protected abstract IndexProvider internalCreate( PageCache pageCache, File storeDir, FileSystemAbstraction fs, | |||
IndexProvider.Monitor monitor, Config config, OperationalMode operationalMode, | |||
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector ); | |||
|
|||
public interface Dependencies | |||
{ | |||
PageCache pageCache(); | |||
|
|||
FileSystemAbstraction fileSystem(); | |||
|
|||
LogService getLogService(); | |||
|
|||
Monitors monitors(); | |||
|
|||
Config getConfig(); | |||
|
|||
RecoveryCleanupWorkCollector recoveryCleanupWorkCollector(); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.