Esempio n. 1
0
 public InputAnonymousInnerClass(InputIterable nodes, InputIterable relationships, IdMapper idMapper, [email protected] badCollector, Input_Estimates estimates)
 {
     this._nodes         = nodes;
     this._relationships = relationships;
     this._idMapper      = idMapper;
     this._badCollector  = badCollector;
     this._estimates     = estimates;
 }
Esempio n. 2
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());
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void migrateWithBatchImporter(org.neo4j.io.layout.DatabaseLayout sourceDirectoryStructure, org.neo4j.io.layout.DatabaseLayout migrationDirectoryStructure, long lastTxId, long lastTxChecksum, long lastTxLogVersion, long lastTxLogByteOffset, org.neo4j.kernel.impl.util.monitoring.ProgressReporter progressReporter, org.neo4j.kernel.impl.store.format.RecordFormats oldFormat, org.neo4j.kernel.impl.store.format.RecordFormats newFormat) throws java.io.IOException
        private void MigrateWithBatchImporter(DatabaseLayout sourceDirectoryStructure, DatabaseLayout migrationDirectoryStructure, long lastTxId, long lastTxChecksum, long lastTxLogVersion, long lastTxLogByteOffset, ProgressReporter progressReporter, RecordFormats oldFormat, RecordFormats newFormat)
        {
            PrepareBatchImportMigration(sourceDirectoryStructure, migrationDirectoryStructure, oldFormat, newFormat);

            bool requiresDynamicStoreMigration = !newFormat.Dynamic().Equals(oldFormat.Dynamic());
            bool requiresPropertyMigration     = !newFormat.Property().Equals(oldFormat.Property()) || requiresDynamicStoreMigration;
            File badFile = sourceDirectoryStructure.File([email protected]_Fields.BAD_FILE_NAME);

            using (NeoStores legacyStore = InstantiateLegacyStore(oldFormat, sourceDirectoryStructure), Stream badOutput = new BufferedOutputStream(new FileStream(badFile, false)))
            {
                Configuration        importConfig         = new Configuration_OverriddenAnonymousInnerClass(this, _config, sourceDirectoryStructure);
                AdditionalInitialIds additionalInitialIds = ReadAdditionalIds(lastTxId, lastTxChecksum, lastTxLogVersion, lastTxLogByteOffset);

                // We have to make sure to keep the token ids if we're migrating properties/labels
                BatchImporter   importer          = BatchImporterFactory.withHighestPriority().instantiate(migrationDirectoryStructure, _fileSystem, _pageCache, importConfig, _logService, withDynamicProcessorAssignment(MigrationBatchImporterMonitor(legacyStore, progressReporter, importConfig), importConfig), additionalInitialIds, _config, newFormat, NO_MONITOR, _jobScheduler);
                InputIterable   nodes             = () => LegacyNodesAsInput(legacyStore, requiresPropertyMigration);
                InputIterable   relationships     = () => LegacyRelationshipsAsInput(legacyStore, requiresPropertyMigration);
                long            propertyStoreSize = StoreSize(legacyStore.PropertyStore) / 2 + StoreSize(legacyStore.PropertyStore.StringStore) / 2 + StoreSize(legacyStore.PropertyStore.ArrayStore) / 2;
                Input_Estimates estimates         = knownEstimates(legacyStore.NodeStore.NumberOfIdsInUse, legacyStore.RelationshipStore.NumberOfIdsInUse, legacyStore.PropertyStore.NumberOfIdsInUse, legacyStore.PropertyStore.NumberOfIdsInUse, propertyStoreSize / 2, propertyStoreSize / 2, 0);
                importer.DoImport(Inputs.input(nodes, relationships, IdMappers.actual(), Collectors.badCollector(badOutput, 0), estimates));

                // During migration the batch importer doesn't necessarily writes all entities, depending on
                // which stores needs migration. Node, relationship, relationship group stores are always written
                // anyways and cannot be avoided with the importer, but delete the store files that weren't written
                // (left empty) so that we don't overwrite those in the real store directory later.
                ICollection <DatabaseFile> storesToDeleteFromMigratedDirectory = new List <DatabaseFile>();
                storesToDeleteFromMigratedDirectory.Add(DatabaseFile.METADATA_STORE);
                if (!requiresPropertyMigration)
                {
                    // We didn't migrate properties, so the property stores in the migrated store are just empty/bogus
                    storesToDeleteFromMigratedDirectory.addAll(asList(DatabaseFile.PROPERTY_STORE, DatabaseFile.PROPERTY_STRING_STORE, DatabaseFile.PROPERTY_ARRAY_STORE));
                }
                if (!requiresDynamicStoreMigration)
                {
                    // We didn't migrate labels (dynamic node labels) or any other dynamic store
                    storesToDeleteFromMigratedDirectory.addAll(asList(DatabaseFile.NODE_LABEL_STORE, DatabaseFile.LABEL_TOKEN_STORE, DatabaseFile.LABEL_TOKEN_NAMES_STORE, DatabaseFile.RELATIONSHIP_TYPE_TOKEN_STORE, DatabaseFile.RELATIONSHIP_TYPE_TOKEN_NAMES_STORE, DatabaseFile.PROPERTY_KEY_TOKEN_STORE, DatabaseFile.PROPERTY_KEY_TOKEN_NAMES_STORE, DatabaseFile.SCHEMA_STORE));
                }
                fileOperation(DELETE, _fileSystem, migrationDirectoryStructure, migrationDirectoryStructure, storesToDeleteFromMigratedDirectory, true, null);
            }
        }
Esempio n. 4
0
 private InputEntity[] Sample(InputIterable source, int size)
 {
     try
     {
         using (InputIterator iterator = source.GetEnumerator(), InputChunk chunk = iterator.NewChunk())
         {
             InputEntity[] sample = new InputEntity[size];
             int           cursor = 0;
             while (cursor < size && iterator.Next(chunk))
             {
                 while (cursor < size && chunk.Next(sample[cursor++] = new InputEntity()))
                 {
                     // just loop
                 }
             }
             return(sample);
         }
     }
     catch (IOException e)
     {
         throw new UncheckedIOException(e);
     }
 }
Esempio n. 5
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public static Input input(final org.neo4j.unsafe.impl.batchimport.InputIterable nodes, final org.neo4j.unsafe.impl.batchimport.InputIterable relationships, final org.neo4j.unsafe.impl.batchimport.cache.idmapping.IdMapper idMapper, final Collector badCollector, org.neo4j.unsafe.impl.batchimport.input.Input_Estimates estimates)
        public static Input Input(InputIterable nodes, InputIterable relationships, IdMapper idMapper, Collector badCollector, Input_Estimates estimates)
        {
            return(new InputAnonymousInnerClass(nodes, relationships, idMapper, badCollector, estimates));
        }