-
-
Notifications
You must be signed in to change notification settings - Fork 885
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
Add free/total inode counts #659
Conversation
I think "inode" is fine; it seems standard terminology/POSIX standard on all the *nix-based systems including mac, and there's no windows equivalent. Check out here for the "new" JNA way to do Sysinfo. |
totalSpace = vfsStat.fsSizeInBlocks.longValue() * vfsStat.fsBlockSize.longValue(); | ||
usableSpace = vfsStat.fsBlocksFree.longValue() * vfsStat.fsBlockSize.longValue(); | ||
} else { | ||
totalSpace = new File(path).getTotalSpace(); |
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.
don't create a new File
object twice.
LOG.error("Failed to get file counts from statvfs. {}", e); | ||
} | ||
|
||
OSFileStore osStore = new OSFileStore(name, volume, path, description, type, uuid, usableSpace, totalSpace, usableFiles, totalFiles); |
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.
Use a no-argument constructor and setters.
* | ||
* @return Usable files / free inodes on the drive (count) | ||
*/ | ||
public long getUsableFiles() { |
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.
per comments, let's go with freeInodes()
96afac1
to
a8cd334
Compare
- Avoid calling new File() twice - use Constructor + setters
Looking good so far.... For Solaris you should be able to do something similar to Linux with the Statvfs structure. For Mac and FreeBSD you're going to have to parse the output of |
Also travis-ci can no longer test on |
Is someone able to help with Solaris / Mac / FreeBSD? I have no such system at hand ... |
I can help with those. Can you get rid of the “-1, -1” add ones to those constructors though? Stick with the original constructors or switch to no-arg with the -1 as the initialization. |
I pushed a new version ... Switched back to the original constructors and added a copy constructor for json instead ... |
Looks good. I'll see if I can check out your branch and send commits to it for the other OS's. |
Heh. Mac was trivial, the needed values were already in the
I've committed implementations for Mac, Solaris, and FreeBSD to your master branch. |
if (split.length > 7) { | ||
inodeFreeMap.put(split[0], ParseUtil.parseLongOrDefault(split[6], 0L)); | ||
// total is actually used + free | ||
if (inodeFreeMap.get(split[0]) >= 0) { |
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 conditional should be removed since I changed the default from -1.
* @return On success, zero is returned. On error, -1 is returned, and errno | ||
* is set appropriately. | ||
*/ | ||
int statvfs(String path, Statvfs buf); |
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.
Need to write a test method for this.
if (split.length > 7) { | ||
inodeFreeMap.put(split[0], ParseUtil.parseLongOrDefault(split[6], 0L)); | ||
// total is actually used + free | ||
if (inodeFreeMap.get(split[0]) >= 0) { |
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.
need to remove this conditional left over from earlier logic.
Codecov Report
@@ Coverage Diff @@
## master #659 +/- ##
============================================
- Coverage 83.9% 83.64% -0.26%
- Complexity 197 198 +1
============================================
Files 28 28
Lines 1460 1480 +20
Branches 211 213 +2
============================================
+ Hits 1225 1238 +13
- Misses 112 117 +5
- Partials 123 125 +2
Continue to review full report at Codecov.
|
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.
Hi,
looks like for Windows now OSFileStore.mount is not set any more ... previously it was the drive (strMount) which is now stored in OSFileStore.logicalVolume ... is this wanted?
No... that error was everywhere and I backed it out the other 4 OS's but since we weren't adding the new fields to Windows I didn't even bother looking! Whoops. Can you fix? |
see #664 |
Hi,
initial pull request ... not sure about the variable names ... in LibC I have called them (free|total)InodeCounts because that's what it is (at least on Linux) ... not sure if it's called like that for all the other OS as well. In FreeBSD it's called
But in LinuxFileSystem I have called them file counts ... let me know what you prefer. Furthermore I had issues using the "new" JNA stuff ... if you convert the existing Sysinfo I can adapt Statvfs as well.
Furthermore I have set it to -1 for all other OS except of Linux ... not sure how to implement it for FreeBSD, Solaris, MacOS, ...