public void start()

in ratis-logservice/src/main/java/org/apache/ratis/logservice/server/MetadataServer.java [69:114]


    public void start() throws IOException  {
        final ServerOpts opts = getServerOpts();
        if (opts.getHost() == null) {
            opts.setHost(LogServiceUtils.getHostName());
        }
        this.lifeCycle = new LifeCycle(this.id);
        RaftProperties properties = new RaftProperties();
        if(opts.getWorkingDir() != null) {
            RaftServerConfigKeys.setStorageDir(properties,
              Collections.singletonList(new File(opts.getWorkingDir())));
        } else {
          String path = getConfig().get(Constants.META_SERVER_WORKDIR_KEY);
          if (path != null) {
            RaftServerConfigKeys.setStorageDir(properties,
              Collections.singletonList(new File(path)));
          }
        }

        // Set properties common to all log service state machines
        setRaftProperties(properties);
        long failureDetectionPeriod = getConfig().
                getLong(Constants.LOG_SERVICE_PEER_FAILURE_DETECTION_PERIOD_KEY,
                Constants.DEFAULT_PEER_FAILURE_DETECTION_PERIOD);
        Set<RaftPeer> peers = getPeersFromQuorum(opts.getMetaQuorum());
        RaftGroupId raftMetaGroupId = RaftGroupId.valueOf(opts.getMetaGroupId());
        RaftGroup metaGroup = RaftGroup.valueOf(raftMetaGroupId, peers);
        metaStateMachine = new MetaStateMachine(raftMetaGroupId, RaftGroupId.valueOf(opts.getLogServerGroupId()),
                failureDetectionPeriod);

        // Make sure that we aren't setting any invalid/harmful properties
        validateRaftProperties(properties);

        server = RaftServer.newBuilder()
                .setGroup(metaGroup)
                .setServerId(RaftPeerId.valueOf(id))
                .setStateMachineRegistry(raftGroupId -> {
                    if(raftGroupId.equals(META_GROUP_ID)) {
                        return metaStateMachine;
                    }
                    return null;
                })
                .setProperties(properties).build();
        lifeCycle.startAndTransition(() -> {
            server.start();
        }, IOException.class);
    }