use of java.util.Arrays.asList in project jackrabbit-oak by apache.
the class ScalabilityRunner method main.
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
OptionSpec<File> base = parser.accepts("base", "Base directory").withRequiredArg().ofType(File.class).defaultsTo(new File("target"));
OptionSpec<String> host = parser.accepts("host", "MongoDB host").withRequiredArg().defaultsTo("localhost");
OptionSpec<Integer> port = parser.accepts("port", "MongoDB port").withRequiredArg().ofType(Integer.class).defaultsTo(27017);
OptionSpec<String> dbName = parser.accepts("db", "MongoDB database").withRequiredArg();
OptionSpec<Boolean> dropDBAfterTest = parser.accepts("dropDBAfterTest", "Whether to drop the MongoDB database after the test").withOptionalArg().ofType(Boolean.class).defaultsTo(true);
OptionSpec<String> rdbjdbcuri = parser.accepts("rdbjdbcuri", "RDB JDBC URI").withOptionalArg().defaultsTo("jdbc:h2:./target/benchmark");
OptionSpec<String> rdbjdbcuser = parser.accepts("rdbjdbcuser", "RDB JDBC user").withOptionalArg().defaultsTo("");
OptionSpec<String> rdbjdbcpasswd = parser.accepts("rdbjdbcpasswd", "RDB JDBC password").withOptionalArg().defaultsTo("");
OptionSpec<String> rdbjdbctableprefix = parser.accepts("rdbjdbctableprefix", "RDB JDBC table prefix").withOptionalArg().defaultsTo("");
OptionSpec<Boolean> mmap = parser.accepts("mmap", "TarMK memory mapping").withOptionalArg().ofType(Boolean.class).defaultsTo("64".equals(System.getProperty("sun.arch.data.model")));
OptionSpec<Integer> cache = parser.accepts("cache", "cache size (MB)").withRequiredArg().ofType(Integer.class).defaultsTo(100);
OptionSpec<Integer> fdsCache = parser.accepts("blobCache", "cache size (MB)").withRequiredArg().ofType(Integer.class).defaultsTo(32);
OptionSpec<Boolean> withStorage = parser.accepts("storage", "Index storage enabled").withOptionalArg().ofType(Boolean.class);
OptionSpec<File> csvFile = parser.accepts("csvFile", "File to write a CSV version of the benchmark data.").withOptionalArg().ofType(File.class);
OptionSpec<Integer> coldSyncInterval = parser.accepts("coldSyncInterval", "interval between sync cycles in sec (Segment-Tar-Cold only)").withRequiredArg().ofType(Integer.class).defaultsTo(5);
OptionSpec<Boolean> coldUseDataStore = parser.accepts("useDataStore", "Whether to use a datastore in the cold standby topology (Segment-Tar-Cold only)").withOptionalArg().ofType(Boolean.class).defaultsTo(Boolean.TRUE);
OptionSpec<Boolean> coldShareDataStore = parser.accepts("shareDataStore", "Whether to share the datastore for primary and standby in the cold standby topology (Segment-Tar-Cold only)").withOptionalArg().ofType(Boolean.class).defaultsTo(Boolean.FALSE);
OptionSpec<Boolean> coldOneShotRun = parser.accepts("oneShotRun", "Whether to do a continuous sync between client and server or sync only once (Segment-Tar-Cold only)").withOptionalArg().ofType(Boolean.class).defaultsTo(Boolean.TRUE);
OptionSpec<Boolean> coldSecure = parser.accepts("secure", "Whether to enable secure communication between primary and standby in the cold standby topology (Segment-Tar-Cold only)").withOptionalArg().ofType(Boolean.class).defaultsTo(Boolean.FALSE);
OptionSpec<?> help = parser.acceptsAll(asList("h", "?", "help"), "show help").forHelp();
OptionSpec<String> nonOption = parser.nonOptions();
OptionSet options = parser.parse(args);
if (options.has(help)) {
parser.printHelpOn(System.out);
System.exit(0);
}
int cacheSize = cache.value(options);
RepositoryFixture[] allFixtures = new RepositoryFixture[] { new JackrabbitRepositoryFixture(base.value(options), cacheSize), OakRepositoryFixture.getMemoryNS(cacheSize * MB), OakRepositoryFixture.getMongo(host.value(options), port.value(options), dbName.value(options), dropDBAfterTest.value(options), cacheSize * MB), OakRepositoryFixture.getMongoWithDS(host.value(options), port.value(options), dbName.value(options), dropDBAfterTest.value(options), cacheSize * MB, base.value(options), fdsCache.value(options)), OakRepositoryFixture.getMongoNS(host.value(options), port.value(options), dbName.value(options), dropDBAfterTest.value(options), cacheSize * MB), OakRepositoryFixture.getSegmentTar(base.value(options), 256, cacheSize, mmap.value(options)), OakRepositoryFixture.getSegmentTarWithDataStore(base.value(options), 256, cacheSize, mmap.value(options), fdsCache.value(options)), OakRepositoryFixture.getSegmentTarWithColdStandby(base.value(options), 256, cacheSize, mmap.value(options), coldUseDataStore.value(options), fdsCache.value(options), coldSyncInterval.value(options), coldShareDataStore.value(options), coldSecure.value(options), coldOneShotRun.value(options)), OakRepositoryFixture.getRDB(rdbjdbcuri.value(options), rdbjdbcuser.value(options), rdbjdbcpasswd.value(options), rdbjdbctableprefix.value(options), dropDBAfterTest.value(options), cacheSize * MB, -1), OakRepositoryFixture.getRDBWithDS(rdbjdbcuri.value(options), rdbjdbcuser.value(options), rdbjdbcpasswd.value(options), rdbjdbctableprefix.value(options), dropDBAfterTest.value(options), cacheSize * MB, base.value(options), fdsCache.value(options), -1) };
ScalabilitySuite[] allSuites = new ScalabilitySuite[] { new ScalabilityBlobSearchSuite(withStorage.value(options)).addBenchmarks(new FullTextSearcher(), new NodeTypeSearcher(), new FormatSearcher(), new FacetSearcher(), new LastModifiedSearcher(Date.LAST_2_HRS), new LastModifiedSearcher(Date.LAST_24_HRS), new LastModifiedSearcher(Date.LAST_7_DAYS), new LastModifiedSearcher(Date.LAST_MONTH), new LastModifiedSearcher(Date.LAST_YEAR), new OrderByDate()), new ScalabilityNodeSuite(withStorage.value(options)).addBenchmarks(new OrderBySearcher(), new SplitOrderBySearcher(), new OrderByOffsetPageSearcher(), new SplitOrderByOffsetPageSearcher(), new OrderByKeysetPageSearcher(), new SplitOrderByKeysetPageSearcher(), new MultiFilterOrderBySearcher(), new MultiFilterSplitOrderBySearcher(), new MultiFilterOrderByOffsetPageSearcher(), new MultiFilterSplitOrderByOffsetPageSearcher(), new MultiFilterOrderByKeysetPageSearcher(), new MultiFilterSplitOrderByKeysetPageSearcher(), new ConcurrentReader(), new ConcurrentWriter()), new ScalabilityNodeRelationshipSuite(withStorage.value(options)).addBenchmarks(new AggregateNodeSearcher()), new ScalabilityStandbySuite().addBenchmarks(new StandbyBulkTransferBenchmark()) };
Set<String> argset = Sets.newHashSet(nonOption.values(options));
List<RepositoryFixture> fixtures = Lists.newArrayList();
for (RepositoryFixture fixture : allFixtures) {
if (argset.remove(fixture.toString())) {
fixtures.add(fixture);
}
}
Map<String, List<String>> argmap = Maps.newHashMap();
// Split the args to get suites and benchmarks (i.e. suite:benchmark1,benchmark2)
for (String arg : argset) {
List<String> tokens = Splitter.on(":").limit(2).splitToList(arg);
if (tokens.size() > 1) {
argmap.put(tokens.get(0), Splitter.on(",").trimResults().splitToList(tokens.get(1)));
} else {
argmap.put(tokens.get(0), null);
}
argset.remove(arg);
}
if (argmap.isEmpty()) {
System.err.println("Warning: no scalability suites specified, " + "supported are: " + Arrays.asList(allSuites));
}
List<ScalabilitySuite> suites = Lists.newArrayList();
for (ScalabilitySuite suite : allSuites) {
if (argmap.containsKey(suite.toString())) {
List<String> benchmarks = argmap.get(suite.toString());
// Only keep requested benchmarks
if (benchmarks != null) {
Iterator<String> iter = suite.getBenchmarks().keySet().iterator();
for (; iter.hasNext(); ) {
String availBenchmark = iter.next();
if (!benchmarks.contains(availBenchmark)) {
iter.remove();
}
}
}
suites.add(suite);
argmap.remove(suite.toString());
}
}
if (argmap.isEmpty()) {
PrintStream out = null;
if (options.has(csvFile)) {
out = new PrintStream(FileUtils.openOutputStream(csvFile.value(options), true), false, Charsets.UTF_8.name());
}
for (ScalabilitySuite suite : suites) {
if (suite instanceof CSVResultGenerator) {
((CSVResultGenerator) suite).setPrintStream(out);
}
suite.run(fixtures);
}
if (out != null) {
out.close();
}
} else {
System.err.println("Unknown arguments: " + argset);
}
}
use of java.util.Arrays.asList in project bullet-core by yahoo.
the class MetaTest method testErrorsAddition.
@Test
public void testErrorsAddition() {
ParsingError errorA = new ParsingError("foo", asList("1", "2"));
ParsingError errorB = new ParsingError("bar", asList("3", "4"));
Meta meta = Meta.of(errorA, errorB);
Map<String, Object> actual = meta.asMap();
Assert.assertEquals(actual.size(), 1);
List<ParsingError> actualErrors = (List<ParsingError>) actual.get(Meta.ERROR_KEY);
Assert.assertEquals(actualErrors.size(), 2);
Assert.assertEquals(actualErrors.get(0).getError(), "foo");
Assert.assertEquals(actualErrors.get(0).getResolutions(), asList("1", "2"));
Assert.assertEquals(actualErrors.get(1).getError(), "bar");
Assert.assertEquals(actualErrors.get(1).getResolutions(), asList("3", "4"));
ParsingError errorC = new ParsingError("baz", asList("5", "6"));
ParsingError errorD = new ParsingError("qux", singletonList("7"));
meta.addErrors(Arrays.asList(errorC, errorD));
Assert.assertEquals(actualErrors.size(), 4);
Assert.assertEquals(actualErrors.get(0).getError(), "foo");
Assert.assertEquals(actualErrors.get(0).getResolutions(), asList("1", "2"));
Assert.assertEquals(actualErrors.get(1).getError(), "bar");
Assert.assertEquals(actualErrors.get(1).getResolutions(), asList("3", "4"));
Assert.assertEquals(actualErrors.get(2).getError(), "baz");
Assert.assertEquals(actualErrors.get(2).getResolutions(), asList("5", "6"));
Assert.assertEquals(actualErrors.get(3).getError(), "qux");
Assert.assertEquals(actualErrors.get(3).getResolutions(), singletonList("7"));
}
use of java.util.Arrays.asList in project bullet-core by yahoo.
the class DistributionTest method testRounding.
@Test
public void testRounding() {
Distribution distribution = makeDistribution(Distribution.Type.QUANTILE, 20, 6, 0.0, 1.0, 0.1);
IntStream.range(0, 10).mapToDouble(i -> (i * 0.1)).mapToObj(d -> RecordBox.get().add("field", d).getRecord()).forEach(distribution::consume);
Clip result = distribution.getResult();
Map<String, Object> metadata = (Map<String, Object>) result.getMeta().asMap().get("meta");
Assert.assertEquals(metadata.size(), 7);
Assert.assertFalse((Boolean) metadata.get("isEst"));
List<BulletRecord> records = result.getRecords();
Assert.assertEquals(records.size(), 11);
Set<String> actualQuantilePoints = records.stream().map(r -> r.get(QUANTILE_FIELD).toString()).collect(Collectors.toSet());
Set<String> expectedQuantilePoints = new HashSet<>(Arrays.asList("0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0"));
Assert.assertEquals(actualQuantilePoints, expectedQuantilePoints);
Assert.assertEquals(distribution.getRecords(), result.getRecords());
Assert.assertEquals(distribution.getMetadata().asMap(), result.getMeta().asMap());
}
use of java.util.Arrays.asList in project motech by motech.
the class LookupProcessorTest method shouldNotUpdateRestExposedValueForLookupsThatHaveThatModifiedByUser.
@Test
public void shouldNotUpdateRestExposedValueForLookupsThatHaveThatModifiedByUser() throws Exception {
when(paranamer.lookupParameterNames(getTestMethodExposedViaRest())).thenReturn(argNames);
AdvancedSettingsDto advanced = mock(AdvancedSettingsDto.class);
RestOptionsDto restOptions = mock(RestOptionsDto.class);
when(schemaHolder.getAdvancedSettings(TEST_CLASS_NAME)).thenReturn(advanced);
when(advanced.getRestOptions()).thenReturn(restOptions);
when(restOptions.isModifiedByUser()).thenReturn(true);
EntityProcessorOutput eop = mockEntityProcessorOutput(new EntityDto(TestClass.class.getName()), Arrays.asList(new FieldDto("aaa", "bbb", TypeDto.STRING)));
lookupProcessor.setEntityProcessingResult(Arrays.asList(eop));
Method method = getTestMethodExposedViaRest();
LookupDto dto = new LookupDto("Test Method Exposed Via Rest", true, false, lookupFieldDtos(argNames), true, "testMethodExposedViaRest", asList(argNames), true);
lookupProcessor.process(method);
Map<String, List<LookupDto>> elements = lookupProcessor.getProcessingResult();
assertTrue(elements.containsKey(TEST_CLASS_NAME));
List<LookupDto> list = elements.get(TEST_CLASS_NAME);
assertEquals(1, list.size());
assertEquals(dto, list.get(0));
}
use of java.util.Arrays.asList in project motech by motech.
the class LookupProcessorTest method shouldProcessMethodWithRangeParam.
@Test
public void shouldProcessMethodWithRangeParam() throws NoSuchMethodException {
FieldDto arg0Field = new FieldDto("arg0Field", "Arg 0 Field", TypeDto.BOOLEAN);
FieldDto rangeField = new FieldDto("rangeField", "Range Field", TypeDto.STRING);
FieldDto regularFieldField = new FieldDto("regularField", "Regular Field", TypeDto.BOOLEAN);
FieldDto rangeFieldField = new FieldDto("rangeFieldDouble", "Range Field Double", TypeDto.DOUBLE);
EntityProcessorOutput eop = mockEntityProcessorOutput(new EntityDto(TestClass.class.getName()), Arrays.asList(arg0Field, rangeField, regularFieldField, rangeFieldField));
lookupProcessor.setEntityProcessingResult(Arrays.asList(eop));
LookupFieldDto[][] expectedFields = { { lookupFieldDto("arg0"), lookupFieldDto("range", RANGE) }, { lookupFieldDto("regularField"), lookupFieldDto("rangeField", RANGE) } };
String[][] expectedFieldsOrder = { { "arg0", "range" }, { "regularField", "rangeField" } };
// test two methods, one with @LookupField annotations, second without
for (int i = 0; i < 2; i++) {
Method method = getTestMethodWithRangeParam(i);
when(paranamer.lookupParameterNames(method)).thenReturn(new String[] { "arg0", "range" });
LookupDto expectedLookup = new LookupDto("Test Method With Range Param " + i, false, false, asList(expectedFields[i]), true, "testMethodWithRangeParam" + i, asList(expectedFieldsOrder[i]), true);
lookupProcessor.process(method);
Map<String, List<LookupDto>> elements = lookupProcessor.getProcessingResult();
assertTrue(elements.containsKey(TEST_CLASS_NAME));
List<LookupDto> list = elements.get(TEST_CLASS_NAME);
assertEquals(1, list.size());
assertEquals(expectedLookup, list.get(0));
assertEquals(asList(VALUE, RANGE), extract(list.get(0).getLookupFields(), on(LookupFieldDto.class).getType()));
lookupProcessor.clear();
}
}
Aggregations