Beispiel #1
0
 public override void CheckIndexRule(StoreIndexDescriptor rule, DynamicRecord record, RecordAccess records, CheckerEngine <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport> engine)
 {
     if (rule.CanSupportUniqueConstraint())
     {
         DynamicRecord obligation = outerInstance.indexObligations[rule.Id];
         if (obligation == null)                                // no pointer to here
         {
             if (rule.OwningConstraint != null)                 // we only expect a pointer if we have an owner
             {
                 engine.Report().missingObligation(Org.Neo4j.Storageengine.Api.schema.SchemaRule_Kind.UniquenessConstraint);
             }
         }
         else
         {
             // if someone points to here, it must be our owner
             if (obligation.Id != rule.OwningConstraint.Value)
             {
                 engine.Report().constraintIndexRuleNotReferencingBack(obligation);
             }
         }
     }
     if (outerInstance.indexAccessors.NotOnlineRules().Contains(rule))
     {
         engine.Report().schemaRuleNotOnline(rule);
     }
 }
Beispiel #2
0
            public override void CheckIndexRule(StoreIndexDescriptor rule, DynamicRecord record, RecordAccess records, CheckerEngine <DynamicRecord, Org.Neo4j.Consistency.report.ConsistencyReport_SchemaConsistencyReport> engine)
            {
                outerInstance.checkSchema(rule, record, records, engine);

                if (rule.CanSupportUniqueConstraint() && rule.OwningConstraint != null)
                {
                    DynamicRecord previousObligation = outerInstance.constraintObligations[rule.OwningConstraint] = record.Clone();
                    if (previousObligation != null)
                    {
                        engine.Report().duplicateObligation(previousObligation);
                    }
                }
            }
Beispiel #3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public boolean visitSchemaRuleCommand(Command.SchemaRuleCommand command) throws java.io.IOException
            public override bool VisitSchemaRuleCommand(Command.SchemaRuleCommand command)
            {
                SchemaRule schemaRule = command.SchemaRule;

                if (command.SchemaRule is StoreIndexDescriptor)
                {
                    StoreIndexDescriptor indexRule = ( StoreIndexDescriptor )schemaRule;
                    // Why apply index updates here? Here's the thing... this is a batch applier, which means that
                    // index updates are gathered throughout the batch and applied in the end of the batch.
                    // Assume there are some transactions creating or modifying nodes that may not be covered
                    // by an existing index, but a later transaction in the same batch creates such an index.
                    // In that scenario the index would be created, populated and then fed the [this time duplicate]
                    // update for the node created before the index. The most straight forward solution is to
                    // apply pending index updates up to this point in this batch before index schema changes occur.
                    outerInstance.applyPendingLabelAndIndexUpdates();

                    switch (command.Mode)
                    {
                    case UPDATE:
                        // Shouldn't we be more clear about that we are waiting for an index to come online here?
                        // right now we just assume that an update to index records means wait for it to be online.
                        if (indexRule.CanSupportUniqueConstraint())
                        {
                            // Register activations into the IndexActivator instead of IndexingService to avoid deadlock
                            // that could insue for applying batches of transactions where a previous transaction in the same
                            // batch acquires a low-level commit lock that prevents the very same index population to complete.
                            outerInstance.indexActivator.ActivateIndex(schemaRule.Id);
                        }
                        break;

                    case CREATE:
                        // Add to list so that all these indexes will be created in one call later
                        CreatedIndexes = CreatedIndexes == null ? new List <StoreIndexDescriptor>() : CreatedIndexes;
                        CreatedIndexes.Add(indexRule);
                        break;

                    case DELETE:
                        outerInstance.indexingService.DropIndex(indexRule);
                        outerInstance.indexActivator.IndexDropped(schemaRule.Id);
                        break;

                    default:
                        throw new System.InvalidOperationException(command.Mode.name());
                    }
                }
                // Keep IndexingService updated on constraint changes
                else if (schemaRule is ConstraintRule)
                {
                    ConstraintRule constraintRule = ( ConstraintRule )schemaRule;
                    switch (command.Mode)
                    {
                    case CREATE:
                    case UPDATE:
                        outerInstance.indexingService.PutConstraint(constraintRule);
                        break;

                    case DELETE:
                        outerInstance.indexingService.RemoveConstraint(constraintRule.Id);
                        break;

                    default:
                        throw new System.InvalidOperationException(command.Mode.name());
                    }
                }
                return(false);
            }