Search in sources :

Example 1 with IdentityPinotHostMapper

use of io.trino.plugin.pinot.client.IdentityPinotHostMapper in project trino by trinodb.

the class TestPinotClient method testBrokersParsed.

@Test
public void testBrokersParsed() {
    HttpClient httpClient = new TestingHttpClient(request -> TestingResponse.mockResponse(HttpStatus.OK, MediaType.JSON_UTF_8, "{\n" + "  \"tableName\": \"dummy\",\n" + "  \"brokers\": [\n" + "    {\n" + "      \"tableType\": \"offline\",\n" + "      \"instances\": [\n" + "        \"Broker_dummy-broker-host1-datacenter1_6513\",\n" + "        \"Broker_dummy-broker-host2-datacenter1_6513\",\n" + "        \"Broker_dummy-broker-host4-datacenter1_6513\"\n" + "      ]\n" + "    },\n" + "    {\n" + "      \"tableType\": \"realtime\",\n" + "      \"instances\": [\n" + "        \"Broker_dummy-broker-host1-datacenter1_6513\",\n" + "        \"Broker_dummy-broker-host2-datacenter1_6513\",\n" + "        \"Broker_dummy-broker-host3-datacenter1_6513\"\n" + "      ]\n" + "    }\n" + "  ],\n" + "  \"server\": [\n" + "    {\n" + "      \"tableType\": \"offline\",\n" + "      \"instances\": [\n" + "        \"Server_dummy-server-host8-datacenter1_7090\",\n" + "        \"Server_dummy-server-host9-datacenter1_7090\"\n" + "      ]\n" + "    },\n" + "    {\n" + "      \"tableType\": \"realtime\",\n" + "      \"instances\": [\n" + "        \"Server_dummy-server-host7-datacenter1_7090\",\n" + "        \"Server_dummy-server-host4-datacenter1_7090\",\n" + "        \"Server_dummy-server-host5-datacenter1_7090\",\n" + "        \"Server_dummy-server-host6-datacenter1_7090\"\n" + "      ]\n" + "    }\n" + "  ]\n" + "}"));
    PinotConfig pinotConfig = new PinotConfig().setMetadataCacheExpiry(new Duration(0, TimeUnit.MILLISECONDS)).setControllerUrls("localhost:7900");
    PinotClient pinotClient = new PinotClient(pinotConfig, new IdentityPinotHostMapper(), httpClient, MetadataUtil.TABLES_JSON_CODEC, MetadataUtil.BROKERS_FOR_TABLE_JSON_CODEC, MetadataUtil.TIME_BOUNDARY_JSON_CODEC, MetadataUtil.BROKER_RESPONSE_NATIVE_JSON_CODEC, PinotControllerAuthenticationProvider.create(PinotEmptyAuthenticationProvider.instance()), PinotBrokerAuthenticationProvider.create(PinotEmptyAuthenticationProvider.instance()));
    ImmutableSet<String> brokers = ImmutableSet.copyOf(pinotClient.getAllBrokersForTable("dummy"));
    Assert.assertEquals(ImmutableSet.of("dummy-broker-host1-datacenter1:6513", "dummy-broker-host2-datacenter1:6513", "dummy-broker-host3-datacenter1:6513", "dummy-broker-host4-datacenter1:6513"), brokers);
}
Also used : IdentityPinotHostMapper(io.trino.plugin.pinot.client.IdentityPinotHostMapper) HttpClient(io.airlift.http.client.HttpClient) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) PinotClient(io.trino.plugin.pinot.client.PinotClient) Duration(io.airlift.units.Duration) Test(org.testng.annotations.Test)

Aggregations

HttpClient (io.airlift.http.client.HttpClient)1 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)1 Duration (io.airlift.units.Duration)1 IdentityPinotHostMapper (io.trino.plugin.pinot.client.IdentityPinotHostMapper)1 PinotClient (io.trino.plugin.pinot.client.PinotClient)1 Test (org.testng.annotations.Test)1