Batch processors

Questions, tips and tricks and techniques for scripting in Servoy

Postby Jan Aleman » Wed Aug 29, 2007 5:21 pm

Make sure to have your cron-entry in a global startup method and you're all set. Something like this:
http://www.servoymagazine.com/home/2007 ... tho_1.html


Looks like Robert will be attending the ServoyWorld Batchprocessors session ;-)
Jan Aleman
Servoy
Jan Aleman
 
Posts: 2083
Joined: Wed Apr 23, 2003 9:49 pm
Location: Planet Earth

Postby IT2Be » Wed Aug 29, 2007 5:24 pm

Looks like Robert will be attending the ServoyWorld Batchprocessors session ;-)
Isn't that that single, very intense, 1:1 session against that ridicule rate :lol:
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby ROCLASI » Wed Aug 29, 2007 5:27 pm

jaleman wrote:Looks like Robert will be attending the ServoyWorld Batchprocessors session ;-)

Maybe I should. :oops:
I've been only using them since they were implemented (what was it? 2.1.x or so?)...or maybe it's the 3 hour drive I just had...
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Postby grahamg » Thu Aug 30, 2007 12:38 am

Maybe I could join Robert in this 'intensive' session.

Have a WebClient solution for an Art Exhibition company that display 3 x GIFs of artists pictures on all the web pages and changes them every 10 seconds. Set the GIF rotation up as batch Processor on server and hums along beautifully.

However, we also have WebClient forms for potential exhibitors/visitors to apply for tickets etc and discovered that if they typing into a field when the GIFs are changed the field focus is lost - can get quite frustrating.

Doing an applicationSavedata() immediately before the rotation saves the field contents but would welcome ideas to avoid the Batch Processor inteferring with form filling.

Regards

Graham Greensall
Worxinfo Ltd
grahamg
 
Posts: 752
Joined: Fri Oct 03, 2003 3:15 pm
Location: Midlands UK

Postby IT2Be » Thu Aug 30, 2007 7:34 am

Maybe a stupid suggestion but why don't you make the gif an animated gif?
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Pierre-andre » Thu Aug 30, 2007 9:56 am

At the moment, the server is working on Windows. But this method have to work with Linux and Mac OS/X.

In first, I wanted to create a stored procedure in PostgreSQL and executed it from servoy. But Postres don't allow to create Procedure, only function. Unfortunately I can't execute a REINDEX, PG_DUMP OR VACUUM command on database in function because "REINDEX cannot be executed inside a transaction block."
http://www.postgresql.org/docs/8.2/inte ... index.html


So I choosed to use cronjob. I created a Startup script :
var jobname = "backup"
var cronTimings = "* 00 22 * * ?"
var startDate = new Date()
var endDate = new Date(startDate.getFullYear()+50,startDate.getMonth(),startDate.getDate())
var args = new Array(directory_postgres,directory_for_backup)

plugins.scheduler.addCronJob(jobname, cronTimings, globals.Backup_DB,startDate,endDate,args)


The method backup:
var directory_postgres = arguments[0]
var directory_for_backup= arguments[1]

//Returns the name of the operating system
var osname = application.getOSName();

if(osname.indexOf("Windows",0)>-1){

var file = plugins.file.convertToJSFile(directory_postgres +"/vacuumdb.exe")
if(file.exists())
application.executeProgram(directory_postgres +"/vacuumdb.exe","-h","localhost","-p","5432","-U","postgres","-d","sopavet")

var file = plugins.file.convertToJSFile(directory_postgres +"/reindexdb.exe")
if(file.exists())
application.executeProgram(directory_postgres +"/reindexdb.exe","-h","localhost","-p","5432","-U","postgres","-d","sopavet"

var file = plugins.file.convertToJSFile(directory_postgres +"/pg_dump.exe")
if(file.exists())
application.executeProgram(directory_postgres +"/pg_dump.exe","-i","-h","localhost","-p","5432","-U","postgres","-F","t","-f","\""directory_for_backup+"/database_save.backup\"","sopavet"

}


I have to add security rules with postgres's user and complete this method for Linux and Mac OS/X.

It's work fine on Windows XP with Postgres 8.1, but I didn't know that batch process use one client license :shock:.So I have to find another way to backup my database.
Pierre-andre
 
Posts: 55
Joined: Mon Aug 20, 2007 9:31 am

Postby IT2Be » Thu Aug 30, 2007 10:04 am

but I didn't know that batch process use one client license .So I have to find another way to backup my database.
But doesn't the cost of one client weight up to the ease of use (as you said yourself)?
Obviously I don't do any sales for Servoy but imho you can create a fully customizable tool against a low price.
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby Pierre-andre » Thu Aug 30, 2007 10:45 am

But doesn't the cost of one client weight up to the ease of use (as you said yourself)?


hehe :wink:

I will try to convince my boss :)
Pierre-andre
 
Posts: 55
Joined: Mon Aug 20, 2007 9:31 am

Postby grahamg » Thu Aug 30, 2007 12:01 pm

Hi Marcel

Yes we looked at animated GIFs but new Images are being added to the Artists database all the time and to be fair to everyone the GIFs have to be selected at random.

Now looking at grabbing say 50 at a time into a Media array (each GIF is only 40-50kb) then just selecting from that array rather than going back to the DB each time.


Graham Greensall
Worxinfo Ltd
grahamg
 
Posts: 752
Joined: Fri Oct 03, 2003 3:15 pm
Location: Midlands UK

Postby Pierre-andre » Fri Aug 31, 2007 2:03 pm

I have a last question about batch processors.

Can I start / Stop / Add or remove a batch processor on Servoy'server in a method (With scheduler plugin for example)?

Thanks to that, I be able to start a Headless client without the webadmin and it will be completely transparent for the user.

thanks
Pierre-andre
 
Posts: 55
Joined: Mon Aug 20, 2007 9:31 am

Postby IT2Be » Fri Aug 31, 2007 2:10 pm

The answer is no, so far I know.

Why would you btw, let it run :)
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby pbakker » Fri Aug 31, 2007 2:21 pm

There are no functions available to add batch processors other than manually through the admin pages.

But you could offcourse have a batchprocessor that runs multiple processes sequentially, based on configuration records that you store in a table.

That batchprocessor could also determine to start a certain process or not based on a value (read: status) in a certain column of the config records.

Paul
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

Postby ROCLASI » Fri Aug 31, 2007 2:26 pm

Actually the answer is yes, with some work you can.

First of all you can remove cronjobs with a method.
The only thing you need to do is setup a table where you manage your cronjobs (records) together with a cronjob that periodically reads this table and checks for changes.
When a cronjob record has changed it removes the running cronjob and reapplies it with the new settings.
When a cronjob record was removed (or marked as such) it simply removes the cronjob.

So it all will be data driven.

Hope this helps.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Postby ROCLASI » Fri Aug 31, 2007 2:28 pm

Ah, I should read better before I reply.
No indeed you can't add batchprocessors via a cronjob. BUT you can use 1 single batchprocessor and use the technique I described in previous post.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Postby IT2Be » Fri Aug 31, 2007 2:32 pm

Glad you saw it! Did not want to correct you again :lol:
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

PreviousNext

Return to Methods

Who is online

Users browsing this forum: No registered users and 7 guests