Example #1
0
        public void RebuildIndex(Node node, bool recursive = false, IndexRebuildLevel rebuildLevel = IndexRebuildLevel.IndexOnly)
        {
            // do nothing in case of IndexOnly level, because this is a NULL populator
            if (rebuildLevel == IndexRebuildLevel.IndexOnly)
            {
                return;
            }

            using (var op = SnTrace.Index.StartOperation("NullPopulator.RefreshIndex. Version: {0}, VersionId: {1}, recursive: {2}, level: {3}", node.Version, node.VersionId, recursive, rebuildLevel))
            {
                using (new Storage.Security.SystemAccount())
                {
                    if (recursive)
                    {
                        using (TreeLock.Acquire(node.Path))
                        {
                            foreach (var n in NodeEnumerator.GetNodes(node.Path))
                            {
                                DataBackingStore.SaveIndexDocument(n, false, false, out _);
                            }
                        }
                    }
                    else
                    {
                        TreeLock.AssertFree(node.Path);
                        DataBackingStore.SaveIndexDocument(node, false, false, out _);
                    }
                }
                op.Successful = true;
            }
        }
Example #2
0
        public async STT.Task RebuildIndexAsync(Node node, CancellationToken cancellationToken, bool recursive = false,
                                                IndexRebuildLevel rebuildLevel = IndexRebuildLevel.IndexOnly)
        {
            // do nothing in case of IndexOnly level, because this is a NULL populator
            if (rebuildLevel == IndexRebuildLevel.IndexOnly)
            {
                return;
            }

            using (var op = SnTrace.Index.StartOperation("NullPopulator.RefreshIndex. Version: {0}, VersionId: {1}, recursive: {2}, level: {3}", node.Version, node.VersionId, recursive, rebuildLevel))
            {
                using (new Storage.Security.SystemAccount())
                {
                    if (recursive)
                    {
                        using (await TreeLock.AcquireAsync(cancellationToken, node.Path).ConfigureAwait(false))
                        {
                            foreach (var n in NodeEnumerator.GetNodes(node.Path))
                            {
                                await DataStore.SaveIndexDocumentAsync(node, false, false, CancellationToken.None)
                                .ConfigureAwait(false);
                            }
                        }
                    }
                    else
                    {
                        await TreeLock.AssertFreeAsync(cancellationToken, node.Path).ConfigureAwait(false);

                        await DataStore.SaveIndexDocumentAsync(node, false, false, CancellationToken.None)
                        .ConfigureAwait(false);
                    }
                }
                op.Successful = true;
            }
        }
Example #3
0
        public void RebuildIndex(Node node, bool recursive = false, IndexRebuildLevel rebuildLevel = IndexRebuildLevel.IndexOnly)
        {
            if (rebuildLevel == IndexRebuildLevel.IndexOnly)
            {
                return;
            }

            using (var op = SnTrace.Index.StartOperation("NullPopulator.RefreshIndex. Version: {0}, VersionId: {1}, recursive: {2}, level: {3}", node.Version, node.VersionId, recursive, rebuildLevel))
            {
                bool hasBinary;
                using (new SenseNet.ContentRepository.Storage.Security.SystemAccount())
                {
                    if (recursive)
                    {
                        using (SenseNet.ContentRepository.Storage.TreeLock.Acquire(node.Path))
                        {
                            foreach (var n in NodeEnumerator.GetNodes(node.Path))
                            {
                                DataBackingStore.SaveIndexDocument(n, false, false, out hasBinary);
                            }
                        }
                    }
                    else
                    {
                        SenseNet.ContentRepository.Storage.TreeLock.AssertFree(node.Path);
                        DataBackingStore.SaveIndexDocument(node, false, false, out hasBinary);
                    }
                }
                op.Successful = true;
            }
        }
        // caller: IndexPopulator.Populator
        public void RebuildIndexDirectly(string path, IndexRebuildLevel level = IndexRebuildLevel.IndexOnly)
        {
            if (level == IndexRebuildLevel.DatabaseAndIndex)
            {
                using (var op2 = SnTrace.Index.StartOperation("IndexPopulator: Rebuild index documents."))
                {
                    using (new SystemAccount())
                    {
                        var node = Node.LoadNode(path);
                        DataBackingStore.SaveIndexDocument(node, false, false, out _);

                        Parallel.ForEach(NodeQuery.QueryNodesByPath(node.Path, true).Nodes,
                                         n => { DataBackingStore.SaveIndexDocument(n, false, false, out _); });
                    }
                    op2.Successful = true;
                }
            }

            using (var op = SnTrace.Index.StartOperation("IndexPopulator: Rebuild index."))
            {
                IndexManager.IndexingEngine.WriteIndex(
                    new[] { new SnTerm(IndexFieldName.InTree, path) },
                    null,
                    SearchManager.LoadIndexDocumentsByPath(path, IndexManager.GetNotIndexedNodeTypes())
                    .Select(d =>
                {
                    var indexDoc = IndexManager.CompleteIndexDocument(d);
                    OnNodeIndexed(d.Path);
                    return(indexDoc);
                }));
                op.Successful = true;
            }
        }
Example #5
0
        // caller: IndexPopulator.Populator
        public async STT.Task RebuildIndexDirectlyAsync(string path, CancellationToken cancellationToken,
                                                        IndexRebuildLevel level = IndexRebuildLevel.IndexOnly)
        {
            if (level == IndexRebuildLevel.DatabaseAndIndex)
            {
                using (var op2 = SnTrace.Index.StartOperation("IndexPopulator: Rebuild index documents."))
                {
                    using (new SystemAccount())
                    {
                        foreach (var node in Node.LoadNode(path).LoadVersions())
                        {
                            SnTrace.Test.Write("@@ WriteDoc: " + node.Path);
                            await DataStore.SaveIndexDocumentAsync(node, false, false, cancellationToken)
                            .ConfigureAwait(false);

                            OnIndexDocumentRefreshed(node.Path, node.Id, node.VersionId, node.Version.ToString());
                        }

                        //TODO: [async] make this parallel async (TPL DataFlow)
                        Parallel.ForEach(NodeQuery.QueryNodesByPath(path, true).Nodes,
                                         n =>
                        {
                            foreach (var node in n.LoadVersions())
                            {
                                SnTrace.Test.Write("@@ WriteDoc: " + node.Path);
                                DataStore.SaveIndexDocumentAsync(node, false, false, cancellationToken)
                                .GetAwaiter().GetResult();
                                OnIndexDocumentRefreshed(node.Path, node.Id, node.VersionId, node.Version.ToString());
                            }
                        });
                    }
                    op2.Successful = true;
                }
            }

            using (var op = SnTrace.Index.StartOperation("IndexPopulator: Rebuild index."))
            {
                await IndexManager.IndexingEngine.WriteIndexAsync(
                    new[] { new SnTerm(IndexFieldName.InTree, path) },
                    null,
                    LoadIndexDocumentsByPath(path),
                    cancellationToken).ConfigureAwait(false);

                op.Successful = true;
            }
        }
Example #6
0
 public void RebuildIndex(Node node, bool recursive = false, IndexRebuildLevel rebuildLevel = IndexRebuildLevel.IndexOnly)
 {
     using (var op = SnTrace.Index.StartOperation("DocumentPopulator.RefreshIndex. Version: {0}, VersionId: {1}, recursive: {2}, level: {3}", node.Version, node.VersionId, recursive, rebuildLevel))
     {
         using (new SenseNet.ContentRepository.Storage.Security.SystemAccount())
         {
             var databaseAndIndex = rebuildLevel == IndexRebuildLevel.DatabaseAndIndex;
             if (recursive)
             {
                 RebuildIndex_Recursive(node, databaseAndIndex);
             }
             else
             {
                 RebuildIndex_NoRecursive(node, databaseAndIndex);
             }
         }
         op.Successful = true;
     }
 }
Example #7
0
 public async STT.Task RebuildIndexAsync(Node node, CancellationToken cancellationToken, bool recursive = false,
                                         IndexRebuildLevel rebuildLevel = IndexRebuildLevel.IndexOnly)
 {
     using (var op = SnTrace.Index.StartOperation("DocumentPopulator.RefreshIndex. Version: {0}, VersionId: {1}, recursive: {2}, level: {3}", node.Version, node.VersionId, recursive, rebuildLevel))
     {
         using (new SystemAccount())
         {
             var databaseAndIndex = rebuildLevel == IndexRebuildLevel.DatabaseAndIndex;
             if (recursive)
             {
                 await RebuildIndex_RecursiveAsync(node, databaseAndIndex, cancellationToken).ConfigureAwait(false);
             }
             else
             {
                 await RebuildIndex_NoRecursiveAsync(node, databaseAndIndex, cancellationToken).ConfigureAwait(false);
             }
         }
         op.Successful = true;
     }
 }
Example #8
0
        // caller: IndexPopulator.Populator
        public void RebuildIndexDirectly(string path, IndexRebuildLevel level = IndexRebuildLevel.IndexOnly)
        {
            if (level == IndexRebuildLevel.DatabaseAndIndex)
            {
                using (var op2 = SnTrace.Index.StartOperation("IndexPopulator: Rebuild index documents."))
                {
                    using (new SystemAccount())
                    {
                        foreach (var node in Node.LoadNode(path).LoadVersions())
                        {
                            DataBackingStore.SaveIndexDocument(node, false, false, out _);
                            OnIndexDocumentRefreshed(node.Path, node.Id, node.VersionId, node.Version.ToString());
                        }

                        Parallel.ForEach(NodeQuery.QueryNodesByPath(path, true).Nodes,
                                         n =>
                        {
                            foreach (var node in n.LoadVersions())
                            {
                                DataBackingStore.SaveIndexDocument(node, false, false, out _);
                                OnIndexDocumentRefreshed(node.Path, node.Id, node.VersionId, node.Version.ToString());
                            }
                        });
                    }
                    op2.Successful = true;
                }
            }

            using (var op = SnTrace.Index.StartOperation("IndexPopulator: Rebuild index."))
            {
                IndexManager.IndexingEngine.WriteIndex(
                    new[] { new SnTerm(IndexFieldName.InTree, path) },
                    null,
                    LoadIndexDocumentsByPath(path));
                op.Successful = true;
            }
        }
Example #9
0
 public STT.Task RebuildIndexDirectlyAsync(string path, CancellationToken cancellationToken,
                                           IndexRebuildLevel level = IndexRebuildLevel.IndexOnly)
 {
     return(STT.Task.CompletedTask);
 }
Example #10
0
 public void RebuildIndexDirectly(string path, IndexRebuildLevel level = IndexRebuildLevel.IndexOnly)
 {
 }