I arrived safe and sound in Prague for the Autodesk cloud accelerator.
Before leaving Switzerland, I took a last little jaunt in nature, over Weissenstein and Rueti, with a nice view of the Swiss alps:
During the trip, I continued to convert my FireRatingCloud C# REST API client from HttpWebRequest to RestSharp.
I implemented the RestSharp PUT call last week; now, let's address the GET call, and remove all traces of the use of HttpWebRequest.
The REST GET call implementation using RestSharp is almost ridiculously simple:
/// <summary> /// GET JSON document data from /// the specified mongoDB collection. /// </summary> public static string Get( string collection_name_and_id ) { var client = new RestClient( RestApiBaseUrl ); var request = new RestRequest( _api_version + "/" + collection_name_and_id, Method.GET ); IRestResponse response = client.Execute( request ); var content = response.Content; // raw content as string return content; }
I had no Internet connection during my travel, so I switched back from the mongolab-hosted database to a local repository instead, and the heroku-hosted node.js web server to a local one as well.
The code includes a toggle for each, by setting the static bool UseLocalServer
in
FireRatingCloud/Util.cs for the web server, and the appropriate database URL in
firerating/server.js like this:
// local database var mongo_uri = 'mongodb://localhost/firerating'; // mongolab hosted var mongo_uri = 'mongodb://revit:revit@ds047742.mongolab.com:47742/firerating';
I ran into one more little problem starting up the mongo database locally, due to lack of hard disk space after compacting the virtual Windows machine hard drive:
C:\Program Files\MongoDB\Server\3.0\bin\mongod.exe 2015-09-13T10:56:51.383+0200 E JOURNAL [initandlisten] Insufficient free space for journal files 2015-09-13T10:56:51.383+0200 I JOURNAL [initandlisten] Please make at least 3379MB available in C:\data\db\journal or use --smallfiles
Checking the mongo help information about disk space usage, I see a number of promising options available, e.g.
--noprealloc disable data file preallocation - will often hurt performance --nssize arg (=16) .ns file size (in MB) for new databases --quota limits each database to a certain number of files (8 default) --smallfiles use a smaller default file size --nojournal disable journaling (journaling is on by default for 64 bit)
The mongo database was perfectly happy to run locally again with the minimised disk size using:
C:\Program Files\MongoDB\Server\3.0\bin > mongod --smallfiles --nojournal
The updated versions of FireRatingCloud are release 2016.0.0.9 implementing the new Get method and 2016.0.0.10 after removing the obsolete HttpWebRequest QueryOrUpsert method and the .NET references it requires.