本文整理汇总了Java中org.apache.drill.exec.rpc.Response类的典型用法代码示例。如果您正苦于以下问题:Java Response类的具体用法?Java Response怎么用?Java Response使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Response类属于org.apache.drill.exec.rpc包,在下文中一共展示了Response类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
@Override
public <S extends ServerConnection<S>, T extends EnumLite>
void process(SaslResponseContext<S, T> context) throws Exception {
final SaslMessage.Builder challenge = SaslMessage.newBuilder();
final SaslServer saslServer = context.connection.getSaslServer();
final byte[] challengeBytes = evaluateResponse(saslServer, context.saslResponse.getData().toByteArray());
if (saslServer.isComplete()) {
challenge.setStatus(SaslStatus.SASL_SUCCESS);
if (challengeBytes != null) {
challenge.setData(ByteString.copyFrom(challengeBytes));
}
handleSuccess(context, challenge, saslServer);
} else {
challenge.setStatus(SaslStatus.SASL_IN_PROGRESS)
.setData(ByteString.copyFrom(challengeBytes));
context.sender.send(new Response(context.saslResponseType, challenge.build()));
}
}
示例2: handle
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
@Override protected void handle(UserToBitConnection connection, int rpcType, ByteBuf pBody, ByteBuf dBody,
ResponseSender sender) throws RpcException {
if (!authComplete) {
// Remote should not be making any requests before authenticating, drop connection
throw new RpcException(String.format("Request of type %d is not allowed without authentication. "
+ "Remote on %s must authenticate before making requests. Connection dropped.", rpcType,
connection.getRemoteAddress()));
}
switch (rpcType) {
case RpcType.QUERY_DATA_VALUE:
queryResultHandler.batchArrived(connection, pBody, dBody);
sender.send(new Response(RpcType.ACK, Acks.OK));
break;
case RpcType.QUERY_RESULT_VALUE:
queryResultHandler.resultArrived(pBody);
sender.send(new Response(RpcType.ACK, Acks.OK));
break;
default:
throw new RpcException(String.format("Unknown Rpc Type %d. ", rpcType));
}
}
示例3: handleReponse
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
@Override
protected Response handleReponse(ConnectionThrottle throttle, int rpcType, ByteBuf pBody, ByteBuf dBody) throws RpcException {
switch (rpcType) {
case RpcType.QUERY_DATA_VALUE:
queryResultHandler.batchArrived(throttle, pBody, dBody);
return new Response(RpcType.ACK, Acks.OK);
case RpcType.QUERY_RESULT_VALUE:
queryResultHandler.resultArrived(pBody);
return new Response(RpcType.ACK, Acks.OK);
default:
throw new RpcException(String.format("Unknown Rpc Type %d. ", rpcType));
}
}
示例4: handle
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
public Response handle(CustomMessage message, DrillBuf dBody) throws RpcException {
final ParsingHandler<?, ?> handler;
try (AutoCloseableLock lock = read.open()) {
handler = handlers.get(message.getType());
}
if (handler == null) {
throw new UserRpcException(
endpoint, "Unable to handle message.",
new IllegalStateException(String.format(
"Unable to handle message. The message type provided [%d] did not have a registered handler.",
message.getType())));
}
final CustomResponse<?> customResponse = handler.onMessage(message.getMessage(), dBody);
@SuppressWarnings("unchecked")
final CustomMessage responseMessage = CustomMessage.newBuilder()
.setMessage(
ByteString.copyFrom(((Controller.CustomSerDe<Object>) handler.getResponseSerDe())
.serializeToSend(customResponse
.getMessage())))
.setType(message.getType())
.build();
// make sure we don't pass in a null array.
final ByteBuf[] dBodies = customResponse.getBodies() == null ? new DrillBuf[0] : customResponse.getBodies();
return new Response(RpcType.RESP_CUSTOM, responseMessage, dBodies);
}
示例5: handleAuthFailure
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
private static <S extends ServerConnection<S>, T extends EnumLite>
void handleAuthFailure(final S connection, final ResponseSender sender,
final Exception e, final T saslResponseType) throws RpcException {
final String remoteAddress = connection.getRemoteAddress().toString();
logger.debug("Authentication using mechanism {} with encryption context {} failed from client {} due to {}",
connection.getSaslServer().getMechanismName(), connection.getEncryptionCtxtString(), remoteAddress, e);
// inform the client that authentication failed, and no more
sender.send(new Response(saslResponseType, SASL_FAILED_MESSAGE));
// drop connection
throw new RpcException(e);
}
示例6: run
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
@Override
public void run() {
final GetServerMetaResp.Builder respBuilder = GetServerMetaResp.newBuilder();
try {
final ServerMeta.Builder metaBuilder = ServerMeta.newBuilder(DEFAULT);
PlannerSettings plannerSettings = new PlannerSettings(session.getOptions(), context.getFunctionImplementationRegistry());
DrillParserConfig config = new DrillParserConfig(plannerSettings);
int identifierMaxLength = config.identifierMaxLength();
Metadata metadata = SqlParser.create("", config).getMetadata();
metaBuilder
.setMaxCatalogNameLength(identifierMaxLength)
.setMaxColumnNameLength(identifierMaxLength)
.setMaxCursorNameLength(identifierMaxLength)
.setMaxSchemaNameLength(identifierMaxLength)
.setMaxTableNameLength(identifierMaxLength)
.setMaxUserNameLength(identifierMaxLength)
.setIdentifierQuoteString(config.quoting().string)
.setIdentifierCasing(getIdentifierCasing(config.unquotedCasing(), config.caseSensitive()))
.setQuotedIdentifierCasing(getIdentifierCasing(config.quotedCasing(), config.caseSensitive()))
.addAllSqlKeywords(Splitter.on(",").split(metadata.getJdbcKeywords()));
respBuilder.setServerMeta(metaBuilder);
respBuilder.setStatus(RequestStatus.OK);
} catch(Throwable t) {
respBuilder.setStatus(RequestStatus.FAILED);
respBuilder.setError(MetadataProvider.createPBError("server meta", t));
} finally {
responseSender.send(new Response(RpcType.SERVER_META, respBuilder.build()));
}
}
示例7: runInternal
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
@Override
protected Response runInternal(final UserSession session, final SchemaTreeProvider schemaProvider) {
final GetCatalogsResp.Builder respBuilder = GetCatalogsResp.newBuilder();
final InfoSchemaFilter filter = createInfoSchemaFilter(
req.hasCatalogNameFilter() ? req.getCatalogNameFilter() : null, null, null, null, null);
try {
final PojoRecordReader<Catalog> records =
getPojoRecordReader(CATALOGS, filter, getConfig(), schemaProvider, session);
List<CatalogMetadata> metadata = new ArrayList<>();
for(Catalog c : records) {
final CatalogMetadata.Builder catBuilder = CatalogMetadata.newBuilder();
catBuilder.setCatalogName(c.CATALOG_NAME);
catBuilder.setDescription(c.CATALOG_DESCRIPTION);
catBuilder.setConnect(c.CATALOG_CONNECT);
metadata.add(catBuilder.build());
}
// Reorder results according to JDBC spec
Collections.sort(metadata, CATALOGS_ORDERING);
respBuilder.addAllCatalogs(metadata);
respBuilder.setStatus(RequestStatus.OK);
} catch (Throwable e) {
respBuilder.setStatus(RequestStatus.FAILED);
respBuilder.setError(createPBError("get catalogs", e));
} finally {
return new Response(RpcType.CATALOGS, respBuilder.build());
}
}
示例8: handle
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
@Override
protected Response handle(ControlConnection connection, int rpcType, ByteBuf pBody, ByteBuf dBody) throws RpcException {
return handler.handle(connection, rpcType, pBody, dBody);
}
示例9: handle
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
@Override
protected Response handle(DataClientConnection connection, int rpcType, ByteBuf pBody, ByteBuf dBody) throws RpcException {
throw new UnsupportedOperationException("DataClient is unidirectional by design.");
}
示例10: handleSuccess
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
private static <S extends ServerConnection<S>, T extends EnumLite>
void handleSuccess(final SaslResponseContext<S, T> context, final SaslMessage.Builder challenge,
final SaslServer saslServer) throws IOException {
final S connection = context.connection;
connection.changeHandlerTo(context.requestHandler);
connection.finalizeSaslSession();
// Check the negotiated property before sending the response back to client
try {
final String negotiatedQOP = saslServer.getNegotiatedProperty(Sasl.QOP).toString();
final String expectedQOP = (connection.isEncryptionEnabled())
? SaslProperties.QualityOfProtection.PRIVACY.getSaslQop()
: SaslProperties.QualityOfProtection.AUTHENTICATION.getSaslQop();
if (!(negotiatedQOP.equals(expectedQOP))) {
throw new SaslException(String.format("Mismatch in negotiated QOP value: %s and Expected QOP value: %s",
negotiatedQOP, expectedQOP));
}
// Update the rawWrapSendSize with the negotiated rawSendSize since we cannot call encode with more than the
// negotiated size of buffer
if (connection.isEncryptionEnabled()) {
final int negotiatedRawSendSize = Integer.parseInt(
saslServer.getNegotiatedProperty(Sasl.RAW_SEND_SIZE).toString());
if (negotiatedRawSendSize <= 0) {
throw new SaslException(String.format("Negotiated rawSendSize: %d is invalid. Please check the configured " +
"value of encryption.sasl.max_wrapped_size. It might be configured to a very small value.",
negotiatedRawSendSize));
}
connection.setWrapSizeLimit(negotiatedRawSendSize);
}
} catch (IllegalStateException | NumberFormatException e) {
throw new SaslException(String.format("Unexpected failure while retrieving negotiated property values (%s)",
e.getMessage()), e);
}
if (logger.isTraceEnabled()) {
logger.trace("Authenticated {} successfully using {} from {} with encryption context {}",
saslServer.getAuthorizationID(), saslServer.getMechanismName(), connection.getRemoteAddress().toString(),
connection.getEncryptionCtxtString());
}
// All checks have passed let's send the response back to client before adding handlers.
context.sender.send(new Response(context.saslResponseType, challenge.build()));
if (connection.isEncryptionEnabled()) {
connection.addSecurityHandlers();
} else {
// Encryption is not required hence we don't need to hold on to saslServer object.
connection.disposeSaslServer();
}
}
示例11: run
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
@Override
public void run() {
final CreatePreparedStatementResp.Builder respBuilder = CreatePreparedStatementResp.newBuilder();
try {
UserClientConnectionWrapper wrapper = new UserClientConnectionWrapper(connection);
final RunQuery limit0Query =
RunQuery.newBuilder()
.setType(QueryType.SQL)
.setPlan(String.format("SELECT * FROM (%s) LIMIT 0", req.getSqlQuery()))
.build();
final QueryId limit0QueryId = userWorker.submitWork(wrapper, limit0Query);
final long timeoutMillis =
userWorker.getSystemOptions().getOption(CREATE_PREPARE_STATEMENT_TIMEOUT_MILLIS).num_val;
try {
if (!wrapper.await(timeoutMillis)) {
logger.error("LIMIT 0 query (QueryId: {}) for prepared statement took longer than {} ms. Cancelling.",
limit0QueryId, timeoutMillis);
userWorker.cancelQuery(limit0QueryId);
final String errorMsg = String.format(
"LIMIT 0 query (QueryId: %s) for prepared statement took longer than %d ms. " +
"Query cancellation requested.\n" +
"Retry after changing the option '%s' to a higher value.",
limit0QueryId, timeoutMillis, CREATE_PREPARE_STATEMENT_TIMEOUT_MILLIS);
setErrorHelper(respBuilder, TIMEOUT, null, errorMsg, ErrorType.SYSTEM);
return;
}
} catch (InterruptedException ex) {
setErrorHelper(respBuilder, FAILED, ex, "Prepared statement creation interrupted.", ErrorType.SYSTEM);
return;
}
if (wrapper.getError() != null) {
setErrorHelper(respBuilder, wrapper.getError(), "Failed to get result set schema for prepare statement.");
return;
}
final PreparedStatement.Builder prepStmtBuilder = PreparedStatement.newBuilder();
for (SerializedField field : wrapper.getFields()) {
prepStmtBuilder.addColumns(serializeColumn(field));
}
prepStmtBuilder.setServerHandle(
PreparedStatementHandle.newBuilder()
.setServerInfo(
ServerPreparedStatementState.newBuilder()
.setSqlQuery(req.getSqlQuery())
.build().toByteString()
)
);
respBuilder.setStatus(OK);
respBuilder.setPreparedStatement(prepStmtBuilder.build());
} catch (Throwable e) {
setErrorHelper(respBuilder, FAILED, e, "Failed to create prepared statement.", ErrorType.SYSTEM);
} finally {
responseSender.send(new Response(RpcType.PREPARED_STATEMENT, respBuilder.build()));
}
}
示例12: handle
import org.apache.drill.exec.rpc.Response; //导入依赖的package包/类
@Override
protected Response handle(int rpcType, ByteBuf pBody, ByteBuf dBody) throws RpcException {
throw new UnsupportedOperationException("This client doesn't support inbound messages.");
}