-
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.
[Remote Store] Permit backed futures to prevent timeouts during uploa…
…d bursts (#12159) (#13645) Signed-off-by: vikasvb90 <[email protected]>
- Loading branch information
Showing
26 changed files
with
1,555 additions
and
132 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
90 changes: 90 additions & 0 deletions
90
...pository-s3/src/main/java/org/opensearch/repositories/s3/GenericStatsMetricPublisher.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,90 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.repositories.s3; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
/** | ||
* Generic stats of repository-s3 plugin. | ||
*/ | ||
public class GenericStatsMetricPublisher { | ||
|
||
private final AtomicLong normalPriorityQSize = new AtomicLong(); | ||
private final AtomicInteger normalPriorityPermits = new AtomicInteger(); | ||
private final AtomicLong lowPriorityQSize = new AtomicLong(); | ||
private final AtomicInteger lowPriorityPermits = new AtomicInteger(); | ||
private final long normalPriorityQCapacity; | ||
private final int maxNormalPriorityPermits; | ||
private final long lowPriorityQCapacity; | ||
private final int maxLowPriorityPermits; | ||
|
||
public GenericStatsMetricPublisher( | ||
long normalPriorityQCapacity, | ||
int maxNormalPriorityPermits, | ||
long lowPriorityQCapacity, | ||
int maxLowPriorityPermits | ||
) { | ||
this.normalPriorityQCapacity = normalPriorityQCapacity; | ||
this.maxNormalPriorityPermits = maxNormalPriorityPermits; | ||
this.lowPriorityQCapacity = lowPriorityQCapacity; | ||
this.maxLowPriorityPermits = maxLowPriorityPermits; | ||
} | ||
|
||
public void updateNormalPriorityQSize(long qSize) { | ||
normalPriorityQSize.addAndGet(qSize); | ||
} | ||
|
||
public void updateLowPriorityQSize(long qSize) { | ||
lowPriorityQSize.addAndGet(qSize); | ||
} | ||
|
||
public void updateNormalPermits(boolean increment) { | ||
if (increment) { | ||
normalPriorityPermits.incrementAndGet(); | ||
} else { | ||
normalPriorityPermits.decrementAndGet(); | ||
} | ||
} | ||
|
||
public void updateLowPermits(boolean increment) { | ||
if (increment) { | ||
lowPriorityPermits.incrementAndGet(); | ||
} else { | ||
lowPriorityPermits.decrementAndGet(); | ||
} | ||
} | ||
|
||
public long getNormalPriorityQSize() { | ||
return normalPriorityQSize.get(); | ||
} | ||
|
||
public int getAcquiredNormalPriorityPermits() { | ||
return normalPriorityPermits.get(); | ||
} | ||
|
||
public long getLowPriorityQSize() { | ||
return lowPriorityQSize.get(); | ||
} | ||
|
||
public int getAcquiredLowPriorityPermits() { | ||
return lowPriorityPermits.get(); | ||
} | ||
|
||
Map<String, Long> stats() { | ||
final Map<String, Long> results = new HashMap<>(); | ||
results.put("NormalPriorityQUtilization", (normalPriorityQSize.get() * 100) / normalPriorityQCapacity); | ||
results.put("LowPriorityQUtilization", (lowPriorityQSize.get() * 100) / lowPriorityQCapacity); | ||
results.put("NormalPriorityPermitsUtilization", (normalPriorityPermits.get() * 100L) / maxNormalPriorityPermits); | ||
results.put("LowPriorityPermitsUtilization", (lowPriorityPermits.get() * 100L) / maxLowPriorityPermits); | ||
return results; | ||
} | ||
} |
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.