From b8b09fb1d07ec5ec626a62383b4811fbbf8568be Mon Sep 17 00:00:00 2001 From: Paul Horn Date: Thu, 5 Sep 2024 17:49:09 +0200 Subject: [PATCH] Remove old way of instantiating record PBI --- .../gds/compat/_522/BatchImporterCompat.java | 173 +----------------- .../neo4j/gds/compat/_522/Neo4jProxyImpl.java | 46 +---- .../gds/compat/_523/BatchImporterCompat.java | 173 +----------------- .../neo4j/gds/compat/_523/Neo4jProxyImpl.java | 46 +---- .../gds/compat/_524/BatchImporterCompat.java | 173 +----------------- .../neo4j/gds/compat/_524/Neo4jProxyImpl.java | 46 +---- .../org/neo4j/gds/compat/Neo4jProxyApi.java | 28 +-- .../compat/batchimport/ExecutionMonitor.java | 65 ------- .../neo4j/gds/compat/batchimport/Monitor.java | 15 -- .../java/org/neo4j/gds/compat/Neo4jProxy.java | 54 ++---- .../core/io/db/GdsParallelBatchImporter.java | 10 +- .../io/db/GraphStoreToDatabaseExporter.java | 6 +- .../db/ProgressTrackerExecutionMonitor.java | 91 +-------- 13 files changed, 36 insertions(+), 890 deletions(-) delete mode 100644 compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/batchimport/ExecutionMonitor.java diff --git a/compatibility/5.22/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_522/BatchImporterCompat.java b/compatibility/5.22/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_522/BatchImporterCompat.java index 7b147045f3..f0fdf96a21 100644 --- a/compatibility/5.22/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_522/BatchImporterCompat.java +++ b/compatibility/5.22/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_522/BatchImporterCompat.java @@ -19,10 +19,8 @@ */ package org.neo4j.gds.compat._522; -import org.neo4j.common.DependencyResolver; import org.neo4j.configuration.Config; import org.neo4j.gds.compat.batchimport.BatchImporter; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.ImportConfig; import org.neo4j.gds.compat.batchimport.InputIterable; import org.neo4j.gds.compat.batchimport.InputIterator; @@ -36,18 +34,14 @@ import org.neo4j.gds.compat.batchimport.input.InputEntityVisitor; import org.neo4j.gds.compat.batchimport.input.ReadableGroups; import org.neo4j.internal.batchimport.AdditionalInitialIds; -import org.neo4j.internal.batchimport.BatchImporterFactory; import org.neo4j.internal.batchimport.IndexConfig; import org.neo4j.internal.batchimport.input.Collectors; import org.neo4j.internal.batchimport.input.Groups; -import org.neo4j.internal.batchimport.staging.CoarseBoundedProgressExecutionMonitor; -import org.neo4j.internal.batchimport.staging.StageExecution; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.layout.DatabaseLayout; import org.neo4j.io.pagecache.context.CursorContextFactory; import org.neo4j.io.pagecache.tracing.PageCacheTracer; import org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl; -import org.neo4j.kernel.impl.transaction.log.EmptyLogTailMetadata; import org.neo4j.kernel.impl.transaction.log.files.TransactionLogInitializer; import org.neo4j.logging.internal.LogService; import org.neo4j.memory.EmptyMemoryTracker; @@ -58,13 +52,12 @@ import java.io.OutputStream; import java.io.PrintStream; import java.nio.charset.StandardCharsets; -import java.util.function.LongConsumer; public final class BatchImporterCompat { private BatchImporterCompat() {} - static BatchImporter instantiateBlockBatchImporter( + static BatchImporter instantiateBatchImporter( DatabaseLayout dbLayout, FileSystemAbstraction fileSystem, ImportConfig config, @@ -104,40 +97,6 @@ private static final class MonitorAdapter implements org.neo4j.internal.batchimp private MonitorAdapter(Monitor delegate) {this.delegate = delegate;} - @Override - public void doubleRelationshipRecordUnitsEnabled() { - delegate.doubleRelationshipRecordUnitsEnabled(); - } - - @Override - public void mayExceedNodeIdCapacity(long capacity, long estimatedCount) { - delegate.mayExceedNodeIdCapacity(capacity, estimatedCount); - } - - @Override - public void mayExceedRelationshipIdCapacity(long capacity, long estimatedCount) { - delegate.mayExceedRelationshipIdCapacity(capacity, estimatedCount); - } - - @Override - public void insufficientHeapSize(long optimalMinimalHeapSize, long heapSize) { - delegate.insufficientHeapSize(optimalMinimalHeapSize, heapSize); - } - - @Override - public void abundantHeapSize(long optimalMinimalHeapSize, long heapSize) { - delegate.abundantHeapSize(optimalMinimalHeapSize, heapSize); - } - - @Override - public void insufficientAvailableMemory( - long estimatedCacheSize, - long optimalMinimalHeapSize, - long availableMemory - ) { - delegate.insufficientAvailableMemory(estimatedCacheSize, optimalMinimalHeapSize, availableMemory); - } - @Override public void started() { delegate.started(); @@ -154,38 +113,6 @@ public void completed(boolean success) { } } - static BatchImporter instantiateRecordBatchImporter( - DatabaseLayout directoryStructure, - FileSystemAbstraction fileSystem, - ImportConfig config, - ExecutionMonitor executionMonitor, - LogService logService, - Config dbConfig, - JobScheduler jobScheduler, - Collector badCollector - ) { - var importer = BatchImporterFactory.withHighestPriority() - .instantiate( - directoryStructure, - fileSystem, - PageCacheTracer.NULL, - new ConfigurationAdapter(config), - logService, - new ExecutionMonitorAdapter(executionMonitor), - AdditionalInitialIds.EMPTY, - new EmptyLogTailMetadata(dbConfig), - dbConfig, - org.neo4j.internal.batchimport.Monitor.NO_MONITOR, - jobScheduler, - badCollector != null ? ((CollectorAdapter) badCollector).delegate : null, - TransactionLogInitializer.getLogFilesInitializer(), - new IndexImporterFactoryImpl(), - EmptyMemoryTracker.INSTANCE, - CursorContextFactory.NULL_CONTEXT_FACTORY - ); - return new BatchImporterReverseAdapter(importer); - } - static final class ConfigurationAdapter implements org.neo4j.internal.batchimport.Configuration { private final ImportConfig inner; @@ -221,104 +148,6 @@ public IndexConfig indexConfig() { } } - static ExecutionMonitor newCoarseBoundedProgressExecutionMonitor( - long highNodeId, - long highRelationshipId, - int batchSize, - LongConsumer progress, - LongConsumer outNumberOfBatches - ) { - var delegate = new CoarseBoundedProgressExecutionMonitor( - highNodeId, - highRelationshipId, - org.neo4j.internal.batchimport.Configuration.withBatchSize( - org.neo4j.internal.batchimport.Configuration.DEFAULT, - batchSize - ) - ) { - @Override - protected void progress(long l) { - progress.accept(l); - } - - long numberOfBatches() { - return this.total(); - } - }; - // Note: this only works because we declare the delegate with `var` - outNumberOfBatches.accept(delegate.numberOfBatches()); - - return new ExecutionMonitor() { - - @Override - public Monitor toMonitor() { - throw new UnsupportedOperationException("Cannot call `toMonitor` on this one"); - } - - @Override - public void start(StageExecution execution) { - delegate.start(execution); - } - - @Override - public void end(StageExecution execution, long totalTimeMillis) { - delegate.end(execution, totalTimeMillis); - } - - @Override - public void done(boolean successful, long totalTimeMillis, String additionalInformation) { - delegate.done(successful, totalTimeMillis, additionalInformation); - } - - @Override - public long checkIntervalMillis() { - return delegate.checkIntervalMillis(); - } - - @Override - public void check(StageExecution execution) { - delegate.check(execution); - } - }; - } - - static final class ExecutionMonitorAdapter implements org.neo4j.internal.batchimport.staging.ExecutionMonitor { - private final ExecutionMonitor delegate; - - ExecutionMonitorAdapter(ExecutionMonitor delegate) {this.delegate = delegate;} - - @Override - public void initialize(DependencyResolver dependencyResolver) { - org.neo4j.internal.batchimport.staging.ExecutionMonitor.super.initialize(dependencyResolver); - this.delegate.initialize(dependencyResolver); - } - - @Override - public void start(StageExecution stageExecution) { - this.delegate.start(stageExecution); - } - - @Override - public void end(StageExecution stageExecution, long l) { - this.delegate.end(stageExecution, l); - } - - @Override - public void done(boolean b, long l, String s) { - this.delegate.done(b, l, s); - } - - @Override - public long checkIntervalMillis() { - return this.delegate.checkIntervalMillis(); - } - - @Override - public void check(StageExecution stageExecution) { - this.delegate.check(stageExecution); - } - } - static final class BatchImporterReverseAdapter implements BatchImporter { private final org.neo4j.internal.batchimport.BatchImporter delegate; diff --git a/compatibility/5.22/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_522/Neo4jProxyImpl.java b/compatibility/5.22/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_522/Neo4jProxyImpl.java index 31a3f111d3..9fc626d750 100644 --- a/compatibility/5.22/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_522/Neo4jProxyImpl.java +++ b/compatibility/5.22/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_522/Neo4jProxyImpl.java @@ -27,7 +27,6 @@ import org.neo4j.gds.compat.CompatCallableProcedure; import org.neo4j.gds.compat.Neo4jProxyApi; import org.neo4j.gds.compat.batchimport.BatchImporter; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.ImportConfig; import org.neo4j.gds.compat.batchimport.Monitor; import org.neo4j.gds.compat.batchimport.input.Collector; @@ -48,14 +47,13 @@ import org.neo4j.values.SequenceValue; import java.io.OutputStream; -import java.util.function.LongConsumer; import static org.neo4j.internal.helpers.collection.Iterators.asRawIterator; public final class Neo4jProxyImpl implements Neo4jProxyApi { @Override - public BatchImporter instantiateBlockBatchImporter( + public BatchImporter instantiateBatchImporter( DatabaseLayout dbLayout, FileSystemAbstraction fileSystem, ImportConfig config, @@ -65,7 +63,7 @@ public BatchImporter instantiateBlockBatchImporter( JobScheduler jobScheduler, Collector badCollector ) { - return BatchImporterCompat.instantiateBlockBatchImporter( + return BatchImporterCompat.instantiateBatchImporter( dbLayout, fileSystem, config, @@ -77,46 +75,6 @@ public BatchImporter instantiateBlockBatchImporter( ); } - @Override - public BatchImporter instantiateRecordBatchImporter( - DatabaseLayout directoryStructure, - FileSystemAbstraction fileSystem, - ImportConfig config, - ExecutionMonitor executionMonitor, - LogService logService, - Config dbConfig, - JobScheduler jobScheduler, - Collector badCollector - ) { - return BatchImporterCompat.instantiateRecordBatchImporter( - directoryStructure, - fileSystem, - config, - executionMonitor, - logService, - dbConfig, - jobScheduler, - badCollector - ); - } - - @Override - public ExecutionMonitor newCoarseBoundedProgressExecutionMonitor( - long highNodeId, - long highRelationshipId, - int batchSize, - LongConsumer progress, - LongConsumer outNumberOfBatches - ) { - return BatchImporterCompat.newCoarseBoundedProgressExecutionMonitor( - highNodeId, - highRelationshipId, - batchSize, - progress, - outNumberOfBatches - ); - } - @Override public ReadableGroups newGroups() { return BatchImporterCompat.newGroups(); diff --git a/compatibility/5.23/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_523/BatchImporterCompat.java b/compatibility/5.23/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_523/BatchImporterCompat.java index f41ebe01e9..71c26553bd 100644 --- a/compatibility/5.23/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_523/BatchImporterCompat.java +++ b/compatibility/5.23/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_523/BatchImporterCompat.java @@ -20,10 +20,8 @@ package org.neo4j.gds.compat._523; import org.neo4j.batchimport.api.IndexConfig; -import org.neo4j.common.DependencyResolver; import org.neo4j.configuration.Config; import org.neo4j.gds.compat.batchimport.BatchImporter; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.ImportConfig; import org.neo4j.gds.compat.batchimport.InputIterable; import org.neo4j.gds.compat.batchimport.InputIterator; @@ -36,18 +34,14 @@ import org.neo4j.gds.compat.batchimport.input.InputChunk; import org.neo4j.gds.compat.batchimport.input.InputEntityVisitor; import org.neo4j.gds.compat.batchimport.input.ReadableGroups; -import org.neo4j.internal.batchimport.BatchImporterFactory; import org.neo4j.internal.batchimport.DefaultAdditionalIds; import org.neo4j.internal.batchimport.input.Collectors; import org.neo4j.internal.batchimport.input.Groups; -import org.neo4j.internal.batchimport.staging.CoarseBoundedProgressExecutionMonitor; -import org.neo4j.internal.batchimport.staging.StageExecution; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.layout.DatabaseLayout; import org.neo4j.io.pagecache.context.CursorContextFactory; import org.neo4j.io.pagecache.tracing.PageCacheTracer; import org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl; -import org.neo4j.kernel.impl.transaction.log.EmptyLogTailMetadata; import org.neo4j.kernel.impl.transaction.log.files.TransactionLogInitializer; import org.neo4j.logging.internal.LogService; import org.neo4j.memory.EmptyMemoryTracker; @@ -58,13 +52,12 @@ import java.io.OutputStream; import java.io.PrintStream; import java.nio.charset.StandardCharsets; -import java.util.function.LongConsumer; public final class BatchImporterCompat { private BatchImporterCompat() {} - static BatchImporter instantiateBlockBatchImporter( + static BatchImporter instantiateBatchImporter( DatabaseLayout dbLayout, FileSystemAbstraction fileSystem, ImportConfig config, @@ -104,40 +97,6 @@ private static final class MonitorAdapter implements org.neo4j.batchimport.api.M private MonitorAdapter(Monitor delegate) {this.delegate = delegate;} - @Override - public void doubleRelationshipRecordUnitsEnabled() { - delegate.doubleRelationshipRecordUnitsEnabled(); - } - - @Override - public void mayExceedNodeIdCapacity(long capacity, long estimatedCount) { - delegate.mayExceedNodeIdCapacity(capacity, estimatedCount); - } - - @Override - public void mayExceedRelationshipIdCapacity(long capacity, long estimatedCount) { - delegate.mayExceedRelationshipIdCapacity(capacity, estimatedCount); - } - - @Override - public void insufficientHeapSize(long optimalMinimalHeapSize, long heapSize) { - delegate.insufficientHeapSize(optimalMinimalHeapSize, heapSize); - } - - @Override - public void abundantHeapSize(long optimalMinimalHeapSize, long heapSize) { - delegate.abundantHeapSize(optimalMinimalHeapSize, heapSize); - } - - @Override - public void insufficientAvailableMemory( - long estimatedCacheSize, - long optimalMinimalHeapSize, - long availableMemory - ) { - delegate.insufficientAvailableMemory(estimatedCacheSize, optimalMinimalHeapSize, availableMemory); - } - @Override public void started() { delegate.started(); @@ -154,38 +113,6 @@ public void completed(boolean success) { } } - static BatchImporter instantiateRecordBatchImporter( - DatabaseLayout directoryStructure, - FileSystemAbstraction fileSystem, - ImportConfig config, - ExecutionMonitor executionMonitor, - LogService logService, - Config dbConfig, - JobScheduler jobScheduler, - Collector badCollector - ) { - var importer = BatchImporterFactory.withHighestPriority() - .instantiate( - directoryStructure, - fileSystem, - PageCacheTracer.NULL, - new ConfigurationAdapter(config), - logService, - new ExecutionMonitorAdapter(executionMonitor), - DefaultAdditionalIds.EMPTY, - new EmptyLogTailMetadata(dbConfig), - dbConfig, - org.neo4j.batchimport.api.Monitor.NO_MONITOR, - jobScheduler, - badCollector != null ? ((CollectorAdapter) badCollector).delegate : null, - TransactionLogInitializer.getLogFilesInitializer(), - new IndexImporterFactoryImpl(), - EmptyMemoryTracker.INSTANCE, - CursorContextFactory.NULL_CONTEXT_FACTORY - ); - return new BatchImporterReverseAdapter(importer); - } - static final class ConfigurationAdapter implements org.neo4j.batchimport.api.Configuration { private final ImportConfig inner; @@ -221,104 +148,6 @@ public IndexConfig indexConfig() { } } - static ExecutionMonitor newCoarseBoundedProgressExecutionMonitor( - long highNodeId, - long highRelationshipId, - int batchSize, - LongConsumer progress, - LongConsumer outNumberOfBatches - ) { - var delegate = new CoarseBoundedProgressExecutionMonitor( - highNodeId, - highRelationshipId, - org.neo4j.batchimport.api.Configuration.withBatchSize( - org.neo4j.batchimport.api.Configuration.DEFAULT, - batchSize - ) - ) { - @Override - protected void progress(long l) { - progress.accept(l); - } - - long numberOfBatches() { - return this.total(); - } - }; - // Note: this only works because we declare the delegate with `var` - outNumberOfBatches.accept(delegate.numberOfBatches()); - - return new ExecutionMonitor() { - - @Override - public Monitor toMonitor() { - throw new UnsupportedOperationException("Cannot call `toMonitor` on this one"); - } - - @Override - public void start(StageExecution execution) { - delegate.start(execution); - } - - @Override - public void end(StageExecution execution, long totalTimeMillis) { - delegate.end(execution, totalTimeMillis); - } - - @Override - public void done(boolean successful, long totalTimeMillis, String additionalInformation) { - delegate.done(successful, totalTimeMillis, additionalInformation); - } - - @Override - public long checkIntervalMillis() { - return delegate.checkIntervalMillis(); - } - - @Override - public void check(StageExecution execution) { - delegate.check(execution); - } - }; - } - - static final class ExecutionMonitorAdapter implements org.neo4j.internal.batchimport.staging.ExecutionMonitor { - private final ExecutionMonitor delegate; - - ExecutionMonitorAdapter(ExecutionMonitor delegate) {this.delegate = delegate;} - - @Override - public void initialize(DependencyResolver dependencyResolver) { - org.neo4j.internal.batchimport.staging.ExecutionMonitor.super.initialize(dependencyResolver); - this.delegate.initialize(dependencyResolver); - } - - @Override - public void start(StageExecution stageExecution) { - this.delegate.start(stageExecution); - } - - @Override - public void end(StageExecution stageExecution, long l) { - this.delegate.end(stageExecution, l); - } - - @Override - public void done(boolean b, long l, String s) { - this.delegate.done(b, l, s); - } - - @Override - public long checkIntervalMillis() { - return this.delegate.checkIntervalMillis(); - } - - @Override - public void check(StageExecution stageExecution) { - this.delegate.check(stageExecution); - } - } - static final class BatchImporterReverseAdapter implements BatchImporter { private final org.neo4j.batchimport.api.BatchImporter delegate; diff --git a/compatibility/5.23/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_523/Neo4jProxyImpl.java b/compatibility/5.23/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_523/Neo4jProxyImpl.java index ff40252bf8..5cf8cbeb1c 100644 --- a/compatibility/5.23/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_523/Neo4jProxyImpl.java +++ b/compatibility/5.23/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_523/Neo4jProxyImpl.java @@ -27,7 +27,6 @@ import org.neo4j.gds.compat.CompatCallableProcedure; import org.neo4j.gds.compat.Neo4jProxyApi; import org.neo4j.gds.compat.batchimport.BatchImporter; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.ImportConfig; import org.neo4j.gds.compat.batchimport.Monitor; import org.neo4j.gds.compat.batchimport.input.Collector; @@ -48,14 +47,13 @@ import org.neo4j.values.SequenceValue; import java.io.OutputStream; -import java.util.function.LongConsumer; import static org.neo4j.internal.helpers.collection.Iterators.asRawIterator; public final class Neo4jProxyImpl implements Neo4jProxyApi { @Override - public BatchImporter instantiateBlockBatchImporter( + public BatchImporter instantiateBatchImporter( DatabaseLayout dbLayout, FileSystemAbstraction fileSystem, ImportConfig config, @@ -65,7 +63,7 @@ public BatchImporter instantiateBlockBatchImporter( JobScheduler jobScheduler, Collector badCollector ) { - return BatchImporterCompat.instantiateBlockBatchImporter( + return BatchImporterCompat.instantiateBatchImporter( dbLayout, fileSystem, config, @@ -77,46 +75,6 @@ public BatchImporter instantiateBlockBatchImporter( ); } - @Override - public BatchImporter instantiateRecordBatchImporter( - DatabaseLayout directoryStructure, - FileSystemAbstraction fileSystem, - ImportConfig config, - ExecutionMonitor executionMonitor, - LogService logService, - Config dbConfig, - JobScheduler jobScheduler, - Collector badCollector - ) { - return BatchImporterCompat.instantiateRecordBatchImporter( - directoryStructure, - fileSystem, - config, - executionMonitor, - logService, - dbConfig, - jobScheduler, - badCollector - ); - } - - @Override - public ExecutionMonitor newCoarseBoundedProgressExecutionMonitor( - long highNodeId, - long highRelationshipId, - int batchSize, - LongConsumer progress, - LongConsumer outNumberOfBatches - ) { - return BatchImporterCompat.newCoarseBoundedProgressExecutionMonitor( - highNodeId, - highRelationshipId, - batchSize, - progress, - outNumberOfBatches - ); - } - @Override public ReadableGroups newGroups() { return BatchImporterCompat.newGroups(); diff --git a/compatibility/5.24/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_524/BatchImporterCompat.java b/compatibility/5.24/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_524/BatchImporterCompat.java index df883a416e..4df16d0b9d 100644 --- a/compatibility/5.24/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_524/BatchImporterCompat.java +++ b/compatibility/5.24/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_524/BatchImporterCompat.java @@ -20,10 +20,8 @@ package org.neo4j.gds.compat._524; import org.neo4j.batchimport.api.IndexConfig; -import org.neo4j.common.DependencyResolver; import org.neo4j.configuration.Config; import org.neo4j.gds.compat.batchimport.BatchImporter; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.ImportConfig; import org.neo4j.gds.compat.batchimport.InputIterable; import org.neo4j.gds.compat.batchimport.InputIterator; @@ -36,18 +34,14 @@ import org.neo4j.gds.compat.batchimport.input.InputChunk; import org.neo4j.gds.compat.batchimport.input.InputEntityVisitor; import org.neo4j.gds.compat.batchimport.input.ReadableGroups; -import org.neo4j.internal.batchimport.BatchImporterFactory; import org.neo4j.internal.batchimport.DefaultAdditionalIds; import org.neo4j.internal.batchimport.input.Collectors; import org.neo4j.internal.batchimport.input.Groups; -import org.neo4j.internal.batchimport.staging.CoarseBoundedProgressExecutionMonitor; -import org.neo4j.internal.batchimport.staging.StageExecution; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.layout.DatabaseLayout; import org.neo4j.io.pagecache.context.CursorContextFactory; import org.neo4j.io.pagecache.tracing.PageCacheTracer; import org.neo4j.kernel.impl.index.schema.IndexImporterFactoryImpl; -import org.neo4j.kernel.impl.transaction.log.EmptyLogTailMetadata; import org.neo4j.kernel.impl.transaction.log.files.TransactionLogInitializer; import org.neo4j.logging.internal.LogService; import org.neo4j.memory.EmptyMemoryTracker; @@ -58,13 +52,12 @@ import java.io.OutputStream; import java.io.PrintStream; import java.nio.charset.StandardCharsets; -import java.util.function.LongConsumer; public final class BatchImporterCompat { private BatchImporterCompat() {} - static BatchImporter instantiateBlockBatchImporter( + static BatchImporter instantiateBatchImporter( DatabaseLayout dbLayout, FileSystemAbstraction fileSystem, ImportConfig config, @@ -104,40 +97,6 @@ private static final class MonitorAdapter implements org.neo4j.batchimport.api.M private MonitorAdapter(Monitor delegate) {this.delegate = delegate;} - @Override - public void doubleRelationshipRecordUnitsEnabled() { - delegate.doubleRelationshipRecordUnitsEnabled(); - } - - @Override - public void mayExceedNodeIdCapacity(long capacity, long estimatedCount) { - delegate.mayExceedNodeIdCapacity(capacity, estimatedCount); - } - - @Override - public void mayExceedRelationshipIdCapacity(long capacity, long estimatedCount) { - delegate.mayExceedRelationshipIdCapacity(capacity, estimatedCount); - } - - @Override - public void insufficientHeapSize(long optimalMinimalHeapSize, long heapSize) { - delegate.insufficientHeapSize(optimalMinimalHeapSize, heapSize); - } - - @Override - public void abundantHeapSize(long optimalMinimalHeapSize, long heapSize) { - delegate.abundantHeapSize(optimalMinimalHeapSize, heapSize); - } - - @Override - public void insufficientAvailableMemory( - long estimatedCacheSize, - long optimalMinimalHeapSize, - long availableMemory - ) { - delegate.insufficientAvailableMemory(estimatedCacheSize, optimalMinimalHeapSize, availableMemory); - } - @Override public void started() { delegate.started(); @@ -154,38 +113,6 @@ public void completed(boolean success) { } } - static BatchImporter instantiateRecordBatchImporter( - DatabaseLayout directoryStructure, - FileSystemAbstraction fileSystem, - ImportConfig config, - ExecutionMonitor executionMonitor, - LogService logService, - Config dbConfig, - JobScheduler jobScheduler, - Collector badCollector - ) { - var importer = BatchImporterFactory.withHighestPriority() - .instantiate( - directoryStructure, - fileSystem, - PageCacheTracer.NULL, - new ConfigurationAdapter(config), - logService, - new ExecutionMonitorAdapter(executionMonitor), - DefaultAdditionalIds.EMPTY, - new EmptyLogTailMetadata(dbConfig), - dbConfig, - org.neo4j.batchimport.api.Monitor.NO_MONITOR, - jobScheduler, - badCollector != null ? ((CollectorAdapter) badCollector).delegate : null, - TransactionLogInitializer.getLogFilesInitializer(), - new IndexImporterFactoryImpl(), - EmptyMemoryTracker.INSTANCE, - CursorContextFactory.NULL_CONTEXT_FACTORY - ); - return new BatchImporterReverseAdapter(importer); - } - static final class ConfigurationAdapter implements org.neo4j.batchimport.api.Configuration { private final ImportConfig inner; @@ -221,104 +148,6 @@ public IndexConfig indexConfig() { } } - static ExecutionMonitor newCoarseBoundedProgressExecutionMonitor( - long highNodeId, - long highRelationshipId, - int batchSize, - LongConsumer progress, - LongConsumer outNumberOfBatches - ) { - var delegate = new CoarseBoundedProgressExecutionMonitor( - highNodeId, - highRelationshipId, - org.neo4j.batchimport.api.Configuration.withBatchSize( - org.neo4j.batchimport.api.Configuration.DEFAULT, - batchSize - ) - ) { - @Override - protected void progress(long l) { - progress.accept(l); - } - - long numberOfBatches() { - return this.total(); - } - }; - // Note: this only works because we declare the delegate with `var` - outNumberOfBatches.accept(delegate.numberOfBatches()); - - return new ExecutionMonitor() { - - @Override - public Monitor toMonitor() { - throw new UnsupportedOperationException("Cannot call `toMonitor` on this one"); - } - - @Override - public void start(StageExecution execution) { - delegate.start(execution); - } - - @Override - public void end(StageExecution execution, long totalTimeMillis) { - delegate.end(execution, totalTimeMillis); - } - - @Override - public void done(boolean successful, long totalTimeMillis, String additionalInformation) { - delegate.done(successful, totalTimeMillis, additionalInformation); - } - - @Override - public long checkIntervalMillis() { - return delegate.checkIntervalMillis(); - } - - @Override - public void check(StageExecution execution) { - delegate.check(execution); - } - }; - } - - static final class ExecutionMonitorAdapter implements org.neo4j.internal.batchimport.staging.ExecutionMonitor { - private final ExecutionMonitor delegate; - - ExecutionMonitorAdapter(ExecutionMonitor delegate) {this.delegate = delegate;} - - @Override - public void initialize(DependencyResolver dependencyResolver) { - org.neo4j.internal.batchimport.staging.ExecutionMonitor.super.initialize(dependencyResolver); - this.delegate.initialize(dependencyResolver); - } - - @Override - public void start(StageExecution stageExecution) { - this.delegate.start(stageExecution); - } - - @Override - public void end(StageExecution stageExecution, long l) { - this.delegate.end(stageExecution, l); - } - - @Override - public void done(boolean b, long l, String s) { - this.delegate.done(b, l, s); - } - - @Override - public long checkIntervalMillis() { - return this.delegate.checkIntervalMillis(); - } - - @Override - public void check(StageExecution stageExecution) { - this.delegate.check(stageExecution); - } - } - static final class BatchImporterReverseAdapter implements BatchImporter { private final org.neo4j.batchimport.api.BatchImporter delegate; diff --git a/compatibility/5.24/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_524/Neo4jProxyImpl.java b/compatibility/5.24/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_524/Neo4jProxyImpl.java index bd9d3b04e3..0c34fe45f0 100644 --- a/compatibility/5.24/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_524/Neo4jProxyImpl.java +++ b/compatibility/5.24/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/_524/Neo4jProxyImpl.java @@ -27,7 +27,6 @@ import org.neo4j.gds.compat.CompatCallableProcedure; import org.neo4j.gds.compat.Neo4jProxyApi; import org.neo4j.gds.compat.batchimport.BatchImporter; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.ImportConfig; import org.neo4j.gds.compat.batchimport.Monitor; import org.neo4j.gds.compat.batchimport.input.Collector; @@ -48,14 +47,13 @@ import org.neo4j.values.SequenceValue; import java.io.OutputStream; -import java.util.function.LongConsumer; import static org.neo4j.internal.helpers.collection.Iterators.asRawIterator; public final class Neo4jProxyImpl implements Neo4jProxyApi { @Override - public BatchImporter instantiateBlockBatchImporter( + public BatchImporter instantiateBatchImporter( DatabaseLayout dbLayout, FileSystemAbstraction fileSystem, ImportConfig config, @@ -65,7 +63,7 @@ public BatchImporter instantiateBlockBatchImporter( JobScheduler jobScheduler, Collector badCollector ) { - return BatchImporterCompat.instantiateBlockBatchImporter( + return BatchImporterCompat.instantiateBatchImporter( dbLayout, fileSystem, config, @@ -77,46 +75,6 @@ public BatchImporter instantiateBlockBatchImporter( ); } - @Override - public BatchImporter instantiateRecordBatchImporter( - DatabaseLayout directoryStructure, - FileSystemAbstraction fileSystem, - ImportConfig config, - ExecutionMonitor executionMonitor, - LogService logService, - Config dbConfig, - JobScheduler jobScheduler, - Collector badCollector - ) { - return BatchImporterCompat.instantiateRecordBatchImporter( - directoryStructure, - fileSystem, - config, - executionMonitor, - logService, - dbConfig, - jobScheduler, - badCollector - ); - } - - @Override - public ExecutionMonitor newCoarseBoundedProgressExecutionMonitor( - long highNodeId, - long highRelationshipId, - int batchSize, - LongConsumer progress, - LongConsumer outNumberOfBatches - ) { - return BatchImporterCompat.newCoarseBoundedProgressExecutionMonitor( - highNodeId, - highRelationshipId, - batchSize, - progress, - outNumberOfBatches - ); - } - @Override public ReadableGroups newGroups() { return BatchImporterCompat.newGroups(); diff --git a/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxyApi.java b/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxyApi.java index b6d005a63b..4be4ac52f3 100644 --- a/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxyApi.java +++ b/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxyApi.java @@ -24,7 +24,6 @@ import org.neo4j.dbms.api.DatabaseNotFoundException; import org.neo4j.exceptions.KernelException; import org.neo4j.gds.compat.batchimport.BatchImporter; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.ImportConfig; import org.neo4j.gds.compat.batchimport.Monitor; import org.neo4j.gds.compat.batchimport.input.Collector; @@ -39,12 +38,11 @@ import org.neo4j.values.SequenceValue; import java.io.OutputStream; -import java.util.function.LongConsumer; public interface Neo4jProxyApi { @CompatSince(minor = 23) - BatchImporter instantiateBlockBatchImporter( + BatchImporter instantiateBatchImporter( DatabaseLayout dbLayout, FileSystemAbstraction fileSystem, ImportConfig config, @@ -55,30 +53,6 @@ BatchImporter instantiateBlockBatchImporter( Collector badCollector ); - @CompatSince(minor = 23) - BatchImporter instantiateRecordBatchImporter( - DatabaseLayout directoryStructure, - FileSystemAbstraction fileSystem, - ImportConfig config, - ExecutionMonitor executionMonitor, - LogService logService, - Config dbConfig, - JobScheduler jobScheduler, - Collector badCollector - ); - - @CompatSince(minor = 23) - default ExecutionMonitor newCoarseBoundedProgressExecutionMonitor( - long highNodeId, - long highRelationshipId, - int batchSize, - LongConsumer progress, - LongConsumer outNumberOfBatches - ) { - throw new UnsupportedOperationException( - "`org.neo4j.gds.compat._519.Neo4jProxyApi.newCoarseBoundedProgressExecutionMonitor` is not yet implemented."); - } - @CompatSince(minor = 23) ReadableGroups newGroups(); diff --git a/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/batchimport/ExecutionMonitor.java b/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/batchimport/ExecutionMonitor.java deleted file mode 100644 index ce2ef85727..0000000000 --- a/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/batchimport/ExecutionMonitor.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) "Neo4j" - * Neo4j Sweden AB [http://neo4j.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.gds.compat.batchimport; - -import org.neo4j.common.DependencyResolver; -import org.neo4j.internal.batchimport.staging.StageExecution; - -/** - * Gets notified now and then about {@link StageExecution}, where statistics can be read and displayed, - * aggregated or in other ways make sense of the data of {@link StageExecution}. - */ -public interface ExecutionMonitor { - - Monitor toMonitor(); - - /** - * Signals start of import. Called only once and before any other method. - * - * @param dependencyResolver {@link DependencyResolver} for getting dependencies from. - */ - default void initialize(DependencyResolver dependencyResolver) { // empty by default - } - - /** - * Signals the start of a {@link StageExecution}. - */ - void start(StageExecution execution); - - /** - * Signals the end of the execution previously {@link #start(StageExecution) started}. - */ - void end(StageExecution execution, long totalTimeMillis); - - /** - * Called after all {@link StageExecution stage executions} have run. - */ - void done(boolean successful, long totalTimeMillis, String additionalInformation); - - /** - * @return rough time interval (in millis) this monitor needs checking. - */ - long checkIntervalMillis(); - - /** - * Called periodically while executing a {@link StageExecution}. - */ - void check(StageExecution execution); -} diff --git a/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/batchimport/Monitor.java b/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/batchimport/Monitor.java index 1c8c6c41d4..e2f0e953c9 100644 --- a/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/batchimport/Monitor.java +++ b/compatibility/api/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/batchimport/Monitor.java @@ -20,21 +20,6 @@ package org.neo4j.gds.compat.batchimport; public interface Monitor { - Monitor NO_MONITOR = new Monitor() {}; - - default void doubleRelationshipRecordUnitsEnabled() {} - - default void mayExceedNodeIdCapacity(long capacity, long estimatedCount) {} - - default void mayExceedRelationshipIdCapacity(long capacity, long estimatedCount) {} - - default void insufficientHeapSize(long optimalMinimalHeapSize, long heapSize) {} - - default void abundantHeapSize(long optimalMinimalHeapSize, long heapSize) {} - - default void insufficientAvailableMemory( - long estimatedCacheSize, long optimalMinimalHeapSize, long availableMemory) {} - /** * Called right before import is starting. */ diff --git a/compatibility/common/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxy.java b/compatibility/common/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxy.java index e454fd96f2..5619fa7fbf 100644 --- a/compatibility/common/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxy.java +++ b/compatibility/common/neo4j-kernel-adapter/src/main/java/org/neo4j/gds/compat/Neo4jProxy.java @@ -33,8 +33,8 @@ import org.neo4j.exceptions.KernelException; import org.neo4j.gds.annotation.SuppressForbidden; import org.neo4j.gds.compat.batchimport.BatchImporter; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.ImportConfig; +import org.neo4j.gds.compat.batchimport.Monitor; import org.neo4j.gds.compat.batchimport.input.Collector; import org.neo4j.gds.compat.batchimport.input.Estimates; import org.neo4j.gds.compat.batchimport.input.ReadableGroups; @@ -102,7 +102,6 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.function.LongConsumer; import java.util.stream.Stream; import static java.lang.String.format; @@ -301,34 +300,21 @@ public static BatchImporter instantiateBatchImporter( FileSystemAbstraction fileSystem, ImportConfig configuration, LogService logService, - ExecutionMonitor executionMonitor, + Monitor executionMonitor, Config dbConfig, JobScheduler jobScheduler, Collector badCollector ) { - if (dbConfig.get(GraphDatabaseSettings.db_format).equals("block")) { - return IMPL.instantiateBlockBatchImporter( - directoryStructure, - fileSystem, - configuration, - executionMonitor.toMonitor(), - logService, - dbConfig, - jobScheduler, - badCollector - ); - } else { - return IMPL.instantiateRecordBatchImporter( - directoryStructure, - fileSystem, - configuration, - executionMonitor, - logService, - dbConfig, - jobScheduler, - badCollector - ); - } + return IMPL.instantiateBatchImporter( + directoryStructure, + fileSystem, + configuration, + executionMonitor, + logService, + dbConfig, + jobScheduler, + badCollector + ); } public static Setting additionalJvm() { @@ -359,22 +345,6 @@ public static long getHighestPossibleRelationshipCount(Read read) { return read.relationshipsGetCount(); } - public static ExecutionMonitor newCoarseBoundedProgressExecutionMonitor( - long highNodeId, - long highRelationshipId, - int batchSize, - LongConsumer progress, - LongConsumer outNumberOfBatches - ) { - return IMPL.newCoarseBoundedProgressExecutionMonitor( - highNodeId, - highRelationshipId, - batchSize, - progress, - outNumberOfBatches - ); - } - public static ReadableGroups newGroups() { return IMPL.newGroups(); } diff --git a/io/core/src/main/java/org/neo4j/gds/core/io/db/GdsParallelBatchImporter.java b/io/core/src/main/java/org/neo4j/gds/core/io/db/GdsParallelBatchImporter.java index c92a064a47..3432899f98 100644 --- a/io/core/src/main/java/org/neo4j/gds/core/io/db/GdsParallelBatchImporter.java +++ b/io/core/src/main/java/org/neo4j/gds/core/io/db/GdsParallelBatchImporter.java @@ -26,8 +26,8 @@ import org.neo4j.gds.compat.GraphDatabaseApiProxy; import org.neo4j.gds.compat.Neo4jProxy; import org.neo4j.gds.compat.batchimport.BatchImporter; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.ImportConfig; +import org.neo4j.gds.compat.batchimport.Monitor; import org.neo4j.gds.compat.batchimport.input.Collector; import org.neo4j.gds.compat.batchimport.input.Input; import org.neo4j.gds.core.utils.ProgressTimer; @@ -54,7 +54,7 @@ public final class GdsParallelBatchImporter { private final Config config; private final Log log; - private final ExecutionMonitor executionMonitor; + private final Monitor executionMonitor; private final FileSystemAbstraction fileSystem; private final LogService logService; @@ -65,7 +65,7 @@ static GdsParallelBatchImporter fromDb( GraphDatabaseService databaseService, Config config, Log log, - ExecutionMonitor executionMonitor + Monitor executionMonitor ) { var dbms = GraphDatabaseApiProxy.resolveDependency(databaseService, DatabaseManagementService.class); return fromDbms(dbms, config, log, executionMonitor); @@ -75,7 +75,7 @@ public static GdsParallelBatchImporter fromDbms( DatabaseManagementService dbms, Config config, Log log, - ExecutionMonitor executionMonitor + Monitor executionMonitor ) { var databaseService = dbms.database(SYSTEM_DATABASE_NAME); var fs = GraphDatabaseApiProxy.resolveDependency(databaseService, FileSystemAbstraction.class); @@ -95,7 +95,7 @@ public static GdsParallelBatchImporter fromDbms( private GdsParallelBatchImporter( Config config, Log log, - ExecutionMonitor executionMonitor, + Monitor executionMonitor, DatabaseManagementService dbms, FileSystemAbstraction fileSystem, LogService logService, diff --git a/io/core/src/main/java/org/neo4j/gds/core/io/db/GraphStoreToDatabaseExporter.java b/io/core/src/main/java/org/neo4j/gds/core/io/db/GraphStoreToDatabaseExporter.java index 133d7f769a..25c321e553 100644 --- a/io/core/src/main/java/org/neo4j/gds/core/io/db/GraphStoreToDatabaseExporter.java +++ b/io/core/src/main/java/org/neo4j/gds/core/io/db/GraphStoreToDatabaseExporter.java @@ -66,11 +66,7 @@ public static GraphStoreToDatabaseExporter of( .useBadCollector(false) .build(); - var executionMonitor = new ProgressTrackerExecutionMonitor( - graphStore, - progressTracker, - pbiConfig.batchSize() - ); + var executionMonitor = new ProgressTrackerExecutionMonitor(graphStore, progressTracker); var parallelBatchImporter = GdsParallelBatchImporter.fromDb(databaseService, pbiConfig, log, executionMonitor); diff --git a/io/core/src/main/java/org/neo4j/gds/core/io/db/ProgressTrackerExecutionMonitor.java b/io/core/src/main/java/org/neo4j/gds/core/io/db/ProgressTrackerExecutionMonitor.java index c364434a06..08881ed161 100644 --- a/io/core/src/main/java/org/neo4j/gds/core/io/db/ProgressTrackerExecutionMonitor.java +++ b/io/core/src/main/java/org/neo4j/gds/core/io/db/ProgressTrackerExecutionMonitor.java @@ -19,42 +19,23 @@ */ package org.neo4j.gds.core.io.db; -import org.apache.commons.lang3.mutable.MutableLong; -import org.neo4j.common.DependencyResolver; import org.neo4j.gds.api.GraphStore; -import org.neo4j.gds.compat.Neo4jProxy; -import org.neo4j.gds.compat.batchimport.ExecutionMonitor; import org.neo4j.gds.compat.batchimport.Monitor; import org.neo4j.gds.core.utils.progress.tasks.ProgressTracker; import org.neo4j.gds.core.utils.progress.tasks.Task; import org.neo4j.gds.core.utils.progress.tasks.Tasks; -import org.neo4j.internal.batchimport.staging.StageExecution; -import static org.neo4j.gds.utils.StringFormatting.formatWithLocale; +public final class ProgressTrackerExecutionMonitor implements Monitor { -public final class ProgressTrackerExecutionMonitor implements ExecutionMonitor { - - private final long totalNumberOfBatches; private final long total; private final ProgressTracker progressTracker; - private final ExecutionMonitor inner; ProgressTrackerExecutionMonitor( GraphStore graphStore, - ProgressTracker progressTracker, - int batchSize + ProgressTracker progressTracker ) { this.total = getTotal(graphStore); this.progressTracker = progressTracker; - var numberOfBatches = new MutableLong(); - this.inner = Neo4jProxy.newCoarseBoundedProgressExecutionMonitor( - graphStore.nodeCount(), - graphStore.relationshipCount(), - batchSize, - this::reportProgress, - numberOfBatches::setValue - ); - this.totalNumberOfBatches = numberOfBatches.longValue(); } public static Task progressTask(GraphStore graphStore) { @@ -73,75 +54,19 @@ private static long getTotal(GraphStore graphStore) { } @Override - public void initialize(DependencyResolver dependencyResolver) { - this.inner.initialize(dependencyResolver); + public void started() { this.progressTracker.beginSubTask(); - this.progressTracker.setVolume(this.totalNumberOfBatches); + this.progressTracker.setVolume(this.total); } @Override - public void start(StageExecution execution) { - this.inner.start(execution); - progressTracker.logInfo(formatWithLocale("%s :: Start", execution.getStageName())); - } - - @Override - public void end(StageExecution execution, long totalTimeMillis) { - this.inner.end(execution, totalTimeMillis); - progressTracker.logInfo(formatWithLocale("%s :: Finished", execution.getStageName())); - } - - @Override - public void done(boolean successful, long totalTimeMillis, String additionalInformation) { - this.inner.done(successful, totalTimeMillis, additionalInformation); - this.progressTracker.endSubTask(); - this.progressTracker.logInfo(additionalInformation); - } - - @Override - public long checkIntervalMillis() { - return this.inner.checkIntervalMillis(); - } - - @Override - public void check(StageExecution execution) { - this.inner.check(execution); - } - - private void reportProgress(long progress) { + public void percentageCompleted(int percentage) { + long progress = (long) (this.total * (percentage / 100.0)); this.progressTracker.logProgress(progress); } @Override - public Monitor toMonitor() { - return new ProgressMonitor(this.total, progressTracker); - } - - private static final class ProgressMonitor implements Monitor { - - private final long total; - private final ProgressTracker progressTracker; - - private ProgressMonitor(long total, ProgressTracker progressTracker) { - this.total = total; - this.progressTracker = progressTracker; - } - - @Override - public void started() { - this.progressTracker.beginSubTask(); - this.progressTracker.setVolume(this.total); - } - - @Override - public void percentageCompleted(int percentage) { - long progress = (long) (this.total * (percentage / 100.0)); - this.progressTracker.logProgress(progress); - } - - @Override - public void completed(boolean success) { - this.progressTracker.endSubTask(); - } + public void completed(boolean success) { + this.progressTracker.endSubTask(); } }