Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run MongoQueryRunner on port 8080 #3094

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.prestosql.plugin.mongodb;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.mongodb.MongoClient;
import io.airlift.log.Logger;
Expand All @@ -36,25 +35,22 @@ public final class MongoQueryRunner

private MongoQueryRunner() {}

public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, TpchTable<?>... tables)
throws Exception
{
return createMongoQueryRunner(server, ImmutableList.copyOf(tables));
}

public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, Iterable<TpchTable<?>> tables)
public static DistributedQueryRunner createMongoQueryRunner(MongoServer server, Iterable<TpchTable<?>> tables, Map<String, String> extraProperties)
throws Exception
{
DistributedQueryRunner queryRunner = null;
try {
queryRunner = DistributedQueryRunner.builder(createSession()).build();
queryRunner = DistributedQueryRunner.builder(createSession())
.setExtraProperties(extraProperties)
.build();

queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");

Map<String, String> properties = ImmutableMap.of(
"mongodb.seeds", server.getAddress().toString(),
"mongodb.socket-keep-alive", "true");
Map<String, String> properties = ImmutableMap.<String, String>builder()
.put("mongodb.seeds", server.getAddress().toString())
.put("mongodb.socket-keep-alive", "true")
.build();

queryRunner.installPlugin(new MongoPlugin());
queryRunner.createCatalog("mongodb", "mongodb", properties);
Expand Down Expand Up @@ -85,7 +81,8 @@ public static void main(String[] args)
throws Exception
{
Logging.initialize();
DistributedQueryRunner queryRunner = createMongoQueryRunner(new MongoServer(), TpchTable.getTables());
Map<String, String> properties = ImmutableMap.of("http-server.http.port", "8080");
DistributedQueryRunner queryRunner = createMongoQueryRunner(new MongoServer(), TpchTable.getTables(), properties);
Thread.sleep(10);
Logger log = Logger.get(MongoQueryRunner.class);
log.info("======== SERVER STARTED ========");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.prestosql.plugin.mongodb;

import com.google.common.collect.ImmutableMap;
import io.prestosql.testing.AbstractTestQueries;
import io.prestosql.testing.QueryRunner;
import io.prestosql.tpch.TpchTable;
Expand All @@ -32,7 +33,7 @@ protected QueryRunner createQueryRunner()
throws Exception
{
this.server = new MongoServer();
return createMongoQueryRunner(server, TpchTable.getTables());
return createMongoQueryRunner(server, TpchTable.getTables(), ImmutableMap.of());
}

@AfterClass(alwaysRun = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected QueryRunner createQueryRunner()
{
this.server = new MongoServer();
this.client = createMongoClient(server);
return createMongoQueryRunner(server, ORDERS);
return createMongoQueryRunner(server, ImmutableList.of(ORDERS), ImmutableMap.of());
}

@AfterClass(alwaysRun = true)
Expand Down