Logger::~Logger() { removeAllHandlers(); delete m_pHandlerList; NdbMutex_Destroy(m_handler_mutex); NdbMutex_Destroy(m_mutex); }
ArbitMgr::~ArbitMgr() { DBUG_ENTER("ArbitMgr::~ArbitMgr"); NdbMutex_Destroy(theThreadMutex); NdbCondition_Destroy(theInputCond); NdbMutex_Destroy(theInputMutex); DBUG_VOID_RETURN; }
void AsyncFile::doStart(Uint32 nodeId, const char * filesystemPath, const char * backup_path) { theFileName.init(nodeId, filesystemPath, backup_path); // Stacksize for filesystem threads // An 8k stack should be enough const NDB_THREAD_STACKSIZE stackSize = 8192; char buf[16]; numAsyncFiles++; BaseString::snprintf(buf, sizeof(buf), "AsyncFile%d", numAsyncFiles); theStartMutexPtr = NdbMutex_Create(); theStartConditionPtr = NdbCondition_Create(); NdbMutex_Lock(theStartMutexPtr); theStartFlag = false; theThreadPtr = NdbThread_Create(runAsyncFile, (void**)this, stackSize, (char*)&buf, NDB_THREAD_PRIO_MEAN); NdbCondition_Wait(theStartConditionPtr, theStartMutexPtr); NdbMutex_Unlock(theStartMutexPtr); NdbMutex_Destroy(theStartMutexPtr); NdbCondition_Destroy(theStartConditionPtr); }
NdbPool* NdbPool::create_instance(Ndb_cluster_connection* cc, Uint32 max_ndb_obj, Uint32 no_conn_obj, Uint32 init_no_ndb_objects) { if (!initPoolMutex()) { return NULL; } NdbMutex_Lock(pool_mutex); NdbPool* a_pool; if (the_pool != NULL) { a_pool = NULL; } else { the_pool = new NdbPool(cc, max_ndb_obj, no_conn_obj); if (!the_pool->init(init_no_ndb_objects)) { delete the_pool; the_pool = NULL; } a_pool = the_pool; } NdbMutex* temp = pool_mutex; if (a_pool == NULL) { pool_mutex = NULL; } NdbMutex_Unlock(pool_mutex); if (a_pool == NULL) { NdbMutex_Destroy(temp); } return a_pool; }
NDBT_TestCaseImpl1::~NDBT_TestCaseImpl1(){ NdbCondition_Destroy(waitThreadsCondPtr); NdbMutex_Destroy(waitThreadsMutexPtr); unsigned i; for(i = 0; i < initializers.size(); i++) delete initializers[i]; initializers.clear(); for(i = 0; i < verifiers.size(); i++) delete verifiers[i]; verifiers.clear(); for(i = 0; i < finalizers.size(); i++) delete finalizers[i]; finalizers.clear(); for(i = 0; i < steps.size(); i++) delete steps[i]; steps.clear(); results.clear(); for(i = 0; i < testTables.size(); i++) delete testTables[i]; testTables.clear(); for(i = 0; i < testResults.size(); i++) delete testResults[i]; testResults.clear(); }
void AsyncFile::doStart() { // Stacksize for filesystem threads #if !defined(DBUG_OFF) && defined (__hpux) // Empirical evidence indicates at least 32k const NDB_THREAD_STACKSIZE stackSize = 32768; #else // Otherwise an 8k stack should be enough const NDB_THREAD_STACKSIZE stackSize = 8192; #endif char buf[16]; numAsyncFiles++; BaseString::snprintf(buf, sizeof(buf), "AsyncFile%d", numAsyncFiles); theStartMutexPtr = NdbMutex_Create(); theStartConditionPtr = NdbCondition_Create(); NdbMutex_Lock(theStartMutexPtr); theStartFlag = false; theThreadPtr = NdbThread_Create(runAsyncFile, (void**)this, stackSize, (char*)&buf, NDB_THREAD_PRIO_MEAN); if (theThreadPtr == 0) ERROR_SET(fatal, NDBD_EXIT_MEMALLOC, "","Could not allocate file system thread"); NdbCondition_Wait(theStartConditionPtr, theStartMutexPtr); NdbMutex_Unlock(theStartMutexPtr); NdbMutex_Destroy(theStartMutexPtr); NdbCondition_Destroy(theStartConditionPtr); }
ClusterMgr::~ClusterMgr() { DBUG_ENTER("ClusterMgr::~ClusterMgr"); doStop(); NdbCondition_Destroy(waitForHBCond); NdbMutex_Destroy(clusterMgrThreadMutex); DBUG_VOID_RETURN; }
SignalQueue::~SignalQueue() { { Guard g(m_mutex); while(m_signalQueueHead != NULL) delete pop(); } NdbMutex_Destroy(m_mutex); m_mutex = NULL; NdbCondition_Destroy(m_cond); m_cond = NULL; }
Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() { DBUG_ENTER("~Ndb_cluster_connection"); TransporterFacade::stop_instance(); if (m_connect_thread) { void *status; g_run_connect_thread= 0; NdbThread_WaitFor(m_connect_thread, &status); NdbThread_Destroy(&m_connect_thread); m_connect_thread= 0; } if (m_transporter_facade != 0) { delete m_transporter_facade; if (m_transporter_facade != TransporterFacade::theFacadeInstance) abort(); TransporterFacade::theFacadeInstance= 0; } if (m_config_retriever) { delete m_config_retriever; m_config_retriever= NULL; } if (ndb_global_event_buffer_mutex != NULL) { NdbMutex_Destroy(ndb_global_event_buffer_mutex); ndb_global_event_buffer_mutex= NULL; } #ifdef VM_TRACE if (ndb_print_state_mutex != NULL) { NdbMutex_Destroy(ndb_print_state_mutex); ndb_print_state_mutex= NULL; } #endif if (m_name) free(m_name); DBUG_VOID_RETURN; }
MultiNdbWakeupHandler::~MultiNdbWakeupHandler() { if (localWakeupMutexPtr) { NdbMutex_Destroy(localWakeupMutexPtr); localWakeupMutexPtr = NULL; } PollGuard pg(* wakeNdb->theImpl); bool rc = wakeNdb->theImpl->m_transporter_facade-> unregisterForWakeup(wakeNdb->theImpl); require(rc); }
void ndb_end_internal() { NdbThread_End(); if (g_ndb_connection_mutex) { NdbMutex_Destroy(g_ndb_connection_mutex); g_ndb_connection_mutex=NULL; } if (g_eventLogger) destroy_event_logger(&g_eventLogger); }
ClusterMgr::~ClusterMgr() { DBUG_ENTER("ClusterMgr::~ClusterMgr"); assert(theStop == 1); if (theArbitMgr != 0) { delete theArbitMgr; theArbitMgr = 0; } NdbCondition_Destroy(waitForHBCond); NdbMutex_Destroy(clusterMgrThreadMutex); DBUG_VOID_RETURN; }
int NdbCondition_Destroy(struct NdbCondition* p_cond) { int result; if(!p_cond) return 1; CloseHandle(p_cond->hEventWaitersDone); NdbMutex_Destroy(p_cond->pNdbMutexWaitersLock); result = (CloseHandle(p_cond->hSemaphore) ? 0 : -1); free(p_cond); return 0; }
void NdbPool::drop_instance() { if (pool_mutex == NULL) { return; } NdbMutex_Lock(pool_mutex); the_pool->release_all(); delete the_pool; the_pool = NULL; NdbMutex* temp = pool_mutex; NdbMutex_Unlock(temp); NdbMutex_Destroy(temp); }
NDBT_Thread::~NDBT_Thread() { if (m_thread != 0) { NdbThread_Destroy(&m_thread); m_thread = 0; } if (m_cond != 0) { NdbCondition_Destroy(m_cond); m_cond = 0; } if (m_mutex != 0) { NdbMutex_Destroy(m_mutex); m_mutex = 0; } }
void EmulatorData::destroy(){ if(theConfiguration) delete theConfiguration; theConfiguration = 0; if(theWatchDog) delete theWatchDog; theWatchDog = 0; if(theThreadConfig) delete theThreadConfig; theThreadConfig = 0; if(theSimBlockList) delete theSimBlockList; theSimBlockList = 0; if(m_socket_server) delete m_socket_server; m_socket_server = 0; NdbMutex_Destroy(theShutdownMutex); if (m_mem_manager) delete m_mem_manager; m_mem_manager = 0; NdbMem_Destroy(); }
struct NdbThread* AsyncIoThread::doStart() { // Stacksize for filesystem threads const NDB_THREAD_STACKSIZE stackSize = 128*1024; char buf[16]; numAsyncFiles++; BaseString::snprintf(buf, sizeof(buf), "AsyncIoThread%d", numAsyncFiles); theStartMutexPtr = NdbMutex_Create(); theStartConditionPtr = NdbCondition_Create(); NdbMutex_Lock(theStartMutexPtr); theStartFlag = false; theThreadPtr = NdbThread_Create(runAsyncIoThread, (void**)this, stackSize, buf, NDB_THREAD_PRIO_MEAN); if (theThreadPtr == 0) { ERROR_SET(fatal, NDBD_EXIT_MEMALLOC, "","Could not allocate file system thread"); } do { NdbCondition_Wait(theStartConditionPtr, theStartMutexPtr); } while (theStartFlag == false); NdbMutex_Unlock(theStartMutexPtr); NdbMutex_Destroy(theStartMutexPtr); NdbCondition_Destroy(theStartConditionPtr); return theThreadPtr; }
MgmApiSession::~MgmApiSession() { DBUG_ENTER("MgmApiSession::~MgmApiSession"); if (m_input) delete m_input; if (m_output) delete m_output; if (m_parser) delete m_parser; if (m_allocated_resources) delete m_allocated_resources; if(m_socket != NDB_INVALID_SOCKET) { NDB_CLOSE_SOCKET(m_socket); m_socket= NDB_INVALID_SOCKET; } if(m_stopSelf < 0) g_RestartServer= true; if(m_stopSelf) g_StopServer= true; NdbMutex_Destroy(m_mutex); DBUG_VOID_RETURN; }
Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() { DBUG_ENTER("~Ndb_cluster_connection"); if (m_transporter_facade != 0) { m_transporter_facade->stop_instance(); } if (m_connect_thread) { void *status; m_run_connect_thread= 0; NdbThread_WaitFor(m_connect_thread, &status); NdbThread_Destroy(&m_connect_thread); m_connect_thread= 0; } if (m_transporter_facade != 0) { delete m_transporter_facade; m_transporter_facade = 0; } if (m_config_retriever) { delete m_config_retriever; m_config_retriever= NULL; } #ifdef VM_TRACE if (ndb_print_state_mutex != NULL) { NdbMutex_Destroy(ndb_print_state_mutex); ndb_print_state_mutex= NULL; } #endif if (m_name) free(m_name); NdbMutex_Lock(g_ndb_connection_mutex); if(--g_ndb_connection_count == 0){ delete NdbDictionary::Column::FRAGMENT; delete NdbDictionary::Column::FRAGMENT_FIXED_MEMORY; delete NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY; delete NdbDictionary::Column::ROW_COUNT; delete NdbDictionary::Column::COMMIT_COUNT; delete NdbDictionary::Column::ROW_SIZE; delete NdbDictionary::Column::RANGE_NO; delete NdbDictionary::Column::DISK_REF; delete NdbDictionary::Column::RECORDS_IN_RANGE; delete NdbDictionary::Column::ROWID; delete NdbDictionary::Column::ROW_GCI; delete NdbDictionary::Column::ANY_VALUE; NdbDictionary::Column::FRAGMENT= 0; NdbDictionary::Column::FRAGMENT_FIXED_MEMORY= 0; NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY= 0; NdbDictionary::Column::ROW_COUNT= 0; NdbDictionary::Column::COMMIT_COUNT= 0; NdbDictionary::Column::ROW_SIZE= 0; NdbDictionary::Column::RANGE_NO= 0; NdbDictionary::Column::DISK_REF= 0; NdbDictionary::Column::RECORDS_IN_RANGE= 0; NdbDictionary::Column::ROWID= 0; NdbDictionary::Column::ROW_GCI= 0; NdbDictionary::Column::ANY_VALUE= 0; delete NdbDictionary::Column::COPY_ROWID; NdbDictionary::Column::COPY_ROWID = 0; } NdbMutex_Unlock(g_ndb_connection_mutex); if (m_event_add_drop_mutex) NdbMutex_Destroy(m_event_add_drop_mutex); DBUG_VOID_RETURN; }
void destroy_mutex() { NdbMutex_Destroy(m_mutex); }
WatchDog::~WatchDog(){ doStop(); NdbMutex_Destroy(m_mutex); }
NDBT_Context::~NDBT_Context(){ NdbCondition_Destroy(propertyCondPtr); NdbMutex_Destroy(propertyMutexPtr); }
int main(int argc, char* argv[]) { ndb_init(); int iRes = -1; g_nNumThreads = 0; g_nMaxCallsPerSecond = 0; long nSeed = 0; bool bStoredTable = true; bool bCreateTable = false; g_bWriteTuple = false; g_bReport = false; g_bReportPlus = false; for(int i=1; i<argc; ++i) { if(argv[i][0]=='-' || argv[i][0]=='/') { switch(argv[i][1]) { case 't': g_nNumThreads = atol(argv[i]+2); break; case 's': nSeed = atol(argv[i]+2); break; case 'b': g_nMaxContextIdPerThread = atol(argv[i]+2); break; case 'm': g_nStatusDataSize = atol(argv[i]+2); if(g_nStatusDataSize>sizeof(STATUS_DATA)) { g_nStatusDataSize = sizeof(STATUS_DATA); } break; case 'i': g_bInsertInitial = true; break; case 'v': g_bVerifyInitial = true; break; case 'd': bCreateTable = true; break; case 'f': bStoredTable = false; break; case 'w': g_bWriteTuple = true; break; case 'r': g_bReport = true; if(argv[i][2]=='+') { g_bReportPlus = true; } break; case 'c': g_nMaxCallsPerSecond = atol(argv[i]+2); break; case '?': default: ShowHelp(argv[0]); return -1; } } else { ShowHelp(argv[0]); return -1; } } if(bCreateTable) puts("-d\tcreate the table"); if(g_bInsertInitial) printf("-i\tinsert initial records\n"); if(g_bVerifyInitial) printf("-v\tverify initial records\n"); if(g_nNumThreads>0) printf("-t%ld\tnumber of threads making calls\n", g_nNumThreads); if(g_nNumThreads>0) { printf("-s%ld\toffset for primary key\n", nSeed); printf("-b%ld\tbatch size per thread\n", g_nMaxContextIdPerThread); } if(g_nMaxCallsPerSecond>0) printf("-c%ld\tmax number of calls per second for this process\n", g_nMaxCallsPerSecond); if(!bStoredTable) puts("-f\tno checkpointing and no logging to disk"); if(g_bWriteTuple) puts("-w\tuse writeTuple instead of insertTuple"); if(g_bReport) puts("-r\treport response time statistics"); if(g_bReportPlus) puts("-r+\treport response time distribution"); if(!bCreateTable && g_nNumThreads<=0) { ShowHelp(argv[0]); return -1; } printf("-m%ld\tsize of context data\n", g_nStatusDataSize); g_szTableName = (bStoredTable ? c_szTableNameStored : c_szTableNameTemp); #ifdef NDB_WIN32 SetConsoleCtrlHandler(ConsoleCtrlHandler, true); #else signal(SIGINT, CtrlCHandler); #endif if(g_bReport) { g_plCountMillisecForCall = new long[c_nMaxMillisecForAllCall]; memset(g_plCountMillisecForCall, 0, c_nMaxMillisecForAllCall*sizeof(long)); g_plCountMillisecForTrans = new long[c_nMaxMillisecForAllTrans]; memset(g_plCountMillisecForTrans, 0, c_nMaxMillisecForAllTrans*sizeof(long)); } g_pNdbMutexIncrement = NdbMutex_Create(); g_pNdbMutexPrintf = NdbMutex_Create(); #ifdef NDB_WIN32 hShutdownEvent = CreateEvent(NULL,TRUE,FALSE,NULL); #endif Ndb* pNdb = new Ndb(c_szDatabaseName); if(!pNdb) { printf("could not construct ndb\n"); return 1; } if(pNdb->init(1) || pNdb->waitUntilReady()) { ReportNdbError("could not initialize ndb\n", pNdb->getNdbError()); delete pNdb; return 2; } if(bCreateTable) { printf("Create CallContext table\n"); if (bStoredTable) { if (CreateCallContextTable(pNdb, c_szTableNameStored, true)) { printf("Create table failed\n"); delete pNdb; return 3; } } else { if (CreateCallContextTable(pNdb, c_szTableNameTemp, false)) { printf("Create table failed\n"); delete pNdb; return 3; } } } if(g_nNumThreads>0) { printf("creating %d threads\n", (int)g_nNumThreads); if(g_bInsertInitial) { printf("each thread will insert %ld initial records, total %ld inserts\n", g_nMaxContextIdPerThread, g_nNumThreads*g_nMaxContextIdPerThread); } if(g_bVerifyInitial) { printf("each thread will verify %ld initial records, total %ld reads\n", g_nMaxContextIdPerThread, g_nNumThreads*g_nMaxContextIdPerThread); } g_nNumberOfInitialInsert = 0; g_nNumberOfInitialVerify = 0; NDB_TICKS tStartTime = NdbTick_CurrentMillisecond(); NdbThread* pThreads[256]; int pnStartingRecordNum[256]; int ij; for(ij=0;ij<g_nNumThreads;ij++) { pnStartingRecordNum[ij] = (ij*g_nMaxContextIdPerThread) + nSeed; } for(ij=0;ij<g_nNumThreads;ij++) { pThreads[ij] = NdbThread_Create(RuntimeCallContext, (void**)(pnStartingRecordNum+ij), 0, "RuntimeCallContext", NDB_THREAD_PRIO_LOW); } //Wait for the threads to finish for(ij=0;ij<g_nNumThreads;ij++) { void* status; NdbThread_WaitFor(pThreads[ij], &status); } NDB_TICKS tEndTime = NdbTick_CurrentMillisecond(); //Print time taken printf("Time Taken for %ld Calls is %ld msec (= %ld calls/sec)\n", g_nNumCallsProcessed, (long)(tEndTime-tStartTime), (long)((1000*g_nNumCallsProcessed)/(tEndTime-tStartTime))); if(g_bInsertInitial) printf("successfully inserted %ld tuples\n", g_nNumberOfInitialInsert); if(g_bVerifyInitial) printf("successfully verified %ld tuples\n", g_nNumberOfInitialVerify); } delete pNdb; #ifdef NDB_WIN32 CloseHandle(hShutdownEvent); #endif NdbMutex_Destroy(g_pNdbMutexIncrement); NdbMutex_Destroy(g_pNdbMutexPrintf); if(g_bReport) { ReportResponseTimeStatistics("Calls", g_plCountMillisecForCall, c_nMaxMillisecForAllCall); ReportResponseTimeStatistics("Transactions", g_plCountMillisecForTrans, c_nMaxMillisecForAllTrans); delete[] g_plCountMillisecForCall; delete[] g_plCountMillisecForTrans; } return 0; }
CPCD::Monitor::~Monitor() { NdbThread_Destroy(&m_monitorThread); NdbCondition_Destroy(m_changeCondition); NdbMutex_Destroy(m_changeMutex); }
Ndb_cluster_connection_impl::~Ndb_cluster_connection_impl() { DBUG_ENTER("~Ndb_cluster_connection"); if (m_first_ndb_object != 0) { g_eventLogger->warning("Deleting Ndb_cluster_connection with Ndb-object" " not deleted"); Ndb * p = m_first_ndb_object; printf("this: %p Ndb-object(s): ", (Ndb_cluster_connection*)this); while (p) { printf("%p ", p); p = p->theImpl->m_next_ndb_object; } printf("\n"); fflush(stdout); } if (m_transporter_facade != 0) { m_transporter_facade->stop_instance(); } if (m_globalDictCache) { delete m_globalDictCache; } if (m_connect_thread) { void *status; m_run_connect_thread= 0; NdbThread_WaitFor(m_connect_thread, &status); NdbThread_Destroy(&m_connect_thread); m_connect_thread= 0; } if (m_transporter_facade != 0) { delete m_transporter_facade; m_transporter_facade = 0; } if (m_config_retriever) { delete m_config_retriever; m_config_retriever= NULL; } NdbMutex_Lock(g_ndb_connection_mutex); if(--g_ndb_connection_count == 0) { NdbColumnImpl::destory_pseudo_columns(); #ifdef VM_TRACE NdbMutex_Destroy(ndb_print_state_mutex); ndb_print_state_mutex= NULL; #endif } NdbMutex_Unlock(g_ndb_connection_mutex); if (m_event_add_drop_mutex) NdbMutex_Destroy(m_event_add_drop_mutex); m_event_add_drop_mutex = 0; if (m_new_delete_ndb_mutex) NdbMutex_Destroy(m_new_delete_ndb_mutex); m_new_delete_ndb_mutex = 0; if(m_multi_wait_group) delete m_multi_wait_group; m_multi_wait_group = 0; DBUG_VOID_RETURN; }
void ndb_end_internal() { if (g_ndb_connection_mutex) NdbMutex_Destroy(g_ndb_connection_mutex); }