@Override public void start() throws IOException { life = new LifeSupport(); readOnly = config.get(Configuration.read_only); storeDir = config.get(Configuration.store_dir); File store = config.get(Configuration.neo_store); storeFactory.ensureStoreExists(); final TransactionFactory tf; if (providers.shouldInterceptCommitting()) { tf = new InterceptingTransactionFactory(); } else { tf = new TransactionFactory(); } neoStore = storeFactory.newNeoStore(store); neoStoreTransactionContextSupplier = new NeoStoreTransactionContextSupplier(neoStore); schemaCache = new SchemaCache(Collections.<SchemaRule>emptyList()); final NodeManager nodeManager = dependencyResolver.resolveDependency(NodeManager.class); Iterator<? extends Cache<?>> caches = nodeManager.caches().iterator(); persistenceCache = new PersistenceCache( (AutoLoadingCache<NodeImpl>) caches.next(), (AutoLoadingCache<RelationshipImpl>) caches.next(), new Thunk<GraphPropertiesImpl>() { @Override public GraphPropertiesImpl evaluate() { return nodeManager.getGraphProperties(); } }, nodeManager); cacheAccess = new BridgingCacheAccess(nodeManager, schemaCache, updateableSchemaState, persistenceCache); try { indexProvider = dependencyResolver.resolveDependency( SchemaIndexProvider.class, SchemaIndexProvider.HIGHEST_PRIORITIZED_OR_NONE); // TODO: Build a real provider map DefaultSchemaIndexProviderMap providerMap = new DefaultSchemaIndexProviderMap(indexProvider); indexingService = life.add( new IndexingService( scheduler, providerMap, new NeoStoreIndexStoreView(locks, neoStore), tokenNameLookup, updateableSchemaState, logging)); integrityValidator = new IntegrityValidator(neoStore, indexingService); xaContainer = xaFactory.newXaContainer( this, config.get(Configuration.logical_log), new CommandFactory(neoStore, indexingService), new NeoStoreInjectedTransactionValidator(integrityValidator), tf, stateFactory, providers, readOnly); labelScanStore = life.add( dependencyResolver .resolveDependency( LabelScanStoreProvider.class, LabelScanStoreProvider.HIGHEST_PRIORITIZED) .getLabelScanStore()); fileListing = new NeoStoreFileListing(xaContainer, storeDir, labelScanStore, indexingService); kernel = life.add( new Kernel( txManager, propertyKeyTokens, labelTokens, relationshipTypeTokens, persistenceManager, lockManager, updateableSchemaState, schemaWriteGuard, indexingService, nodeManager, neoStore, persistenceCache, schemaCache, providerMap, labelScanStore, readOnly)); life.init(); // TODO: Why isn't this done in the init() method of the indexing service? if (!readOnly) { neoStore.setRecoveredStatus(true); try { indexingService.initIndexes(loadIndexRules()); xaContainer.openLogicalLog(); } finally { neoStore.setRecoveredStatus(false); } } if (!xaContainer.getResourceManager().hasRecoveredTransactions()) { neoStore.makeStoreOk(); } else { msgLog.debug("Waiting for TM to take care of recovered " + "transactions."); } idGenerators = new ArrayMap<>((byte) 5, false, false); this.idGenerators.put(Node.class, neoStore.getNodeStore()); this.idGenerators.put(Relationship.class, neoStore.getRelationshipStore()); this.idGenerators.put(RelationshipType.class, neoStore.getRelationshipTypeStore()); this.idGenerators.put(Label.class, neoStore.getLabelTokenStore()); this.idGenerators.put(PropertyStore.class, neoStore.getPropertyStore()); this.idGenerators.put( PropertyKeyTokenRecord.class, neoStore.getPropertyStore().getPropertyKeyTokenStore()); setLogicalLogAtCreationTime(xaContainer.getLogicalLog()); life.start(); } catch (Throwable e) { // Something unexpected happened during startup try { // Close the neostore, so that locks are released properly neoStore.close(); } catch (Exception closeException) { msgLog.logMessage("Couldn't close neostore after startup failure"); } throw Exceptions.launderedException(e); } }
private void initializeStores() throws IOException { LockManager lockManager = new LockManagerImpl(new RagManager()); final Config config = new Config( MapUtil.stringMap( InternalAbstractGraphDatabase.Configuration.store_dir.name(), path.getPath(), InternalAbstractGraphDatabase.Configuration.neo_store.name(), "neo", InternalAbstractGraphDatabase.Configuration.logical_log.name(), file("nioneo_logical.log").getPath()), GraphDatabaseSettings.class); StoreFactory sf = new StoreFactory( config, new DefaultIdGeneratorFactory(), new DefaultWindowPoolFactory(), fs.get(), StringLogger.DEV_NULL, null); NodeManager nodeManager = mock(NodeManager.class); @SuppressWarnings("rawtypes") List caches = Arrays.asList((Cache) mock(AutoLoadingCache.class), (Cache) mock(AutoLoadingCache.class)); when(nodeManager.caches()).thenReturn(caches); ds = new NeoStoreXaDataSource( config, sf, StringLogger.DEV_NULL, new XaFactory( config, TxIdGenerator.DEFAULT, new PlaceboTm(lockManager, TxIdGenerator.DEFAULT), fs.get(), new Monitors(), new DevNullLoggingService(), RecoveryVerifier.ALWAYS_VALID, LogPruneStrategies.NO_PRUNING), TransactionStateFactory.noStateFactory(new DevNullLoggingService()), new TransactionInterceptorProviders( Collections.<TransactionInterceptorProvider>emptyList(), dependencyResolverForConfig(config)), null, new SingleLoggingService(DEV_NULL), new KernelSchemaStateStore(), mock(TokenNameLookup.class), dependencyResolverForNoIndexProvider(nodeManager), mock(AbstractTransactionManager.class), mock(PropertyKeyTokenHolder.class), mock(LabelTokenHolder.class), mock(RelationshipTypeTokenHolder.class), mock(PersistenceManager.class), mock(LockManager.class), mock(SchemaWriteGuard.class)); ds.init(); ds.start(); xaCon = ds.getXaConnection(); pStore = xaCon.getPropertyStore(); rtStore = xaCon.getRelationshipTypeStore(); }