use of org.apache.drill.exec.rpc.RpcException in project drill by apache.
the class JdbcConnectTriesTestEmbeddedBits method testDirectConnectionConnectTriesLessThanDrillbitCount.
@Test
public void testDirectConnectionConnectTriesLessThanDrillbitCount() throws SQLException {
Connection connection = null;
try {
connection = testDrillDriver.connect("jdbc:drill:drillbit=127.0.0.1:5000,127.0.0.1:5001;tries=1", getDefaultProperties());
fail();
} catch (SQLException ex) {
assertNull(connection);
assertTrue(ex.getCause() instanceof RpcException);
assertTrue(ex.getCause().getCause() instanceof ExecutionException);
}
}
use of org.apache.drill.exec.rpc.RpcException in project drill by apache.
the class ControlMessageHandler method handle.
@Override
public void handle(ControlConnection connection, int rpcType, ByteBuf pBody, ByteBuf dBody, ResponseSender sender) throws RpcException {
if (RpcConstants.EXTRA_DEBUGGING) {
logger.debug("Received bit com message of type {}", rpcType);
}
switch(rpcType) {
case RpcType.REQ_CANCEL_FRAGMENT_VALUE:
{
final FragmentHandle handle = get(pBody, FragmentHandle.PARSER);
cancelFragment(handle);
sender.send(ControlRpcConfig.OK);
break;
}
case RpcType.REQ_CUSTOM_VALUE:
{
final CustomMessage customMessage = get(pBody, CustomMessage.PARSER);
sender.send(handlerRegistry.handle(customMessage, (DrillBuf) dBody));
break;
}
case RpcType.REQ_RECEIVER_FINISHED_VALUE:
{
final FinishedReceiver finishedReceiver = get(pBody, FinishedReceiver.PARSER);
receivingFragmentFinished(finishedReceiver);
sender.send(ControlRpcConfig.OK);
break;
}
case RpcType.REQ_FRAGMENT_STATUS_VALUE:
final FragmentStatus status = get(pBody, FragmentStatus.PARSER);
requestFragmentStatus(status);
// TODO: Support a type of message that has no response.
sender.send(ControlRpcConfig.OK);
break;
case RpcType.REQ_QUERY_CANCEL_VALUE:
{
final QueryId queryId = get(pBody, QueryId.PARSER);
final Ack cancelStatus = requestQueryCancel(queryId);
if (cancelStatus.getOk()) {
sender.send(ControlRpcConfig.OK);
} else {
sender.send(ControlRpcConfig.FAIL);
}
break;
}
case RpcType.REQ_INITIALIZE_FRAGMENTS_VALUE:
{
final InitializeFragments fragments = get(pBody, InitializeFragments.PARSER);
initializeFragment(fragments);
sender.send(ControlRpcConfig.OK);
break;
}
case RpcType.REQ_QUERY_STATUS_VALUE:
{
final QueryId queryId = get(pBody, QueryId.PARSER);
final QueryProfile profile = requestQueryStatus(queryId);
sender.send(new Response(RpcType.RESP_QUERY_STATUS, profile));
break;
}
case RpcType.REQ_UNPAUSE_FRAGMENT_VALUE:
{
final FragmentHandle handle = get(pBody, FragmentHandle.PARSER);
resumeFragment(handle);
sender.send(ControlRpcConfig.OK);
break;
}
default:
throw new RpcException("Not yet supported.");
}
}
use of org.apache.drill.exec.rpc.RpcException in project drill by apache.
the class RuntimeFilterSink method route.
private void route(RuntimeFilterWritable srcRuntimeFilterWritable) {
BitData.RuntimeFilterBDef runtimeFilterB = srcRuntimeFilterWritable.getRuntimeFilterBDef();
int joinMajorId = runtimeFilterB.getMajorFragmentId();
UserBitShared.QueryId queryId = runtimeFilterB.getQueryId();
List<String> probeFields = runtimeFilterB.getProbeFieldsList();
List<Integer> sizeInBytes = runtimeFilterB.getBloomFilterSizeInBytesList();
long rfIdentifier = runtimeFilterB.getRfIdentifier();
DrillBuf[] data = srcRuntimeFilterWritable.getData();
List<CoordinationProtos.DrillbitEndpoint> scanNodeEps = joinMjId2probeScanEps.get(joinMajorId);
int scanNodeSize = scanNodeEps.size();
srcRuntimeFilterWritable.retainBuffers(scanNodeSize - 1);
int scanNodeMjId = joinMjId2ScanMjId.get(joinMajorId);
for (int minorId = 0; minorId < scanNodeEps.size(); minorId++) {
BitData.RuntimeFilterBDef.Builder builder = BitData.RuntimeFilterBDef.newBuilder();
for (String probeField : probeFields) {
builder.addProbeFields(probeField);
}
BitData.RuntimeFilterBDef runtimeFilterBDef = builder.setQueryId(queryId).setMajorFragmentId(scanNodeMjId).setMinorFragmentId(minorId).setToForeman(false).setRfIdentifier(rfIdentifier).addAllBloomFilterSizeInBytes(sizeInBytes).build();
RuntimeFilterWritable runtimeFilterWritable = new RuntimeFilterWritable(runtimeFilterBDef, data);
CoordinationProtos.DrillbitEndpoint drillbitEndpoint = scanNodeEps.get(minorId);
DataTunnel dataTunnel = drillbitContext.getDataConnectionsPool().getTunnel(drillbitEndpoint);
Consumer<RpcException> exceptionConsumer = new Consumer<RpcException>() {
@Override
public void accept(final RpcException e) {
logger.warn("fail to broadcast a runtime filter to the probe side scan node", e);
}
@Override
public void interrupt(final InterruptedException e) {
logger.warn("fail to broadcast a runtime filter to the probe side scan node", e);
}
};
RpcOutcomeListener<BitData.AckWithCredit> statusHandler = new DataTunnelStatusHandler(exceptionConsumer, sendingAccountor);
AccountingDataTunnel accountingDataTunnel = new AccountingDataTunnel(dataTunnel, sendingAccountor, statusHandler);
accountingDataTunnel.sendRuntimeFilter(runtimeFilterWritable);
}
}
use of org.apache.drill.exec.rpc.RpcException in project drill by apache.
the class ConnectTriesPropertyTestClusterBits method testConnectFailureUsingZKWithOnlyFakeBits.
@Test
public void testConnectFailureUsingZKWithOnlyFakeBits() throws Exception {
Properties props = new Properties();
props.setProperty("tries", "3");
// Test with Cluster Coordinator connection
RemoteServiceSet localServiceSet = RemoteServiceSet.getLocalServiceSet();
DrillClient client = new DrillClient(drillConfig, localServiceSet.getCoordinator());
// Create couple of fake drillbit endpoints and register with cluster coordinator
DrillbitEndpoint fakeEndPoint1 = DrillbitEndpoint.newBuilder().setAddress("127.0.0.1").setUserPort(5000).build();
DrillbitEndpoint fakeEndPoint2 = DrillbitEndpoint.newBuilder().setAddress("127.0.0.1").setUserPort(5001).build();
ClusterCoordinator.RegistrationHandle fakeEndPoint1Handle = localServiceSet.getCoordinator().register(fakeEndPoint1);
ClusterCoordinator.RegistrationHandle fakeEndPoint2Handle = localServiceSet.getCoordinator().register(fakeEndPoint2);
try {
client.connect(props);
fail();
} catch (RpcException ex) {
assertTrue(ex.getCause() instanceof ExecutionException);
client.close();
} finally {
// Remove the fake drillbits from local cluster cordinator
localServiceSet.getCoordinator().unregister(fakeEndPoint1Handle);
localServiceSet.getCoordinator().unregister(fakeEndPoint2Handle);
}
}
use of org.apache.drill.exec.rpc.RpcException in project drill by apache.
the class DrillClient method runQuery.
/**
* Run query based on list of fragments that were supposedly produced during query planning phase. Supported
* query type is {@link QueryType#EXECUTION}
* @param type
* @param planFragments
* @param resultsListener
* @throws RpcException
*/
public void runQuery(QueryType type, List<PlanFragment> planFragments, UserResultsListener resultsListener) throws RpcException {
// QueryType can be only executional
checkArgument((QueryType.EXECUTION == type), "Only EXECUTION type query is supported with PlanFragments");
// setting Plan on RunQuery will be used for logging purposes and therefore can not be null
// since there is no Plan string provided we will create a JsonArray out of individual fragment Plans
ArrayNode jsonArray = objectMapper.createArrayNode();
for (PlanFragment fragment : planFragments) {
try {
jsonArray.add(objectMapper.readTree(fragment.getFragmentJson()));
} catch (IOException e) {
logger.error("Exception while trying to read PlanFragment JSON for {}", fragment.getHandle().getQueryId(), e);
throw new RpcException(e);
}
}
final String fragmentsToJsonString;
try {
fragmentsToJsonString = objectMapper.writeValueAsString(jsonArray);
} catch (JsonProcessingException e) {
logger.error("Exception while trying to get JSONString from Array of individual Fragments Json for %s", e);
throw new RpcException(e);
}
final UserProtos.RunQuery query = newBuilder().setType(type).addAllFragments(planFragments).setPlan(fragmentsToJsonString).setResultsMode(STREAM_FULL).build();
client.submitQuery(resultsListener, query);
}
Aggregations