protected static <T extends IMongoConfig> void applyNet(T config, List<String> ret) { Net net = config.net(); ret.add("--port"); ret.add("" + net.getPort()); if (net.isIpv6()) { ret.add("--ipv6"); } if (net.getBindIp() != null) { ret.add("--bind_ip"); if (Objects.equals("localhost", net.getBindIp()) && config.version().enabled(Feature.NO_BIND_IP_TO_LOCALHOST)) { ret.add("127.0.0.1"); } else { ret.add(net.getBindIp()); } } }
protected static <T extends IMongoConfig> void applyDefaultOptions(T config, List<String> ret) { if (!config.version().enabled(Feature.NO_HTTP_INTERFACE_ARG)) { ret.add("--nohttpinterface"); } }
@Override protected final void onAfterProcessStart(ProcessControl process, IRuntimeConfig runtimeConfig) throws IOException { ProcessOutput outputConfig = runtimeConfig.getProcessOutput(); LogWatchStreamProcessor logWatch = new LogWatchStreamProcessor(successMessage(), knownFailureMessages(), StreamToLineProcessor.wrap(outputConfig.getOutput())); Processors.connect(process.getReader(), logWatch); Processors.connect(process.getError(), StreamToLineProcessor.wrap(outputConfig.getError())); logWatch.waitForResult(getConfig().timeout().getStartupTimeout()); if (logWatch.isInitWithSuccess()) { setProcessId(Mongod.getMongodProcessId(logWatch.getOutput(), -1)); } else { String failureFound = logWatch.getFailureFound(); if (failureFound==null) { failureFound="\n" + "----------------------\n" + "Hmm.. no failure message.. \n" + "...the cause must be somewhere in the process output\n" + "----------------------\n" + ""+logWatch.getOutput(); } try { // Process could be finished with success here! In this case no need to throw an exception! if(process.waitFor() != 0){ throw new IOException("Could not start process: "+failureFound); } } catch (InterruptedException e) { throw new IOException("Could not start process: "+failureFound, e); } } }
private static Configuration getConf() throws IOException { MongoDBIndexingConfigBuilder builder = MongoIndexingConfiguration.builder() .setUseMockMongo(USE_MOCK).setUseInference(USE_INFER).setAuths("U"); if (USE_MOCK) { final EmbeddedMongoFactory factory = EmbeddedMongoFactory.newFactory(); final IMongoConfig connectionConfig = factory.getMongoServerDetails(); final Net net = connectionConfig.net(); builder.setMongoHost(net.getBindIp() == null ? "127.0.0.1" : net.getBindIp()) .setMongoPort(net.getPort() + ""); } else { // User name and password must be filled in: builder = builder.setMongoUser(MONGO_USER) .setMongoPassword(MONGO_PASSWORD) .setMongoHost(MONGO_INSTANCE_URL) .setMongoPort(MONGO_INSTANCE_PORT); } return builder.setMongoDBName(MONGO_DB) .setMongoCollectionPrefix(MONGO_COLL_PREFIX) .setUseMongoFreetextIndex(true) .setMongoFreeTextPredicates(RDFS.LABEL.stringValue()).build(); }