Search in sources :

Example 1 with BinaryScaledAmount

use of com.yahoo.binaryprefix.BinaryScaledAmount in project vespa by vespa-engine.

the class SearchChains method setCacheSizeForHttpProviders.

private void setCacheSizeForHttpProviders(BinaryScaledAmount totalProviderCacheSize) {
    double totalCacheWeight = 0;
    for (HttpProvider provider : httpProviders()) {
        totalCacheWeight += provider.getCacheWeight();
    }
    final BinaryScaledAmount cacheUnit = totalProviderCacheSize.divide(totalCacheWeight);
    for (HttpProvider provider : httpProviders()) {
        provider.setCacheSize(cacheUnit.multiply(provider.getCacheWeight()));
    }
}
Also used : BinaryScaledAmount(com.yahoo.binaryprefix.BinaryScaledAmount)

Example 2 with BinaryScaledAmount

use of com.yahoo.binaryprefix.BinaryScaledAmount in project vespa by vespa-engine.

the class SearchChainsTestBase method setupSearchChains.

@Before
public void setupSearchChains() {
    SearchChains searchChains = new DomSearchChainsBuilder().build(root, servicesXml());
    searchChains.initialize(MockSearchClusters.twoMockClusterSpecsByName(root), new BinaryScaledAmount(100, BinaryPrefix.mega));
    root.freezeModelTopology();
}
Also used : DomSearchChainsBuilder(com.yahoo.vespa.model.builder.xml.dom.chains.search.DomSearchChainsBuilder) BinaryScaledAmount(com.yahoo.binaryprefix.BinaryScaledAmount) Before(org.junit.Before)

Example 3 with BinaryScaledAmount

use of com.yahoo.binaryprefix.BinaryScaledAmount in project vespa by vespa-engine.

the class BinaryScaledAmountParser method parse.

public static BinaryScaledAmount parse(String valueString) {
    Matcher matcher = pattern.matcher(valueString);
    if (!matcher.matches()) {
        throw new RuntimeException("Pattern and schema is out of sync.");
    }
    double amount = Double.valueOf(matcher.group(1));
    String binaryPrefixString = matcher.group(3);
    return new BinaryScaledAmount(amount, asBinaryPrefix(binaryPrefixString));
}
Also used : Matcher(java.util.regex.Matcher) BinaryScaledAmount(com.yahoo.binaryprefix.BinaryScaledAmount)

Aggregations

BinaryScaledAmount (com.yahoo.binaryprefix.BinaryScaledAmount)3 DomSearchChainsBuilder (com.yahoo.vespa.model.builder.xml.dom.chains.search.DomSearchChainsBuilder)1 Matcher (java.util.regex.Matcher)1 Before (org.junit.Before)1