Java Code Examples for org.elasticsearch.common.unit.ByteSizeValue#bytesAsInt()

The following examples show how to use org.elasticsearch.common.unit.ByteSizeValue#bytesAsInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecoverySettings.java    From crate with Apache License 2.0 4 votes vote down vote up
public void setChunkSize(ByteSizeValue chunkSize) { // only settable for tests
    if (chunkSize.bytesAsInt() <= 0) {
        throw new IllegalArgumentException("chunkSize must be > 0");
    }
    this.chunkSize = chunkSize;
}
 
Example 2
Source File: Netty4HttpServerTransport.java    From crate with Apache License 2.0 4 votes vote down vote up
public Netty4HttpServerTransport(Settings settings,
                                 NetworkService networkService,
                                 BigArrays bigArrays,
                                 ThreadPool threadPool,
                                 NamedXContentRegistry xContentRegistry,
                                 PipelineRegistry pipelineRegistry,
                                 NodeClient nodeClient) {
    Netty4Utils.setAvailableProcessors(EsExecutors.PROCESSORS_SETTING.get(settings));
    this.settings = settings;
    this.networkService = networkService;
    this.bigArrays = bigArrays;
    this.threadPool = threadPool;
    this.xContentRegistry = xContentRegistry;
    this.pipelineRegistry = pipelineRegistry;
    this.nodeClient = nodeClient;

    this.maxContentLength = SETTING_HTTP_MAX_CONTENT_LENGTH.get(settings);
    this.maxChunkSize = SETTING_HTTP_MAX_CHUNK_SIZE.get(settings);
    this.maxHeaderSize = SETTING_HTTP_MAX_HEADER_SIZE.get(settings);
    this.maxInitialLineLength = SETTING_HTTP_MAX_INITIAL_LINE_LENGTH.get(settings);
    this.resetCookies = SETTING_HTTP_RESET_COOKIES.get(settings);
    this.maxCompositeBufferComponents = SETTING_HTTP_NETTY_MAX_COMPOSITE_BUFFER_COMPONENTS.get(settings);
    this.workerCount = SETTING_HTTP_WORKER_COUNT.get(settings);
    this.port = SETTING_HTTP_PORT.get(settings);
    // we can't make the network.bind_host a fallback since we already fall back to http.host hence the extra conditional here
    List<String> httpBindHost = SETTING_HTTP_BIND_HOST.get(settings);
    this.bindHosts = (httpBindHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_BIND_HOST_SETTING.get(settings) : httpBindHost)
        .toArray(Strings.EMPTY_ARRAY);
    // we can't make the network.publish_host a fallback since we already fall back to http.host hence the extra conditional here
    List<String> httpPublishHost = SETTING_HTTP_PUBLISH_HOST.get(settings);
    this.publishHosts = (httpPublishHost.isEmpty() ? NetworkService.GLOBAL_NETWORK_PUBLISH_HOST_SETTING.get(settings) : httpPublishHost)
        .toArray(Strings.EMPTY_ARRAY);
    this.detailedErrorsEnabled = SETTING_HTTP_DETAILED_ERRORS_ENABLED.get(settings);
    this.readTimeoutMillis = Math.toIntExact(SETTING_HTTP_READ_TIMEOUT.get(settings).getMillis());

    ByteSizeValue receivePredictor = SETTING_HTTP_NETTY_RECEIVE_PREDICTOR_SIZE.get(settings);
    recvByteBufAllocator = new FixedRecvByteBufAllocator(receivePredictor.bytesAsInt());

    this.compression = SETTING_HTTP_COMPRESSION.get(settings);
    this.compressionLevel = SETTING_HTTP_COMPRESSION_LEVEL.get(settings);
    this.pipeliningMaxEvents = SETTING_PIPELINING_MAX_EVENTS.get(settings);
    this.corsConfig = buildCorsConfig(settings);

    logger.debug("using max_chunk_size[{}], max_header_size[{}], max_initial_line_length[{}], max_content_length[{}], " +
            "receive_predictor[{}], max_composite_buffer_components[{}], pipelining_max_events[{}]",
        maxChunkSize, maxHeaderSize, maxInitialLineLength, maxContentLength,
        receivePredictor, maxCompositeBufferComponents, pipeliningMaxEvents);
}
 
Example 3
Source File: PrimaryReplicaSyncer.java    From crate with Apache License 2.0 4 votes vote down vote up
void setChunkSize(ByteSizeValue chunkSize) { // only settable for tests
    if (chunkSize.bytesAsInt() <= 0) {
        throw new IllegalArgumentException("chunkSize must be > 0");
    }
    this.chunkSize = chunkSize;
}