k_StopWatch::~k_StopWatch() { if (mb_Print) { QString ls_Duration = getTimeAsString(); *mk_OutputStream_ << ms_Message.arg(ls_Duration); } }
int main (int argc, char **argv) { std::vector<int> pcd_indices; pcd_indices = pcl::console::parse_file_extension_argument (argc, argv, ".pcd"); pcl::PointCloud<pcl::PointXYZRGB>::Ptr sum_clouds (new pcl::PointCloud<pcl::PointXYZRGB>); CloudVector clouds; for (size_t i = 0; i < pcd_indices.size (); i++) { CloudPtr pc (new Cloud); pcl::io::loadPCDFile (argv[pcd_indices[i]], *pc); std::cout << "loading file: " << argv[pcd_indices[i]] << " size: " << pc->size () << std::endl; *sum_clouds += *pc; } std::string result_filename ("merged"); result_filename += getTimeAsString(); result_filename += ".pcd"; pcl::io::savePCDFileASCII (result_filename.c_str (), *sum_clouds); std::cout << "saving result to " << result_filename << std::endl; return 0; }
short ExExeUtilTcb::executeQuery(char * task, char * object, char * query, NABoolean displayStartTime, NABoolean displayEndTime, short &rc, short * warning, Lng32 * ec, NABoolean moveErrorRow, NABoolean continueOnError, NABoolean monitorThis) { short retcode = 0; char buf[BUFFER_SIZE]; while (1) { switch (pqStep_) { case PROLOGUE_: { warning_ = 0; startTime_ = NA_JulianTimestamp(); elapsedTime_ = 0; if (displayStartTime) { getStatusString(task, "Started", object, buf); if (moveRowToUpQueue(buf, 0, &rc)) return 1; } pqStep_ = EXECUTE_; rc = WORK_RESCHEDULE_AND_RETURN; return 1; } break; case EXECUTE_: { retcode = cliInterface()->fetchRowsPrologue(query,FALSE,monitorThis); if (retcode < 0) { pqStep_ = ERROR_RETURN_; break; } pqStep_ = FETCH_ROW_; } break; case FETCH_ROW_: { retcode = (short)cliInterface()->fetch(); if (retcode < 0) { pqStep_ = ERROR_RETURN_; break; } if ((retcode > 0) && (retcode != 100)) warning_ = retcode; if ((retcode != 100) && (cliInterface()->outputBuf())) pqStep_ = RETURN_ROW_; else pqStep_ = CLOSE_; } break; case RETURN_ROW_: { char * ptr; Lng32 len; cliInterface()->getPtrAndLen(1, ptr, len); retcode = moveRowToUpQueue(ptr, len, &rc); if (retcode) return 1; pqStep_ = FETCH_ROW_; } break; case CLOSE_: { retcode = cliInterface()->fetchRowsEpilogue(""); if (retcode < 0) { pqStep_ = ERROR_RETURN_; break; } pqStep_ = EPILOGUE_; } break; case EPILOGUE_: { endTime_ = NA_JulianTimestamp(); elapsedTime_ = endTime_ - startTime_; if (displayEndTime) { char timeBuf[200]; getTimeAsString(elapsedTime_, timeBuf); getStatusString(task, "Ended", object, buf, timeBuf); if (moveRowToUpQueue(buf, 0, &rc)) return 1; } pqStep_ = ALL_DONE_; rc = WORK_RESCHEDULE_AND_RETURN; return 1; } break; case ERROR_RETURN_: { Lng32 sqlcode = 0; char * stringParam1 = NULL; Lng32 intParam1 = ComDiags_UnInitialized_Int; retcode = (short)cliInterface()->retrieveSQLDiagnostics(getDiagsArea()); if (moveErrorRow) { if (retcode == 0) { ComDiagsArea * da = getDiagsArea(); sqlcode = (short)da->mainSQLCODE(); ComCondition * cc; if (sqlcode < 0) cc = da->getErrorEntry(1); else cc = da->getWarningEntry(1); if (sqlcode < 0 && ec != NULL) *ec = sqlcode; if (cc->getOptionalStringCharSet(0) == CharInfo::ISO88591 || cc->getOptionalStringCharSet(0) == CharInfo::UTF8) stringParam1 = (char*)cc->getOptionalString(0); else stringParam1 = NULL; intParam1 = cc->getOptionalInteger(0); } else { sqlcode = retcode; } Lng32 errorBufLen = 200 + (stringParam1 ? strlen(stringParam1) : 0); char * errorBuf = new(getHeap()) char[errorBufLen]; str_sprintf(errorBuf, "%d", sqlcode); if (stringParam1) str_sprintf(&errorBuf[strlen(errorBuf)], ", %s", stringParam1); if (intParam1 != ComDiags_UnInitialized_Int) str_sprintf(&errorBuf[strlen(errorBuf)], ", %d", intParam1); char * outBuf = new(getHeap()) char[errorBufLen+400]; getStatusString(task, "Error", NULL, outBuf, NULL, NULL, errorBuf); NADELETEBASIC(errorBuf, getHeap()); if ((moveErrorRow) && (moveRowToUpQueue(outBuf, 0, &rc))) { NADELETEBASIC(outBuf, getHeap()); return 1; } NADELETEBASIC(outBuf, getHeap()); } // close cursor, etc. Ignore errors. cliInterface()->fetchRowsEpilogue(""); if (continueOnError) { pqStep_ = ALL_DONE_; rc = WORK_RESCHEDULE_AND_RETURN; return 1; } else { pqStep_ = PROLOGUE_; return -1; } } break; case ALL_DONE_: { pqStep_ = PROLOGUE_; if (warning) *warning = warning_; return 0; } break; } } }
static int waitClusterStatus(const char* _addr, ndb_mgm_node_status _status) { int _startphase = -1; #ifndef NDB_WIN /* Ignore SIGPIPE */ signal(SIGPIPE, SIG_IGN); #endif handle = ndb_mgm_create_handle(); if (handle == NULL){ g_err << "Could not create ndb_mgm handle" << endl; return -1; } g_info << "Connecting to mgmsrv at " << _addr << endl; if (ndb_mgm_set_connectstring(handle, _addr)) { MGMERR(handle); g_err << "Connectstring " << _addr << " invalid" << endl; return -1; } if (ndb_mgm_connect(handle,0,0,1)) { MGMERR(handle); g_err << "Connection to " << _addr << " failed" << endl; return -1; } int attempts = 0; int resetAttempts = 0; const int MAX_RESET_ATTEMPTS = 10; bool allInState = false; Uint64 time_now = NdbTick_CurrentMillisecond(); Uint64 timeout_time = time_now + 1000 * _timeout; while (allInState == false){ if (_timeout > 0 && time_now > timeout_time){ /** * Timeout has expired waiting for the nodes to enter * the state we want */ bool waitMore = false; /** * Make special check if we are waiting for * cluster to become started */ if(_status == NDB_MGM_NODE_STATUS_STARTED){ waitMore = true; /** * First check if any node is not starting * then it's no idea to wait anymore */ for (size_t n = 0; n < ndbNodes.size(); n++){ if (ndbNodes[n].node_status != NDB_MGM_NODE_STATUS_STARTED && ndbNodes[n].node_status != NDB_MGM_NODE_STATUS_STARTING) waitMore = false; } } if (!waitMore || resetAttempts > MAX_RESET_ATTEMPTS){ g_err << "waitNodeState(" << ndb_mgm_get_node_status_string(_status) <<", "<<_startphase<<")" << " timeout after " << attempts << " attempts" << endl; return -1; } g_err << "waitNodeState(" << ndb_mgm_get_node_status_string(_status) <<", "<<_startphase<<")" << " resetting timeout " << resetAttempts << endl; timeout_time = time_now + 1000 * _timeout; resetAttempts++; } if (attempts > 0) NdbSleep_MilliSleep(100); if (getStatus() != 0){ return -1; } /* Assume all nodes are in state(if there is any) */ allInState = (ndbNodes.size() > 0); /* Loop through all nodes and check their state */ for (size_t n = 0; n < ndbNodes.size(); n++) { ndb_mgm_node_state* ndbNode = &ndbNodes[n]; assert(ndbNode != NULL); g_info << "Node " << ndbNode->node_id << ": " << ndb_mgm_get_node_status_string(ndbNode->node_status)<< endl; if (ndbNode->node_status != _status) allInState = false; } if (!allInState) { char time[9]; g_info << "[" << getTimeAsString(time) << "] " << "Waiting for cluster enter state " << ndb_mgm_get_node_status_string(_status) << endl; } attempts++; time_now = NdbTick_CurrentMillisecond(); } return 0; }
QString k_StopWatch::getTimeAsString() { return getTimeAsString(this->get_Time()); }