@Override public void installPlugin(Plugin plugin) { source.installPlugin(plugin); }
public DistributedQueryRunner buildWithoutCatalogs() throws Exception { DistributedQueryRunner queryRunner = super.build(); try { queryRunner.installPlugin(new TpchPlugin()); return queryRunner; } catch (Exception e) { queryRunner.close(); throw e; } } }
private static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties) throws Exception { DistributedQueryRunner queryRunner = new DistributedQueryRunner(testSessionBuilder().build(), DEFAULT_WORKER_COUNT, extraProperties); queryRunner.installPlugin(new GeoPlugin()); return queryRunner; }
@BeforeClass private void setUp() throws Exception { session = testSessionBuilder() .setSystemProperty("task_concurrency", "1") .setCatalog("tpch") .setSchema("tiny") .setClientInfo("{\"clientVersion\":\"testVersion\"}") .build(); queryRunner = new DistributedQueryRunner(session, 1); queryRunner.installPlugin(new TpchPlugin()); queryRunner.installPlugin(new TestingEventListenerPlugin(generatedEvents)); queryRunner.installPlugin(new ResourceGroupManagerPlugin()); queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of("tpch.splits-per-node", Integer.toString(SPLITS_PER_NODE))); queryRunner.getCoordinator().getResourceGroupManager().get() .setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_simple.json"))); }
public static DistributedQueryRunner createQueryRunner(Session session, Map<String, String> properties) throws Exception { DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 2, properties); try { queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); return queryRunner; } catch (Exception e) { queryRunner.close(); throw e; } } }
@Test(timeOut = 240_000) public void testResourceGroupManagerWithTwoDashboardQueriesRequestedAtTheSameTime() throws Exception { try (DistributedQueryRunner queryRunner = createQueryRunner()) { queryRunner.installPlugin(new ResourceGroupManagerPlugin()); queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json"))); QueryId firstDashboardQuery = createDashboardQuery(queryRunner); QueryId secondDashboardQuery = createDashboardQuery(queryRunner); ImmutableSet<QueryState> queuedOrRunning = ImmutableSet.of(QUEUED, RUNNING); waitForQueryState(queryRunner, firstDashboardQuery, queuedOrRunning); waitForQueryState(queryRunner, secondDashboardQuery, queuedOrRunning); } }
@Test public void testMemoryFraction() throws Exception { try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder().build()) { queryRunner.installPlugin(new ResourceGroupManagerPlugin()); getResourceGroupManager(queryRunner).setConfigurationManager("file", ImmutableMap.of( "resource-groups.config-file", getResourceFilePath("resource_groups_memory_percentage.json"))); queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk"); waitForGlobalResourceGroup(queryRunner); } }
@Test(timeOut = 240_000) public void testClientTagsBasedSelection() throws Exception { try (DistributedQueryRunner queryRunner = createQueryRunner()) { queryRunner.installPlugin(new ResourceGroupManagerPlugin()); queryRunner.getCoordinator().getResourceGroupManager().get() .setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_client_tags_based_config.json"))); assertResourceGroup(queryRunner, newSessionWithTags(ImmutableSet.of("a")), LONG_LASTING_QUERY, createResourceGroupId("global", "a", "default")); assertResourceGroup(queryRunner, newSessionWithTags(ImmutableSet.of("b")), LONG_LASTING_QUERY, createResourceGroupId("global", "b")); assertResourceGroup(queryRunner, newSessionWithTags(ImmutableSet.of("a", "c")), LONG_LASTING_QUERY, createResourceGroupId("global", "a", "c")); } }
public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties) throws Exception { Session session = testSessionBuilder() .setCatalog("blackhole") .setSchema("default") .build(); DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 4, extraProperties); try { queryRunner.installPlugin(new BlackHolePlugin()); queryRunner.createCatalog("blackhole", "blackhole", ImmutableMap.of()); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of()); return queryRunner; } catch (Exception e) { closeAllSuppress(e, queryRunner); throw e; } }
@Test public void testPathToRoot() throws Exception { try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder().build()) { queryRunner.installPlugin(new ResourceGroupManagerPlugin()); InternalResourceGroupManager<?> manager = getResourceGroupManager(queryRunner); manager.setConfigurationManager("file", ImmutableMap.of( "resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json"))); queryRunner.execute(testSessionBuilder().setCatalog("tpch").setSchema("tiny").setSource("dashboard-foo").build(), "SELECT COUNT(*), clerk FROM orders GROUP BY clerk"); List<ResourceGroupInfo> path = manager.getPathToRoot(new ResourceGroupId(new ResourceGroupId(new ResourceGroupId("global"), "user-user"), "dashboard-user")); assertEquals(path.size(), 3); assertTrue(path.get(1).getSubGroups() != null); assertEquals(path.get(2).getId(), new ResourceGroupId("global")); assertEquals(path.get(2).getHardConcurrencyLimit(), 100); assertEquals(path.get(2).getRunningQueries(), null); } }
public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties) throws Exception { Session session = testSessionBuilder() .setCatalog(CATALOG) .setSchema("default") .build(); DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 4, extraProperties); try { queryRunner.installPlugin(new MemoryPlugin()); queryRunner.createCatalog(CATALOG, "memory", ImmutableMap.of()); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of()); copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, session, TpchTable.getTables()); return queryRunner; } catch (Exception e) { closeAllSuppress(e, queryRunner); throw e; } }
@Test(timeOut = 240_000) public void testResourceGroupManagerWithTooManyQueriesScheduled() throws Exception { try (DistributedQueryRunner queryRunner = createQueryRunner()) { queryRunner.installPlugin(new ResourceGroupManagerPlugin()); queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json"))); QueryId firstDashboardQuery = createDashboardQuery(queryRunner); waitForQueryState(queryRunner, firstDashboardQuery, RUNNING); QueryId secondDashboardQuery = createDashboardQuery(queryRunner); waitForQueryState(queryRunner, secondDashboardQuery, QUEUED); QueryId thirdDashboardQuery = createDashboardQuery(queryRunner); waitForQueryState(queryRunner, thirdDashboardQuery, FAILED); } }
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") public static DistributedQueryRunner createJmxQueryRunner() throws Exception { DistributedQueryRunner queryRunner = null; try { queryRunner = new DistributedQueryRunner(createSession(), 3); queryRunner.installPlugin(new JmxPlugin()); queryRunner.createCatalog("jmx", "jmx"); return queryRunner; } catch (Throwable e) { closeAllSuppress(e, queryRunner); throw e; } }
private void testRejection() throws Exception { try (DistributedQueryRunner queryRunner = createQueryRunner()) { queryRunner.installPlugin(new ResourceGroupManagerPlugin()); queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json"))); QueryId queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY); waitForQueryState(queryRunner, queryId, FAILED); QueryManager queryManager = queryRunner.getCoordinator().getQueryManager(); assertEquals(queryManager.getQueryInfo(queryId).getErrorCode(), QUERY_REJECTED.toErrorCode()); } }
private static DistributedQueryRunner createQueryRunner() throws Exception { Session session = testSessionBuilder() .setCatalog("tpch_indexed") .setSchema(TINY_SCHEMA_NAME) .build(); DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 3); queryRunner.installPlugin(new IndexedTpchPlugin(INDEX_SPEC)); queryRunner.createCatalog("tpch_indexed", "tpch_indexed"); return queryRunner; } }
public static DistributedQueryRunner createQueryRunner(Session session) throws Exception { DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session) .setNodeCount(2) .build(); try { queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); return queryRunner; } catch (Exception e) { queryRunner.close(); throw e; } } }
public static DistributedQueryRunner createJdbcQueryRunner(Iterable<TpchTable<?>> tables) throws Exception { DistributedQueryRunner queryRunner = null; try { queryRunner = new DistributedQueryRunner(createSession(), 3); queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); Map<String, String> properties = TestingH2JdbcModule.createProperties(); createSchema(properties, "tpch"); queryRunner.installPlugin(new JdbcPlugin("base-jdbc", new TestingH2JdbcModule())); queryRunner.createCatalog("jdbc", "base-jdbc", properties); copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables); return queryRunner; } catch (Throwable e) { closeAllSuppress(e, queryRunner); throw e; } }
public static DistributedQueryRunner createQueryRunner() throws Exception { DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(testSessionBuilder().build()) .setNodeCount(2) .build(); try { queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); return queryRunner; } catch (Exception e) { queryRunner.close(); throw e; } } }
@Test(timeOut = 240_000) public void testQueryTypeBasedSelection() throws Exception { try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder().build()) { queryRunner.installPlugin(new ResourceGroupManagerPlugin()); queryRunner.getCoordinator().getResourceGroupManager().get() .setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_query_type_based_config.json"))); assertResourceGroup(queryRunner, newAdhocSession(), LONG_LASTING_QUERY, createResourceGroupId("global", "select")); assertResourceGroup(queryRunner, newAdhocSession(), "SHOW TABLES", createResourceGroupId("global", "describe")); assertResourceGroup(queryRunner, newAdhocSession(), "EXPLAIN " + LONG_LASTING_QUERY, createResourceGroupId("global", "explain")); assertResourceGroup(queryRunner, newAdhocSession(), "DESCRIBE lineitem", createResourceGroupId("global", "describe")); assertResourceGroup(queryRunner, newAdhocSession(), "RESET SESSION " + HASH_PARTITION_COUNT, createResourceGroupId("global", "data_definition")); } }
public static QueryRunner createKuduQueryRunnerTpch(Iterable<TpchTable<?>> tables) throws Exception { DistributedQueryRunner runner = null; String kuduSchema = isSchemaEmulationEnabled() ? "tpch" : "default"; try { runner = DistributedQueryRunner.builder(createSession(kuduSchema)).setNodeCount(3).build(); runner.installPlugin(new TpchPlugin()); runner.createCatalog("tpch", "tpch"); installKuduConnector(runner, kuduSchema); copyTpchTables(runner, "tpch", TINY_SCHEMA_NAME, createSession(kuduSchema), tables); return runner; } catch (Throwable e) { closeAllSuppress(e, runner); throw e; } }