use of io.nosqlbench.driver.pulsar.exception.PulsarDriverUnsupportedOpException in project nosqlbench by nosqlbench.
the class ReadyPulsarOp method resolve.
private LongFunction<PulsarOp> resolve() {
String stmtOpType = lookupStaticParameter("optype", true, null);
if (cmdTpl.containsKey("topic_url")) {
throw new PulsarDriverParamException("[resolve()] \"topic_url\" parameter is not valid. Perhaps you mean \"topic_uri\"?");
}
// Doc-level parameter: topic_uri
LongFunction<String> topicUriFunc = lookupParameterFunc(PulsarActivityUtil.DOC_LEVEL_PARAMS.TOPIC_URI.label);
logger.info("topic_uri: {}", topicUriFunc.apply(0));
// Doc-level parameter: async_api
boolean useAsyncApi = BooleanUtils.toBoolean(lookupStaticParameter(PulsarActivityUtil.DOC_LEVEL_PARAMS.ASYNC_API.label, false, "false"));
LongFunction<Boolean> asyncApiFunc = (l) -> useAsyncApi;
logger.info("async_api: {}", useAsyncApi);
// Doc-level parameter: use_transaction
boolean useTransaction = BooleanUtils.toBoolean(lookupStaticParameter(PulsarActivityUtil.DOC_LEVEL_PARAMS.USE_TRANSACTION.label, false, "false"));
LongFunction<Boolean> useTransactionFunc = (l) -> useTransaction;
logger.info("use_transaction: {}", useTransaction);
// Doc-level parameter: admin_delop
boolean adminDelOp = BooleanUtils.toBoolean(lookupStaticParameter(PulsarActivityUtil.DOC_LEVEL_PARAMS.ADMIN_DELOP.label, false, "false"));
LongFunction<Boolean> adminDelOpFunc = (l) -> adminDelOp;
logger.info("admin_delop: {}", adminDelOp);
// Doc-level parameter: seq_tracking
boolean seqTracking = BooleanUtils.toBoolean(lookupStaticParameter(PulsarActivityUtil.DOC_LEVEL_PARAMS.SEQ_TRACKING.label, false, "false"));
LongFunction<Boolean> seqTrackingFunc = (l) -> seqTracking;
logger.info("seq_tracking: {}", seqTracking);
// TODO: Collapse this pattern into a simple version and flatten out all call sites
LongFunction<String> payloadRttFieldFunc = lookupParameterFunc(RTT_TRACKING_FIELD, false, "");
logger.info("payload_rtt_field_func: {}", payloadRttFieldFunc.apply(0));
// Admin operation: create/delete tenant
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.ADMIN_TENANT.label)) {
return resolveAdminTenant(clientSpace, asyncApiFunc, adminDelOpFunc);
} else // Admin operation: create/delete namespace
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.ADMIN_NAMESPACE.label)) {
return resolveAdminNamespace(clientSpace, asyncApiFunc, adminDelOpFunc);
} else // Admin operation: create/delete topic
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.ADMIN_TOPIC.label)) {
return resolveAdminTopic(clientSpace, topicUriFunc, asyncApiFunc, adminDelOpFunc);
} else // Regular/non-admin operation: single message sending (producer)
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.MSG_SEND.label)) {
return resolveMsgSend(clientSpace, topicUriFunc, asyncApiFunc, useTransactionFunc, seqTrackingFunc);
} else // Regular/non-admin operation: single message consuming from a single topic (consumer)
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.MSG_CONSUME.label)) {
return resolveMsgConsume(clientSpace, topicUriFunc, asyncApiFunc, useTransactionFunc, seqTrackingFunc, parseEndToEndStartingTimeSourceParameter(EndToEndStartingTimeSource.NONE), payloadRttFieldFunc);
} else // Regular/non-admin operation: single message consuming from multiple-topics (consumer)
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.MSG_MULTI_CONSUME.label)) {
return resolveMultiTopicMsgConsume(clientSpace, topicUriFunc, asyncApiFunc, useTransactionFunc, seqTrackingFunc, payloadRttFieldFunc);
} else // Regular/non-admin operation: single message consuming a single topic (reader)
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.MSG_READ.label)) {
return resolveMsgRead(clientSpace, topicUriFunc, asyncApiFunc);
} else // Regular/non-admin operation: batch message processing - batch start
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.BATCH_MSG_SEND_START.label)) {
return resolveMsgBatchSendStart(clientSpace, topicUriFunc, asyncApiFunc);
} else // Regular/non-admin operation: batch message processing - message sending (producer)
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.BATCH_MSG_SEND.label)) {
return resolveMsgBatchSend(clientSpace, asyncApiFunc);
} else // Regular/non-admin operation: batch message processing - batch send
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.BATCH_MSG_SEND_END.label)) {
return resolveMsgBatchSendEnd(clientSpace, asyncApiFunc);
} else // Regular/non-admin operation: end-to-end message processing - sending message
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.E2E_MSG_PROC_SEND.label)) {
return resolveMsgSend(clientSpace, topicUriFunc, asyncApiFunc, useTransactionFunc, seqTrackingFunc);
} else // Regular/non-admin operation: end-to-end message processing - consuming message
if (StringUtils.equalsIgnoreCase(stmtOpType, PulsarActivityUtil.OP_TYPES.E2E_MSG_PROC_CONSUME.label)) {
return resolveMsgConsume(clientSpace, topicUriFunc, asyncApiFunc, useTransactionFunc, seqTrackingFunc, parseEndToEndStartingTimeSourceParameter(EndToEndStartingTimeSource.MESSAGE_PUBLISH_TIME), payloadRttFieldFunc);
} else // Invalid operation type
{
throw new PulsarDriverUnsupportedOpException();
}
}
Aggregations