Exemple #1
0
        private static StoreFactory OpenStore(FileSystemAbstraction fileSystem, File storeDir, Config config, PageCache pageCache)
        {
            IdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fileSystem);
            NullLogProvider    logProvider        = NullLogProvider.Instance;

            return(new StoreFactory(DatabaseLayout.of(storeDir), config, idGeneratorFactory, pageCache, fileSystem, logProvider, EmptyVersionContextSupplier.EMPTY));
        }
Exemple #2
0
        private static long GetHighId(DefaultIdGeneratorFactory factory, IdType idType, File idFile)
        {
            IdGenerator idGenerator = factory.Open(idFile, idType, () => - 1L, long.MaxValue);
            long        highId      = idGenerator.HighId;

            idGenerator.Dispose();
            return(highId);
        }
Exemple #3
0
        private IdAllocationState DeriveIdAllocationState(DatabaseLayout databaseLayout)
        {
            DefaultIdGeneratorFactory factory = new DefaultIdGeneratorFactory(_fs);

            long[] highIds = new long[] { GetHighId(factory, NODE, databaseLayout.IdNodeStore()), GetHighId(factory, RELATIONSHIP, databaseLayout.IdRelationshipStore()), GetHighId(factory, PROPERTY, databaseLayout.IdPropertyStore()), GetHighId(factory, STRING_BLOCK, databaseLayout.IdPropertyStringStore()), GetHighId(factory, ARRAY_BLOCK, databaseLayout.IdPropertyArrayStore()), GetHighId(factory, PROPERTY_KEY_TOKEN, databaseLayout.IdPropertyKeyTokenStore()), GetHighId(factory, PROPERTY_KEY_TOKEN_NAME, databaseLayout.IdPropertyKeyTokenNamesStore()), GetHighId(factory, RELATIONSHIP_TYPE_TOKEN, databaseLayout.IdRelationshipTypeTokenStore()), GetHighId(factory, RELATIONSHIP_TYPE_TOKEN_NAME, databaseLayout.IdRelationshipTypeTokenNamesStore()), GetHighId(factory, LABEL_TOKEN, databaseLayout.IdLabelTokenStore()), GetHighId(factory, LABEL_TOKEN_NAME, databaseLayout.IdLabelTokenNamesStore()), GetHighId(factory, NEOSTORE_BLOCK, databaseLayout.IdMetadataStore()), GetHighId(factory, SCHEMA, databaseLayout.IdSchemaStore()), GetHighId(factory, NODE_LABELS, databaseLayout.IdNodeLabelStore()), GetHighId(factory, RELATIONSHIP_GROUP, databaseLayout.IdRelationshipGroupStore()) };

            return(new IdAllocationState(highIds, FIRST_INDEX));
        }
Exemple #4
0
        private AbstractDynamicStore NewTestableDynamicStore()
        {
            DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(_fs);
            AbstractDynamicStore      store = new AbstractDynamicStoreAnonymousInnerClass(this, _storeFile, _idFile, Config.defaults(), idGeneratorFactory, _pageCache, NullLogProvider.Instance, _formats.dynamic(), _formats.storeVersion());

            store.Initialise(true);
            return(store);
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            _config = Config.defaults();
            DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(_fs.get());

            _storeFactory = new StoreFactory(_testDirectory.databaseLayout(), _config, idGeneratorFactory, PageCacheRule.getPageCache(_fs.get()), _fs.get(), NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);
            _neoStores    = _storeFactory.openAllNeoStores(true);
            _store        = _neoStores.SchemaStore;
        }
Exemple #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.kernel.impl.store.NeoStores createNeoStore(org.neo4j.io.fs.FileSystemAbstraction fs, org.neo4j.io.pagecache.PageCache pageCache) throws java.io.IOException
        private NeoStores CreateNeoStore(FileSystemAbstraction fs, PageCache pageCache)
        {
            Config config = Config.defaults();
            DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
            NullLogProvider           logProvider        = NullLogProvider.Instance;
            StoreFactory storeFactory = new StoreFactory(_testDirectory.databaseLayout(), config, idGeneratorFactory, pageCache, fs, logProvider, EmptyVersionContextSupplier.EMPTY);

            return(storeFactory.OpenAllNeoStores(true));
        }
Exemple #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            FileSystemAbstraction     fs = FileSystemRule.get();
            DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
            PageCache    pageCache = PageCacheRule.getPageCache(fs);
            StoreFactory factory   = new StoreFactory(TestDirectory.databaseLayout(), Config.defaults(), idGeneratorFactory, pageCache, fs, NullLogProvider.Instance, EmptyVersionContextSupplier.EMPTY);

            _neoStores  = factory.OpenAllNeoStores(true);
            _arrayStore = _neoStores.PropertyStore.ArrayStore;
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setupStores()
        public virtual void SetupStores()
        {
            DatabaseLayout            storeLayout        = Storage.directory().databaseLayout();
            Config                    config             = Config.defaults(pagecache_memory, "8m");
            PageCache                 pageCache          = Storage.pageCache();
            FileSystemAbstraction     fs                 = Storage.fileSystem();
            DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
            NullLogProvider           logProvider        = NullLogProvider.Instance;
            StoreFactory              storeFactory       = new StoreFactory(storeLayout, config, idGeneratorFactory, pageCache, fs, logProvider, EMPTY);

            _neoStores = storeFactory.OpenAllNeoStores(true);
        }
Exemple #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void dump(org.neo4j.io.layout.DatabaseLayout databaseLayout) throws java.io.IOException
        internal virtual void Dump(DatabaseLayout databaseLayout)
        {
            using (DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction(), PageCache pageCache = createPageCache(fs, createInitialisedScheduler()))
            {
                DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
                Config       config       = Config.defaults();
                StoreFactory storeFactory = new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, fs, LogProvider(), EmptyVersionContextSupplier.EMPTY);

                using (NeoStores neoStores = storeFactory.OpenNeoStores(StoreTypes))
                {
                    RecordStore <RECORD> store = store(neoStores);
                    RECORD record = store.NewRecord();
                    for (long next = FirstRecord; next != -1;)
                    {
                        store.GetRecord(next, record, RecordLoad.FORCE);
                        Console.WriteLine(record);
                        next = next(record);
                    }
                }
            }
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustCloseAllStoresIfNeoStoresFailToOpen()
        public virtual void MustCloseAllStoresIfNeoStoresFailToOpen()
        {
            PageCache              pageCache      = Rules.pageCache();
            DatabaseLayout         databaseLayout = Rules.directory().databaseLayout();
            Config                 config         = Config.defaults();
            FileSystemAbstraction  fs             = Rules.fileSystem();
            IdGeneratorFactory     idGenFactory   = new DefaultIdGeneratorFactory(fs);
            LogProvider            logProvider    = NullLogProvider.Instance;
            VersionContextSupplier versions       = EmptyVersionContextSupplier.EMPTY;
            RecordFormats          formats        = Standard.LATEST_RECORD_FORMATS;

            (new RecordFormatPropertyConfigurator(formats, config)).configure();
            bool create = true;

            StoreType[]  storeTypes  = StoreType.values();
            OpenOption[] openOptions = new OpenOption[0];
            NeoStores    neoStores   = new NeoStores(databaseLayout, config, idGenFactory, pageCache, logProvider, fs, versions, formats, create, storeTypes, openOptions);
            File         schemaStore = neoStores.SchemaStore.StorageFile;

            neoStores.Close();

            // Make the schema store inaccessible, to sabotage the next initialisation we'll do.
            assumeTrue(schemaStore.setReadable(false));
            assumeTrue(schemaStore.setWritable(false));

            try
            {
                // This should fail due to the permissions we changed above.
                // And when it fails, the already-opened stores should be closed.
                new NeoStores(databaseLayout, config, idGenFactory, pageCache, logProvider, fs, versions, formats, create, storeTypes, openOptions);
                fail("Opening NeoStores should have thrown.");
            }
            catch (Exception)
            {
            }

            // We verify that the successfully opened stores were closed again by the failed NeoStores open,
            // by closing the page cache, which will throw if not all files have been unmapped.
            pageCache.Close();
        }
Exemple #11
0
        private DirectStoreAccess DirectStoreAccess(bool readOnly)
        {
            if (_directStoreAccess == null)
            {
                _life.start();
                JobScheduler scheduler = _life.add(JobSchedulerFactory.createInitialisedScheduler());
                _fileSystem = new DefaultFileSystemAbstraction();
                PageCache   pageCache   = GetPageCache(_fileSystem);
                LogProvider logProvider = NullLogProvider.Instance;
                Config      config      = Config.defaults(GraphDatabaseSettings.read_only, readOnly ? TRUE : FALSE);
                DefaultIdGeneratorFactory idGeneratorFactory = new DefaultIdGeneratorFactory(_fileSystem);
                StoreFactory storeFactory = new StoreFactory(_directory.databaseLayout(), config, idGeneratorFactory, pageCache, _fileSystem, logProvider, EmptyVersionContextSupplier.EMPTY);
                _neoStore = storeFactory.OpenAllNeoStores();
                StoreAccess nativeStores;
                if (_keepStatistics)
                {
                    AccessStatistics accessStatistics = new AccessStatistics();
                    _statistics  = new VerboseStatistics(accessStatistics, new DefaultCounts(defaultConsistencyCheckThreadsNumber()), NullLog.Instance);
                    nativeStores = new AccessStatsKeepingStoreAccess(_neoStore, accessStatistics);
                }
                else
                {
                    _statistics  = Statistics.NONE;
                    nativeStores = new StoreAccess(_neoStore);
                }
                nativeStores.Initialize();

                IndexStoreView indexStoreView = new NeoStoreIndexStoreView(LockService.NO_LOCK_SERVICE, nativeStores.RawNeoStores);

                Monitors         monitors       = new Monitors();
                LabelScanStore   labelScanStore = StartLabelScanStore(pageCache, indexStoreView, monitors, readOnly);
                IndexProviderMap indexes        = CreateIndexes(pageCache, _fileSystem, _directory.databaseDir(), config, scheduler, logProvider, monitors);
                TokenHolders     tokenHolders   = new TokenHolders(new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_PROPERTY_KEY), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_LABEL), new DelegatingTokenHolder(new ReadOnlyTokenCreator(), Org.Neo4j.Kernel.impl.core.TokenHolder_Fields.TYPE_RELATIONSHIP_TYPE));
                tokenHolders.PropertyKeyTokens().InitialTokens      = _neoStore.PropertyKeyTokenStore.Tokens;
                tokenHolders.LabelTokens().InitialTokens            = _neoStore.LabelTokenStore.Tokens;
                tokenHolders.RelationshipTypeTokens().InitialTokens = _neoStore.RelationshipTypeTokenStore.Tokens;
                _directStoreAccess = new DirectStoreAccess(nativeStores, labelScanStore, indexes, tokenHolders);
            }
            return(_directStoreAccess);
        }
Exemple #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void main(String... args) throws Exception
        public static void Main(params string[] args)
        {
            if (args == null || args.Length == 0)
            {
                Console.Error.WriteLine("SYNTAX: [file[:id[,id]*]]+");
                Console.Error.WriteLine("where 'id' can be single id or range like: lowId-highId");
                return;
            }

            using (DefaultFileSystemAbstraction fs = new DefaultFileSystemAbstraction(), PageCache pageCache = createPageCache(fs, createInitialisedScheduler()))
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory idGeneratorFactory = new org.neo4j.kernel.impl.store.id.DefaultIdGeneratorFactory(fs);
                DefaultIdGeneratorFactory        idGeneratorFactory = new DefaultIdGeneratorFactory(fs);
                System.Func <File, StoreFactory> createStoreFactory = file => new StoreFactory(DatabaseLayout.of(file.ParentFile), Config.defaults(), idGeneratorFactory, pageCache, fs, LogProvider(), EmptyVersionContextSupplier.EMPTY);

                foreach (string arg in args)
                {
                    DumpFile(createStoreFactory, arg);
                }
            }
        }
Exemple #13
0
 public AbstractDynamicStoreAnonymousInnerClass(AbstractDynamicStoreTest outerInstance, File storeFile, File idFile, Config defaults, DefaultIdGeneratorFactory idGeneratorFactory, PageCache pageCache, NullLogProvider getInstance, Org.Neo4j.Kernel.impl.store.format.RecordFormat <DynamicRecord> dynamic, string storeVersion) : base(storeFile, idFile, defaults, IdType.ARRAY_BLOCK, idGeneratorFactory, pageCache, getInstance, "test", BLOCK_SIZE, dynamic, storeVersion)
 {
     this.outerInstance = outerInstance;
 }