Search in sources :

Example 51 with ByteSizeValue

use of org.elasticsearch.common.unit.ByteSizeValue in project crate by crate.

the class AzureRepositorySettingsTests method testChunkSize.

public void testChunkSize() {
    // default chunk size
    AzureRepository azureRepository = azureRepository(Settings.EMPTY);
    assertEquals(AzureStorageService.MAX_CHUNK_SIZE, azureRepository.chunkSize());
    // chunk size in settings
    int size = randomIntBetween(1, 256);
    azureRepository = azureRepository(Settings.builder().put("chunk_size", size + "mb").build());
    assertEquals(new ByteSizeValue(size, ByteSizeUnit.MB), azureRepository.chunkSize());
    // zero bytes is not allowed
    IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> azureRepository(Settings.builder().put("chunk_size", "0").build()));
    assertEquals("failed to parse value [0] for setting [chunk_size], must be >= [1b]", e.getMessage());
    // negative bytes not allowed
    e = expectThrows(IllegalArgumentException.class, () -> azureRepository(Settings.builder().put("chunk_size", "-1").build()));
    assertEquals("failed to parse value [-1] for setting [chunk_size], must be >= [1b]", e.getMessage());
    // greater than max chunk size not allowed
    e = expectThrows(IllegalArgumentException.class, () -> azureRepository(Settings.builder().put("chunk_size", "257mb").build()));
    assertEquals("failed to parse value [257mb] for setting [chunk_size], must be <= [256mb]", e.getMessage());
}
Also used : ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue)

Example 52 with ByteSizeValue

use of org.elasticsearch.common.unit.ByteSizeValue in project crate by crate.

the class IndexShard method onSettingsChanged.

public void onSettingsChanged() {
    Engine engineOrNull = getEngineOrNull();
    if (engineOrNull != null) {
        final boolean disableTranslogRetention = indexSettings.isSoftDeleteEnabled() && useRetentionLeasesInPeerRecovery;
        engineOrNull.onSettingsChanged(disableTranslogRetention ? TimeValue.MINUS_ONE : indexSettings.getTranslogRetentionAge(), disableTranslogRetention ? new ByteSizeValue(-1) : indexSettings.getTranslogRetentionSize(), indexSettings.getSoftDeleteRetentionOperations());
    }
}
Also used : ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) ReadOnlyEngine(org.elasticsearch.index.engine.ReadOnlyEngine) Engine(org.elasticsearch.index.engine.Engine)

Example 53 with ByteSizeValue

use of org.elasticsearch.common.unit.ByteSizeValue in project crate by crate.

the class CrateCircuitBreakerServiceTest method testBreakingExceptionMessage.

@Test
public void testBreakingExceptionMessage() throws Exception {
    String message = HierarchyCircuitBreakerService.breakingExceptionMessage("dummy", 1234);
    assertThat(message, is(String.format(Locale.ENGLISH, HierarchyCircuitBreakerService.BREAKING_EXCEPTION_MESSAGE, "dummy", 1234, new ByteSizeValue(1234))));
}
Also used : ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) Test(org.junit.Test)

Example 54 with ByteSizeValue

use of org.elasticsearch.common.unit.ByteSizeValue in project crate by crate.

the class RowAccountingWithEstimatorsTest method testCircuitBreakingWorks.

@Test
public void testCircuitBreakingWorks() throws Exception {
    RowAccountingWithEstimators rowAccounting = new RowAccountingWithEstimators(Collections.singletonList(DataTypes.INTEGER), ConcurrentRamAccounting.forCircuitBreaker("test", new MemoryCircuitBreaker(new ByteSizeValue(10, ByteSizeUnit.BYTES), 1.01, LogManager.getLogger(RowAccountingWithEstimatorsTest.class))));
    expectedException.expect(CircuitBreakingException.class);
    RowGenerator.range(0, 3).forEach(rowAccounting::accountForAndMaybeBreak);
}
Also used : MemoryCircuitBreaker(org.elasticsearch.common.breaker.MemoryCircuitBreaker) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue) Test(org.junit.Test)

Example 55 with ByteSizeValue

use of org.elasticsearch.common.unit.ByteSizeValue in project crate by crate.

the class ElasticsearchConcurrentMergeScheduler method doMerge.

@Override
protected void doMerge(MergeSource mergeSource, MergePolicy.OneMerge merge) throws IOException {
    int totalNumDocs = merge.totalNumDocs();
    long totalSizeInBytes = merge.totalBytesSize();
    long timeNS = System.nanoTime();
    OnGoingMerge onGoingMerge = new OnGoingMerge(merge);
    onGoingMerges.add(onGoingMerge);
    if (logger.isTraceEnabled()) {
        logger.trace("merge [{}] starting..., merging [{}] segments, [{}] docs, [{}] size, into [{}] estimated_size", OneMergeHelper.getSegmentName(merge), merge.segments.size(), totalNumDocs, new ByteSizeValue(totalSizeInBytes), new ByteSizeValue(merge.estimatedMergeBytes));
    }
    try {
        beforeMerge(onGoingMerge);
        super.doMerge(mergeSource, merge);
    } finally {
        long tookMS = TimeValue.nsecToMSec(System.nanoTime() - timeNS);
        onGoingMerges.remove(onGoingMerge);
        afterMerge(onGoingMerge);
        long stoppedMS = TimeValue.nsecToMSec(merge.getMergeProgress().getPauseTimes().get(MergePolicy.OneMergeProgress.PauseReason.STOPPED));
        long throttledMS = TimeValue.nsecToMSec(merge.getMergeProgress().getPauseTimes().get(MergePolicy.OneMergeProgress.PauseReason.PAUSED));
        final Thread thread = Thread.currentThread();
        long totalBytesWritten = OneMergeHelper.getTotalBytesWritten(thread, merge);
        double mbPerSec = OneMergeHelper.getMbPerSec(thread, merge);
        String message = String.format(Locale.ROOT, "merge segment [%s] done: took [%s], [%,.1f MB], [%,d docs], [%s stopped], [%s throttled], [%,.1f MB written], [%,.1f MB/sec throttle]", OneMergeHelper.getSegmentName(merge), TimeValue.timeValueMillis(tookMS), totalSizeInBytes / 1024f / 1024f, totalNumDocs, TimeValue.timeValueMillis(stoppedMS), TimeValue.timeValueMillis(throttledMS), totalBytesWritten / 1024f / 1024f, mbPerSec);
        if (tookMS > 20000) {
            // if more than 20 seconds, DEBUG log it
            logger.debug("{}", message);
        } else if (logger.isTraceEnabled()) {
            logger.trace("{}", message);
        }
    }
}
Also used : OnGoingMerge(org.elasticsearch.index.merge.OnGoingMerge) ByteSizeValue(org.elasticsearch.common.unit.ByteSizeValue)

Aggregations

ByteSizeValue (org.elasticsearch.common.unit.ByteSizeValue)145 Settings (org.elasticsearch.common.settings.Settings)23 Test (org.junit.Test)21 IOException (java.io.IOException)16 CountDownLatch (java.util.concurrent.CountDownLatch)13 ArrayList (java.util.ArrayList)11 TimeValue (org.elasticsearch.common.unit.TimeValue)11 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)9 Matchers.containsString (org.hamcrest.Matchers.containsString)9 List (java.util.List)8 AtomicReference (java.util.concurrent.atomic.AtomicReference)8 Path (java.nio.file.Path)7 Translog (org.elasticsearch.index.translog.Translog)7 Arrays (java.util.Arrays)6 Collections (java.util.Collections)6 Collectors (java.util.stream.Collectors)6 BulkProcessor (org.elasticsearch.action.bulk.BulkProcessor)6 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)6 BytesArray (org.elasticsearch.common.bytes.BytesArray)6 Matchers.equalTo (org.hamcrest.Matchers.equalTo)6