Search in sources :

Example 41 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by axbaretto.

the class ClusterMockStorageFixture method insertMockStorage.

/**
 * This should be called after bits are started
 * @param name nthe mock storage name we are going to create
 */
public void insertMockStorage(String name, boolean breakRegisterSchema) {
    for (Drillbit bit : drillbits()) {
        // Bit name and registration.
        final StoragePluginRegistry pluginRegistry = bit.getContext().getStorage();
        MockStorageEngineConfig config = MockStorageEngineConfig.INSTANCE;
        @SuppressWarnings("resource") MockBreakageStorage plugin = new MockBreakageStorage(MockStorageEngineConfig.INSTANCE, bit.getContext(), name);
        ((StoragePluginRegistryImpl) pluginRegistry).definePlugin(name, config, plugin);
        plugin.setBreakRegister(breakRegisterSchema);
    }
}
Also used : StoragePluginRegistry(org.apache.drill.exec.store.StoragePluginRegistry) MockStorageEngineConfig(org.apache.drill.exec.store.mock.MockStorageEngineConfig) MockBreakageStorage(org.apache.drill.exec.store.mock.MockBreakageStorage) Drillbit(org.apache.drill.exec.server.Drillbit) StoragePluginRegistryImpl(org.apache.drill.exec.store.StoragePluginRegistryImpl)

Example 42 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by axbaretto.

the class TestGracefulShutdown method testRestApiShutdown.

/*
   Test default shutdown through RestApi
   */
@Test
public void testRestApiShutdown() throws Exception {
    String[] drillbits = { "db1", "db2", "db3" };
    ClusterFixtureBuilder builder = ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk().withBits(drillbits);
    builder = enableWebServer(builder);
    QueryBuilder.QuerySummaryFuture listener;
    final String sql = "select * from dfs.root.`.`";
    try (ClusterFixture cluster = builder.build();
        final ClientFixture client = cluster.clientFixture()) {
        Drillbit drillbit = cluster.drillbit("db1");
        int port = drillbit.getContext().getConfig().getInt("drill.exec.http.port");
        int grace_period = drillbit.getContext().getConfig().getInt(ExecConstants.GRACE_PERIOD);
        listener = client.queryBuilder().sql(sql).futureSummary();
        Thread.sleep(10000);
        while (port < 8048) {
            URL url = new URL("http://localhost:" + port + "/shutdown");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            if (conn.getResponseCode() != 200) {
                throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
            }
            port++;
        }
        Thread.sleep(grace_period);
        Collection<DrillbitEndpoint> drillbitEndpoints = cluster.drillbit().getContext().getClusterCoordinator().getAvailableEndpoints();
        long currentTime = System.currentTimeMillis();
        long stopTime = currentTime + WAIT_TIMEOUT_MS;
        while (currentTime < stopTime) {
            if (listener.isDone() && drillbitEndpoints.size() == 2) {
                return;
            }
            Thread.sleep(100L);
            currentTime = System.currentTimeMillis();
        }
        Assert.fail("Timed out");
    }
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) URL(java.net.URL) HttpURLConnection(java.net.HttpURLConnection) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) Drillbit(org.apache.drill.exec.server.Drillbit) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 43 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by axbaretto.

the class TestGracefulShutdown method testOnlineEndPoints.

/*
  Start multiple drillbits and then shutdown a drillbit. Query the online
  endpoints and check if the drillbit still exists.
   */
@Test
public void testOnlineEndPoints() throws Exception {
    String[] drillbits = { "db1", "db2", "db3", "db4", "db5", "db6" };
    ClusterFixtureBuilder builder = ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk().withBits(drillbits);
    enableDrillPortHunting(builder);
    try (ClusterFixture cluster = builder.build()) {
        Drillbit drillbit = cluster.drillbit("db2");
        DrillbitEndpoint drillbitEndpoint = drillbit.getRegistrationHandle().getEndPoint();
        int grace_period = drillbit.getContext().getConfig().getInt(ExecConstants.GRACE_PERIOD);
        new Thread(new Runnable() {

            public void run() {
                try {
                    cluster.closeDrillbit("db2");
                } catch (Exception e) {
                    fail();
                }
            }
        }).start();
        Thread.sleep(grace_period);
        long currentTime = System.currentTimeMillis();
        long stopTime = currentTime + WAIT_TIMEOUT_MS;
        while (currentTime < stopTime) {
            Collection<DrillbitEndpoint> drillbitEndpoints = cluster.drillbit().getContext().getClusterCoordinator().getOnlineEndPoints();
            if (!drillbitEndpoints.contains(drillbitEndpoint)) {
                // Success
                return;
            }
            Thread.sleep(100L);
            currentTime = System.currentTimeMillis();
        }
        Assert.fail("Timed out");
    }
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) Drillbit(org.apache.drill.exec.server.Drillbit) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) IOException(java.io.IOException) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 44 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by axbaretto.

the class TestGracefulShutdown method testRestApi.

/*
   Test shutdown through RestApi
   */
@Test
public void testRestApi() throws Exception {
    String[] drillbits = { "db1", "db2", "db3" };
    ClusterFixtureBuilder builder = ClusterFixture.bareBuilder(dirTestWatcher).withLocalZk().withBits(drillbits);
    builder = enableWebServer(builder);
    QueryBuilder.QuerySummaryFuture listener;
    final String sql = "select * from dfs.root.`.`";
    try (ClusterFixture cluster = builder.build();
        final ClientFixture client = cluster.clientFixture()) {
        Drillbit drillbit = cluster.drillbit("db1");
        int port = drillbit.getContext().getConfig().getInt("drill.exec.http.port");
        int grace_period = drillbit.getContext().getConfig().getInt(ExecConstants.GRACE_PERIOD);
        listener = client.queryBuilder().sql(sql).futureSummary();
        Thread.sleep(60000);
        while (port < 8049) {
            URL url = new URL("http://localhost:" + port + "/gracefulShutdown");
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            if (conn.getResponseCode() != 200) {
                throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
            }
            port++;
        }
        Thread.sleep(grace_period);
        Collection<DrillbitEndpoint> drillbitEndpoints = cluster.drillbit().getContext().getClusterCoordinator().getOnlineEndPoints();
        long currentTime = System.currentTimeMillis();
        long stopTime = currentTime + WAIT_TIMEOUT_MS;
        while (currentTime < stopTime) {
            if (listener.isDone()) {
                break;
            }
            Thread.sleep(100L);
            currentTime = System.currentTimeMillis();
        }
        Assert.assertTrue(listener.isDone());
        Assert.assertEquals(1, drillbitEndpoints.size());
    }
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) URL(java.net.URL) HttpURLConnection(java.net.HttpURLConnection) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) Drillbit(org.apache.drill.exec.server.Drillbit) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Example 45 with Drillbit

use of org.apache.drill.exec.server.Drillbit in project drill by apache.

the class TestMergingReceiver method twoBitTwoExchange.

// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestMergingReceiver.class);
@Test
public void twoBitTwoExchange() throws Exception {
    final RemoteServiceSet serviceSet = RemoteServiceSet.getLocalServiceSet();
    try (final Drillbit bit1 = new Drillbit(CONFIG, serviceSet);
        final Drillbit bit2 = new Drillbit(CONFIG, serviceSet);
        final DrillClient client = new DrillClient(CONFIG, serviceSet.getCoordinator())) {
        bit1.run();
        bit2.run();
        client.connect();
        final List<QueryDataBatch> results = client.runQuery(org.apache.drill.exec.proto.UserBitShared.QueryType.PHYSICAL, Files.asCharSource(DrillFileUtils.getResourceAsFile("/mergerecv/merging_receiver.json"), Charsets.UTF_8).read());
        int count = 0;
        final RecordBatchLoader batchLoader = new RecordBatchLoader(client.getAllocator());
        // print the results
        for (final QueryDataBatch b : results) {
            final QueryData queryData = b.getHeader();
            final int rowCount = queryData.getRowCount();
            count += rowCount;
            // loaded but not used, just to test
            batchLoader.load(queryData.getDef(), b.getData());
            b.release();
            batchLoader.clear();
        }
        assertEquals(200000, count);
    }
}
Also used : QueryDataBatch(org.apache.drill.exec.rpc.user.QueryDataBatch) Drillbit(org.apache.drill.exec.server.Drillbit) QueryData(org.apache.drill.exec.proto.UserBitShared.QueryData) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) RecordBatchLoader(org.apache.drill.exec.record.RecordBatchLoader) DrillClient(org.apache.drill.exec.client.DrillClient) OperatorTest(org.apache.drill.categories.OperatorTest) Test(org.junit.Test) SlowTest(org.apache.drill.categories.SlowTest)

Aggregations

Drillbit (org.apache.drill.exec.server.Drillbit)158 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)132 Test (org.junit.Test)129 DrillClient (org.apache.drill.exec.client.DrillClient)119 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)119 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)79 SlowTest (org.apache.drill.categories.SlowTest)74 ValueVector (org.apache.drill.exec.vector.ValueVector)66 OperatorTest (org.apache.drill.categories.OperatorTest)47 VectorWrapper (org.apache.drill.exec.record.VectorWrapper)28 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)24 DrillConfig (org.apache.drill.common.config.DrillConfig)20 ExecTest (org.apache.drill.exec.ExecTest)13 VectorTest (org.apache.drill.categories.VectorTest)12 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)11 QueryData (org.apache.drill.exec.proto.UserBitShared.QueryData)10 StoragePluginRegistry (org.apache.drill.exec.store.StoragePluginRegistry)8 VarBinaryVector (org.apache.drill.exec.vector.VarBinaryVector)7 IOException (java.io.IOException)6 ZookeeperHelper (org.apache.drill.exec.ZookeeperHelper)6