-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Cassandra-16565 trunk remove Sigar #2842
Cassandra-16565 trunk remove Sigar #2842
Conversation
Should the startup check log a message if it is disabled?
|
@smiklosovic I rebased on trunk and picked up the Harry changes. What do we need to do to move this forward? |
@michaelsembwever short answer is: no, I did not use the script. I have fixed the issues. As I noted in Slack (and here for public record) I didn't know that what it was for. I will have to update the 'change dependencies' documentation I recently submitted. In addition when I tried to run the script on a The SED comands in the script have blank files for script names (the single quotes after the -i as noted below:
If I remove the single quotes it works on my system but I am reticent to include this in this fix. |
* | ||
* @return non-empty optional with degradation messages if the system is in degraded mode, empty optional otherwise. | ||
*/ | ||
public Optional<String> isDegraded() |
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.
@Claudenw I was thinking about adding some tests for this. As of now, we just don't test the logic in this method. SystemInfo might be mocked by Mockito on its methods to return whatever we want instead of oshi returning it and then we could make assertions on various corner cases and values so we might watch what degradation string we resolve here.
Another option is to not use Mockito but we might just extend this class and override its methods, returning whatever we want. Then we might do assertions on isDegraded
output.
{ | ||
Supplier<String> expectedNumProc = () -> { | ||
// only check proc on nproc linux | ||
if (oshi.SystemInfo.getCurrentPlatform() == PlatformEnum.LINUX) |
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.
@Claudenw we can use platform
method of this class instead of oshi.SystemInfo.getCurrentPlatform()
and platform
might return PlatformEnum
instead of String
.
That way, except reusing the code, it will also unblocks us when we will go to mock what this class is doing when testing various scenarios.
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.
Switching to returning the PlatformEnum exposes the underlying classes of the SystemInfo class. This will make it more complex to replace the functionality later. I think that SystemInfo should isolate the developer from the underlying classes that provide the functionality. We could make SystemInfo an interface and move the current code to a SystemInfoImpl class, then @jacek-lewandowski suggestion (below) that there be a provider, and your observation that Mockito might be used become easier to implement.
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.
@Claudenw one nice advantage of returning enum is that you can use it in case
and it is compile time safe ... We can just compare enums directly. I do not think it is a lot to ask for given how comfortable its usage will be. We are not planning to change the impl anytime soon again.
I can imagine a lot of people would ask "what platform I am at" quite frequently and dealing with "equals" and Linux string etc every time is ... nah.
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.
@Claudenw do you plan to use platform()
here?
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.
No, it is an internal call, so no need to go though the method.
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.
@Claudenw how do you want to mock the operating system this is run on when testing various scenarios? If we used platform()
here then we could mock it returns something else from "Linux".
It looks ok, I have one general comment - I think that something like |
…StartupChecks, fixed nbproject issues
The latest changes DO NOT implement a provider, and do not expose the underlying SystemInfo implementation. I still need some clarity on whether or not SystemInfo should be an interface with the current code as an implementation. |
@Claudenw I'd say it is up to you because SystemInfo looks like something easy to mock. |
@Claudenw I dont think we need an interface for this. It is not like it is a hobby to change the guts of this every quarter or some custom impls would be necessary to justify an interface for that. I think that SystemInfo, as is, is mockable already. cc @jacek-lewandowski |
yup, just as said, I'm fine with either approach |
@Claudenw will you add a provider for SystemInfo? |
@michaelsembwever The dev documentation update mentioning the |
The provider has been added. I think this now implements all agreed suggestions from the reviews. |
Please at least memoize the value from the default provider. Also name |
review fixes and suggested improvements
Thanks for sending a pull request! Here are some tips if you're new here:
Commit messages should follow the following format:
The Cassandra Jira
Removed Sigar references from the build scripts and library.
Removed SigarLibrary.java and replaced it with SystemInfo.java and updated the calls.
Switched to OSHI library
Modified
warnIfRunningInDegradedMode
as noted on the ticket CASSANDRA-16565