File size or free space for hub “drive”

I’ve created a rule to write various variables (i.e., freeMemory) to a hub file for subsequent importing into Excel. Currently, (but subject to change) the rule runs every 5 minutes and appends a new row with current data. Apparently 1GB of the hub’s RAM is dedicated to secondary storage. I did not find a method to determine size of the file being created or space remaining of the 1GB. Although the rule is only saving ~30 bytes/write, I would prefer to have it automatically stop at a certain threshold – file size or space remaining. Is there a method available? Currently I am limiting the rule to run for a calendar month. (Running every 5 minutes saving 30 bytes will take 340 years to fill 1GB.)

Also, is there a file present method?

1 Like

There isn't a file exists method, so I just trap this exception if downloadHubFile throws it, which is basically the same as a check for the file and a read of its contents (if found):

java.nio.file.NoSuchFileException

2 Likes

How are you appending? I guess you read the existing contents, then add your new update to the end, then upload the file again. So, you always know at least know how big your file is.

I assume if the available space was filled you would get some sort of disk full exception when you tried to upload the file, but I haven't tried it.

If you're writing from RM, I doubt it's quite as compact as your raw data appears to be, but you're right that running out of space from just this use case doesn't seem likely to eat up much space.

1 Like

Don't overlook WebCoRE and its long-term storage option(s), such as Fuel Streams, to which you can not only save attribute or hub data, but easily recall it or use for graphing, etc. That might be a more ready-made solution compared with RM and file management.

3 Likes

I’ve considered webcore and will investigate.

I researched this forum the many methods used to extract, export, and graph hub data. To complete my original post, here’s my method: export data and create CSV file using RM, use VBA code in Excel to download and import the data into a worksheet query. Version 1.0.
Rule:


Worksheet (xlsm, not xlxs):

VBA code:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.