public static boolean isValidServiceTypeAndMethod()

in inlong-tubemq/tubemq-core/src/main/java/org/apache/inlong/tubemq/corerpc/codec/PbEnDecoder.java [250:329]


    public static boolean isValidServiceTypeAndMethod(int serviceId,
            int methodId,
            final StringBuilder sBuilder) throws Exception {
        // #lizard forgives
        // First confirm the valid data according to the service ID according to the service ID.
        switch (serviceId) {
            case RpcConstants.RPC_SERVICE_TYPE_MASTER_SERVICE: {
                switch (methodId) {
                    case RpcConstants.RPC_MSG_MASTER_PRODUCER_REGISTER:
                    case RpcConstants.RPC_MSG_MASTER_PRODUCER_HEARTBEAT:
                    case RpcConstants.RPC_MSG_MASTER_PRODUCER_CLOSECLIENT:
                    case RpcConstants.RPC_MSG_MASTER_CONSUMER_REGISTER:
                    case RpcConstants.RPC_MSG_MASTER_CONSUMER_HEARTBEAT:
                    case RpcConstants.RPC_MSG_MASTER_CONSUMER_CLOSECLIENT:
                    case RpcConstants.RPC_MSG_MASTER_CONSUMER_REGISTER_V2:
                    case RpcConstants.RPC_MSG_MASTER_CONSUMER_HEARTBEAT_V2:
                    case RpcConstants.RPC_MSG_MASTER_CONSUMER_GET_PART_META:
                    case RpcConstants.RPC_MSG_MASTER_BROKER_REGISTER:
                    case RpcConstants.RPC_MSG_MASTER_BROKER_HEARTBEAT:
                    case RpcConstants.RPC_MSG_MASTER_BROKER_CLOSECLIENT: {
                        return true;
                    }
                    default: {
                        if (sBuilder != null) {
                            sBuilder.append("Unsupported method ").append(methodId)
                                    .append("in service type ").append(serviceId)
                                    .append("!");
                        }
                        return false;
                    }
                }
            }
            case RpcConstants.RPC_SERVICE_TYPE_BROKER_READ_SERVICE: {
                switch (methodId) {
                    case RpcConstants.RPC_MSG_BROKER_PRODUCER_REGISTER:
                    case RpcConstants.RPC_MSG_BROKER_PRODUCER_HEARTBEAT:
                    case RpcConstants.RPC_MSG_BROKER_PRODUCER_SENDMESSAGE:
                    case RpcConstants.RPC_MSG_BROKER_CONSUMER_REGISTER:
                    case RpcConstants.RPC_MSG_BROKER_CONSUMER_HEARTBEAT:
                    case RpcConstants.RPC_MSG_BROKER_CONSUMER_GETMESSAGE:
                    case RpcConstants.RPC_MSG_BROKER_CONSUMER_COMMIT:
                    case RpcConstants.RPC_MSG_BROKER_CONSUMER_CLOSE: {
                        return true;
                    }
                    default: {
                        if (sBuilder != null) {
                            sBuilder.append("Unsupported method ").append(methodId)
                                    .append("in service type ").append(serviceId)
                                    .append("!");
                        }
                        return false;
                    }
                }
            }
            case RpcConstants.RPC_SERVICE_TYPE_BROKER_WRITE_SERVICE: {
                switch (methodId) {
                    case RpcConstants.RPC_MSG_BROKER_PRODUCER_REGISTER:
                    case RpcConstants.RPC_MSG_BROKER_PRODUCER_HEARTBEAT:
                    case RpcConstants.RPC_MSG_BROKER_PRODUCER_SENDMESSAGE:
                    case RpcConstants.RPC_MSG_BROKER_PRODUCER_CLOSE: {
                        return true;
                    }
                    default: {
                        if (sBuilder != null) {
                            sBuilder.append("Unsupported method ").append(methodId)
                                    .append("in service type ").append(serviceId)
                                    .append("!");
                        }
                        return false;
                    }
                }
            }
            default: {
                if (sBuilder != null) {
                    sBuilder.append("Service Type is invalid!");
                }
                return false;
            }
        }
    }