Commit 22075623 authored by lw's avatar lw

corrected bugs in wb_volrepdb, finished meta volumes in db and dbs

parent c2327079
......@@ -484,7 +484,7 @@ static dbs_sVolRef *findVolref(dbs_sMenv *mep, pwr_tVid vid)
}
void
dbs_Split(pwr_tStatus *sts, dbs_sMenv *mep)
dbs_Split(pwr_tStatus *sts, dbs_sMenv *mep, char *dirName)
{
int i;
......@@ -497,7 +497,7 @@ dbs_Split(pwr_tStatus *sts, dbs_sMenv *mep)
size_t bytes;
size_t size;
FILE *fp;
char fileName[256];
char fileName[512];
char *p;
vep = &mep->venv[i + 1];
......@@ -508,7 +508,7 @@ dbs_Split(pwr_tStatus *sts, dbs_sMenv *mep)
printf(" size %d, index %d, nSect %d\n", vep->size, vep->index, vep->nSect);
size = offset = vep->size;
sprintf(fileName, "%s.dbs", vep->vp->name);
sprintf(fileName, "%s/%s.dbs", dirName, vep->vp->name);
cdh_ToLower(fileName, fileName);
fp = fopen(fileName, "w+b");
......
......@@ -616,7 +616,7 @@ struct dbs_sScObject {
%
%dbs_sMenv *dbs_Map(pwr_tStatus*, const char*);
%dbs_sVenv *dbs_Vmap(pwr_tStatus*, int index, dbs_sMenv *);
%void dbs_Split(pwr_tStatus *sts, dbs_sMenv *mep);
%void dbs_Split(pwr_tStatus *sts, dbs_sMenv *mep, char *dirName);
%pwr_tBoolean dbs_Unmap(pwr_tStatus *sts, dbs_sMenv *);
%int dbs_nVolRef(pwr_tStatus *sts, const dbs_sMenv *mep);
%
......
......@@ -109,8 +109,8 @@ int main( int argc, char *argv[])
if (!oep->flags.b.inClass) printf("[%d] not in class\n", oep->o.oid.oix);
if (!oep->flags.b.inRbody && oep->o.body[0].size != 0) printf("[%d] not in rbody\n", oep->o.oid.oix);
if (!oep->flags.b.inDbody && oep->o.body[1].size != 0) printf("[%d] not in dbody\n", oep->o.oid.oix);
if (oep->flags.b.inRbody && oep->o.body[0].size == 0) printf("[%d] in rbody\n", oep->o.oid.oix);
if (oep->flags.b.inDbody && oep->o.body[1].size == 0) printf("[%d] in dbody\n", oep->o.oid.oix);
//if (oep->flags.b.inRbody && oep->o.body[0].size == 0) printf("[%d] in rbody\n", oep->o.oid.oix);
//if (oep->flags.b.inDbody && oep->o.body[1].size == 0) printf("[%d] in dbody\n", oep->o.oid.oix);
if (!oep->flags.b.pOk) {
#if 1
if (oep->poep != NULL && oep->poep->flags.b.inOhead) {
......@@ -169,8 +169,10 @@ printname(pwr_tOid poid, pwr_tObjName name, pwr_tOid oid)
sOentry *oep;
count_name++;
printf("N [%10.10d.%10.10d] %d:%s\n", oid.vid, oid.oix, strlen(name), name);
if (cdh_ObjidIsNull(poid) || poid.oix == 0) {
printf("N [%10.10d.%10.10d] %d:%s\n", oid.vid, oid.oix, strlen(name), name);
}
oep = (sOentry *)tree_Find(&sts, oid_th, &oid);
if (EVEN(sts)) {
printf("Name: object not found %d.%d, %s\n", oid.vid, oid.oix, name);
......@@ -197,7 +199,7 @@ printclass(pwr_tOid oid, pwr_tCid cid)
sOentry *oep;
count_class++;
printf("C [%10.10d.%10.10d] <%d>\n", oid.vid, oid.oix, cid);
//printf("C [%10.10d.%10.10d] <%d>\n", oid.vid, oid.oix, cid);
oep = (sOentry *)tree_Find(&sts, oid_th, &oid);
if (EVEN(sts)) {
......@@ -221,10 +223,12 @@ printohead(pwr_tOid oid, db_sObject *op)
if (cdh_ObjidIsNotEqual(oid, op->oid))
printf("Ohead: oid not equal %s oid: %d.%d != %d.%d\n", op->name, oid.vid, oid.oix, op->oid.vid, op->oid.oix);
// printf("O [%10.10d.%10.10d] [%10.10d.%10.10d] P [%10.10d.%10.10d] %d:%s\n B [%10.10d.%10.10d] A [%10.10d.%10.10d] F [%10.10d.%10.10d] L [%10.10d.%10.10d] \n", oid.vid, oid.oix, op->oid.vid, op->oid.oix, op->poid.vid, op->poid.oix, strlen(op->name), op->name, op->boid.vid, op->boid.oix, op->aoid.vid, op->aoid.oix, op->foid.vid, op->foid.oix, op->loid.vid, op->loid.oix);
printf("P [%6.6d] B [%6.6d] O [%6.6d] A [%6.6d] F [%6.6d] L [%6.6d]\n", op->poid.oix, op->boid.oix, op->oid.oix, op->aoid.oix, op->foid.oix, op->loid.oix);
// printf("O [%10.10d.%10.10d] [%10.10d.%10.10d] P [%10.10d.%10.10d] %d:%s\n B [%10.10d.%10.10d] A [%10.10d.%10.10d] F [%10.10d.%10.10d] L [%10.10d.%10.10d] \n", oid.vid, oid.oix, op->oid.vid, op->oid.oix, op->poid.vid, op->poid.oix, strlen(op->name), op->name, op->boid.vid, op->boid.oix, op->aoid.vid, op->aoid.oix, op->foid.vid, op->foid.oix, op->loid.vid, op->loid.oix);
if (cdh_ObjidIsNull(op->poid) || op->poid.oix == 0) {
printf("P [%6.6d] B [%6.6d] O [%6.6d] A [%6.6d] F [%6.6d] L [%6.6d]\n", op->poid.oix, op->boid.oix, op->oid.oix, op->aoid.oix, op->foid.oix, op->loid.oix);
}
oep = (sOentry *)tree_Insert(&sts, oid_th, &oid);
if (sts == TREE__INSERTED) {
oep->flags.b.inOhead = 1;
......
#include "pwr.h"
#include "wb_merep.h"
#include "wb_erep.h"
#include "wb_env.h"
#include "wb_vrepdbs.h"
......@@ -17,7 +18,7 @@
#include "co_dbs.h"
#include "co_time.h"
#if 1
#if 0
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
......@@ -125,10 +126,10 @@ int main( int argc, char *argv[])
printf("\nDitt namn baklnges r: %s\n", bnamn);
}
#elif 0
#elif 1
int main( int argc, char *argv[])
{
pwr_tStatus sts;
//pwr_tStatus sts;
//dbs_sEnv env;
//dbs_sEnv *ep;
wb_erep *erep = new wb_erep();
......@@ -150,13 +151,14 @@ int main( int argc, char *argv[])
//db.importVolume(*vdbs);
db.close();
wb_vrepdb vdb(erep, argv[2]);
wb_name n("VHX-NU4-KOM-EVELINA-Transar-W-cn254");
wb_orepdb *op = (wb_orepdb *)vdb.object(&sts, n);
wb_vrepdb vdb(erep, 1000, pwr_eClass_RootVolume, "Kalle", "/home/lw/kalle");
//wb_vrepdb vdb(erep, argv[2]);
//wb_name n("VHX-NU4-KOM-EVELINA-Transar-W-cn254");
//wb_orepdb *op = (wb_orepdb *)vdb.object(&sts, n);
wb_dbs adbs(vdbs);
adbs.setFileName("alasse.dbs");
adbs.importVolume(vdb);
//wb_dbs adbs(vdbs);
//adbs.setFileName("alasse.dbs");
//adbs.importVolume(vdb);
}
#elif 0
......
......@@ -1196,7 +1196,14 @@ bool wb_db::importDbody(pwr_tOid oid, size_t size, void *body)
return true;
}
bool wb_db::importMeta(dbs_sEnv *ep)
bool wb_db::importMeta(dbs_sMenv *mep)
{
pwr_tStatus sts = 1;
printf("Import meta, my filename: %s\n", m_fileName);
if (mep != 0)
dbs_Split(&sts, mep, m_fileName);
return true;
}
......@@ -99,7 +99,7 @@ public:
bool importDocBlock(pwr_tOid oid, size_t size, char *block) { return true;}
bool importMeta(dbs_sEnv *ep);
bool importMeta(dbs_sMenv *mep);
};
......
......@@ -1142,7 +1142,7 @@ wb_dbs::classInsert(sOentry *oep)
}
bool
wb_dbs::importMeta(dbs_sEnv *ep)
wb_dbs::importMeta(dbs_sMenv *mep)
{
return true;
}
......
......@@ -155,7 +155,7 @@ public:
virtual bool importDocBlock(pwr_tOid oid, size_t size, char *block) { return true;}
virtual bool importMeta(dbs_sEnv *ep);
virtual bool importMeta(dbs_sMenv *mep);
private:
......
......@@ -24,7 +24,7 @@ public:
virtual bool importDocBlock(pwr_tOid oid, size_t size, char *block) = 0;
virtual bool importMeta(dbs_sEnv *ep) = 0;
virtual bool importMeta(dbs_sMenv *mep) = 0;
};
......
......@@ -758,13 +758,19 @@ ldh_GetReferenceInfo(ldh_tSession session, pwr_tOid oid, ldh_sRefInfo *rip)
pwr_tStatus
ldh_GetRootList(ldh_tSession session, pwr_tOid *oid)
{
wb_session *sp = (wb_session *)session;
wb_object o = sp->object();
if (!o) return o.sts();
try {
wb_session *sp = (wb_session *)session;
wb_object o = sp->object();
if (!o) return o.sts();
*oid = o.oid();
*oid = o.oid();
return o.sts();
return o.sts();
} catch (wb_error& e) {
return e.sts();
}
}
/* Get first object in root list of volume with volume id 'vid'. */
......
#include <iostream>
#include <stdlib.h>
#include "wb_merep.h"
#include "wb_cdrep.h"
......@@ -58,6 +59,18 @@ wb_mvrep *wb_merep::volume(pwr_tStatus *sts, const char *name)
return 0;
}
void wb_merep:: copyFiles(const char *dirName)
{
mvrep_iterator it;
for ( it = m_mvrepdbs.begin(); it != m_mvrepdbs.end(); it++) {
wb_vrepdbs *dp = (wb_vrepdbs *)it->second;
char cmd[512];
sprintf(cmd, "cp %s %s", dp->fileName(), dirName);
printf("%s\n", cmd);
system(cmd);
}
}
wb_orep *wb_merep::object(pwr_tStatus *sts, pwr_tOid oid)
{
wb_vrep *vrep = volume( sts, oid.vid);
......
......@@ -3,6 +3,7 @@
#include "wb_mvrep.h"
#include "wb_attrname.h"
#include "wb_vrepdbs.h"
#include <map>
using namespace std;
......@@ -28,6 +29,8 @@ public:
wb_mvrep *volume(pwr_tStatus *sts, pwr_tVid vid);
wb_mvrep *volume(pwr_tStatus *sts, const char *name);
void copyFiles(const char *dirname);
wb_orep *object(pwr_tStatus *sts, pwr_tOid oid);
void addDbs( pwr_tStatus *sts, wb_mvrep *mvrep);
void removeDbs( pwr_tStatus *sts, wb_mvrep *mvrep);
......
......@@ -9,7 +9,7 @@
#include "wb_dbs.h"
#include "db_cxx.h"
#include "wb_ldh.h"
#include "wb_merep.h"
void wb_vrepdb::unref()
{
......@@ -52,6 +52,8 @@ wb_vrepdb::wb_vrepdb(wb_erep *erep, pwr_tVid vid, pwr_tCid cid, const char *volu
m_cid = m_db->cid();
m_merep = m_erep->merep();
m_merep->copyFiles(fileName);
}
wb_erep *wb_vrepdb::erep()
......@@ -399,6 +401,7 @@ wb_orep* wb_vrepdb::createObject(pwr_tStatus *sts, wb_cdef cdef, wb_destination
printf("wb_vrepdb::createObject, c.put rs %d\n", rs);
rs = txn->commit(0);
return new (this) wb_orepdb(&o.m_o);
}
catch (DbException &e) {
......@@ -451,8 +454,6 @@ bool wb_vrepdb::deleteFamilyMember(pwr_tOid oid, wb_db_txn *txn)
wb_db_ohead o(m_db, oid);
o.get(txn);
//if (rs)
//printf("wb_vrepdb::deleteFamilyMember, o.get rs %d\n", rs);
deleteFamilyMember(o.foid(), txn);
......@@ -472,15 +473,15 @@ bool wb_vrepdb::deleteFamilyMember(pwr_tOid oid, wb_db_txn *txn)
// if (rs)
//printf("wb_vrepdb::deleteFamilyMember, rb.get rs %d\n", rs);
rs = o.del(txn);
if (rs)
printf("wb_vrepdb::deleteFamilyMember, o.del rs %d\n", rs);
wb_db_name n(m_db, o.oid(), o.poid(), o.normname());
rs = n.del(txn);
if (rs)
printf("wb_vrepdb::deleteFamilyMember, n.del rs %d\n", rs);
rs = o.del(txn);
if (rs)
printf("wb_vrepdb::deleteFamilyMember, o.del rs %d\n", rs);
return true;
}
......@@ -1114,7 +1115,7 @@ void wb_vrepdb::unadopt(wb_db_txn *txn, wb_db_ohead &o)
}
wb_db_name n(m_db, o.oid(), o.poid(), o.normname());
n.del(txn);
rc = n.del(txn);
if (rc)
printf("wb_vrepdb::unadopt, n.del rc %d\n", rc);
......@@ -1122,9 +1123,13 @@ void wb_vrepdb::unadopt(wb_db_txn *txn, wb_db_ohead &o)
o.aoid(pwr_cNOid);
o.boid(pwr_cNOid);
p.put(txn);
rc = p.put(txn);
if (rc)
printf("wb_vrepdb::unadopt, p.put rc %d\n", rc);
rc = o.put(txn);
if (rc)
printf("wb_vrepdb::unadopt, o.put rc %d\n", rc);
}
bool wb_vrepdb::exportVolume(wb_import &i)
......
......@@ -2,6 +2,7 @@
#define wb_vrepdb_h
#include "wb_vrep.h"
#include "wb_vrepdbs.h"
#include "wb_orepdb.h"
#include "wb_db.h"
#include "db_cxx.h"
......
#include "wb_vrepdbs.h"
#include "wb_orepdbs.h"
#include "wb_erep.h"
#include "wb_merep.h"
#include "wb_erep.h"
#include "wb_import.h"
#include "wb_treeimport.h"
......@@ -507,11 +507,14 @@ bool wb_vrepdbs::exportDbody(wb_import &i)
bool wb_vrepdbs::exportDocBlock(wb_import &i)
{
return false;
}
bool wb_vrepdbs::exportMeta(wb_import &i)
{
i.importMeta(dbsenv()->mp);
return false;
}
......
......@@ -332,7 +332,7 @@ public:
virtual bool importRbody(pwr_tOid oid, size_t size, void *body);
virtual bool importDbody(pwr_tOid oid, size_t size, void *body);
virtual bool importDocBlock(pwr_tOid oid, size_t size, char *block);
virtual bool importMeta(dbs_sEnv *ep) { return true;}
virtual bool importMeta(dbs_sMenv *mep) { return true;}
bool importBuildObject( mem_object *memo);
void loadWbl( char *filename, pwr_tStatus *sts);
void freeObject( mem_object *mem);
......
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