コード例 #1
0
 public IndexSamplingControllerFactory(IndexSamplingConfig config, IndexStoreView storeView, JobScheduler scheduler, TokenNameLookup tokenNameLookup, LogProvider logProvider)
 {
     this._config          = config;
     this._storeView       = storeView;
     this._scheduler       = scheduler;
     this._tokenNameLookup = tokenNameLookup;
     this._logProvider     = logProvider;
 }
コード例 #2
0
 public RecoveryConditionAnonymousInnerClass(IndexSamplingControllerFactory outerInstance, LogProvider logProvider, TokenNameLookup tokenNameLookup)
 {
     this.outerInstance    = outerInstance;
     this._logProvider     = logProvider;
     this._tokenNameLookup = tokenNameLookup;
     log      = logProvider.GetLog(typeof(IndexSamplingController));
     register = newDoubleLongRegister();
 }
コード例 #3
0
 public static string[] GetPropertyKeys(TokenNameLookup tokenNameLookup, int[] propertyIds)
 {
     string[] propertyKeys = new string[propertyIds.Length];
     for (int i = 0; i < propertyIds.Length; i++)
     {
         propertyKeys[i] = tokenNameLookup.PropertyKeyGetName(propertyIds[i]);
     }
     return(propertyKeys);
 }
コード例 #4
0
 public static string[] GetPropertyKeys(TokenNameLookup tokenNameLookup, LabelSchemaDescriptor descriptor)
 {
     int[]    propertyKeyIds = descriptor.PropertyIds;
     string[] propertyKeys   = new string[propertyKeyIds.Length];
     for (int i = 0; i < propertyKeyIds.Length; i++)
     {
         propertyKeys[i] = tokenNameLookup.PropertyKeyGetName(propertyKeyIds[i]);
     }
     return(propertyKeys);
 }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowExceptionOnRelationshipRuleNotFound() throws org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionOnRelationshipRuleNotFound()
        {
            TokenNameLookup tokenNameLookup = DefaultTokenNameLookup;

            // EXPECT
            ExpectedException.expect(typeof(SchemaRuleNotFoundException));
            ExpectedException.expect(new KernelExceptionUserMessageMatcher <>(tokenNameLookup, "No relationship property existence constraint was found for -[:Type1(prop1)]-."));

            //WHEN
            _storage.constraintsGetSingle(ConstraintDescriptorFactory.existsForRelType(TypeId(TYPE1), PropId(PROP1)));
        }
コード例 #6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void showIndices(DbStructureVisitor visitor, org.neo4j.kernel.api.KernelTransaction ktx, org.neo4j.internal.kernel.api.TokenNameLookup nameLookup) throws org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException
        private void ShowIndices(DbStructureVisitor visitor, KernelTransaction ktx, TokenNameLookup nameLookup)
        {
            SchemaRead schemaRead = ktx.SchemaRead();

            foreach (IndexReference reference in loop(sortByType(schemaRead.IndexesGetAll())))
            {
                string userDescription        = reference.Schema().userDescription(nameLookup);
                double uniqueValuesPercentage = schemaRead.IndexUniqueValuesSelectivity(reference);
                long   size = schemaRead.IndexSize(reference);
                visitor.VisitIndex(( IndexDescriptor )reference, userDescription, uniqueValuesPercentage, size);
            }
        }
コード例 #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowExceptionOnNodeRuleNotFound() throws org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionOnNodeRuleNotFound()
        {
            // GIVEN
            TokenNameLookup tokenNameLookup = DefaultTokenNameLookup;

            // EXPECT
            ExpectedException.expect(typeof(SchemaRuleNotFoundException));
            ExpectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "No node property existence constraint was found for :Label1(prop1)."));

            // WHEN
            _storage.constraintsGetSingle(ConstraintDescriptorFactory.existsForLabel(LabelId(LABEL1), PropId(PROP1)));
        }
コード例 #8
0
        public override string GetUserMessage(TokenNameLookup tokenNameLookup)
        {
            string message = "Unable to drop " + _constraint.userDescription(tokenNameLookup);

            if (Cause is KernelException)
            {
                KernelException cause = ( KernelException )Cause;

//JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET:
//ORIGINAL LINE: return String.format("%s:%n%s", message, cause.getUserMessage(tokenNameLookup));
                return(string.Format("%s:%n%s", message, cause.GetUserMessage(tokenNameLookup)));
            }
            return(message);
        }
コード例 #9
0
        internal ModularDatabaseCreationContext(string databaseName, PlatformModule platformModule, DatabaseEditionContext editionContext, Procedures procedures, GraphDatabaseFacade facade)
        {
            this._databaseName = databaseName;
            this._config       = platformModule.Config;
            DatabaseIdContext idContext = editionContext.IdContext;

            this._idGeneratorFactory = idContext.IdGeneratorFactory;
            this._idController       = idContext.IdController;
            this._databaseLayout     = platformModule.StoreLayout.databaseLayout(databaseName);
            this._logService         = platformModule.Logging;
            this._scheduler          = platformModule.JobScheduler;
            this._globalDependencies = platformModule.Dependencies;
            this._tokenHolders       = editionContext.CreateTokenHolders();
            this._tokenNameLookup    = new NonTransactionalTokenNameLookup(_tokenHolders);
            this._locks = editionContext.CreateLocks();
            this._statementLocksFactory    = editionContext.CreateStatementLocksFactory();
            this._schemaWriteGuard         = editionContext.SchemaWriteGuard;
            this._transactionEventHandlers = new TransactionEventHandlers(facade);
            this._monitors = new Monitors(platformModule.Monitors);
            this._indexingServiceMonitor = _monitors.newMonitor(typeof(IndexingService.Monitor));
            this._physicalLogMonitor     = _monitors.newMonitor(typeof(LogFileCreationMonitor));
            this._fs = platformModule.FileSystem;
            this._transactionStats = editionContext.CreateTransactionMonitor();
            this._databaseHealth   = new DatabaseHealth(platformModule.PanicEventGenerator, _logService.getInternalLog(typeof(DatabaseHealth)));
            this._transactionHeaderInformationFactory = editionContext.HeaderInformationFactory;
            this._commitProcessFactory  = editionContext.CommitProcessFactory;
            this._autoIndexing          = new InternalAutoIndexing(platformModule.Config, _tokenHolders.propertyKeyTokens());
            this._indexConfigStore      = new IndexConfigStore(_databaseLayout, _fs);
            this._explicitIndexProvider = new DefaultExplicitIndexProvider();
            this._pageCache             = platformModule.PageCache;
            this._constraintSemantics   = editionContext.ConstraintSemantics;
            this._tracers    = platformModule.Tracers;
            this._procedures = procedures;
            this._ioLimiter  = editionContext.IoLimiter;
            this._clock      = platformModule.Clock;
            this._databaseAvailabilityGuard    = editionContext.CreateDatabaseAvailabilityGuard(_clock, _logService, _config);
            this._databaseAvailability         = new DatabaseAvailability(_databaseAvailabilityGuard, _transactionStats, platformModule.Clock, AwaitActiveTransactionDeadlineMillis);
            this._coreAPIAvailabilityGuard     = new CoreAPIAvailabilityGuard(_databaseAvailabilityGuard, editionContext.TransactionStartTimeout);
            this._accessCapability             = editionContext.AccessCapability;
            this._storeCopyCheckPointMutex     = new StoreCopyCheckPointMutex();
            this._recoveryCleanupWorkCollector = platformModule.RecoveryCleanupWorkCollector;
            this._databaseInfo               = platformModule.DatabaseInfo;
            this._versionContextSupplier     = platformModule.VersionContextSupplier;
            this._collectionsFactorySupplier = platformModule.CollectionsFactorySupplier;
            this._kernelExtensionFactories   = platformModule.KernelExtensionFactories;
            this._watcherServiceFactory      = editionContext.WatcherServiceFactory;
            this._facade          = facade;
            this._engineProviders = platformModule.EngineProviders;
        }
コード例 #10
0
        public virtual string EvidenceMessage(TokenNameLookup tokenNameLookup, SchemaDescriptor schema)
        {
            Debug.Assert(Schema.PropertyIds.length == _propertyValues.size());

            string labelName = tokenNameLookup.LabelGetName(Schema.keyId());

            if (_addedNodeId == NO_SUCH_NODE)
            {
                return(format("Node(%d) already exists with label `%s` and %s", _existingNodeId, labelName, PropertyString(tokenNameLookup, Schema.PropertyIds)));
            }
            else
            {
                return(format("Both Node(%d) and Node(%d) have the label `%s` and %s", _existingNodeId, _addedNodeId, labelName, PropertyString(tokenNameLookup, Schema.PropertyIds)));
            }
        }
コード例 #11
0
        private string PropertyString(TokenNameLookup tokenNameLookup, int[] propertyIds)
        {
            StringBuilder sb  = new StringBuilder();
            string        sep = propertyIds.Length > 1 ? "properties " : "property ";

            for (int i = 0; i < propertyIds.Length; i++)
            {
                sb.Append(sep);
                sep = ", ";
                sb.Append('`');
                sb.Append(tokenNameLookup.PropertyKeyGetName(propertyIds[i]));
                sb.Append("` = ");
                sb.Append(_propertyValues.valueAt(i).prettyPrint());
            }
            return(sb.ToString());
        }
コード例 #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowExceptionOnRelationshipDuplicateRuleFound() throws org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionOnRelationshipDuplicateRuleFound()
        {
            // GIVEN
            TokenNameLookup tokenNameLookup = DefaultTokenNameLookup;

            SchemaStorage schemaStorageSpy = Mockito.spy(_storage);

            Mockito.when(schemaStorageSpy.LoadAllSchemaRules(any(), any(), anyBoolean())).thenReturn(Iterators.iterator(GetRelationshipPropertyExistenceConstraintRule(1L, TYPE1, PROP1), GetRelationshipPropertyExistenceConstraintRule(2L, TYPE1, PROP1)));

            //EXPECT
            ExpectedException.expect(typeof(DuplicateSchemaRuleException));
            ExpectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "Multiple relationship property existence constraints found for -[:Type1(prop1)]-."));

            // WHEN
            schemaStorageSpy.ConstraintsGetSingle(ConstraintDescriptorFactory.existsForRelType(TypeId(TYPE1), PropId(PROP1)));
        }
コード例 #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowExceptionOnNodeDuplicateRuleFound() throws org.neo4j.kernel.api.exceptions.schema.DuplicateSchemaRuleException, org.neo4j.kernel.api.exceptions.schema.SchemaRuleNotFoundException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldThrowExceptionOnNodeDuplicateRuleFound()
        {
            // GIVEN
            TokenNameLookup tokenNameLookup = DefaultTokenNameLookup;

            SchemaStorage schemaStorageSpy = Mockito.spy(_storage);

            Mockito.when(schemaStorageSpy.LoadAllSchemaRules(any(), any(), anyBoolean())).thenReturn(Iterators.iterator(GetUniquePropertyConstraintRule(1L, LABEL1, PROP1), GetUniquePropertyConstraintRule(2L, LABEL1, PROP1)));

            //EXPECT
            ExpectedException.expect(typeof(DuplicateSchemaRuleException));
            ExpectedException.expect(new KernelExceptionUserMessageMatcher(tokenNameLookup, "Multiple uniqueness constraints found for :Label1(prop1)."));

            // WHEN
            schemaStorageSpy.ConstraintsGetSingle(ConstraintDescriptorFactory.uniqueForLabel(LabelId(LABEL1), PropId(PROP1)));
        }
コード例 #14
0
        public override string GetUserMessage(TokenNameLookup tokenNameLookup)
        {
            SchemaDescriptor schema  = ConstraintConflict.schema();
            StringBuilder    message = new StringBuilder();

            for (IEnumerator <IndexEntryConflictException> iterator = _conflicts.GetEnumerator(); iterator.MoveNext();)
            {
                IndexEntryConflictException conflict = iterator.Current;
                message.Append(conflict.EvidenceMessage(tokenNameLookup, schema));
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                if (iterator.hasNext())
                {
                    message.Append(Environment.NewLine);
                }
            }
            return(message.ToString());
        }
コード例 #15
0
        public override string GetUserMessage(TokenNameLookup tokenNameLookup)
        {
            string message = "Unable to create " + _constraint.prettyPrint(tokenNameLookup);

            if (!string.ReferenceEquals(_cause, null))
            {
//JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET:
//ORIGINAL LINE: message = String.format("%s:%n%s", message, cause);
                message = string.Format("%s:%n%s", message, _cause);
            }
            if (Cause is KernelException)
            {
                KernelException cause = ( KernelException )Cause;

//JAVA TO C# CONVERTER TODO TASK: The following line has a Java format specifier which cannot be directly translated to .NET:
//ORIGINAL LINE: return String.format("%s:%n%s", message, cause.getUserMessage(tokenNameLookup));
                return(string.Format("%s:%n%s", message, cause.GetUserMessage(tokenNameLookup)));
            }
            return(message);
        }
コード例 #16
0
ファイル: SchemaUtil.cs プロジェクト: Neo4Net/Neo4Net
        public static string NiceProperties(TokenNameLookup tokenNameLookup, int[] propertyIds, string prefix, bool useBrackets)
        {
            StringBuilder properties = new StringBuilder();

            if (useBrackets)
            {
                properties.Append("(");
            }
            for (int i = 0; i < propertyIds.Length; i++)
            {
                if (i > 0)
                {
                    properties.Append(", ");
                }
                properties.Append(prefix).Append(tokenNameLookup.PropertyKeyGetName(propertyIds[i]));
            }
            if (useBrackets)
            {
                properties.Append(")");
            }
            return(properties.ToString());
        }
コード例 #17
0
 protected internal static string MessageWithLabelAndPropertyName(TokenNameLookup tokenNameLookup, string formatString, SchemaDescriptor descriptor)
 {
     return(string.format(formatString, descriptor.UserDescription(tokenNameLookup)));
 }
コード例 #18
0
        public RecordStorageEngine(DatabaseLayout databaseLayout, Config config, PageCache pageCache, FileSystemAbstraction fs, LogProvider logProvider, LogProvider userLogProvider, TokenHolders tokenHolders, SchemaState schemaState, ConstraintSemantics constraintSemantics, JobScheduler scheduler, TokenNameLookup tokenNameLookup, LockService lockService, IndexProviderMap indexProviderMap, IndexingService.Monitor indexingServiceMonitor, DatabaseHealth databaseHealth, ExplicitIndexProvider explicitIndexProvider, IndexConfigStore indexConfigStore, IdOrderingQueue explicitIndexTransactionOrdering, IdGeneratorFactory idGeneratorFactory, IdController idController, Monitors monitors, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, OperationalMode operationalMode, VersionContextSupplier versionContextSupplier)
        {
            this._tokenHolders   = tokenHolders;
            this._schemaState    = schemaState;
            this._lockService    = lockService;
            this._databaseHealth = databaseHealth;
            this._explicitIndexProviderLookup      = explicitIndexProvider;
            this._indexConfigStore                 = indexConfigStore;
            this._constraintSemantics              = constraintSemantics;
            this._explicitIndexTransactionOrdering = explicitIndexTransactionOrdering;

            this._idController = idController;
            StoreFactory factory = new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, fs, logProvider, versionContextSupplier);

            _neoStores = factory.OpenAllNeoStores(true);

            try
            {
                _schemaCache   = new SchemaCache(constraintSemantics, Collections.emptyList(), indexProviderMap);
                _schemaStorage = new SchemaStorage(_neoStores.SchemaStore);

                NeoStoreIndexStoreView neoStoreIndexStoreView = new NeoStoreIndexStoreView(lockService, _neoStores);
                bool readOnly = config.Get(GraphDatabaseSettings.read_only) && operationalMode == OperationalMode.single;
                monitors.AddMonitorListener(new LoggingMonitor(logProvider.GetLog(typeof(NativeLabelScanStore))));
                _labelScanStore = new NativeLabelScanStore(pageCache, databaseLayout, fs, new FullLabelStream(neoStoreIndexStoreView), readOnly, monitors, recoveryCleanupWorkCollector);

                _indexStoreView        = new DynamicIndexStoreView(neoStoreIndexStoreView, _labelScanStore, lockService, _neoStores, logProvider);
                this._indexProviderMap = indexProviderMap;
                _indexingService       = IndexingServiceFactory.createIndexingService(config, scheduler, indexProviderMap, _indexStoreView, tokenNameLookup, Iterators.asList(_schemaStorage.loadAllSchemaRules()), logProvider, userLogProvider, indexingServiceMonitor, schemaState, readOnly);

                _integrityValidator = new IntegrityValidator(_neoStores, _indexingService);
                _cacheAccess        = new BridgingCacheAccess(_schemaCache, schemaState, tokenHolders);

                _explicitIndexApplierLookup = new Org.Neo4j.Kernel.Impl.Api.ExplicitIndexApplierLookup_Direct(explicitIndexProvider);

                _labelScanStoreSync = new WorkSync <Supplier <LabelScanWriter>, LabelUpdateWork>(_labelScanStore.newWriter);

                _commandReaderFactory = new RecordStorageCommandReaderFactory();
                _indexUpdatesSync     = new WorkSync <IndexingUpdateService, IndexUpdatesWork>(_indexingService);

                _denseNodeThreshold = config.Get(GraphDatabaseSettings.dense_node_threshold);
                _recordIdBatchSize  = config.Get(GraphDatabaseSettings.record_id_batch_size);
            }
            catch (Exception failure)
            {
                _neoStores.close();
                throw failure;
            }
        }
コード例 #19
0
        private void ShowUniqueConstraints(DbStructureVisitor visitor, KernelTransaction ktx, TokenNameLookup nameLookup)
        {
            IEnumerator <ConstraintDescriptor> constraints = ktx.SchemaRead().constraintsGetAll();

            while (constraints.MoveNext())
            {
                ConstraintDescriptor constraint = constraints.Current;
                string userDescription          = constraint.PrettyPrint(nameLookup);

                if (constraint is UniquenessConstraintDescriptor)
                {
                    visitor.VisitUniqueConstraint(( UniquenessConstraintDescriptor )constraint, userDescription);
                }
                else if (constraint is NodeExistenceConstraintDescriptor)
                {
                    NodeExistenceConstraintDescriptor existenceConstraint = ( NodeExistenceConstraintDescriptor )constraint;
                    visitor.VisitNodePropertyExistenceConstraint(existenceConstraint, userDescription);
                }
                else if (constraint is RelExistenceConstraintDescriptor)
                {
                    RelExistenceConstraintDescriptor existenceConstraint = ( RelExistenceConstraintDescriptor )constraint;
                    visitor.VisitRelationshipPropertyExistenceConstraint(existenceConstraint, userDescription);
                }
                else if (constraint is NodeKeyConstraintDescriptor)
                {
                    NodeKeyConstraintDescriptor nodeKeyConstraint = ( NodeKeyConstraintDescriptor )constraint;
                    visitor.VisitNodeKeyConstraint(nodeKeyConstraint, userDescription);
                }
                else
                {
                    throw new System.ArgumentException("Unknown constraint type: " + constraint.GetType() + ", " + "constraint: " + constraint);
                }
            }
        }
コード例 #20
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: private IndexSamplingController.RecoveryCondition createIndexRecoveryCondition(final org.neo4j.logging.LogProvider logProvider, final org.neo4j.internal.kernel.api.TokenNameLookup tokenNameLookup)
        private IndexSamplingController.RecoveryCondition CreateIndexRecoveryCondition(LogProvider logProvider, TokenNameLookup tokenNameLookup)
        {
            return(new RecoveryConditionAnonymousInnerClass(this, logProvider, tokenNameLookup));
        }
コード例 #21
0
        public static IndexingService CreateIndexingService(Config config, JobScheduler scheduler, IndexProviderMap providerMap, IndexStoreView storeView, TokenNameLookup tokenNameLookup, IEnumerable <SchemaRule> schemaRules, LogProvider internalLogProvider, LogProvider userLogProvider, IndexingService.Monitor monitor, SchemaState schemaState, bool readOnly)
        {
            IndexSamplingConfig            samplingConfig        = new IndexSamplingConfig(config);
            MultiPopulatorFactory          multiPopulatorFactory = MultiPopulatorFactory.ForConfig(config);
            IndexMapReference              indexMapRef           = new IndexMapReference();
            IndexSamplingControllerFactory factory = new IndexSamplingControllerFactory(samplingConfig, storeView, scheduler, tokenNameLookup, internalLogProvider);
            IndexSamplingController        indexSamplingController = factory.Create(indexMapRef);
            IndexProxyCreator              proxySetup = new IndexProxyCreator(samplingConfig, storeView, providerMap, tokenNameLookup, internalLogProvider);

            return(new IndexingService(proxySetup, providerMap, indexMapRef, storeView, schemaRules, indexSamplingController, tokenNameLookup, scheduler, schemaState, multiPopulatorFactory, internalLogProvider, userLogProvider, monitor, readOnly));
        }
コード例 #22
0
 public override string GetUserMessage(TokenNameLookup tokenNameLookup)
 {
     return(format("Unable to validate constraint %s", ConstraintConflict.userDescription(tokenNameLookup)));
 }
コード例 #23
0
ファイル: SchemaUtil.cs プロジェクト: Neo4Net/Neo4Net
 public static string NiceProperties(TokenNameLookup tokenNameLookup, int[] propertyIds)
 {
     return(NiceProperties(tokenNameLookup, propertyIds, "", false));
 }