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());
}
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());
}
}
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))));
}
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);
}
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);
}
}
}
Aggregations