forked from TrueCloudLab/frostfs-sdk-java
[#32] Provide a pool of clients to grpc
Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
parent
3c3ed76727
commit
e9e9480701
56 changed files with 1712 additions and 59 deletions
31
client/src/main/java/info/frostfs/sdk/pool/MethodStatus.java
Normal file
31
client/src/main/java/info/frostfs/sdk/pool/MethodStatus.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package info.frostfs.sdk.pool;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class MethodStatus {
|
||||
@Getter(AccessLevel.NONE)
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private final String name;
|
||||
private StatusSnapshot snapshot;
|
||||
|
||||
public MethodStatus(String name) {
|
||||
this.name = name;
|
||||
this.snapshot = new StatusSnapshot();
|
||||
}
|
||||
|
||||
void incRequests(long elapsed) {
|
||||
lock.lock();
|
||||
try {
|
||||
snapshot.setAllTime(snapshot.getAllTime() + elapsed);
|
||||
snapshot.setAllRequests(snapshot.getAllRequests() + 1);
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue