-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Getting a list of active grains in Orleans for monitoring #1772
Conversation
…ics(SiloAddress[] hostsIds), GetDetailedGrainStatistics()) , that can be used to get more details about all the active grains.
…nt to be returned when GetDetailedGrainStatistics is called.
… in having the entire type object
Hi @Dewaldf, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! TTYL, DNFBOT; |
@Dewaldf, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
…t the attribute is not checked for every grain. Fixed code formatting.
isManagementFilterableGrain = | ||
data.GrainInstanceType.IsDefined(typeof (ManagementFilterableGrain), false); | ||
//we need to add the new type to the dictionary now,so that we do not need to get attribute for everygrain. | ||
if (!checkedTypes.ContainsKey(data.GrainInstanceType)) |
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 second if
doesn't seem necessary.
Not sure why you need this |
Removed extra if in GetDetailedGrainStatistics method
…th the ManagementFilterableGrain attibute in the system. Refactored the GetDetailedGrainStatistics method to use GetGrainTypeList method to get the types to return.
Just committed changes as suggested. @gabikliot, The reason I decided to use the The |
You have to think about the API in general terms, for all future usages and not just for your one particular case. The caller needs an ability to decide what grains he is interested in. And not the callee, which is in this case the grain itself. Grain developer can not know at the time he is writing the grain which client of the management interface will want what. For example, look at In our case we want (at least) 2 function: get all grain types and get grains for a given type. That way the portal (the client of the management API) has the full flexibility and can for example iterate over all types and pick which ones he is interested in. |
@@ -318,4 +318,9 @@ public ImplicitStreamSubscriptionAttribute(string streamNamespace) | |||
Namespace = streamNamespace; | |||
} | |||
} | |||
|
|||
[AttributeUsage(AttributeTargets.Class)] | |||
public sealed class ManagementFilterableGrain : Attribute |
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.
As pointed out in the review this interface is un-necessary.
Added methods to get all active grain types on the ManagementGrain Changed methods to get active grains by passing in the types the developer would be interested in
Committed the suggested changes. |
/// <param name="hostsIds">List of silos this command is to be sent to.</param> | ||
/// <param name="types">Array of grain types to filter the results with</param> | ||
/// <returns></returns> | ||
Task<DetailedGrainStatistic[]> GetDetailedGrainStatistics(SiloAddress[] hostsIds, string[] types); |
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.
Wouldn't it be better to have a single method with default arguments?
GetDetailedGrainStatistics(string[] types = null, SiloAddress[] hostsIds=null)
where nulls mean all types and all silos respectively?
I would also flip the order of arguments assuming that specifying grain types would be a more common case than specifying a list of silos. That way GetDetailedGrainStatistics()
and GetDetailedGrainStatistics(grainTypes)
would be convenient shortcuts.
I had the methods the way you suggested in the last comment, but then changed it because it was not consistent with the |
Sorry if I confused you. I didn't realize that was how it was already done. I still think a single method is better than 4 overloads. :-) |
…ults of null. Changed the order of the parameter so that types is the firt param Changed GetActiveGrainTypes to be one method with default params instead of overload.
No worries, I have just committed the changes as suggested.
|
Thank you, @Dewaldf! Did you think about exposing this functionality via OrleansManager.exe? |
Hi, |
I think it'd be better to keep OrleansManager.exe in sync with the |
Gives the developer to get a list of active grains from Orleans, for monitoring etc. See #1751.
Since the list that could be returned could be a very big list, I added an attribute that the developer will need to decorate his class with, if he wants that type of grain to be returned. This gives developers the opportunity to specify only certain grains.