Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move check pointing in its own thread
Check pointing can be triggered based on time and number of transactions, default values are 5 minutes and 100_000 txs respectively. Introduce CheckPointTracer in order to trace check point events, which are now disconnected from LogAppendEvents.
- Loading branch information
1 parent
001de30
commit 6d43d73
Showing
29 changed files
with
1,098 additions
and
156 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
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
84 changes: 84 additions & 0 deletions
84
...l/src/main/java/org/neo4j/kernel/impl/transaction/log/checkpoint/CheckPointScheduler.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Copyright (c) 2002-2015 "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.io.IOException; | ||
|
||
import org.neo4j.kernel.impl.store.UnderlyingStorageException; | ||
import org.neo4j.kernel.impl.util.JobScheduler; | ||
import org.neo4j.kernel.lifecycle.LifecycleAdapter; | ||
|
||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
import static org.neo4j.kernel.impl.util.JobScheduler.Groups.checkPoint; | ||
|
||
public class CheckPointScheduler extends LifecycleAdapter | ||
{ | ||
private final CheckPointer checkPointer; | ||
private final JobScheduler scheduler; | ||
private final long recurringPeriodMillis; | ||
private final Runnable job = new Runnable() | ||
{ | ||
@Override | ||
public void run() | ||
{ | ||
try | ||
{ | ||
checkPointer.checkPointIfNeeded(); | ||
} | ||
catch ( IOException e ) | ||
{ | ||
// no need to reschedule since the check pointer has raised a kernel panic and a shutdown is expected | ||
throw new UnderlyingStorageException( e ); | ||
} | ||
|
||
// reschedule only if it is not stopped | ||
if ( !stopped ) | ||
{ | ||
handle = scheduler.schedule( checkPoint, job, recurringPeriodMillis, MILLISECONDS ); | ||
} | ||
} | ||
}; | ||
|
||
private volatile JobScheduler.JobHandle handle; | ||
private volatile boolean stopped = false; | ||
|
||
public CheckPointScheduler( CheckPointer checkPointer, JobScheduler scheduler, long recurringPeriodMillis ) | ||
{ | ||
this.checkPointer = checkPointer; | ||
this.scheduler = scheduler; | ||
this.recurringPeriodMillis = recurringPeriodMillis; | ||
} | ||
|
||
@Override | ||
public void start() throws Throwable | ||
{ | ||
handle = scheduler.schedule( checkPoint, job, recurringPeriodMillis, MILLISECONDS ); | ||
} | ||
|
||
@Override | ||
public void stop() throws Throwable | ||
{ | ||
stopped = true; | ||
if ( handle != null ) | ||
{ | ||
handle.cancel( false ); | ||
} | ||
} | ||
} |
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
56 changes: 56 additions & 0 deletions
56
.../src/main/java/org/neo4j/kernel/impl/transaction/log/checkpoint/CheckPointThresholds.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2002-2015 "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; | ||
|
||
public class CheckPointThresholds | ||
{ | ||
public static CheckPointThreshold or( final CheckPointThreshold... thresholds ) | ||
{ | ||
return new CheckPointThreshold() | ||
{ | ||
@Override | ||
public boolean isCheckPointingNeeded() | ||
{ | ||
for ( CheckPointThreshold threshold : thresholds ) | ||
{ | ||
if ( threshold.isCheckPointingNeeded() ) | ||
{ | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
@Override | ||
public void checkPointHappened( long transactionId ) | ||
{ | ||
for ( CheckPointThreshold threshold : thresholds ) | ||
{ | ||
threshold.checkPointHappened( transactionId ); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
private CheckPointThresholds() | ||
{ | ||
} | ||
} |
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.