当前位置: 首页>>代码示例>>Java>>正文


Java Builder.setIoThreads方法代码示例

本文整理汇总了Java中io.undertow.Undertow.Builder.setIoThreads方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.setIoThreads方法的具体用法?Java Builder.setIoThreads怎么用?Java Builder.setIoThreads使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.undertow.Undertow.Builder的用法示例。


在下文中一共展示了Builder.setIoThreads方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBuilder

import io.undertow.Undertow.Builder; //导入方法依赖的package包/类
private Builder createBuilder(int port) {
	Builder builder = Undertow.builder();
	if (this.bufferSize != null) {
		builder.setBufferSize(this.bufferSize);
	}
	if (this.buffersPerRegion != null) {
		builder.setBuffersPerRegion(this.buffersPerRegion);
	}
	if (this.ioThreads != null) {
		builder.setIoThreads(this.ioThreads);
	}
	if (this.workerThreads != null) {
		builder.setWorkerThreads(this.workerThreads);
	}
	if (this.directBuffers != null) {
		builder.setDirectBuffers(this.directBuffers);
	}
	if (getSsl() != null && getSsl().isEnabled()) {
		configureSsl(getSsl(), port, builder);
	}
	else {
		builder.addHttpListener(port, getListenAddress());
	}
	for (UndertowBuilderCustomizer customizer : this.builderCustomizers) {
		customizer.customize(builder);
	}
	return builder;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:29,代码来源:UndertowEmbeddedServletContainerFactory.java

示例2: configureServerPerformance

import io.undertow.Undertow.Builder; //导入方法依赖的package包/类
private static void configureServerPerformance(Builder serverBuilder, ServerConfig config) {
    // TODO investigate serverBuilder.setWorkerThreads
    // Per default Builder#setWorkerThreads gets set to ioThreads * 8, but it does not get updated, when setting ioThreads,
    // so we need to set worker threads explicitly
    
    
    int undertow_minimum = 2;//may not be less than 2 because of the inner workings of Undertow
    int ioThreads, workerThreads;
    switch (config.serverPerformance()) {
        case HIGHEST:
            ioThreads = Math.max(Runtime.getRuntime().availableProcessors() << 1, undertow_minimum);
            workerThreads = ioThreads * 8;
            serverBuilder.setBufferSize(1024 * 16);
            break;
        case HIGH:
            ioThreads = Math.max(Runtime.getRuntime().availableProcessors(), undertow_minimum);
            workerThreads = ioThreads * 8;
            break;
        default:
        case MEDIUM:
            ioThreads = Math.max(Runtime.getRuntime().availableProcessors() / 2, undertow_minimum);
            workerThreads = ioThreads * 4;
            break;
        case LOW:
            ioThreads = undertow_minimum;
            workerThreads = ioThreads;
            break;
        case CUSTOM:
            ioThreads = Math.max(config.ioThreads(), undertow_minimum);
            workerThreads = ioThreads * 8;
            break;
    }
    
    serverBuilder.setIoThreads(ioThreads);
    serverBuilder.setWorkerThreads(workerThreads);
    serverBuilder.setSocketOption(Options.BACKLOG, config.backlog());
}
 
开发者ID:MTDdk,项目名称:jawn,代码行数:38,代码来源:UndertowServer.java

示例3: configureServerPerformance

import io.undertow.Undertow.Builder; //导入方法依赖的package包/类
private void configureServerPerformance(Builder serverBuilder, ServerConfig config) {
    // TODO investigate serverBuilder.setWorkerThreads
    // Per default Builder#setWorkerThreads gets set to ioThreads * 8, but it does not get updated, when setting ioThreads,
    // so we need to set worker threads explicitly
    
    
    int undertow_minimum = 2;//may not be less than 2 because of the inner workings of Undertow
    switch (config.serverPerformance()) {
        case HIGHEST:
            int ioThreads = Math.max(Runtime.getRuntime().availableProcessors() << 1, undertow_minimum);
            serverBuilder.setIoThreads(ioThreads);
            serverBuilder.setWorkerThreads(ioThreads * 8);
            serverBuilder.setBufferSize(1024 * 16);
            break;
        case HIGH:
            serverBuilder.setIoThreads(Math.max(Runtime.getRuntime().availableProcessors(), undertow_minimum));
            break;
        case MEDIUM:
            serverBuilder.setIoThreads(Math.max(Runtime.getRuntime().availableProcessors() / 2, undertow_minimum));
            break;
        case LOW:
            serverBuilder.setIoThreads(undertow_minimum); 
            break;
        case CUSTOM:
            serverBuilder.setIoThreads(Math.max(config.ioThreads(), undertow_minimum));
            break;
    }
    
    serverBuilder.setSocketOption(Options.BACKLOG, config.backlog());
}
 
开发者ID:MTDdk,项目名称:jawn,代码行数:31,代码来源:UndertowServerOld.java

示例4: createServer

import io.undertow.Undertow.Builder; //导入方法依赖的package包/类
protected io.undertow.Undertow createServer(HttpHandler contextHandler) {

        int ports = settings.getHttpPort() + settings.getHttpsPort() + settings.getAjpPort();
        Preconditions.checkState(ports > 0, "No port specified! Please review your server port settings!");

        log.debug("Configuring Undertow engine");

        Builder builder = io.undertow.Undertow.builder();

        if (settings.getHttpPort() > 0) {
            // HTTP
            builder.addHttpListener(settings.getHttpPort(), settings.getHttpListenAddress());
            logSetting(Settings.Setting.undertow_httpPort, settings.getHttpPort());
        }

        if (settings.getHttpsPort() > 0) {
            // HTTPS
            builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true);
            try {
                KeyStore keyStore = loadKeyStore(settings.getKeystoreFile(), settings.getKeystorePassword());
                KeyStore trustStore = loadKeyStore(settings.getTruststoreFile(), settings.getTruststorePassword());
                SSLContext sslContext = createSSLContext(keyStore, trustStore);
                builder.addHttpsListener(settings.getHttpsPort(), settings.getHttpsListenAddress(), sslContext);
                logSetting(Settings.Setting.undertow_httpsPort, settings.getHttpsPort());
            } catch (Exception e) {
                throw new FathomException(e, "Failed to setup an Undertow SSL listener!");
            }
        }

        if (settings.getAjpPort() > 0) {
            // AJP
            builder.addAjpListener(settings.getAjpPort(), settings.getAjpListenAddress());
            logSetting(Settings.Setting.undertow_ajpPort, settings.getAjpPort());
        }

        int ioThreads = settings.getInteger(Settings.Setting.undertow_ioThreads, 0);
        if (ioThreads > 0) {
            builder.setIoThreads(ioThreads);
            logSetting(Settings.Setting.undertow_ioThreads, ioThreads);
        }

        int workerThreads = settings.getInteger(Settings.Setting.undertow_workerThreads, 0);
        if (workerThreads > 0) {
            builder.setWorkerThreads(workerThreads);
            logSetting(Settings.Setting.undertow_workerThreads, workerThreads);
        }

        long bufferSize = settings.getBytes(Settings.Setting.undertow_bufferSize, null);
        if (bufferSize > 0) {
            builder.setBufferSize((int) bufferSize);
            logSetting(Settings.Setting.undertow_bufferSize, bufferSize);
        }

        builder.setHandler(contextHandler);
        io.undertow.Undertow server = builder.build();
        return server;
    }
 
开发者ID:gitblit,项目名称:fathom,代码行数:58,代码来源:Server.java

示例5: createServer

import io.undertow.Undertow.Builder; //导入方法依赖的package包/类
protected Undertow createServer(HttpHandler contextHandler) {
    Builder builder = Undertow.builder();
    // TODO is it a better option?
    if (getSettings().getBufferSize() > 0) {
        builder.setBufferSize(getSettings().getBufferSize());
    }
    // method builder.setBuffersPerRegion is deprecated
    /*
    if (getSettings().getBuffersPerRegion() > 0) {
        builder.setBuffersPerRegion(getSettings().getBuffersPerRegion());
    }
    */
    if (getSettings().getDirectBuffers()) {
        builder.setDirectBuffers(getSettings().getDirectBuffers());
    }
    if (getSettings().getIoThreads() > 0) {
        builder.setIoThreads(getSettings().getIoThreads());
    }
    if (getSettings().getWorkerThreads() > 0) {
        builder.setWorkerThreads(getSettings().getWorkerThreads());
    }

    if (getSettings().getKeystoreFile() == null) {
        // HTTP
        builder.addHttpListener(getSettings().getPort(), getSettings().getHost());
    } else {
        // HTTPS
        builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true);
        try {
            KeyStore keyStore = loadKeyStore(getSettings().getKeystoreFile(), getSettings().getKeystorePassword());
            KeyStore trustStore = loadKeyStore(getSettings().getTruststoreFile(), getSettings().getTruststorePassword());
            SSLContext sslContext = createSSLContext(keyStore, trustStore);
            builder.addHttpsListener(getSettings().getPort(), getSettings().getHost(), sslContext);
        } catch (Exception e) {
            throw new PippoRuntimeException(e, "Failed to setup an Undertow SSL listener!");
        }
    }

    // add undertow options
    getSettings().addUndertowOptions(builder);
    builder.setHandler(contextHandler);

    return builder.build();
}
 
开发者ID:decebals,项目名称:pippo,代码行数:45,代码来源:UndertowServer.java


注:本文中的io.undertow.Undertow.Builder.setIoThreads方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。