Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

using event emitter for task processing

  • Loading branch information...
commit 207bad115a0a4148f35e238fd1121a30b8f0bd5a 1 parent b44ec2c
@openmason authored
View
3  History.md
@@ -1,4 +1,5 @@
-# release 0.2.4
+# release 0.2.5
+ * using event emitter for processing jobs
* switched to zmqrpc for cloud management
* fan-out feature added (check feedconfig.yaml)
* javascript modules can be loaded from job config
View
8 README.md
@@ -59,7 +59,7 @@ Have two terminals, one for the server and another one for submitting the job
cloudd server
# terminal 2
- cloudd examples/hellomyworld.yaml
+ cloudd submit HW examples/hellomyworld.yaml
## Usage
To run the server
@@ -78,11 +78,13 @@ Command line utilities
cloudd jobs
# to submit a new job
- cloudd submit sample-job-file.yaml
+ cloudd submit job-id sample-job-file.yaml
+
+ # to submit a cron job (say every 5 seconds)
+ cloudd cron "*/5 * * * * *" job-id sample-job-file.yaml
## Config file
* id's for the job and task cannot have '#'
* input is a field that would be passed to task
-
View
4 lib/cloudd.js
@@ -91,6 +91,10 @@ exports.start = function(port) {
_service = new zmqrpc(cmdport, true);
_service.context(CloudManagement);
_service.run();
+ _jobsList.setMaxListeners(0);
+ _jobsList.on('job', function(jobid) {
+ _jobsList.process();
+ });
};
/* returns current version
View
19 lib/job.js
@@ -2,13 +2,15 @@
* Cloudd - copyright(c) 2011-2013 openmason.
* MIT License.
*/
-var _ = require('underscore');
-var os = require('os');
+var _ = require('underscore');
+var os = require('os');
var winston = require('winston');
+var events = require('events');
+var util = require('util');
-var ds = require('./ds/buckets');
-var task = require('./task');
-var dag = require('./dag');
+var ds = require('./ds/buckets');
+var task = require('./task');
+var dag = require('./dag');
var _pkgname = '[cloudd] ';
@@ -186,19 +188,24 @@ Job.prototype.toStringObj = function() {
// ----------------
var JobList = function() {
+ // set the emitter
+ events.EventEmitter.call(this);
this.jobs = {};
this.taskQ = new task.TaskQ();
this.maxTasks = os.cpus().length;
winston.info(_pkgname + 'max workers['+this.maxTasks+']');
};
+// bind eventemitter
+util.inherits(JobList, events.EventEmitter);
+
/*
* Submit a new job to the joblist
*/
JobList.prototype.submit = function(jobid, config) {
var myJob = new Job(jobid, config);
this.jobs[myJob.id] = myJob;
- this.process();
+ this.emit('job', myJob.id);
};
/*
View
2  package.json
@@ -2,7 +2,7 @@
"name": "cloudd",
"description": "node based job execution engine",
"homepage": "https://github.com/openmason/cloudd",
- "version": "0.2.4",
+ "version": "0.2.5",
"author": "el aras <openmason@gmail.com>",
"dependencies": {
"underscore": ">= 1.4.3",
Please sign in to comment.
Something went wrong with that request. Please try again.