public CompletableFuture query()

in ratis-logservice/src/main/java/org/apache/ratis/logservice/server/MetaStateMachine.java [207:257]


    public CompletableFuture<Message> query(Message request) {
        Timer.Context timerContext = null;
        MetaServiceProtos.MetaServiceRequestProto.TypeCase type = null;
        if (currentGroup == null) {
            try {
                List<RaftGroup> x =
                        StreamSupport.stream(raftServer.getGroups().spliterator(), false)
                          .filter(group -> group.getGroupId().equals(metadataGroupId)).collect(Collectors.toList());
                if (x.size() == 1) {
                    currentGroup = x.get(0);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        MetaServiceProtos.MetaServiceRequestProto req;
        try {
            req = MetaServiceProtos.MetaServiceRequestProto.parseFrom(request.getContent());
        } catch (InvalidProtocolBufferException e) {
            e.printStackTrace();
            return null;
        }
        type = req.getTypeCase();
        // Main purpose of this try catch block is to make sure that
        // timerContext.stop() is run after return.
        try {
            timerContext = logServiceMetaDataMetrics.getTimer(type.name()).time();
            switch (type) {

                case CREATELOG:
                    return processCreateLogRequest(req);
                case LISTLOGS:
                    return processListLogsRequest();
                case GETLOG:
                    return processGetLogRequest(req);
                case DELETELOG:
                    return processDeleteLog(req);
                default:
                    CompletableFuture<Message> reply = super.query(request);
                    return reply;
            }
        } catch (Exception e) {
            LOG.error("Exception during Meta State Machine query");
            throw e;
        } finally {
            if (timerContext != null) {
                timerContext.stop();
            }
        }
    }