Commit 5f915d6f authored by project's avatar project

--no commit message

--no commit message
parent 6b01852f
...@@ -6,10 +6,10 @@ var importer = require('./importer'); ...@@ -6,10 +6,10 @@ var importer = require('./importer');
module.exports.create = function(prm) module.exports.create = function(prm)
{ {
return new BSSHandler(prm); return new BSSEngine(prm);
} }
function BSSHandler(prm) function BSSEngine(prm)
{ {
if(typeof prm == 'string'){ if(typeof prm == 'string'){
prm = {'file':prm}; prm = {'file':prm};
...@@ -17,25 +17,22 @@ function BSSHandler(prm) ...@@ -17,25 +17,22 @@ function BSSHandler(prm)
// this.repos_dir = prm.repos_dir; // this.repos_dir = prm.repos_dir;
// this.name = prm.name; // this.name = prm.name;
this.file = prm.file; this.file = prm.file;
this.concurrent = 0;
} }
function name2path(n){ BSSEngine.prototype.filepath = function()
return n.split('.').join('/');
}
BSSHandler.prototype.filepath = function()
{ {
//return this.repos_dir + '/' + name2path(this.name) + '.bss'; //return this.repos_dir + '/' + name2path(this.name) + '.bss';
return this.file; return this.file;
} }
BSSHandler.prototype.exists = function() BSSEngine.prototype.exists = function()
{ {
var fp = this.filepath(); var fp = this.filepath();
return fs.existsSync(fp); return fs.existsSync(fp);
} }
BSSHandler.prototype.open = function(cb) BSSEngine.prototype.open = function(cb)
{ {
var self = this; var self = this;
...@@ -64,13 +61,13 @@ BSSHandler.prototype.open = function(cb) ...@@ -64,13 +61,13 @@ BSSHandler.prototype.open = function(cb)
} }
BSSHandler.prototype.close = function(cb) BSSEngine.prototype.close = function(cb)
{ {
this.bss.close(cb); this.bss.close(cb);
} }
BSSHandler.prototype.cmd = function(cmd,cb) BSSEngine.prototype.cmd = function(cmd,cb)
{ {
var command = cmd.command; var command = cmd.command;
var param = cmd.param; var param = cmd.param;
...@@ -84,7 +81,7 @@ BSSHandler.prototype.cmd = function(cmd,cb) ...@@ -84,7 +81,7 @@ BSSHandler.prototype.cmd = function(cmd,cb)
} }
} }
BSSHandler.prototype.cmd_write = function(prm,cb) BSSEngine.prototype.cmd_write = function(prm,cb)
{ {
var data = prm.data; var data = prm.data;
var meta = prm.meta; var meta = prm.meta;
......
var BSSEngine = require('./bss_engine');
module.exports = BSSPool;
function BSSPool(prm)
{
this.repos_dir = prm.repos_dir
this.pool = [];
}
BSSPool.prototype.get = function(name,cb)
{
var filepath = this.repos_dir + '/' + name2path(name) + '.bss'
var bssname = name;
}
function name2path(name){
return name.split('.').join('/');
}
var BSSPool = require('./bsspool');
function Db(cfg)
{
this.repos_dir = cfg.repos_dir;
this.bsspool = new BSSPool({'repos_dir':this.repos_dir});
}
Db.prototype.request = function(req,cb)
{
if(req.object_type!='storage_service_request'){
return cb(null,result_error('invalid request'));
}
var cmd = req.command;
switch (cmd) {
case 'write':
var prm_w = {
'storage' : req.storage_name,
'meta' : req.meta,
'data' : req.resource.value
}
this.bsscmd_w(prm_w,cb)
break;
default:
cb(null,result_error('invalid command'));
}
}
Db.prototype.bsscmd_w = function(cmd,cb)
{
var filepath = this.repos_dir + '/' + name2path(cmd.storage) + '.bss'
var bssname = cmd.storage;
}
function name2path(name){
return name.split('.').join('/');
}
function result_error(msg)
{
return {'status':'ERR','msg':msg}
}
function result_ok(msg)
{
return {'status':'OK','msg':msg}
}
...@@ -76,6 +76,7 @@ function run_job(cfg) ...@@ -76,6 +76,7 @@ function run_job(cfg)
var dm_i = domain.create(); var dm_i = domain.create();
dm_i.on('error', function(err) { dm_i.on('error', function(err) {
console.log('plugins error'); console.log('plugins error');
console.log(err);
callback(err) callback(err)
}); });
...@@ -98,6 +99,7 @@ function run_job(cfg) ...@@ -98,6 +99,7 @@ function run_job(cfg)
var dm_t = domain.create(); var dm_t = domain.create();
dm_t.on('error', function(err) { dm_t.on('error', function(err) {
console.log('plugins error'); console.log('plugins error');
console.log(err);
callback(err) callback(err)
}); });
...@@ -120,6 +122,7 @@ function run_job(cfg) ...@@ -120,6 +122,7 @@ function run_job(cfg)
var dm_o = domain.create(); var dm_o = domain.create();
dm_o.on('error', function(err) { dm_o.on('error', function(err) {
console.log('plugins error'); console.log('plugins error');
console.log(err);
callback(err) callback(err)
}); });
......
...@@ -22,9 +22,9 @@ const crypto = require("crypto"); ...@@ -22,9 +22,9 @@ const crypto = require("crypto");
// //
// console.log(id); // console.log(id);
var bss_handler = ctx.getLib('storage-service/lib/bss_handler'); var bss_handler = ctx.getLib('storage-service/lib/bss_engine');
var bss = bss_handler.create('d:/testfile/hnd.bss'); var bss = bss_handler.create('d:/testfile/new/slash/hnd.bss');
bss.open(function(err){ bss.open(function(err){
console.log('open'); console.log('open');
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment