本文整理汇总了C++中DB_DEBUG函数的典型用法代码示例。如果您正苦于以下问题:C++ DB_DEBUG函数的具体用法?C++ DB_DEBUG怎么用?C++ DB_DEBUG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DB_DEBUG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
void
CVarDataFile::MarkSlotDeleted(UInt32 inSlotPos, RecIDT inRecID) {
RecIDT recID = 0; // use 0 as deleted slot marker
#if DB_DEBUG_MODE || DB_INTEGRITY_CHECKING
ASSERT(mBytesUsed <= mAllocatedBytes); // can't use more than we've allocated
ASSERT((mAllocatedBytes+mFirstItemPos) == GetLength()); // LFileStream needs to be in synch
if (GetLength() < (SInt32)inSlotPos) {
DB_LOG("ERROR: Delete Rec " << inRecID << " pos: "<<inSlotPos <<" FAILED, overran datafile length "<<GetLength()<<"B");
DB_DEBUG("ERROR: Trying to delete-mark slot at offset "<<inSlotPos<<", but datafile is only "<<GetLength()<<" bytes long.", DEBUG_ERROR);
Throw_( dbIndexCorrupt );
}
SetMarker(inSlotPos + kVarDBFileRecIDOffset, streamFrom_Start); // debugging, check old ID
ReadBlock(&recID, kSizeOfRecID);
#if PLATFORM_LITTLE_ENDIAN
recID = BigEndian32_ToNative(recID);
#endif // PLATFORM_LITTLE_ENDIAN
DB_DEBUG("MarkSlotDeleted(); deleted_id: " << recID, DEBUG_TRIVIA);
if (recID != inRecID) {
DB_LOG("ERROR: Delete Rec " << inRecID << " pos: "<<inSlotPos << " FAILED, slot has Record "<<recID);
DB_DEBUG("ERROR: Tried to delete Record ID " << inRecID << " but record " <<recID
<<" found in slot at "<<inSlotPos, DEBUG_ERROR);
Throw_( dbIndexCorrupt );
}
if (recID == 0) {
DB_LOG("WARNING: Delete Rec " << inRecID << " pos: "<<inSlotPos << " previously deleted");
DB_DEBUG("NON-CRITICAL ERROR: Deleting a slot with a zero (deleted) ID", DEBUG_ERROR);
}
recID = 0;
#endif
// writing zero, don't worry about endian swap
SetMarker(inSlotPos + kVarDBFileRecIDOffset, streamFrom_Start); // move to position of recID in slot
WriteBlock(&recID, kSizeOfRecID); // write the deletion maker
DB_LOG("Deleted Rec " << inRecID << " pos: "<<inSlotPos);
DB_DEBUG("MarkSlotDeleted(); pos: " << inSlotPos, DEBUG_TRIVIA);
}
示例2: SetDefaultComparator
ADataStore::ADataStore() { // ** NOT THREAD SAFE **
itsDefaultComparator = (LComparator*)nil;
mBatchMode = false;
mLastRecID = 0;
mFileOpen = false;
itsStream = (LStream*)nil;
SetDefaultComparator(new CRecIDComparator); // use a ID comparator as initial default
#if DB_THREAD_SUPPORT
if (UEnvironment::HasFeature(env_HasThreadsManager)) {
mChangeID = new LMutexSemaphore();
mAccessHeader = new LMutexSemaphore();
mAccessData = new LMutexSemaphore();
mChangeInfo = new LMutexSemaphore();
ThrowIfNil_(mChangeID);
ThrowIfNil_(mAccessHeader);
ThrowIfNil_(mAccessData);
ThrowIfNil_(mChangeInfo);
} else {
mChangeID = (LMutexSemaphore*)nil;
mAccessHeader = (LMutexSemaphore*)nil;
mAccessData = (LMutexSemaphore*)nil;
mChangeInfo = (LMutexSemaphore*)nil;
}
#endif
DB_DEBUG("Contructed v1.0 Datastore", DEBUG_TRIVIA);
}
示例3: _remove_clusters_from_fed
static int _remove_clusters_from_fed(mysql_conn_t *mysql_conn, List clusters)
{
int rc = SLURM_SUCCESS;
char *query = NULL;
char *name = NULL;
char *names = NULL;
ListIterator itr = NULL;
xassert(clusters);
itr = list_iterator_create(clusters);
while ((name = list_next(itr)))
xstrfmtcat(names, "%s'%s'", names ? "," : "", name );
xstrfmtcat(query, "UPDATE %s "
"SET federation='', fed_id=0, fed_state=%u "
"WHERE name IN (%s) and deleted=0",
cluster_table, CLUSTER_FED_STATE_NA, names);
if (debug_flags & DEBUG_FLAG_FEDR)
DB_DEBUG(mysql_conn->conn, "query\n%s", query);
rc = mysql_db_query(mysql_conn, query);
xfree(query);
if (rc)
error("Failed to remove clusters %s from federation", names);
xfree(names);
return rc;
}
示例4: ASSERT
ADataStore::ADataStore(SInt16 inStrcResID) { // ** NOT THREAD SAFE **
ASSERT(inStrcResID >= 128); // Strc ids 0..127 are reserved for internal use
itsDefaultComparator = (LComparator*)nil;
mBatchMode = false;
mLastRecID = 0;
mFileOpen = false;
mOwnsComparator = false;
itsStream = (LStream*)nil;
SetDefaultComparator(new CRecIDComparator, true); // use a ID comparator as initial default
mStrcResID = inStrcResID;
mStructure = (UStructure*)nil;
#if DB_THREAD_SUPPORT
if (UEnvironment::HasFeature(env_HasThreadsManager)) {
mChangeID = new LMutexSemaphore();
mAccessHeader = new LMutexSemaphore();
mAccessData = new LMutexSemaphore();
mChangeInfo = new LMutexSemaphore();
ThrowIfNil_(mChangeID);
ThrowIfNil_(mAccessHeader);
ThrowIfNil_(mAccessData);
ThrowIfNil_(mChangeInfo);
} else {
mChangeID = (LMutexSemaphore*)nil;
mAccessHeader = (LMutexSemaphore*)nil;
mAccessData = (LMutexSemaphore*)nil;
mChangeInfo = (LMutexSemaphore*)nil;
}
#endif
DB_DEBUG("Contructed v1.5 Datastore: struct id " << inStrcResID, DEBUG_TRIVIA);
}
示例5: DB_DEBUG
UInt32
CVarDataFile::AddNewEmptySlot(SInt32 inSize) {
if (inSize > mLargestRecSize) {
DB_DEBUG("New largest rec is "<<inSize<<" bytes. Previously "<<mLargestRecSize, DEBUG_TRIVIA);
mLargestRecSize = inSize; // keep track of largest record
}
mItemCount++;
mAllocatedSlots = mItemCount + 1L; // update #slots
UInt32 oldBytesUsed = mBytesUsed;
mBytesUsed += inSize;
if (mBytesUsed >= mAllocatedBytes) {
if (!mBatchMode) {
mAllocatedBytes = mBytesUsed + kAllocationBlockSize;
} else {
mAllocatedBytes = mBytesUsed + kAllocationBlockSize*8L; // big blocks for batches
}
ASSERT(mAllocatedBytes > mBytesUsed);
ASSERT(mAllocatedBytes >= (SInt32)(mItemCount*RecSizeToSlotSize(sizeof(DatabaseRec)))); // must have at least a header
UInt32 fileSize = mFirstItemPos + mAllocatedBytes;
// fill the newly allocated stuff with FFFF
UInt32 eraseStart = mFirstItemPos + oldBytesUsed;
ASSERT(eraseStart < fileSize);
UInt32 eraseLen = fileSize - eraseStart;
void* p = std::malloc(eraseLen);
SetLength(fileSize); // expand file
if (p) {
std::memset(p, 0xff, eraseLen);
SetMarker(eraseStart, streamFrom_Start);
WriteBlock(p, eraseLen); // fill the unused part of the data file
} else {
DB_DEBUG("Failed to malloc "<<eraseLen<<" bytes for new space erasure in data file", DEBUG_ERROR);
}
if (!mBatchMode) {
WriteHeader(); // write new # slots, etc.. in disk file header
}
}
UInt32 recPos = oldBytesUsed + mFirstItemPos;
SetMarker(recPos + kVarDBFileSlotSizeOffset, streamFrom_Start); // write the slot size in the slot
inSize = Native_ToBigEndian32(inSize);
WriteBlock(&inSize, kSizeOfSlotSize);
inSize = BigEndian32_ToNative(inSize); // restore endianness
RecIDT tempID = 0; // debugging, make sure the ID is cleared from new slots
WriteBlock(&tempID, sizeof(RecIDT));
DB_LOG("Add New Slot size: " << inSize << "B pos: "<<recPos <<" slots: " << mAllocatedSlots);
DB_DEBUG("AddNewEmptySlot(); size: "<<inSize<<" pos: "<<recPos<<" slots: "<<mAllocatedSlots, DEBUG_TRIVIA);
return recPos;
}
示例6: as_mysql_register_ctld
extern int as_mysql_register_ctld(mysql_conn_t *mysql_conn,
char *cluster, uint16_t port)
{
char *query = NULL;
char *address = NULL;
char hostname[255];
time_t now = time(NULL);
uint32_t flags = slurmdb_setup_cluster_flags();
int rc = SLURM_SUCCESS;
if (slurmdbd_conf)
fatal("clusteracct_storage_g_register_ctld "
"should never be called from the slurmdbd.");
if (check_connection(mysql_conn) != SLURM_SUCCESS)
return ESLURM_DB_CONNECTION;
if (!mysql_conn->cluster_name) {
error("%s:%d no cluster name", THIS_FILE, __LINE__);
return SLURM_ERROR;
}
if (!mysql_conn->cluster_name)
mysql_conn->cluster_name = xstrdup(cluster);
info("Registering slurmctld for cluster %s at port %u in database.",
cluster, port);
gethostname(hostname, sizeof(hostname));
/* check if we are running on the backup controller */
if (slurmctld_conf.backup_controller
&& !strcmp(slurmctld_conf.backup_controller, hostname)) {
address = slurmctld_conf.backup_addr;
} else
address = slurmctld_conf.control_addr;
query = xstrdup_printf(
"update %s set deleted=0, mod_time=%ld, "
"control_host='%s', control_port=%u, last_port=%u, "
"rpc_version=%d, dimensions=%d, flags=%u, "
"plugin_id_select=%d where name='%s';",
cluster_table, now, address, port, port, SLURM_PROTOCOL_VERSION,
SYSTEM_DIMENSIONS, flags, select_get_plugin_id(), cluster);
xstrfmtcat(query,
"insert into %s "
"(timestamp, action, name, actor, info) "
"values (%ld, %d, '%s', '%s', '%s %u %u %u %u');",
txn_table,
now, DBD_MODIFY_CLUSTERS, cluster,
slurmctld_conf.slurm_user_name, address, port,
SYSTEM_DIMENSIONS, flags, select_get_plugin_id());
if (debug_flags & DEBUG_FLAG_DB_ASSOC)
DB_DEBUG(mysql_conn->conn, "query\n%s", query);
rc = mysql_db_query(mysql_conn, query);
xfree(query);
return rc;
}
示例7: _add_clusters_to_fed
static int _add_clusters_to_fed(mysql_conn_t *mysql_conn, List clusters,
const char *fed)
{
int rc = SLURM_SUCCESS;
char *query = NULL;
char *name = NULL;
char *names = NULL;
char *indexes = NULL;
ListIterator itr = NULL;
int last_id = -1;
xassert(fed);
xassert(clusters);
itr = list_iterator_create(clusters);
while ((name = list_next(itr))) {
int id;
if ((rc = as_mysql_get_fed_cluster_id(mysql_conn, name, fed,
last_id, &id)))
goto end_it;
last_id = id;
xstrfmtcat(indexes, "WHEN name='%s' THEN %d ", name, id);
xstrfmtcat(names, "%s'%s'", names ? "," : "", name);
}
/* Keep the same fed_state if the cluster isn't changing feds.
* Also note that mysql evaluates from left to right and uses the
* updated column values in case statements. So the check for federation
* in the fed_state case statement must happen before fed_state is set
* or the federation will always equal the federation in the case
* statement. */
xstrfmtcat(query, "UPDATE %s "
"SET "
"fed_state = CASE WHEN federation='%s' THEN fed_state ELSE %u END, "
"fed_id = CASE %s END, "
"federation='%s' "
"WHERE name IN (%s) and deleted=0",
cluster_table, fed, CLUSTER_FED_STATE_ACTIVE, indexes, fed,
names);
if (debug_flags & DEBUG_FLAG_FEDR)
DB_DEBUG(mysql_conn->conn, "query\n%s", query);
rc = mysql_db_query(mysql_conn, query);
if (rc)
error("Failed to add clusters %s to federation %s",
names, fed);
end_it:
xfree(query);
xfree(names);
xfree(indexes);
list_iterator_destroy(itr);
return rc;
}
示例8: WriteHeader
bool // ** NOT THREAD SAFE **
ADataStore::SetBatchMode(bool inBatchMode) {
bool oldBatchMode = mBatchMode;
mBatchMode = inBatchMode;
if (!mBatchMode) {
WriteHeader(); // write the header now that we are done with batch mode
}
DB_DEBUG("SetBatchMode("<<inBatchMode<<")", DEBUG_TRIVIA);
return(oldBatchMode);
}
示例9: as_mysql_fix_runaway_jobs
extern int as_mysql_fix_runaway_jobs(mysql_conn_t *mysql_conn, uint32_t uid,
List runaway_jobs)
{
char *query = NULL, *job_ids = NULL;
slurmdb_job_rec_t *job = NULL;
ListIterator iter = NULL;
int rc = SLURM_SUCCESS;
slurmdb_job_rec_t *first_job;
list_sort(runaway_jobs, _job_sort_by_start_time);
first_job = list_peek(runaway_jobs);
if (check_connection(mysql_conn) != SLURM_SUCCESS)
return ESLURM_DB_CONNECTION;
if (!is_user_min_admin_level(mysql_conn, uid, SLURMDB_ADMIN_OPERATOR)) {
slurmdb_user_rec_t user;
memset(&user, 0, sizeof(slurmdb_user_rec_t));
user.uid = uid;
if (!is_user_any_coord(mysql_conn, &user)) {
error("Only admins/operators/coordinators "
"can fix runaway jobs");
return ESLURM_ACCESS_DENIED;
}
}
iter = list_iterator_create(runaway_jobs);
while ((job = list_next(iter))) {
xstrfmtcat(job_ids, "%s%d", ((job_ids) ? "," : ""), job->jobid);
}
query = xstrdup_printf("UPDATE \"%s_%s\" SET time_end="
"GREATEST(time_start, time_eligible, time_submit), "
"state=%d WHERE id_job IN (%s);",
mysql_conn->cluster_name, job_table,
JOB_COMPLETE, job_ids);
if (debug_flags & DEBUG_FLAG_DB_QUERY)
DB_DEBUG(mysql_conn->conn, "query\n%s", query);
mysql_db_query(mysql_conn, query);
xfree(query);
xfree(job_ids);
/* Set rollup to the the last day of the previous month of the first
* runaway job */
rc = _first_job_roll_up(mysql_conn, first_job->start);
if (rc != SLURM_SUCCESS) {
error("Failed to fix runaway jobs");
return SLURM_ERROR;
}
return rc;
}
示例10: DB_DEBUG
bool // ** NOT THREAD SAFE **
ADataStore::ReadHeader() {
Bool8 fileOpen;
itsStream->SetMarker(0, streamFrom_Start);
*itsStream >> mStreamType;
*itsStream >> mStreamVersion;
*itsStream >> fileOpen;
*itsStream >> mLastRecID;
DB_DEBUG("ReadHeader(): "<< (fileOpen?"already open":"closed"), DEBUG_TRIVIA);
return fileOpen;
}
示例11: hss_mysql_query_mmeidentity
int hss_mysql_query_mmeidentity(const int id_mme_identity,
mysql_mme_identity_t *mme_identity_p)
{
MYSQL_RES *res;
MYSQL_ROW row;
char query[1000];
if ((db_desc->db_conn == NULL) || (mme_identity_p == NULL)) {
return EINVAL;
}
memset(mme_identity_p, 0, sizeof(mysql_mme_identity_t));
sprintf(query, "SELECT mmehost,mmerealm FROM mmeidentity WHERE "
"mmeidentity.idmmeidentity='%d' ", id_mme_identity);
DB_DEBUG("Query: %s\n", query);
pthread_mutex_lock(&db_desc->db_cs_mutex);
if (mysql_query(db_desc->db_conn, query)) {
pthread_mutex_unlock(&db_desc->db_cs_mutex);
DB_ERROR("Query execution failed: %s\n",
mysql_error(db_desc->db_conn));
mysql_thread_end();
return EINVAL;
}
res = mysql_store_result(db_desc->db_conn);
pthread_mutex_unlock(&db_desc->db_cs_mutex);
if ((row = mysql_fetch_row(res)) != NULL) {
if (row[0] != NULL) {
memcpy(mme_identity_p->mme_host, row[0], strlen(row[0]));
} else {
mme_identity_p->mme_host[0] = '\0';
}
if (row[1] != NULL) {
memcpy(mme_identity_p->mme_realm, row[1], strlen(row[1]));
} else {
mme_identity_p->mme_realm[0] = '\0';
}
mysql_free_result(res);
mysql_thread_end();
return 0;
}
mysql_free_result(res);
mysql_thread_end();
return EINVAL;
}
示例12: as_mysql_remove_resv
extern int as_mysql_remove_resv(mysql_conn_t *mysql_conn,
slurmdb_reservation_rec_t *resv)
{
int rc = SLURM_SUCCESS;
char *query = NULL;
if (!resv) {
error("No reservation was given to remove");
return SLURM_ERROR;
}
if (!resv->id) {
error("An id is needed to remove a reservation.");
return SLURM_ERROR;
}
if (!resv->time_start) {
error("A start time is needed to remove a reservation.");
return SLURM_ERROR;
}
if (!resv->cluster || !resv->cluster[0]) {
error("A cluster name is needed to remove a reservation.");
return SLURM_ERROR;
}
/* first delete the resv that hasn't happened yet. */
query = xstrdup_printf("delete from \"%s_%s\" where time_start > %ld "
"and id_resv=%u and time_start=%ld;",
resv->cluster, resv_table, resv->time_start_prev,
resv->id,
resv->time_start);
/* then update the remaining ones with a deleted flag and end
* time of the time_start_prev which is set to when the
* command was issued */
xstrfmtcat(query,
"update \"%s_%s\" set time_end=%ld, "
"deleted=1 where deleted=0 and "
"id_resv=%u and time_start=%ld;",
resv->cluster, resv_table, resv->time_start_prev,
resv->id, resv->time_start);
if (debug_flags & DEBUG_FLAG_DB_RESV)
DB_DEBUG(mysql_conn->conn, "query\n%s", query);
rc = mysql_db_query(mysql_conn, query);
xfree(query);
return rc;
}
示例13: _reset_default_wckey
static int _reset_default_wckey(mysql_conn_t *mysql_conn,
slurmdb_wckey_rec_t *wckey)
{
time_t now = time(NULL);
int rc = SLURM_SUCCESS;
char *query = NULL;
MYSQL_RES *result = NULL;
MYSQL_ROW row;
if ((wckey->is_def != 1)
|| !wckey->cluster || !wckey->user || !wckey->name)
return SLURM_ERROR;
xstrfmtcat(query, "update \"%s_%s\" set is_def=0, mod_time=%ld "
"where (user='%s' && wckey_name!='%s' && is_def=1);"
"select id_wckey from \"%s_%s\" "
"where (user='%s' && wckey_name!='%s' && is_def=1);",
wckey->cluster, wckey_table, (long)now,
wckey->user, wckey->name,
wckey->cluster, wckey_table,
wckey->user, wckey->name);
if (debug_flags & DEBUG_FLAG_DB_WCKEY)
DB_DEBUG(mysql_conn->conn, "query\n%s", query);
if (!(result = mysql_db_query_ret(mysql_conn, query, 1))) {
xfree(query);
rc = SLURM_ERROR;
goto end_it;
}
xfree(query);
while ((row = mysql_fetch_row(result))) {
slurmdb_wckey_rec_t *mod_wckey =
xmalloc(sizeof(slurmdb_wckey_rec_t));
slurmdb_init_wckey_rec(mod_wckey, 0);
mod_wckey->id = slurm_atoul(row[0]);
mod_wckey->is_def = 0;
if (addto_update_list(mysql_conn->update_list,
SLURMDB_MODIFY_WCKEY,
mod_wckey)
!= SLURM_SUCCESS) {
slurmdb_destroy_wckey_rec(mod_wckey);
error("couldn't add to the update list");
rc = SLURM_ERROR;
break;
}
}
mysql_free_result(result);
end_it:
return rc;
}
示例14: mutex
void //** Thread Safe **
ADataStore::WriteHeader(bool inFileOpen) {
Bool8 fileOpen = inFileOpen;
#if DB_THREAD_SUPPORT
StSafeMutex mutex(mAccessHeader);
#endif
ASSERT(sizeof(RecIDT) == sizeof(UInt32)); // precondition for this to work correctly
// don't write the type and version info each time
itsStream->SetMarker(sizeof(OSType) + sizeof(UInt32), streamFrom_Start);
*itsStream << fileOpen; //***CW8 // platform independant files
*itsStream << mLastRecID;
DB_DEBUG("WriteHeader("<<(int)inFileOpen<<")", DEBUG_TRIVIA);
}
示例15: _process_cluster_usage
static int _process_cluster_usage(mysql_conn_t *mysql_conn,
char *cluster_name,
time_t curr_start, time_t curr_end,
time_t now, local_cluster_usage_t *c_usage)
{
int rc = SLURM_SUCCESS;
char *query = NULL;
ListIterator itr;
local_tres_usage_t *loc_tres;
if (!c_usage)
return rc;
/* Now put the lists into the usage tables */
xassert(c_usage->loc_tres);
itr = list_iterator_create(c_usage->loc_tres);
while ((loc_tres = list_next(itr))) {
_setup_cluster_tres_usage(mysql_conn, cluster_name,
curr_start, curr_end, now,
c_usage->start, loc_tres, &query);
}
list_iterator_destroy(itr);
if (!query)
return rc;
xstrfmtcat(query,
" on duplicate key update "
"mod_time=%ld, count=VALUES(count), "
"alloc_secs=VALUES(alloc_secs), "
"down_secs=VALUES(down_secs), "
"pdown_secs=VALUES(pdown_secs), "
"idle_secs=VALUES(idle_secs), "
"over_secs=VALUES(over_secs), "
"resv_secs=VALUES(resv_secs)",
now);
/* Spacing out the inserts here instead of doing them
all at once in the end proves to be faster. Just FYI
so we don't go testing again and again.
*/
if (debug_flags & DEBUG_FLAG_DB_USAGE)
DB_DEBUG(mysql_conn->conn, "query\n%s", query);
rc = mysql_db_query(mysql_conn, query);
xfree(query);
if (rc != SLURM_SUCCESS)
error("Couldn't add cluster hour rollup");
return rc;
}