Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static long importData(String title, int numRunners, InputIterable data, org.neo4j.unsafe.impl.batchimport.store.BatchingNeoStores stores, System.Func<EntityImporter> visitors, org.neo4j.unsafe.impl.batchimport.staging.ExecutionMonitor executionMonitor, org.neo4j.unsafe.impl.batchimport.stats.StatsProvider memoryStatsProvider) throws java.io.IOException
        private static long ImportData(string title, int numRunners, InputIterable data, BatchingNeoStores stores, System.Func <EntityImporter> visitors, ExecutionMonitor executionMonitor, StatsProvider memoryStatsProvider)
        {
            LongAdder        roughEntityCountProgress = new LongAdder();
            ExecutorService  pool         = Executors.newFixedThreadPool(numRunners, new NamedThreadFactory(title + "Importer"));
            IoMonitor        writeMonitor = new IoMonitor(stores.IoTracer);
            ControllableStep step         = new ControllableStep(title, roughEntityCountProgress, Configuration.DEFAULT, writeMonitor, memoryStatsProvider);
            StageExecution   execution    = new StageExecution(title, null, Configuration.DEFAULT, Collections.singletonList(step), 0);
            long             startTime    = currentTimeMillis();

            using (InputIterator dataIterator = data.GetEnumerator())
            {
                executionMonitor.Start(execution);
                for (int i = 0; i < numRunners; i++)
                {
                    pool.submit(new ExhaustingEntityImporterRunnable(execution, dataIterator, visitors(), roughEntityCountProgress));
                }
                pool.shutdown();

                long nextWait = 0;
                try
                {
                    while (!pool.awaitTermination(nextWait, TimeUnit.MILLISECONDS))
                    {
                        executionMonitor.Check(execution);
                        nextWait = executionMonitor.NextCheckTime() - currentTimeMillis();
                    }
                }
                catch (InterruptedException e)
                {
                    Thread.CurrentThread.Interrupt();
                    throw new IOException(e);
                }
            }

            execution.AssertHealthy();
            step.MarkAsCompleted();
            writeMonitor.Stop();
            executionMonitor.End(execution, currentTimeMillis() - startTime);
            execution.AssertHealthy();

            return(roughEntityCountProgress.sum());
        }
 public MonitoredChannel(Channel <TPacket> innerChannel) : base(innerChannel)
 {
     IoMonitor = new IoMonitor <TPacket>(this);
 }