Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,15 @@ private async Task TryCreateCosmosResources()
var containerProperties = new ContainerProperties(_options.ContainerName, PARTITION_KEY);
containerProperties.IndexingPolicy.IndexingMode = IndexingMode.Consistent;
containerProperties.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Address/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Port/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Generation/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Hostname/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/SiloName/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/\"SuspectingSilos\"/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/\"SuspectingTimes\"/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/StartTime/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/IAmAliveTime/*" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Address/?" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Port/?" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Generation/?" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Hostname/?" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/SiloName/?" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/\"SuspectingSilos\"/[]/?" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/\"SuspectingTimes\"/[]/?" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/StartTime/?" });
containerProperties.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/IAmAliveTime/?" });

const int maxRetries = 3;
for (var retry = 0; retry <= maxRetries; ++retry)
Expand Down
15 changes: 13 additions & 2 deletions src/Azure/Orleans.Persistence.Cosmos/CosmosGrainStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,9 @@ private async Task TryCreateResources()

var stateContainer = new ContainerProperties(_options.ContainerName, _options.PartitionKeyPath);
stateContainer.IndexingPolicy.IndexingMode = IndexingMode.Consistent;
stateContainer.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/*" });
stateContainer.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/\"State\"/*" });
stateContainer.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/*" });
stateContainer.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = $"/{nameof(GrainStateEntity<object>.GrainType)}/?" });
stateContainer.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = ToScalarIndexPath(_options.PartitionKeyPath) });

if (_options.StateFieldsToIndex != null)
{
Expand Down Expand Up @@ -369,6 +370,16 @@ private async Task TryDeleteDatabase()
}
}

private static string ToScalarIndexPath(string path)
{
if (path.EndsWith("/?", StringComparison.Ordinal))
{
return path;
}

return path.EndsWith("/", StringComparison.Ordinal) ? $"{path}?" : $"{path}/?";
}

private void ResetGrainState<T>(IGrainState<T> grainState)
{
grainState.State = CreateInstance<T>();
Expand Down
4 changes: 2 additions & 2 deletions src/Azure/Orleans.Reminders.Cosmos/CosmosReminderTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ private async Task TryCreateCosmosResourcesCore()

remindersCollection.IndexingPolicy.IndexingMode = IndexingMode.Consistent;
remindersCollection.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/*" });
remindersCollection.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/StartAt/*" });
remindersCollection.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Period/*" });
remindersCollection.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/StartAt/?" });
remindersCollection.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/Period/?" });
remindersCollection.IndexingPolicy.IndexingMode = IndexingMode.Consistent;

const int maxRetries = 3;
Expand Down
Loading