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


Java ByteSizeValue.getBytes方法代码示例

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


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

示例1: FileInfo

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
/**
 * Constructs a new instance of file info
 *
 * @param name         file name as stored in the blob store
 * @param metaData  the files meta data
 * @param partSize     size of the single chunk
 */
public FileInfo(String name, StoreFileMetaData metaData, ByteSizeValue partSize) {
    this.name = name;
    this.metadata = metaData;

    long partBytes = Long.MAX_VALUE;
    if (partSize != null) {
        partBytes = partSize.getBytes();
    }

    long totalLength = metaData.length();
    long numberOfParts = totalLength / partBytes;
    if (totalLength % partBytes > 0) {
        numberOfParts++;
    }
    if (numberOfParts == 0) {
        numberOfParts++;
    }
    this.numberOfParts = numberOfParts;
    this.partSize = partSize;
    this.partBytes = partBytes;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:BlobStoreIndexShardSnapshot.java

示例2: MemoryCircuitBreaker

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
/**
 * Create a circuit breaker that will break if the number of estimated
 * bytes grows above the limit. All estimations will be multiplied by
 * the given overheadConstant. Uses the given oldBreaker to initialize
 * the starting offset.
 * @param limit circuit breaker limit
 * @param overheadConstant constant multiplier for byte estimations
 * @param oldBreaker the previous circuit breaker to inherit the used value from (starting offset)
 */
public MemoryCircuitBreaker(ByteSizeValue limit, double overheadConstant, MemoryCircuitBreaker oldBreaker, Logger logger) {
    this.memoryBytesLimit = limit.getBytes();
    this.overheadConstant = overheadConstant;
    if (oldBreaker == null) {
        this.used = new AtomicLong(0);
        this.trippedCount = new AtomicLong(0);
    } else {
        this.used = oldBreaker.used;
        this.trippedCount = oldBreaker.trippedCount;
    }
    this.logger = logger;
    if (logger.isTraceEnabled()) {
        logger.trace("Creating MemoryCircuitBreaker with a limit of {} bytes ({}) and a overhead constant of {}",
                this.memoryBytesLimit, limit, this.overheadConstant);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:MemoryCircuitBreaker.java

示例3: BulkProcessor

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
BulkProcessor(Client client, BackoffPolicy backoffPolicy, Listener listener, @Nullable String name, int concurrentRequests, int bulkActions, ByteSizeValue bulkSize, @Nullable TimeValue flushInterval) {
    this.bulkActions = bulkActions;
    this.bulkSize = bulkSize.getBytes();

    this.bulkRequest = new BulkRequest();
    this.bulkRequestHandler = (concurrentRequests == 0) ? BulkRequestHandler.syncHandler(client, backoffPolicy, listener) : BulkRequestHandler.asyncHandler(client, backoffPolicy, listener, concurrentRequests);

    if (flushInterval != null) {
        this.scheduler = (ScheduledThreadPoolExecutor) Executors.newScheduledThreadPool(1, EsExecutors.daemonThreadFactory(client.settings(), (name != null ? "[" + name + "]" : "") + "bulk_processor"));
        this.scheduler.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
        this.scheduler.setContinueExistingPeriodicTasksAfterShutdownPolicy(false);
        this.scheduledFuture = this.scheduler.scheduleWithFixedDelay(new Flush(), flushInterval.millis(), flushInterval.millis(), TimeUnit.MILLISECONDS);
    } else {
        this.scheduler = null;
        this.scheduledFuture = null;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:BulkProcessor.java

示例4: createBootstrap

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
private Bootstrap createBootstrap() {
    final Bootstrap bootstrap = new Bootstrap();
    bootstrap.group(new NioEventLoopGroup(workerCount, daemonThreadFactory(settings, TRANSPORT_CLIENT_BOSS_THREAD_NAME_PREFIX)));
    bootstrap.channel(NioSocketChannel.class);

    bootstrap.handler(getClientChannelInitializer());

    bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, Math.toIntExact(defaultConnectionProfile.getConnectTimeout().millis()));
    bootstrap.option(ChannelOption.TCP_NODELAY, TCP_NO_DELAY.get(settings));
    bootstrap.option(ChannelOption.SO_KEEPALIVE, TCP_KEEP_ALIVE.get(settings));

    final ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.get(settings);
    if (tcpSendBufferSize.getBytes() > 0) {
        bootstrap.option(ChannelOption.SO_SNDBUF, Math.toIntExact(tcpSendBufferSize.getBytes()));
    }

    final ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.get(settings);
    if (tcpReceiveBufferSize.getBytes() > 0) {
        bootstrap.option(ChannelOption.SO_RCVBUF, Math.toIntExact(tcpReceiveBufferSize.getBytes()));
    }

    bootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);

    final boolean reuseAddress = TCP_REUSE_ADDRESS.get(settings);
    bootstrap.option(ChannelOption.SO_REUSEADDR, reuseAddress);

    bootstrap.validate();

    return bootstrap;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:Netty4Transport.java

示例5: createFallbackSettings

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
private Settings createFallbackSettings() {
    Settings.Builder fallbackSettingsBuilder = Settings.builder();

    List<String> fallbackBindHost = TransportSettings.BIND_HOST.get(settings);
    if (fallbackBindHost.isEmpty() == false) {
        fallbackSettingsBuilder.putArray("bind_host", fallbackBindHost);
    }

    List<String> fallbackPublishHost = TransportSettings.PUBLISH_HOST.get(settings);
    if (fallbackPublishHost.isEmpty() == false) {
        fallbackSettingsBuilder.putArray("publish_host", fallbackPublishHost);
    }

    boolean fallbackTcpNoDelay = settings.getAsBoolean("transport.netty.tcp_no_delay", TcpSettings.TCP_NO_DELAY.get(settings));
    fallbackSettingsBuilder.put("tcp_no_delay", fallbackTcpNoDelay);

    boolean fallbackTcpKeepAlive = settings.getAsBoolean("transport.netty.tcp_keep_alive", TcpSettings.TCP_KEEP_ALIVE.get(settings));
    fallbackSettingsBuilder.put("tcp_keep_alive", fallbackTcpKeepAlive);

    boolean fallbackReuseAddress = settings.getAsBoolean("transport.netty.reuse_address", TcpSettings.TCP_REUSE_ADDRESS.get(settings));
    fallbackSettingsBuilder.put("reuse_address", fallbackReuseAddress);

    ByteSizeValue fallbackTcpSendBufferSize = settings.getAsBytesSize("transport.netty.tcp_send_buffer_size",
        TCP_SEND_BUFFER_SIZE.get(settings));
    if (fallbackTcpSendBufferSize.getBytes() >= 0) {
        fallbackSettingsBuilder.put("tcp_send_buffer_size", fallbackTcpSendBufferSize);
    }

    ByteSizeValue fallbackTcpBufferSize = settings.getAsBytesSize("transport.netty.tcp_receive_buffer_size",
        TCP_RECEIVE_BUFFER_SIZE.get(settings));
    if (fallbackTcpBufferSize.getBytes() >= 0) {
        fallbackSettingsBuilder.put("tcp_receive_buffer_size", fallbackTcpBufferSize);
    }

    return fallbackSettingsBuilder.build();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:Netty4Transport.java

示例6: configureSocket

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
private void configureSocket(Socket socket) throws SocketException {
    socket.setTcpNoDelay(TCP_NO_DELAY.get(settings));
    ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.get(settings);
    if (tcpSendBufferSize.getBytes() > 0) {
        socket.setSendBufferSize(tcpSendBufferSize.bytesAsInt());
    }
    ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.get(settings);
    if (tcpReceiveBufferSize.getBytes() > 0) {
        socket.setReceiveBufferSize(tcpReceiveBufferSize.bytesAsInt());
    }
    socket.setReuseAddress(TCP_REUSE_ADDRESS.get(settings));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:MockTcpTransport.java

示例7: setRequestBreakerLimit

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
private void setRequestBreakerLimit(ByteSizeValue newRequestMax, Double newRequestOverhead) {
    BreakerSettings newRequestSettings = new BreakerSettings(CircuitBreaker.REQUEST, newRequestMax.getBytes(), newRequestOverhead,
            HierarchyCircuitBreakerService.this.requestSettings.getType());
    registerBreaker(newRequestSettings);
    HierarchyCircuitBreakerService.this.requestSettings = newRequestSettings;
    logger.info("Updated breaker settings request: {}", newRequestSettings);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:HierarchyCircuitBreakerService.java

示例8: setInFlightRequestsBreakerLimit

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
private void setInFlightRequestsBreakerLimit(ByteSizeValue newInFlightRequestsMax, Double newInFlightRequestsOverhead) {
    BreakerSettings newInFlightRequestsSettings = new BreakerSettings(CircuitBreaker.IN_FLIGHT_REQUESTS, newInFlightRequestsMax.getBytes(),
        newInFlightRequestsOverhead, HierarchyCircuitBreakerService.this.inFlightRequestsSettings.getType());
    registerBreaker(newInFlightRequestsSettings);
    HierarchyCircuitBreakerService.this.inFlightRequestsSettings = newInFlightRequestsSettings;
    logger.info("Updated breaker settings for in-flight requests: {}", newInFlightRequestsSettings);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:HierarchyCircuitBreakerService.java

示例9: setFieldDataBreakerLimit

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
private void setFieldDataBreakerLimit(ByteSizeValue newFielddataMax, Double newFielddataOverhead) {
    long newFielddataLimitBytes = newFielddataMax == null ? HierarchyCircuitBreakerService.this.fielddataSettings.getLimit() : newFielddataMax.getBytes();
    newFielddataOverhead = newFielddataOverhead == null ? HierarchyCircuitBreakerService.this.fielddataSettings.getOverhead() : newFielddataOverhead;
    BreakerSettings newFielddataSettings = new BreakerSettings(CircuitBreaker.FIELDDATA, newFielddataLimitBytes, newFielddataOverhead,
            HierarchyCircuitBreakerService.this.fielddataSettings.getType());
    registerBreaker(newFielddataSettings);
    HierarchyCircuitBreakerService.this.fielddataSettings = newFielddataSettings;
    logger.info("Updated breaker settings field data: {}", newFielddataSettings);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:HierarchyCircuitBreakerService.java

示例10: IndicesQueryCache

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
public IndicesQueryCache(Settings settings) {
    super(settings);
    final ByteSizeValue size = INDICES_CACHE_QUERY_SIZE_SETTING.get(settings);
    final int count = INDICES_CACHE_QUERY_COUNT_SETTING.get(settings);
    logger.debug("using [node] query cache with size [{}] max filter count [{}]",
            size, count);
    if (INDICES_QUERIES_CACHE_ALL_SEGMENTS_SETTING.get(settings)) {
        cache = new ElasticsearchLRUQueryCache(count, size.getBytes(), context -> true);
    } else {
        cache = new ElasticsearchLRUQueryCache(count, size.getBytes());
    }
    sharedRamBytesUsed = 0;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:IndicesQueryCache.java

示例11: IndexingMemoryController

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
IndexingMemoryController(Settings settings, ThreadPool threadPool, Iterable<IndexShard> indexServices) {
    super(settings);
    this.indexShards = indexServices;

    ByteSizeValue indexingBuffer = INDEX_BUFFER_SIZE_SETTING.get(settings);

    String indexingBufferSetting = settings.get(INDEX_BUFFER_SIZE_SETTING.getKey());
    // null means we used the default (10%)
    if (indexingBufferSetting == null || indexingBufferSetting.endsWith("%")) {
        // We only apply the min/max when % value was used for the index buffer:
        ByteSizeValue minIndexingBuffer = MIN_INDEX_BUFFER_SIZE_SETTING.get(this.settings);
        ByteSizeValue maxIndexingBuffer = MAX_INDEX_BUFFER_SIZE_SETTING.get(this.settings);
        if (indexingBuffer.getBytes() < minIndexingBuffer.getBytes()) {
            indexingBuffer = minIndexingBuffer;
        }
        if (maxIndexingBuffer.getBytes() != -1 && indexingBuffer.getBytes() > maxIndexingBuffer.getBytes()) {
            indexingBuffer = maxIndexingBuffer;
        }
    }
    this.indexingBuffer = indexingBuffer;

    this.inactiveTime = SHARD_INACTIVE_TIME_SETTING.get(this.settings);
    // we need to have this relatively small to free up heap quickly enough
    this.interval = SHARD_MEMORY_INTERVAL_TIME_SETTING.get(this.settings);

    this.statusChecker = new ShardsIndicesStatusChecker();

    logger.debug("using indexing buffer size [{}] with {} [{}], {} [{}]",
                 this.indexingBuffer,
                 SHARD_INACTIVE_TIME_SETTING.getKey(), this.inactiveTime,
                 SHARD_MEMORY_INTERVAL_TIME_SETTING.getKey(), this.interval);
    this.scheduler = scheduleTask(threadPool);

    // Need to save this so we can later launch async "write indexing buffer to disk" on shards:
    this.threadPool = threadPool;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:37,代码来源:IndexingMemoryController.java

示例12: getRateLimiter

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
/**
 * Configures RateLimiter based on repository and global settings
 *
 * @param repositorySettings repository settings
 * @param setting            setting to use to configure rate limiter
 * @param defaultRate        default limiting rate
 * @return rate limiter or null of no throttling is needed
 */
private RateLimiter getRateLimiter(Settings repositorySettings, String setting, ByteSizeValue defaultRate) {
    ByteSizeValue maxSnapshotBytesPerSec = repositorySettings.getAsBytesSize(setting,
            settings.getAsBytesSize(setting, defaultRate));
    if (maxSnapshotBytesPerSec.getBytes() <= 0) {
        return null;
    } else {
        return new RateLimiter.SimpleRateLimiter(maxSnapshotBytesPerSec.getMbFrac());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:BlobStoreRepository.java

示例13: parseByteSize

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
public static ByteSizeValue parseByteSize(String s, ByteSizeValue minValue, ByteSizeValue maxValue, String key) {
    ByteSizeValue value = ByteSizeValue.parseBytesSizeValue(s, key);
    if (value.getBytes() < minValue.getBytes()) {
        throw new IllegalArgumentException("Failed to parse value [" + s + "] for setting [" + key + "] must be >= " + minValue);
    }
    if (value.getBytes() > maxValue.getBytes()) {
        throw new IllegalArgumentException("Failed to parse value [" + s + "] for setting [" + key + "] must be <= " + maxValue);
    }
    return value;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:Setting.java

示例14: doStart

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
@Override
protected void doStart() {
    boolean success = false;
    try {
        this.serverOpenChannels = new Netty4OpenChannelsHandler(logger);

        serverBootstrap = new ServerBootstrap();

        serverBootstrap.group(new NioEventLoopGroup(workerCount, daemonThreadFactory(settings,
            HTTP_SERVER_WORKER_THREAD_NAME_PREFIX)));
        serverBootstrap.channel(NioServerSocketChannel.class);

        serverBootstrap.childHandler(configureServerChannelHandler());

        serverBootstrap.childOption(ChannelOption.TCP_NODELAY, SETTING_HTTP_TCP_NO_DELAY.get(settings));
        serverBootstrap.childOption(ChannelOption.SO_KEEPALIVE, SETTING_HTTP_TCP_KEEP_ALIVE.get(settings));

        final ByteSizeValue tcpSendBufferSize = SETTING_HTTP_TCP_SEND_BUFFER_SIZE.get(settings);
        if (tcpSendBufferSize.getBytes() > 0) {
            serverBootstrap.childOption(ChannelOption.SO_SNDBUF, Math.toIntExact(tcpSendBufferSize.getBytes()));
        }

        final ByteSizeValue tcpReceiveBufferSize = SETTING_HTTP_TCP_RECEIVE_BUFFER_SIZE.get(settings);
        if (tcpReceiveBufferSize.getBytes() > 0) {
            serverBootstrap.childOption(ChannelOption.SO_RCVBUF, Math.toIntExact(tcpReceiveBufferSize.getBytes()));
        }

        serverBootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);
        serverBootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);

        final boolean reuseAddress = SETTING_HTTP_TCP_REUSE_ADDRESS.get(settings);
        serverBootstrap.option(ChannelOption.SO_REUSEADDR, reuseAddress);
        serverBootstrap.childOption(ChannelOption.SO_REUSEADDR, reuseAddress);

        this.boundAddress = createBoundHttpAddress();
        if (logger.isInfoEnabled()) {
            logger.info("{}", boundAddress);
        }
        success = true;
    } finally {
        if (success == false) {
            doStop(); // otherwise we leak threads since we never moved to started
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:46,代码来源:Netty4HttpServerTransport.java

示例15: createServerBootstrap

import org.elasticsearch.common.unit.ByteSizeValue; //导入方法依赖的package包/类
private void createServerBootstrap(String name, Settings settings) {
    if (logger.isDebugEnabled()) {
        logger.debug("using profile[{}], worker_count[{}], port[{}], bind_host[{}], publish_host[{}], compress[{}], "
                + "connect_timeout[{}], connections_per_node[{}/{}/{}/{}/{}], receive_predictor[{}->{}]",
            name, workerCount, settings.get("port"), settings.get("bind_host"), settings.get("publish_host"), compress,
            defaultConnectionProfile.getConnectTimeout(),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.RECOVERY),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.BULK),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.REG),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.STATE),
            defaultConnectionProfile.getNumConnectionsPerType(TransportRequestOptions.Type.PING),
            receivePredictorMin, receivePredictorMax);
    }

    final ThreadFactory workerFactory = daemonThreadFactory(this.settings, TRANSPORT_SERVER_WORKER_THREAD_NAME_PREFIX, name);

    final ServerBootstrap serverBootstrap = new ServerBootstrap();

    serverBootstrap.group(new NioEventLoopGroup(workerCount, workerFactory));
    serverBootstrap.channel(NioServerSocketChannel.class);

    serverBootstrap.childHandler(getServerChannelInitializer(name, settings));

    serverBootstrap.childOption(ChannelOption.TCP_NODELAY, TCP_NO_DELAY.get(settings));
    serverBootstrap.childOption(ChannelOption.SO_KEEPALIVE, TCP_KEEP_ALIVE.get(settings));

    final ByteSizeValue tcpSendBufferSize = TCP_SEND_BUFFER_SIZE.getDefault(settings);
    if (tcpSendBufferSize != null && tcpSendBufferSize.getBytes() > 0) {
        serverBootstrap.childOption(ChannelOption.SO_SNDBUF, Math.toIntExact(tcpSendBufferSize.getBytes()));
    }

    final ByteSizeValue tcpReceiveBufferSize = TCP_RECEIVE_BUFFER_SIZE.getDefault(settings);
    if (tcpReceiveBufferSize != null && tcpReceiveBufferSize.getBytes() > 0) {
        serverBootstrap.childOption(ChannelOption.SO_RCVBUF, Math.toIntExact(tcpReceiveBufferSize.bytesAsInt()));
    }

    serverBootstrap.option(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);
    serverBootstrap.childOption(ChannelOption.RCVBUF_ALLOCATOR, recvByteBufAllocator);

    final boolean reuseAddress = TCP_REUSE_ADDRESS.get(settings);
    serverBootstrap.option(ChannelOption.SO_REUSEADDR, reuseAddress);
    serverBootstrap.childOption(ChannelOption.SO_REUSEADDR, reuseAddress);

    serverBootstrap.validate();

    serverBootstraps.put(name, serverBootstrap);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:48,代码来源:Netty4Transport.java


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