-
Couldn't load subscription status.
- Fork 2.1k
Silo Metadata and Placement Filtering #9271
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
Merged
ReubenBond
merged 20 commits into
dotnet:main
from
rkargMsft:silo-metadata-and-placement-filtering
Feb 27, 2025
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7395b99
Initial implementation
rkargMsft 8aa83aa
Remove dead silos from metadata cache
rkargMsft d65153c
Allow overwriting of metadata values
rkargMsft 3ee780a
Adding Silo Metadata tests
rkargMsft 47899c1
Tests for Grain Placement Filter
rkargMsft 9f4f60d
Tests for silo metadata placement filters
rkargMsft d715fdd
Adding test category
rkargMsft 814a3ba
Testing loading silo metadata from config
rkargMsft d969a85
Required and Preferred match filtering unit tests
rkargMsft 9b44825
Testing multiple metadata keys in attribute
rkargMsft 49e12bd
Ordering support for filters
rkargMsft 6aa01d5
Moving reusable types to Core projects
rkargMsft 27ddb5e
Correct comment
rkargMsft c6905be
Correcting documentation
rkargMsft 0bc5ded
Allowing chaining extension method
rkargMsft 3c8a962
#nullable enable for new files
rkargMsft 005d8c6
Review suggestions
ReubenBond 9aae9d0
Fixups
ReubenBond ec8a407
Add PlacementFilterContext
ReubenBond ac45d1e
rename file
ReubenBond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/Orleans.Runtime/MembershipService/SiloMetadata/ISiloMetadataCache.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| #nullable enable | ||
|
|
||
| namespace Orleans.Runtime.MembershipService.SiloMetadata; | ||
|
|
||
| public interface ISiloMetadataCache | ||
| { | ||
| SiloMetadata GetMetadata(SiloAddress siloAddress); | ||
| SiloMetadata GetSiloMetadata(SiloAddress siloAddress); | ||
| } |
3 changes: 1 addition & 2 deletions
3
src/Orleans.Runtime/MembershipService/SiloMetadata/ISiloMetadataClient.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,9 @@ | ||
| using System.Threading.Tasks; | ||
| using Orleans.Services; | ||
|
|
||
| #nullable enable | ||
| namespace Orleans.Runtime.MembershipService.SiloMetadata; | ||
|
|
||
| public interface ISiloMetadataClient : IGrainServiceClient<ISiloMetadataGrainService> | ||
| internal interface ISiloMetadataClient | ||
| { | ||
| Task<SiloMetadata> GetSiloMetadata(SiloAddress siloAddress); | ||
| } |
5 changes: 2 additions & 3 deletions
5
...SiloMetadata/ISiloMetadataGrainService.cs → ...SiloMetadata/ISiloMetadataSystemTarget.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
src/Orleans.Runtime/MembershipService/SiloMetadata/SiloMetadataClient.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,14 @@ | ||
| using System; | ||
| using System.Threading.Tasks; | ||
| using Orleans.Runtime.Services; | ||
|
|
||
| #nullable enable | ||
| namespace Orleans.Runtime.MembershipService.SiloMetadata; | ||
|
|
||
| public class SiloMetadataClient(IServiceProvider serviceProvider) | ||
| : GrainServiceClient<ISiloMetadataGrainService>(serviceProvider), ISiloMetadataClient | ||
| internal sealed class SiloMetadataClient(IInternalGrainFactory grainFactory) : ISiloMetadataClient | ||
| { | ||
| public async Task<SiloMetadata> GetSiloMetadata(SiloAddress siloAddress) | ||
| { | ||
| var grainService = GetGrainService(siloAddress); | ||
| var metadata = await grainService.GetSiloMetadata(); | ||
| var metadataSystemTarget = grainFactory.GetSystemTarget<ISiloMetadataSystemTarget>(Constants.SiloMetadataType, siloAddress); | ||
| var metadata = await metadataSystemTarget.GetSiloMetadata(); | ||
| return metadata; | ||
| } | ||
| } |
31 changes: 21 additions & 10 deletions
31
src/Orleans.Runtime/MembershipService/SiloMetadata/SiloMetadataGrainService.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,34 @@ | ||
| using System; | ||
| using System.Threading; | ||
| using System.Threading.Tasks; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Extensions.Options; | ||
|
|
||
| #nullable enable | ||
| namespace Orleans.Runtime.MembershipService.SiloMetadata; | ||
|
|
||
| public class SiloMetadataGrainService : GrainService, ISiloMetadataGrainService | ||
| internal sealed class SiloMetadataSystemTarget( | ||
| IOptions<SiloMetadata> siloMetadata, | ||
| ILocalSiloDetails localSiloDetails, | ||
| ILoggerFactory loggerFactory, | ||
| IServiceProvider serviceProvider) | ||
| : SystemTarget(Constants.SiloMetadataType, localSiloDetails.SiloAddress, loggerFactory), ISiloMetadataSystemTarget, ILifecycleParticipant<ISiloLifecycle> | ||
| { | ||
| private readonly SiloMetadata _siloMetadata; | ||
| private readonly SiloMetadata _siloMetadata = siloMetadata.Value; | ||
|
|
||
| public SiloMetadataGrainService(IOptions<SiloMetadata> siloMetadata) : base() | ||
| { | ||
| _siloMetadata = siloMetadata.Value; | ||
| } | ||
| public Task<SiloMetadata> GetSiloMetadata() => Task.FromResult(_siloMetadata); | ||
|
|
||
| public SiloMetadataGrainService(IOptions<SiloMetadata> siloMetadata, GrainId grainId, Silo silo, ILoggerFactory loggerFactory) : base(grainId, silo, loggerFactory) | ||
| void ILifecycleParticipant<ISiloLifecycle>.Participate(ISiloLifecycle lifecycle) | ||
| { | ||
| _siloMetadata = siloMetadata.Value; | ||
| } | ||
| lifecycle.Subscribe(nameof(SiloMetadataSystemTarget), ServiceLifecycleStage.RuntimeInitialize, OnRuntimeInitializeStart, OnRuntimeInitializeStop); | ||
|
|
||
| public Task<SiloMetadata> GetSiloMetadata() => Task.FromResult(_siloMetadata); | ||
| Task OnRuntimeInitializeStart(CancellationToken token) | ||
| { | ||
| serviceProvider.GetRequiredService<Catalog>().RegisterSystemTarget(this); | ||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| Task OnRuntimeInitializeStop(CancellationToken token) => Task.CompletedTask; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This previous code was copied from DistributedGrainDirectory. Should there be a follow up issue to update usages of the prior pattern with this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we should clean up the other instances.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #9360