ServerConfig转ServerTransportConfig

@param serverConfig 服务端配置
@return ServerTransportConfig 服务传输层配置
506368
private static ServerTransportConfig convertConfig(ServerConfig serverConfig) {
        ServerTransportConfig serverTransportConfig = new ServerTransportConfig();
        serverTransportConfig.setPort(serverConfig.getPort());
        serverTransportConfig.setProtocolType(serverConfig.getProtocol());
        serverTransportConfig.setHost(serverConfig.getBoundHost());
        serverTransportConfig.setContextPath(serverConfig.getContextPath());
        serverTransportConfig.setBizMaxThreads(serverConfig.getMaxThreads());
        serverTransportConfig.setBizPoolType(serverConfig.getThreadPoolType());
        serverTransportConfig.setIoThreads(serverConfig.getIoThreads());
        serverTransportConfig.setChannelListeners(serverConfig.getOnConnect());
        serverTransportConfig.setMaxConnection(serverConfig.getAccepts());
        serverTransportConfig.setPayload(serverConfig.getPayload());
        serverTransportConfig.setTelnet(serverConfig.isTelnet());
        serverTransportConfig.setUseEpoll(serverConfig.isEpoll());
        serverTransportConfig.setBizPoolQueueType(serverConfig.getQueueType());
        serverTransportConfig.setBizPoolQueues(serverConfig.getQueues());
        serverTransportConfig.setDaemon(serverConfig.isDaemon());
        serverTransportConfig.setParameters(serverConfig.getParameters());
        serverTransportConfig.setContainer(serverConfig.getTransport());
        return serverTransportConfig;
    }
566994
public static EventLoopGroup getServerBossEventLoopGroup(ServerTransportConfig config) {
        String type = config.getProtocolType();
        EventLoopGroup bossGroup = serverBossGroups.get(type);
        if (bossGroup == null) {
            synchronized (NettyHelper.class) {
                bossGroup = serverBossGroups.get(config.getProtocolType());
                if (bossGroup == null) {
                    int bossThreads = config.getBossThreads();
                    bossThreads = bossThreads <= 0 ? Math.max(4, SystemInfo.getCpuCores() / 2) : bossThreads;
                    NamedThreadFactory threadName =
                            new NamedThreadFactory("SEV-BOSS-" + config.getPort(), config.isDaemon());
                    bossGroup = config.isUseEpoll() ?
                        new EpollEventLoopGroup(bossThreads, threadName) :
                        new NioEventLoopGroup(bossThreads, threadName);
                    serverBossGroups.put(type, bossGroup);
                    refCounter.putIfAbsent(bossGroup, new AtomicInteger(0));
                }
            }
        }
        refCounter.get(bossGroup).incrementAndGet();
        return bossGroup;
    }
839254
public function getServerConfiguration(string $serverId)
    {
        if (!$this->hasServerConfiguration($serverId)) {
            return array();
        }
        //====================================================================//
        //  Populate Servers Config From Parameters
        $configuration = $this->configuration['connections'][$serverId]['config'];
        //====================================================================//
        //  Complete Servers Config From Cache
        if ($this->configuration['cache']['enabled']) {
            $configuration = array_replace_recursive(
                $configuration,
                $this->getConnectorConfigurationFromCache($serverId)
            );
        }

        return $configuration;
    }
1145272
def server_socket(self, config):
		
		if self.__server_socket is None:
			self.__server_socket = self.create_server_socket(config)
			self.__server_socket.bind(self.bind_socket(config).pair())
		return self.__server_socket
473801
public function setConfiguration( models\VPN\Server\Config\ServerConfig $serverConfig){
        $service = sprintf( self::API_VPN_SERVER_CONFIG, $serverConfig->getId());
        $rest = $this->getService( $service);
        $rest->PUT( $serverConfig);

        return $rest->getResult( models\VPN\Server\Config\ServerConfig::class);
    }
53557
protected Server configureJetty(final int port) {
        final Server server = new Server();
        final ServerConnector connector = new ServerConnector(server);
        final ServletContextHandler sch = getServletContextHandler();

        // TODO: make all of this configurable
        connector.setIdleTimeout((int)TimeUnit.HOURS.toMillis(1));
        connector.setSoLingerTime(-1);
        connector.setPort(port);

        server.addConnector(connector);

        // set the injector as an attribute in the context
        sch.setAttribute("guice-injector", getInjector());

        // prevent the JSESSIONID from getting set via a URL argument
        sch.setInitParameter("org.eclipse.jetty.servlet.SessionIdPathParameterName", "none");

        // if we're using a database, then install the filter
        if(!settings.getDatabaseSettings().getNotUsed()) {
            // setup a FilterHolder for the Guice Persistence
            final FilterHolder persistFilter = new FilterHolder(getInjector().getInstance(PersistFilter.class));

            // add the filter to the context
            sch.addFilter(persistFilter, "/*", DISPATCHER_TYPES);
        }

        // configure a FilterHolder for Guice
        final FilterHolder filterHolder = new FilterHolder(GuiceFilter.class);

        sch.addFilter(filterHolder, "/*", DISPATCHER_TYPES);
        sch.addServlet(DefaultServlet.class, "/*");

        //server.setDumpAfterStart(true);
        server.setHandler(sch);


        return server;
    }
1248524
public function createStream($serverconfig = null)
    {
        if ($serverconfig == null) {
            $serverconfig = $this->default_streamserver_config;
        }
        $stream = new $this->stream_class;
        $stream->setRtmpServer($this->streamserver_config[$serverconfig]['rtmp_url']);
        $stream->setRtmpApp($this->streamserver_config[$serverconfig]['app']);
        return $stream;
    }
571906
private ClusterManagerService.Client getCMSClient()
    throws TTransportException {
    // Get the current configuration
    CoronaConf conf = new CoronaConf(getConf());
    return getCMSClient(conf);
  }
544523
public static ServerParams load(String[] args) throws ConfigurationException {
        if (INSTANCE != null) {
            logger.warn("Configuration is loaded already. Use ServerParams.getInstance() method. ");
            return INSTANCE;
        }

        INSTANCE = new ServerParams();
        INSTANCE.parseConfigFile(getConfigUrl());
        INSTANCE.parseCommandLineArgs(args);
        INSTANCE.parseOverrideFile();
        INSTANCE.printConfig();
        
        // TODO: Delete the next line when ServerConfig is phased out.
        copyParamsToServerConfig();
        return INSTANCE;
    }
1137767
public Optional<ServerPort> activePort() {
        final Server server = this.server;
        return server != null ? server.activePort() : Optional.empty();
    }
777953
public static Map<String, Object> getTransportProperties(TransportsConfiguration transportsConfiguration) {
        Map<String, Object> transportProperties = new HashMap<>();
        Set<TransportProperty> transportPropertiesSet = transportsConfiguration.getTransportProperties();
        if (transportPropertiesSet != null && !transportPropertiesSet.isEmpty()) {
            transportProperties = transportPropertiesSet.stream().collect(
                    Collectors.toMap(TransportProperty::getName, TransportProperty::getValue));

        }
        return transportProperties;
    }
689133
function DistribusTransport(config) {
  this.id = config && config.id || null;
  this['default'] = config && config['default'] || false;
  this.host = config && config.host || new distribus.Host(config);

  this.networkId = this.host.networkId; // FIXME: networkId can change when host connects to another host.
}
81695
public static HostAndPort hostAndPort(AbstractConfig config, String key) {
    return hostAndPort(config, key, null);
  }
728028
function handleServerConfig (serverConfig) {
	if (!serverConfig) {
		return defaultServerConfig;
	} else if (!serverConfig.hasOwnProperty('hostname') || !serverConfig.hasOwnProperty('port')) {
		return defaultServerConfig;
	}

	return serverConfig;
}
667832
public List<String> buildUrls() {
        if (exported) {
            List<ServerConfig> servers = providerConfig.getServer();
            if (servers != null && !servers.isEmpty()) {
                List<String> urls = new ArrayList<String>();
                for (ServerConfig server : servers) {
                    StringBuilder sb = new StringBuilder(200);
                    sb.append(server.getProtocol()).append("://").append(server.getHost())
                        .append(":").append(server.getPort()).append(server.getContextPath())
                        .append(providerConfig.getInterfaceId())
                        .append("?uniqueId=").append(providerConfig.getUniqueId())
                        .append(getKeyPairs("version", "1.0"))
                        .append(getKeyPairs("delay", providerConfig.getDelay()))
                        .append(getKeyPairs("weight", providerConfig.getWeight()))
                        .append(getKeyPairs("register", providerConfig.isRegister()))
                        .append(getKeyPairs("maxThreads", server.getMaxThreads()))
                        .append(getKeyPairs("ioThreads", server.getIoThreads()))
                        .append(getKeyPairs("threadPoolType", server.getThreadPoolType()))
                        .append(getKeyPairs("accepts", server.getAccepts()))
                        .append(getKeyPairs("dynamic", providerConfig.isDynamic()))
                        .append(getKeyPairs(RpcConstants.CONFIG_KEY_RPC_VERSION, Version.RPC_VERSION));
                    urls.add(sb.toString());
                }
                return urls;
            }
        }
        return null;
    }
1241672
@Override
	public TServerTransport getTransport() throws TTransportException {
		if (serverSocket == null) {
			TSSLTransportParameters params = getServerConfiguration().getSslTransportParameters();
			serverSocket = params == null ? new TServerSocket(getServerPort())
					: TSSLTransportFactory.getServerSocket(getServerPort(), 0, null, params);
		}
		return serverSocket;
	}
125454
public static CloudBigtableScanConfiguration BuildExportConfig(ExportOptions options) {
    ValueProvider<ReadRowsRequest> request = new RequestValueProvider(options);
    CloudBigtableScanConfiguration.Builder configBuilder =
        new CloudBigtableScanConfiguration.Builder()
            .withProjectId(options.getBigtableProject())
            .withInstanceId(options.getBigtableInstanceId())
            .withTableId(options.getBigtableTableId())
            .withAppProfileId(options.getBigtableAppProfileId())
            .withRequest(request);

    return configBuilder.build();
  }