Page 1 of 1
Uncompressing GZIP from Jade
Posted: Mon May 07, 2012 2:11 pm
by alanvl
Does anyone have any experience with uncompressing GZIP data from within Jade?
We do have a semi-working solution by using a command line execution of a BAT file that uses gzip.exe. The issue with this is that it uses the file system, and it appears that it might not be thread-safe? There are times where we are getting uncompressed results in one request that were actually the result of a prior request.
Keen to use an "in memory" solution.
Have tried the "decompress" option in zlib with no luck (is possible that we missed something).
Re: Uncompressing GZIP from Jade
Posted: Mon May 07, 2012 2:35 pm
by torrie
I don't know of an in-memory solution, but you can probably make the command line solution thread safe. (I'm assuming that the calls to gzip generate file names that are unique to each call?)
You could use some type of flag to indicate that gzip is in use and then wait. A good option would be to use a shared transient. When the app needs to run gzip, it would attempt to lock the shared transient first. If a lock was obtained, then the process would run gzip, releasing the lock once gzip had returned. If the lock was not available, then the application would assume that another process was using gzip. It could then wait for the other process to finish, or return to the user. You probably want to create the shared transient when the Jade Node starts up (e.g. a nongui application specified as a serverapp in the INI file) A basic example is below: (I'd build a timeout for a production system in case zgip crashed etc.)
Code: Select all
vars
oGZIPLock : GZIPLock;
begin
oGZIPLock := GZIPLock.firstSharedTransientInstance;
while not tryLock( oGZIPLock, Exclusive_Lock, Session_Duration, 20000 )
// Wait for the lock to clear e.g. another process is running gzip
process.sleep( 1000 );
endwhile;
// Call GZIP now we have a lock
node.createExternalProcess( "","gzip.exe", ... );
epilog
unlock( oGZIPLock );
Re: Uncompressing GZIP from Jade
Posted: Mon May 07, 2012 2:55 pm
by alanvl
Thanks for the reply Torrie.
We are using unique file names based upon the instance id of the process and the files being created - we are also purging the files at completion. One of the issues we have is the need to multi process within and across multiple nodes.
Re: Uncompressing GZIP from Jade
Posted: Tue May 08, 2012 1:18 am
by ghosttie
We use the
DotNetZip .NET class library
Re: Uncompressing GZIP from Jade
Posted: Tue May 08, 2012 10:22 pm
by alanvl
Thanks for that. I'll give DotNetZip a go when I can get it installed - am having a problem installing windows sdk framework which I believe is required to install the .Net library (New to this side of things)