Esempio n. 1
0
  private StoreLayerModule buildStoreLayer(
      Config config,
      final NeoStore neoStore,
      PersistenceCache persistenceCache,
      PropertyKeyTokenHolder propertyKeyTokenHolder,
      LabelTokenHolder labelTokens,
      RelationshipTypeTokenHolder relationshipTypeTokens,
      IndexingService indexingService,
      SchemaCache schemaCache) {
    Provider<NeoStore> neoStoreProvider =
        new Provider<NeoStore>() {
          @Override
          public NeoStore instance() {
            return neoStoreModule.neoStore();
          }
        };

    final StoreReadLayer storeLayer;
    if (config.get(GraphDatabaseSettings.cache_type).equals(CacheLayer.EXPERIMENTAL_OFF)) {
      storeLayer =
          new DiskLayer(
              propertyKeyTokenHolder,
              labelTokens,
              relationshipTypeTokens,
              new SchemaStorage(neoStore.getSchemaStore()),
              neoStoreProvider,
              indexingService);
    } else {
      storeLayer =
          new CacheLayer(
              new DiskLayer(
                  propertyKeyTokenHolder,
                  labelTokens,
                  relationshipTypeTokens,
                  new SchemaStorage(neoStore.getSchemaStore()),
                  neoStoreProvider,
                  indexingService),
              persistenceCache,
              indexingService,
              schemaCache);
    }

    return new StoreLayerModule() {
      @Override
      public StoreReadLayer storeLayer() {
        return storeLayer;
      }
    };
  }
  public NeoStoreTransactionContext(
      NeoStoreTransactionContextSupplier supplier, NeoStore neoStore) {
    this.supplier = supplier;
    this.neoStore = neoStore;

    recordChangeSet = new RecordChangeSet(neoStore);

    locker = new TransactionalRelationshipLocker();
    relationshipGroupGetter = new RelationshipGroupGetter(neoStore.getRelationshipGroupStore());
    propertyTraverser = new PropertyTraverser();
    propertyCreator = new PropertyCreator(neoStore.getPropertyStore(), propertyTraverser);
    propertyDeleter = new PropertyDeleter(neoStore.getPropertyStore(), propertyTraverser);
    relationshipCreator =
        new RelationshipCreator(locker, relationshipGroupGetter, neoStore.getDenseNodeThreshold());
    relationshipDeleter = new RelationshipDeleter(locker, relationshipGroupGetter, propertyDeleter);
  }
Esempio n. 3
0
  private IndexingModule buildIndexing(
      Config config,
      JobScheduler scheduler,
      SchemaIndexProvider indexProvider,
      LockService lockService,
      TokenNameLookup tokenNameLookup,
      Logging logging,
      IndexingService.Monitor indexingServiceMonitor,
      NeoStore neoStore,
      UpdateableSchemaState updateableSchemaState) {
    final DefaultSchemaIndexProviderMap providerMap =
        new DefaultSchemaIndexProviderMap(indexProvider);

    final IndexingService indexingService =
        IndexingService.create(
            new IndexSamplingConfig(config),
            scheduler,
            providerMap,
            new NeoStoreIndexStoreView(lockService, neoStore),
            tokenNameLookup,
            updateableSchemaState,
            toList(new SchemaStorage(neoStore.getSchemaStore()).allIndexRules()),
            logging,
            indexingServiceMonitor);
    final IntegrityValidator integrityValidator = new IntegrityValidator(neoStore, indexingService);

    // TODO Move to constructor
    final LabelScanStore labelScanStore =
        dependencyResolver
            .resolveDependency(
                LabelScanStoreProvider.class, LabelScanStoreProvider.HIGHEST_PRIORITIZED)
            .getLabelScanStore();

    life.add(indexingService);
    life.add(labelScanStore);

    return new IndexingModule() {
      @Override
      public IndexingService indexingService() {
        return indexingService;
      }

      @Override
      public LabelScanStore labelScanStore() {
        return labelScanStore;
      }

      @Override
      public IntegrityValidator integrityValidator() {
        return integrityValidator;
      }

      @Override
      public SchemaIndexProviderMap schemaIndexProviderMap() {
        return providerMap;
      }
    };
  }
 public void createRelationshipTypeToken(String name, int id) {
   TokenCreator<RelationshipTypeTokenRecord> creator =
       new TokenCreator<>(neoStore.getRelationshipTypeTokenStore());
   creator.createToken(name, id, getRelationshipTypeTokenRecords());
 }
 public void createLabelToken(String name, int id) {
   TokenCreator<LabelTokenRecord> creator = new TokenCreator<>(neoStore.getLabelTokenStore());
   creator.createToken(name, id, getLabelTokenRecords());
 }
 public void createPropertyKeyToken(String name, int id) {
   TokenCreator<PropertyKeyTokenRecord> creator =
       new TokenCreator<>(neoStore.getPropertyKeyTokenStore());
   creator.createToken(name, id, getPropertyKeyTokenRecords());
 }
Esempio n. 7
0
  private CacheModule buildCaches(
      final NeoStore neoStore,
      Caches cacheProvider,
      NodeManager nodeManager,
      LabelTokenHolder labelTokens,
      RelationshipTypeTokenHolder relationshipTypeTokens,
      PropertyKeyTokenHolder propertyKeyTokenHolder) {
    final UpdateableSchemaState updateableSchemaState =
        new KernelSchemaStateStore(logging.getMessagesLog(KernelSchemaStateStore.class));

    final SchemaCache schemaCache = new SchemaCache(Collections.<SchemaRule>emptyList());

    final AutoLoadingCache<NodeImpl> nodeCache =
        new AutoLoadingCache<>(cacheProvider.node(), nodeLoader(neoStore.getNodeStore()));
    final AutoLoadingCache<RelationshipImpl> relationshipCache =
        new AutoLoadingCache<>(
            cacheProvider.relationship(), relationshipLoader(neoStore.getRelationshipStore()));
    RelationshipLoader relationshipLoader =
        new RelationshipLoader(
            lockService, relationshipCache, new RelationshipChainLoader(neoStore));
    final PersistenceCache persistenceCache =
        new PersistenceCache(
            nodeCache,
            relationshipCache,
            nodeManager,
            relationshipLoader,
            propertyKeyTokenHolder,
            relationshipTypeTokens,
            labelTokens);
    final CacheAccessBackDoor cacheAccess =
        new BridgingCacheAccess(schemaCache, updateableSchemaState, persistenceCache);

    life.add(
        new LifecycleAdapter() {
          @Override
          public void start() throws Throwable {
            loadSchemaCache();
          }

          @Override
          public void stop() throws Throwable {}
        });

    return new CacheModule() {
      @Override
      public SchemaCache schemaCache() {
        return schemaCache;
      }

      @Override
      public UpdateableSchemaState updateableSchemaState() {
        return updateableSchemaState;
      }

      @Override
      public PersistenceCache persistenceCache() {
        return persistenceCache;
      }

      @Override
      public CacheAccessBackDoor cacheAccess() {
        return cacheAccess;
      }

      @Override
      public Cache<NodeImpl> nodeCache() {
        return nodeCache;
      }

      @Override
      public Cache<RelationshipImpl> relationshipCache() {
        return relationshipCache;
      }
    };
  }