-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IGNITE-20697 Store crash recovery data to checkpoint recovery files
- Loading branch information
1 parent
871db13
commit 619220d
Showing
12 changed files
with
160 additions
and
46 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
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
70 changes: 70 additions & 0 deletions
70
...ignite/internal/processors/cache/persistence/pagemem/FillRateBasedThrottlingStrategy.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,70 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.processors.cache.persistence.pagemem; | ||
|
||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
import static org.apache.ignite.internal.processors.cache.persistence.pagemem.PagesWriteThrottlePolicy.CP_BUF_FILL_THRESHOLD; | ||
|
||
/** | ||
* Logic used to protect memory (Checkpoint Buffer) from exhaustion using throttling duration based on storage fill rate. | ||
*/ | ||
class FillRateBasedThrottlingStrategy implements ThrottlingStrategy { | ||
/** | ||
* Minimum throttle time. 10 microseconds. | ||
*/ | ||
private static final long MIN_THROTTLE_NANOS = 10_000L; | ||
|
||
/** | ||
* Maximum throttle time. 1 second. | ||
*/ | ||
private static final long MAX_THROTTLE_NANOS = 1_000_000_000L; | ||
|
||
/** | ||
* The exponent to calculate park time. | ||
*/ | ||
private static final double POW = Math.log((double)MAX_THROTTLE_NANOS / MIN_THROTTLE_NANOS); | ||
|
||
/** */ | ||
private final CheckpointBufferOverflowWatchdog cpBufOverflowWatchdog; | ||
|
||
/** */ | ||
private final AtomicBoolean throttlingStarted = new AtomicBoolean(); | ||
|
||
/** */ | ||
FillRateBasedThrottlingStrategy(CheckpointBufferOverflowWatchdog watchdog) { | ||
cpBufOverflowWatchdog = watchdog; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public long protectionParkTime() { | ||
double fillRate = cpBufOverflowWatchdog.fillRate(); | ||
|
||
if (fillRate < CP_BUF_FILL_THRESHOLD) | ||
return 0; | ||
|
||
throttlingStarted.set(true); | ||
|
||
return (long)(Math.exp(POW * (fillRate - CP_BUF_FILL_THRESHOLD) / (1 - CP_BUF_FILL_THRESHOLD)) * MIN_THROTTLE_NANOS); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override public boolean reset() { | ||
return throttlingStarted.compareAndSet(true, 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
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
20 changes: 20 additions & 0 deletions
20
...a/org/apache/ignite/internal/processors/cache/persistence/pagemem/ThrottlingStrategy.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,20 @@ | ||
package org.apache.ignite.internal.processors.cache.persistence.pagemem; | ||
|
||
/** | ||
* Strategy used to protect memory from exhaustion. | ||
*/ | ||
public interface ThrottlingStrategy { | ||
/** | ||
* Computes next duration (in nanos) to throttle a thread. | ||
* | ||
* @return park time in nanos. | ||
*/ | ||
public long protectionParkTime(); | ||
|
||
/** | ||
* Resets the state. Invoked when no throttling is needed anymore. | ||
* | ||
* @return {@code true} if the instance was not already in a reset state | ||
*/ | ||
public boolean reset(); | ||
} |
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.