use of com.hedera.services.sysfiles.domain.throttling.ThrottleDefinitions in project hedera-services by hashgraph.
the class HapiThrottlingTest method delegatesRebuild.
@Test
void delegatesRebuild() {
// setup:
ThrottleDefinitions defs = new ThrottleDefinitions();
// when:
subject.rebuildFor(defs);
// then:
verify(delegate).rebuildFor(defs);
}
use of com.hedera.services.sysfiles.domain.throttling.ThrottleDefinitions in project hedera-services by hashgraph.
the class TxnAwareHandleThrottlingTest method otherMethodsPassThrough.
@Test
void otherMethodsPassThrough() {
// setup:
ThrottleDefinitions defs = new ThrottleDefinitions();
List<DeterministicThrottle> whatever = List.of(DeterministicThrottle.withTps(1));
given(delegate.allActiveThrottles()).willReturn(whatever);
given(delegate.activeThrottlesFor(HederaFunctionality.CryptoTransfer)).willReturn(whatever);
// when:
var all = subject.allActiveThrottles();
var onlyXfer = subject.activeThrottlesFor(HederaFunctionality.CryptoTransfer);
subject.rebuildFor(defs);
// then:
verify(delegate).rebuildFor(defs);
assertSame(whatever, all);
assertSame(whatever, onlyXfer);
}
use of com.hedera.services.sysfiles.domain.throttling.ThrottleDefinitions in project hedera-services by hashgraph.
the class DeterministicThrottling method rebuildFor.
@Override
public void rebuildFor(ThrottleDefinitions defs) {
List<DeterministicThrottle> newActiveThrottles = new ArrayList<>();
EnumMap<HederaFunctionality, List<Pair<DeterministicThrottle, Integer>>> reqLists = new EnumMap<>(HederaFunctionality.class);
int n = capacitySplitSource.getAsInt();
for (var bucket : defs.getBuckets()) {
try {
var mapping = bucket.asThrottleMapping(n);
var throttle = mapping.getLeft();
var reqs = mapping.getRight();
for (var req : reqs) {
reqLists.computeIfAbsent(req.getLeft(), ignore -> new ArrayList<>()).add(Pair.of(throttle, req.getRight()));
}
newActiveThrottles.add(throttle);
} catch (IllegalStateException badBucket) {
log.error("When constructing bucket '{}' from state: {}", bucket.getName(), badBucket.getMessage());
}
}
EnumMap<HederaFunctionality, ThrottleReqsManager> newFunctionReqs = new EnumMap<>(HederaFunctionality.class);
reqLists.forEach((function, reqs) -> newFunctionReqs.put(function, new ThrottleReqsManager(reqs)));
functionReqs = newFunctionReqs;
activeThrottles = newActiveThrottles;
logResolvedDefinitions();
}
Aggregations