MCPcopy Create free account
hub / github.com/questdb/questdb / getDBSizeClass

Method getDBSizeClass

core/src/main/java/io/questdb/Telemetry.java:299–332  ·  view source on GitHub ↗
(CairoConfiguration configuration)

Source from the content-addressed store, hash-verified

297 }
298
299 private short getDBSizeClass(CairoConfiguration configuration) {
300 dbSizeEstimateStartTimestamp = clock.getTicks();
301
302 final long dbSize;
303 try {
304 final Path path = Path.PATH.get().of(configuration.getDbRoot());
305 dbSize = getDirSize(configuration.getFilesFacade(), path, true, Misc.getThreadLocalSink());
306 if (hasTimedOut()) {
307 LOG.info().$("Unable to estimate DB size, disk scanning timed out").$();
308 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_UNKNOWN;
309 }
310 } catch (Throwable e) {
311 LOG.info().$("Unable to estimate DB size, error=").$(e).$();
312 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_UNKNOWN;
313 }
314
315 if (dbSize <= 10 * Numbers.SIZE_1GB) { // 0 - <10GB
316 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_BASE;
317 } else if (dbSize <= 50 * Numbers.SIZE_1GB) { // 1 - (10GB,50GB]
318 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_BASE - 1;
319 } else if (dbSize <= 100 * Numbers.SIZE_1GB) { // 2 - (50GB,100GB]
320 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_BASE - 2;
321 } else if (dbSize <= 500 * Numbers.SIZE_1GB) { // 3 - (100GB,500GB]
322 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_BASE - 3;
323 } else if (dbSize <= Numbers.SIZE_1TB) { // 4 - (500GB,1TB]
324 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_BASE - 4;
325 } else if (dbSize <= 5 * Numbers.SIZE_1TB) { // 5 - (1TB,5TB]
326 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_BASE - 5;
327 } else if (dbSize <= 10 * Numbers.SIZE_1TB) { // 6 - (5TB,10TB]
328 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_BASE - 6;
329 }
330 // 7 - >10TB
331 return TelemetryEvent.SYSTEM_DB_SIZE_CLASS_BASE - 7;
332 }
333
334 private long getDirSize(FilesFacade ff, Path path, boolean topLevel, StringSink sink) {
335 long totalSize = 0L;

Callers 1

initMethod · 0.95

Calls 10

getDirSizeMethod · 0.95
getThreadLocalSinkMethod · 0.95
hasTimedOutMethod · 0.95
getTicksMethod · 0.65
ofMethod · 0.65
getMethod · 0.65
getDbRootMethod · 0.65
getFilesFacadeMethod · 0.65
$Method · 0.65
infoMethod · 0.65

Tested by

no test coverage detected