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);
}
}
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");
}
}
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");
}
}
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());
}
}
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);
}
}
Aggregations