Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the concept of check-point threshold policies.
These are service loaded based on the 'dbms.checkpoint' setting, and used as factories of the concrete CheckPointThreshold instances. This allows us to easily add more varied kinds of check point thresholds in the future.
- Loading branch information
Showing
7 changed files
with
181 additions
and
30 deletions.
There are no files selected for viewing
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
67 changes: 67 additions & 0 deletions
67
...main/java/org/neo4j/kernel/impl/transaction/log/checkpoint/CheckPointThresholdPolicy.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,67 @@ | |||
/* | |||
* Copyright (c) 2002-2017 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.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.transaction.log.checkpoint; | |||
|
|||
import java.time.Clock; | |||
import java.util.NoSuchElementException; | |||
|
|||
import org.neo4j.helpers.Service; | |||
import org.neo4j.kernel.configuration.Config; | |||
import org.neo4j.logging.LogProvider; | |||
|
|||
/** | |||
* The {@link CheckPointThresholdPolicy} specifies the overall <em>type</em> of threshold that should be used for | |||
* deciding when to check point. | |||
* | |||
* The is determined by the {@link org.neo4j.graphdb.factory.GraphDatabaseSettings#check_point_policy} setting, and | |||
* based on this, the concrete policies are loaded and used to | |||
* {@link CheckPointThreshold#createThreshold(Config, Clock, org.neo4j.logging.LogProvider) create} the final and fully configured check point | |||
* thresholds. | |||
*/ | |||
public abstract class CheckPointThresholdPolicy extends Service | |||
{ | |||
/** | |||
* Create a new instance of a service implementation identified with the | |||
* specified key(s). | |||
* | |||
* @param key the main key for identifying this service implementation | |||
* @param altKeys alternative spellings of the identifier of this service | |||
*/ | |||
protected CheckPointThresholdPolicy( String key, String... altKeys ) | |||
{ | |||
super( key, altKeys ); | |||
} | |||
|
|||
/** | |||
* Load the {@link CheckPointThresholdPolicy} by the given name. | |||
* | |||
* @throws NoSuchElementException if the policy was not found. | |||
*/ | |||
public static CheckPointThresholdPolicy loadPolicy( String policyName ) throws NoSuchElementException | |||
{ | |||
return Service.load( CheckPointThresholdPolicy.class, policyName ); | |||
} | |||
|
|||
/** | |||
* Create a {@link CheckPointThreshold} instance based on this policy and the given configurations. | |||
*/ | |||
public abstract CheckPointThreshold createThreshold( Config config, Clock clock, | |||
LogProvider logProvider ); | |||
} |
55 changes: 55 additions & 0 deletions
55
...c/main/java/org/neo4j/kernel/impl/transaction/log/checkpoint/PeriodicThresholdPolicy.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,55 @@ | |||
/* | |||
* Copyright (c) 2002-2017 "Neo Technology," | |||
* Network Engine for Objects in Lund AB [http://neotechnology.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.transaction.log.checkpoint; | |||
|
|||
import java.time.Clock; | |||
|
|||
import org.neo4j.graphdb.factory.GraphDatabaseSettings; | |||
import org.neo4j.helpers.Service; | |||
import org.neo4j.kernel.configuration.Config; | |||
import org.neo4j.logging.LogProvider; | |||
|
|||
import static org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointThreshold.or; | |||
|
|||
/** | |||
* The {@code periodic} check point threshold policy uses the {@link GraphDatabaseSettings#check_point_interval_time} | |||
* and {@link GraphDatabaseSettings#check_point_interval_tx} to decide when check points processes should be started. | |||
*/ | |||
@Service.Implementation( CheckPointThresholdPolicy.class ) | |||
public class PeriodicThresholdPolicy extends CheckPointThresholdPolicy | |||
{ | |||
public PeriodicThresholdPolicy() | |||
{ | |||
super( "periodically", "periodic", "interval" ); | |||
} | |||
|
|||
@Override | |||
public CheckPointThreshold createThreshold( Config config, Clock clock, LogProvider logProvider ) | |||
{ | |||
int txThreshold = config.get( GraphDatabaseSettings.check_point_interval_tx ); | |||
final CountCommittedTransactionThreshold countCommittedTransactionThreshold = | |||
new CountCommittedTransactionThreshold( txThreshold ); | |||
|
|||
long timeMillisThreshold = config.get( GraphDatabaseSettings.check_point_interval_time ).toMillis(); | |||
TimeCheckPointThreshold timeCheckPointThreshold = new TimeCheckPointThreshold( timeMillisThreshold, clock ); | |||
|
|||
return or( countCommittedTransactionThreshold, timeCheckPointThreshold ); | |||
} | |||
} |
1 change: 1 addition & 0 deletions
1
...A-INF/services/org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointThresholdPolicy
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 @@ | |||
org.neo4j.kernel.impl.transaction.log.checkpoint.PeriodicThresholdPolicy |
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