Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

dbreg_stat.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1997-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: dbreg_stat.c,v 12.5 2005/10/12 15:01:47 margo Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 #include <string.h>
00015 #endif
00016 
00017 #include "db_int.h"
00018 #include "dbinc/db_page.h"
00019 #include "dbinc/db_am.h"
00020 #include "dbinc/log.h"
00021 #include "dbinc/txn.h"
00022 
00023 #ifdef HAVE_STATISTICS
00024 static int __dbreg_print_dblist __P((DB_ENV *, u_int32_t));
00025 
00026 /*
00027  * __dbreg_stat_print --
00028  *      Print the dbreg statistics.
00029  *
00030  * PUBLIC: int __dbreg_stat_print __P((DB_ENV *, u_int32_t));
00031  */
00032 int
00033 __dbreg_stat_print(dbenv, flags)
00034         DB_ENV *dbenv;
00035         u_int32_t flags;
00036 {
00037         int ret;
00038 
00039         if (LF_ISSET(DB_STAT_ALL) &&
00040             (ret = __dbreg_print_dblist(dbenv, flags)) != 0)
00041                 return (ret);
00042 
00043         return (0);
00044 }
00045 
00046 /*
00047  * __dbreg_print_fname --
00048  *      Display the contents of an FNAME structure.
00049  *
00050  * PUBLIC: void __dbreg_print_fname __P((DB_ENV *, FNAME *));
00051  */
00052 void
00053 __dbreg_print_fname(dbenv, fnp)
00054         DB_ENV *dbenv;
00055         FNAME *fnp;
00056 {
00057         static const FN fn[] = {
00058                 { DB_FNAME_DURABLE,     "DB_FNAME_DURABLE" },
00059                 { DB_FNAME_NOTLOGGED,   "DB_FNAME_NOTLOGGED" },
00060                 { 0,                    NULL }
00061         };
00062 
00063         __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00064         __db_msg(dbenv, "DB handle FNAME contents:");
00065         STAT_LONG("log ID", fnp->id);
00066         STAT_ULONG("Meta pgno", fnp->meta_pgno);
00067         __db_print_fileid(dbenv, fnp->ufid, "\tFile ID");
00068         STAT_ULONG("create txn", fnp->create_txnid);
00069         __db_prflags(dbenv, NULL, fnp->flags, fn, NULL, "\tFlags");
00070 }
00071 
00072 /*
00073  * __dbreg_print_dblist --
00074  *      Display the DB_ENV's list of files.
00075  */
00076 static int
00077 __dbreg_print_dblist(dbenv, flags)
00078         DB_ENV *dbenv;
00079         u_int32_t flags;
00080 {
00081         DB *dbp;
00082         DB_LOG *dblp;
00083         FNAME *fnp;
00084         LOG *lp;
00085         int del, first;
00086         char *name;
00087 
00088         dblp = dbenv->lg_handle;
00089         lp = dblp->reginfo.primary;
00090 
00091         __db_msg(dbenv, "%s", DB_GLOBAL(db_line));
00092         __db_msg(dbenv, "LOG FNAME list:");
00093         __mutex_print_debug_single(
00094             dbenv, "File name mutex", lp->mtx_filelist, flags);
00095 
00096         STAT_LONG("Fid max", lp->fid_max);
00097 
00098         MUTEX_LOCK(dbenv, lp->mtx_filelist);
00099         for (first = 1, fnp = SH_TAILQ_FIRST(&lp->fq, __fname);
00100             fnp != NULL; fnp = SH_TAILQ_NEXT(fnp, q, __fname)) {
00101                 if (first) {
00102                         first = 0;
00103                         __db_msg(dbenv,
00104                             "ID\tName\tType\tPgno\tTxnid\tDBP-info");
00105                 }
00106                 if (fnp->name_off == INVALID_ROFF)
00107                         name = "";
00108                 else
00109                         name = R_ADDR(&dblp->reginfo, fnp->name_off);
00110 
00111                 dbp = fnp->id >= dblp->dbentry_cnt ? NULL :
00112                     dblp->dbentry[fnp->id].dbp;
00113                 del = fnp->id >= dblp->dbentry_cnt ? 0 :
00114                     dblp->dbentry[fnp->id].deleted;
00115                 __db_msg(dbenv, "%ld\t%s\t%s\t%lu\t%lx\t%s %d %lx %lx",
00116                     (long)fnp->id, name,
00117                     __db_dbtype_to_string(fnp->s_type),
00118                     (u_long)fnp->meta_pgno, (u_long)fnp->create_txnid,
00119                     dbp == NULL ? "No DBP" : "DBP", del, P_TO_ULONG(dbp),
00120                     (u_long)(dbp == NULL ? 0 : dbp->flags));
00121         }
00122         MUTEX_UNLOCK(dbenv, lp->mtx_filelist);
00123 
00124         return (0);
00125 }
00126 #endif

Generated on Sun Dec 25 12:14:24 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2