private void doSelectMaster(final String host, final String port, final String contextPath) {
        // try getting lock
        try {
            boolean selected = shenyuClusterSelectMasterService.selectMaster(host, port, contextPath);
            if (!selected) {
                LOG.info("select master fail, wait for next period");
                return;
            }
            
            LOG.info("select master success");
            
            // start upstream check task
            upstreamCheckService.setup();
            
            // load api
            loadServiceDocEntry.loadApiDocument();
            
            boolean renewed = shenyuClusterSelectMasterService.checkMasterStatus();
            
            while (renewed) {
                // sleeps selectPeriod seconds then renew the lock
                TimeUnit.SECONDS.sleep(clusterProperties.getSelectPeriod());
                
                renewed = shenyuClusterSelectMasterService.checkMasterStatus();
                if (renewed) {
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("renew master success");
                    }
                }
            }
        } catch (Exception e) {
            LOG.error("select master error", e);
            // close the upstream check service
            upstreamCheckService.close();
            
            String message = String.format("renew master fail, %s", e.getMessage());
            throw new ShenyuException(message);
        } finally {
            try {
                shenyuClusterSelectMasterService.releaseMaster();
            } catch (Exception e) {
                LOG.error("release master error", e);
            }
        }
    }
start master select task.

@param host host
@param port port
@param contextPath contextPath
shenyu-admin/src/main/java/org/apache/shenyu/admin/mode/cluster/service/ShenyuClusterService.java