Package org.elasticsearch.common.unit

Examples of org.elasticsearch.common.unit.ByteSizeValue


            stopWatch.stop();
            if (logger.isDebugEnabled()) {
                StringBuilder sb = new StringBuilder();
                sb.append('[').append(request.shardId().index().name()).append(']').append('[').append(request.shardId().id()).append("] ");
                sb.append("recovery completed from ").append(request.sourceNode()).append(", took[").append(stopWatch.totalTime()).append("]\n");
                sb.append("   phase1: recovered_files [").append(recoveryStatus.phase1FileNames.size()).append("]").append(" with total_size of [").append(new ByteSizeValue(recoveryStatus.phase1TotalSize)).append("]")
                        .append(", took [").append(timeValueMillis(recoveryStatus.phase1Time)).append("], throttling_wait [").append(timeValueMillis(recoveryStatus.phase1ThrottlingWaitTime)).append(']')
                        .append("\n");
                sb.append("         : reusing_files   [").append(recoveryStatus.phase1ExistingFileNames.size()).append("] with total_size of [").append(new ByteSizeValue(recoveryStatus.phase1ExistingTotalSize)).append("]\n");
                sb.append("   phase2: recovered [").append(recoveryStatus.phase2Operations).append("]").append(" transaction log operations")
                        .append(", took [").append(timeValueMillis(recoveryStatus.phase2Time)).append("]")
                        .append("\n");
                sb.append("   phase3: recovered [").append(recoveryStatus.phase3Operations).append("]").append(" transaction log operations")
                        .append(", took [").append(timeValueMillis(recoveryStatus.phase3Time)).append("]");
View Full Code Here


        this.indicesService = indicesService;

        int concurrentStreams = componentSettings.getAsInt("concurrent_streams", 5);
        this.concurrentStreamPool = DynamicExecutors.newScalingThreadPool(1, concurrentStreams, TimeValue.timeValueSeconds(5).millis(), EsExecutors.daemonThreadFactory(settings, "[recovery_stream]"));

        this.fileChunkSize = componentSettings.getAsBytesSize("file_chunk_size", new ByteSizeValue(100, ByteSizeUnit.KB));
        this.translogOps = componentSettings.getAsInt("translog_ops", 1000);
        this.translogSize = componentSettings.getAsBytesSize("translog_size", new ByteSizeValue(100, ByteSizeUnit.KB));
        this.compress = componentSettings.getAsBoolean("compress", true);

        logger.debug("using concurrent_streams [{}], file_chunk_size [{}], translog_size [{}], translog_ops [{}], and compress [{}]",
                concurrentStreams, fileChunkSize, translogSize, translogOps, compress);
View Full Code Here

                        totalSize += md.length();
                    }
                    response.phase1TotalSize = totalSize;
                    response.phase1ExistingTotalSize = existingTotalSize;

                    logger.trace("[{}][{}] recovery [phase1] to {}: recovering_files [{}] with total_size [{}], reusing_files [{}] with total_size [{}]", request.shardId().index().name(), request.shardId().id(), request.targetNode(), response.phase1FileNames.size(), new ByteSizeValue(totalSize), response.phase1ExistingFileNames.size(), new ByteSizeValue(existingTotalSize));

                    RecoveryFilesInfoRequest recoveryInfoFilesRequest = new RecoveryFilesInfoRequest(request.shardId(), response.phase1FileNames, response.phase1FileSizes,
                            response.phase1ExistingFileNames, response.phase1ExistingFileSizes, response.phase1TotalSize, response.phase1ExistingTotalSize);
                    transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.FILES_INFO, recoveryInfoFilesRequest, VoidTransportResponseHandler.INSTANCE_SAME).txGet();

                    final CountDownLatch latch = new CountDownLatch(response.phase1FileNames.size());
                    final AtomicReference<Exception> lastException = new AtomicReference<Exception>();
                    for (final String name : response.phase1FileNames) {
                        concurrentStreamPool.execute(new Runnable() {
                            @Override public void run() {
                                IndexInput indexInput = null;
                                try {
                                    final int BUFFER_SIZE = (int) fileChunkSize.bytes();
                                    byte[] buf = new byte[BUFFER_SIZE];
                                    StoreFileMetaData md = shard.store().metaData(name);
                                    indexInput = snapshot.getDirectory().openInput(name);
                                    long len = indexInput.length();
                                    long readCount = 0;
                                    while (readCount < len) {
                                        if (shard.state() == IndexShardState.CLOSED) { // check if the shard got closed on us
                                            throw new IndexShardClosedException(shard.shardId());
                                        }
                                        int toRead = readCount + BUFFER_SIZE > len ? (int) (len - readCount) : BUFFER_SIZE;
                                        long position = indexInput.getFilePointer();
                                        indexInput.readBytes(buf, 0, toRead, false);
                                        transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.FILE_CHUNK, new RecoveryFileChunkRequest(request.shardId(), name, position, len, md.checksum(), buf, toRead),
                                                TransportRequestOptions.options().withCompress(compress).withLowType(), VoidTransportResponseHandler.INSTANCE_SAME).txGet();
                                        readCount += toRead;
                                    }
                                    indexInput.close();
                                } catch (Exception e) {
                                    lastException.set(e);
                                } finally {
                                    if (indexInput != null) {
                                        try {
                                            indexInput.close();
                                        } catch (IOException e) {
                                            // ignore
                                        }
                                    }
                                    latch.countDown();
                                }
                            }
                        });
                    }

                    latch.await();

                    if (lastException.get() != null) {
                        throw lastException.get();
                    }

                    // now, set the clean files request
                    Set<String> snapshotFiles = Sets.newHashSet(snapshot.getFiles());
                    transportService.submitRequest(request.targetNode(), RecoveryTarget.Actions.CLEAN_FILES, new RecoveryCleanFilesRequest(shard.shardId(), snapshotFiles), VoidTransportResponseHandler.INSTANCE_SAME).txGet();

                    stopWatch.stop();
                    logger.trace("[{}][{}] recovery [phase1] to {}: took [{}]", request.shardId().index().name(), request.shardId().id(), request.targetNode(), stopWatch.totalTime());
                    response.phase1Time = stopWatch.totalTime().millis();
                } catch (Throwable e) {
                    throw new RecoverFilesRecoveryException(request.shardId(), response.phase1FileNames.size(), new ByteSizeValue(totalSize), e);
                }
            }

            @Override public void phase2(Translog.Snapshot snapshot) throws ElasticSearchException {
                if (shard.state() == IndexShardState.CLOSED) {
View Full Code Here

    public TimeValue getTime() {
        return time();
    }

    public ByteSizeValue indexSize() {
        return new ByteSizeValue(indexSize);
    }
View Full Code Here

    public TimeValue getTime() {
        return time();
    }

    public ByteSizeValue indexSize() {
        return new ByteSizeValue(indexSize);
    }
View Full Code Here

    public ByteSizeValue getIndexSize() {
        return indexSize();
    }

    public ByteSizeValue reusedIndexSize() {
        return new ByteSizeValue(reusedIndexSize);
    }
View Full Code Here

    public ByteSizeValue getReusedIndexSize() {
        return reusedIndexSize();
    }

    public ByteSizeValue expectedRecoveredIndexSize() {
        return new ByteSizeValue(indexSize - reusedIndexSize);
    }
View Full Code Here

    /**
     * How much of the index has been recovered.
     */
    public ByteSizeValue recoveredIndexSize() {
        return new ByteSizeValue(recoveredIndexSize);
    }
View Full Code Here

    public ThriftServer(Settings settings, NetworkService networkService, NodeService nodeService, ThriftRestImpl client) {
        super(settings);
        this.client = client;
        this.networkService = networkService;
        this.nodeService = nodeService;
        this.frame = (int) componentSettings.getAsBytesSize("frame", new ByteSizeValue(-1)).bytes();
        this.port = componentSettings.get("port", "9500-9600");
        this.bindHost = componentSettings.get("bind_host", settings.get("transport.bind_host", settings.get("transport.host")));
        this.publishHost = componentSettings.get("publish_host", settings.get("transport.publish_host", settings.get("transport.host")));

        if (componentSettings.get("protocol", "binary").equals("compact")) {
View Full Code Here

        settings.get("http.bind_host", settings.get("http.host")));
    publishHost = componentSettings.get("publish_host",
        settings.get("http.publish_host", settings.get("http.host")));
    this.networkService = networkService;

    ByteSizeValue maxContentLength = componentSettings.getAsBytesSize(
        "max_content_length", settings.getAsBytesSize(
            "http.max_content_length", new ByteSizeValue(100,
                ByteSizeUnit.MB)));
    maxChunkSize = componentSettings.getAsBytesSize(
        "max_chunk_size", settings.getAsBytesSize(
            "http.max_chunk_size", new ByteSizeValue(8,
                ByteSizeUnit.KB)));
    maxHeaderSize = componentSettings.getAsBytesSize(
        "max_header_size", settings.getAsBytesSize(
            "http.max_header_size", new ByteSizeValue(8,
                ByteSizeUnit.KB)));

    blockingServer = settings.getAsBoolean(
        "http.blocking_server",
        settings.getAsBoolean(TCP_BLOCKING_SERVER,
            settings.getAsBoolean(TCP_BLOCKING, false)));

    tcpNoDelay = componentSettings.getAsBoolean("tcp_no_delay",
        settings.getAsBoolean(TCP_NO_DELAY, true));
    tcpKeepAlive = componentSettings.getAsBoolean(
        "tcp_keep_alive", settings.getAsBoolean(TCP_KEEP_ALIVE, true));
    reuseAddress = componentSettings.getAsBoolean(
        "reuse_address",
        settings.getAsBoolean(TCP_REUSE_ADDRESS,
            NetworkUtils.defaultReuseAddress()));
    tcpSendBufferSize = componentSettings.getAsBytesSize(
        "tcp_send_buffer_size", settings.getAsBytesSize(
            TCP_SEND_BUFFER_SIZE, TCP_DEFAULT_SEND_BUFFER_SIZE));
    tcpReceiveBufferSize = componentSettings.getAsBytesSize(
        "tcp_receive_buffer_size", settings.getAsBytesSize(
            TCP_RECEIVE_BUFFER_SIZE,
            TCP_DEFAULT_RECEIVE_BUFFER_SIZE));

    compression = settings.getAsBoolean("http.compression", false);
    compressionLevel = settings.getAsInt("http.compression_level", 6);

    // validate max content length
    if (maxContentLength.bytes() > Integer.MAX_VALUE) {
      logger.warn("maxContentLength[" + maxContentLength
          + "] set to high value, resetting it to [100mb]");
      maxContentLength = new ByteSizeValue(100, ByteSizeUnit.MB);
    }
    this.maxContentLength = maxContentLength;

    logger.debug("port: " + port);
    logger.debug("bindHost: " + bindHost);
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.unit.ByteSizeValue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.