use of com.facebook.buck.util.concurrent.ResourceAmounts in project buck by facebook.
the class BuckConfig method getResourceAmountsPerRuleType.
public ImmutableMap<String, ResourceAmounts> getResourceAmountsPerRuleType() {
ImmutableMap.Builder<String, ResourceAmounts> result = ImmutableMap.builder();
ImmutableMap<String, String> entries = getEntriesForSection(RESOURCES_PER_RULE_SECTION_HEADER);
for (String ruleName : entries.keySet()) {
ImmutableList<String> configAmounts = getListWithoutComments(RESOURCES_PER_RULE_SECTION_HEADER, ruleName);
Preconditions.checkArgument(configAmounts.size() == ResourceAmounts.RESOURCE_TYPE_COUNT, "Buck config entry [%s].%s contains %s values, but expected to contain %s values " + "in the following order: cpu, memory, disk_io, network_io", RESOURCES_PER_RULE_SECTION_HEADER, ruleName, configAmounts.size(), ResourceAmounts.RESOURCE_TYPE_COUNT);
ResourceAmounts amounts = ResourceAmounts.of(Integer.valueOf(configAmounts.get(0)), Integer.valueOf(configAmounts.get(1)), Integer.valueOf(configAmounts.get(2)), Integer.valueOf(configAmounts.get(3)));
result.put(ruleName, amounts);
}
return result.build();
}
use of com.facebook.buck.util.concurrent.ResourceAmounts in project buck by facebook.
the class BuckConfigTest method testGettingResourceAmountsPerRuleType.
@Test
public void testGettingResourceAmountsPerRuleType() throws IOException {
Reader reader = new StringReader(Joiner.on('\n').join("[resources_per_rule]", "some_rule = 1, 20, 3, 4", "other_rule = 4,30,2,1"));
BuckConfig config = BuckConfigTestUtils.createWithDefaultFilesystem(temporaryFolder, reader);
ImmutableMap<String, ResourceAmounts> result = config.getResourceAmountsPerRuleType();
assertEquals(ImmutableMap.of("some_rule", ResourceAmounts.of(1, 20, 3, 4), "other_rule", ResourceAmounts.of(4, 30, 2, 1)), result);
}
Aggregations