Skip to content
Snippets Groups Projects
Commit c909ab66 authored by Thomas Bock's avatar Thomas Bock :speech_balloon:
Browse files

runmp timing

parent f5c9af90
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,7 @@ var all = {
port: 50005
},
system : {
heartbeat: 200,
heartbeat: 500,
par_delay_mult: 100, // Multiplikator
db_delay_mult: 200, // Multiplikator
vxi11_buffer_time: 100
......@@ -106,7 +106,7 @@ all.logger.streams.push({
type: 'raw',
level: "trace",
stream: new BunyanToGelfStream({
host: '172.30.56.22',
host: 'a73435',
port: 12201})
});
......
......@@ -15,7 +15,6 @@ var _ = require("underscore")
, fetch = require("./load.fetch")
, distribute = require("./load.distribute")
, insert = require("./load.insert")
, log = bunyan.createLogger(conf.logger)
, mem = broker.createClient({port: conf.mem.port})
, ok = {ok:true}
......@@ -226,4 +225,4 @@ exports.distribute = distribute;
exports.fetch = fetch;
exports.expand_cust = expand_cust;
exports.expand_task = expand_task;
exports.insert = insert;
\ No newline at end of file
exports.insert = insert;
......@@ -232,17 +232,18 @@ var observe = function (ch, path, cb){
mem.get([mpid, no, "ctrl"], function (err, cmdstr){
if(!err){
mem.get([mpid, no, "state"], function (err, state){
if(!err){
if(!err){
dispatch([mpid, no, "ctrl"], cmdstr, state, function (err, path){
if(!err){
if(_.isFunction(cb)){
cb(null, path);
if(!err){
if(_.isFunction(cb)){
cb(null, path);
}
}else{
log.error(err
, "error on observe dispatch");
stop_cont(path, "stop_container_obs", timerId, cb)
}
}else{
log.error(err
, "error on observe dispatch");
stop_cont(path, "stop_container_obs", timerId, cb)
}
});
}else{
log.error(err
......@@ -287,7 +288,7 @@ var observe = function (ch, path, cb){
exports.observe = observe;
var dispatch = function(path, cmdstr, state, cb){
if(path && _.isArray(path) && path.length >= 2){
if(path && _.isArray(path) && path.length >= 2){
var mpid = path[0]
, no = path[1];
......@@ -391,7 +392,10 @@ exports.time_to_exchange = time_to_exchange;
* @param {String} channel
*/
var shout = function (path, channel, cmdstr, newstr, cb){
if(path && _.isArray(path) && path.length >= 2){
log.trace(ok,
"shout on " + path + channel + ", " + cmdstr + ", " + newstr);
if(path && _.isArray(path) && path.length >= 2){
var cmdarr = cmd_to_array(cmdstr)
, cmdH = _.first(cmdarr)
......
......@@ -23,60 +23,57 @@ var _ = require("underscore"),
* @param {Function} cb Callback Funktion
*/
module.exports = function(task, cb) {
var path = task.Path,
mpdef = task.Mp,
cont = task.Container,
ctitle = task.ContainerTitle,
poll = 1000,
ro = {
ok: true
},
err;
mem.get([mpdef], function(err, mp) {
if (_.isUndefined(mp)) {
err = new Error("get request to " + mpdef + " fails");
log.error(err, "mp not available");
cb(err);
} else {
var idx = mp.meta.container.Title.indexOf(ctitle);
if (idx > -1) {
cont = idx;
log.trace(ro, "found container with title " + ctitle + "at position " + idx)
}
if (!_.isUndefined(cont)) {
var cpath = [mpdef, cont, "ctrl"],
cmd = [conf.ctrlStr.load, conf.ctrlStr.run].join(";");
mem.set(cpath, cmd, function(err) {
if (!err) {
var inid = setInterval(function() {
mem.get(cpath, function(err, res) {
if (!err) {
if (res == conf.ctrlStr.ready) {
clearTimeout(inid);
cb(null, ro);
}
} else {
clearTimeout(inid);
err = new Error("can not get mp below: " + cpath.join("."));
log.error(err);
cb(err);
}
});
}, poll)
} else {
err = new Error("can not set mp below: " + cpath.join("."));
log.error(err);
cb(err);
}
}); //set cmd
} else {
err = new Error("can not find container with title: " + ctitle);
log.error(err);
cb(err);
}
}
}); // get cpath
var path = task.Path,
mpdef = task.Mp,
cont = task.Container,
ctitle = task.ContainerTitle,
poll = 1000,
ro = {ok: true},
err;
mem.get([mpdef], function(err, mp) {
if (_.isUndefined(mp)) {
err = new Error("get request to " + mpdef + " fails");
log.error(err, "mp not available");
cb(err);
} else {
var idx = mp.meta.container.Title.indexOf(ctitle);
if (idx > -1) {
cont = idx;
log.trace(ro, "found container with title " + ctitle + "at position " + idx)
}
if (!_.isUndefined(cont)) {
var cpath = [mpdef, cont, "ctrl"],
cmd = [conf.ctrlStr.load, conf.ctrlStr.run].join(";");
mem.set(cpath, cmd, function(err) {
if (!err) {
// poll the ctrl path
var inid = setInterval(function() {
mem.get(cpath, function(err, res) {
if (!err) {
if (res == conf.ctrlStr.ready) {
clearTimeout(inid);
cb(null, ro);
}
} else {
clearTimeout(inid);
err = new Error("can not get mp below: " + cpath.join("."));
log.error(err);
cb(err);
}
});
}, poll)
} else {
err = new Error("can not set mp below: " + cpath.join("."));
log.error(err);
cb(err);
}
}); //set cmd
} else {
err = new Error("can not find container with title: " + ctitle);
log.error(err);
cb(err);
}
}
}); // get cpath
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment