Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added lease expired exception. #8

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/DotJEM.Json.Index2.Management/IJsonIndexManager.cs
Original file line number Diff line number Diff line change
@@ -128,6 +128,11 @@ public async Task ResetIndexAsync()
{
await jsonDocumentSource.StopAsync().ConfigureAwait(false);
index.Storage.Delete();
//TODO: Force a commit after delete to see if that helps?
using (var lease = index.WriterManager.Lease())
{
lease.Value.Commit();
}
await jsonDocumentSource.ResetAsync().ConfigureAwait(false);
await jsonDocumentSource.StartAsync().ConfigureAwait(false);
}
26 changes: 25 additions & 1 deletion src/DotJEM.Json.Index2/IO/JsonIndexWriterManager.cs
Original file line number Diff line number Diff line change
@@ -47,7 +47,15 @@
if (writer != null)
return writer;

return writer = Open(index);
try
{
return writer = Open(index);
}
catch (Exception e)

Check warning on line 54 in src/DotJEM.Json.Index2/IO/JsonIndexWriterManager.cs

GitHub Actions / build

The variable 'e' is declared but never used
{
Debug.WriteLine("ACTIVE LEASES: " +leases.Count);
throw;
}
}
}
}
@@ -148,6 +156,11 @@
{
throw new ObjectDisposedException("Index writer lease has been returned or is expired.");
}

if (IsExpired)
{
throw new LeaseExpiredException("Index writer lease has been returned or is expired.");
}
return manager.Writer;
}
}
@@ -178,4 +191,15 @@
}
}

}

public class LeaseExpiredException : Exception
{
public LeaseExpiredException(string message) : base(message)
{
}

public LeaseExpiredException(string message, Exception innerException) : base(message, innerException)
{
}
}

Unchanged files with check annotations Beta

// followed by a trimming of unneeded features. But we should do more to make it especially useful for JSON.
public class JsonAnalyzer : Analyzer
{
public LuceneVersion Version { get; }

Check warning on line 17 in src/DotJEM.Json.Index2/Analysis/JsonAnalyzer.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsonAnalyzer.Version'
public int MaxTokenLength { get; set; } = 4096;

Check warning on line 18 in src/DotJEM.Json.Index2/Analysis/JsonAnalyzer.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsonAnalyzer.MaxTokenLength'
public JsonAnalyzer(LuceneVersion version)

Check warning on line 20 in src/DotJEM.Json.Index2/Analysis/JsonAnalyzer.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsonAnalyzer.JsonAnalyzer(LuceneVersion)'
{
Version = version;
}
protected override TokenStreamComponents CreateComponents(string fieldName, TextReader reader)

Check warning on line 25 in src/DotJEM.Json.Index2/Analysis/JsonAnalyzer.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'JsonAnalyzer.CreateComponents(string, TextReader)'
{
ClassicTokenizer src = new (Version, reader);
src.MaxTokenLength = MaxTokenLength;
namespace DotJEM.Json.Index2.Configuration
{
public interface IFactory<out TService>

Check warning on line 5 in src/DotJEM.Json.Index2/Configuration/IFactory.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'IFactory<TService>'
{
TService Create();

Check warning on line 7 in src/DotJEM.Json.Index2/Configuration/IFactory.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'IFactory<TService>.Create()'
}
public class FuncFactory<TService> : IFactory<TService>

Check warning on line 10 in src/DotJEM.Json.Index2/Configuration/IFactory.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'FuncFactory<TService>'
{
private readonly Func<TService> fac;
public FuncFactory(Func<TService> fac) => this.fac = fac;

Check warning on line 13 in src/DotJEM.Json.Index2/Configuration/IFactory.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'FuncFactory<TService>.FuncFactory(Func<TService>)'
public TService Create() => fac();

Check warning on line 14 in src/DotJEM.Json.Index2/Configuration/IFactory.cs

GitHub Actions / build

Missing XML comment for publicly visible type or member 'FuncFactory<TService>.Create()'
}
public class InstanceFactory<TService> : IFactory<TService>