Uncompressing GZIP from Jade

Forums for specific tips, techniques and example code
alanvl
Posts: 29
Joined: Fri Aug 14, 2009 9:16 pm

Uncompressing GZIP from Jade

Postby alanvl » Mon May 07, 2012 2:11 pm

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).

torrie
Posts: 92
Joined: Fri Aug 14, 2009 11:24 am

Re: Uncompressing GZIP from Jade

Postby torrie » Mon May 07, 2012 2:35 pm

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 );

alanvl
Posts: 29
Joined: Fri Aug 14, 2009 9:16 pm

Re: Uncompressing GZIP from Jade

Postby alanvl » Mon May 07, 2012 2:55 pm

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.

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: Uncompressing GZIP from Jade

Postby ghosttie » Tue May 08, 2012 1:18 am

We use the DotNetZip .NET class library
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

alanvl
Posts: 29
Joined: Fri Aug 14, 2009 9:16 pm

Re: Uncompressing GZIP from Jade

Postby alanvl » Tue May 08, 2012 10:22 pm

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)


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 11 guests

cron