void ProjectBase::launchProblems(QList<Problem*> problems, bool useSeparateThread ) { if(!_problemLaunchMutex.tryLock()) { QString msg = "Another problem is already running. Could not launch a new one."; InfoSender::instance()->send(Info(msg)); } else { // Create temporary directory where calculations are performed createTempDir(); QList<MOThreads::ProblemThread*> threads; for(int i=0;i<problems.size();i++) { //Copy launched problem from selected one Problem* launchedProblem; launchedProblem = problems.at(i)->clone(); //Create problem thread ProblemConfig config; MOThreads::ProblemThread* launchThread = new MOThreads::ProblemThread(this,launchedProblem,config); // connect signals connect(launchThread,SIGNAL(begun(Problem*)),this,SIGNAL(problemBegun(Problem*))); connect(launchThread,SIGNAL(newProgress(float)),this,SIGNAL(newProblemProgress(float))); connect(launchThread,SIGNAL(newProgress(float,int,int)),this,SIGNAL(newProblemProgress(float,int,int))); connect(launchThread,SIGNAL(finished(Problem*,Result*)),this,SLOT(onProblemFinished(Problem*,Result*))); connect(launchThread,SIGNAL(finished(Problem*,Result*)),this,SIGNAL(problemFinished(Problem*,Result*))); // store thread-problem _problemsThreads.insert(launchedProblem,launchThread); threads.push_back(launchThread); } for(int i=0;i<threads.size()-1;i++) { connect(threads.at(i),SIGNAL(finished()),threads.at(i+1),SLOT(start())); } // start first thread if(threads.size()>0) { if(useSeparateThread) threads.at(0)->start(); else threads.at(0)->run(); } else _problemLaunchMutex.unlock(); } }
/** * Verify that the fuse workload works on the local FS. * * @return 0 on success; error code otherwise */ static int verifyFuseWorkload(void) { char tempDir[PATH_MAX]; EXPECT_ZERO(createTempDir(tempDir, sizeof(tempDir), 0755)); EXPECT_ZERO(runFuseWorkload(tempDir, "test")); EXPECT_ZERO(recursiveDelete(tempDir)); return 0; }
MOThreads::ProblemThread* ProjectBase::launchProblem(Problem* problem, bool useSeparateThread) { if(useSeparateThread && !_problemLaunchMutex.tryLock()) { QString msg = "Another problem is already running. Could not launch a new one."; InfoSender::instance()->send(Info(msg)); return NULL; } else { //Copy launched problem from selected one Problem* launchedProblem; launchedProblem = problem->clone(); // Create temporary directory where calculations are performed createTempDir(); //Create problem thread ProblemConfig config; MOThreads::ProblemThread* launchThread = new MOThreads::ProblemThread(this,launchedProblem,config); // connect signals connect(launchThread,SIGNAL(begun(Problem*)),this,SIGNAL(problemBegun(Problem*))); connect(launchThread,SIGNAL(newProgress(float)),this,SIGNAL(newProblemProgress(float))); connect(launchThread,SIGNAL(newProgress(float,int,int)),this,SIGNAL(newProblemProgress(float,int,int))); connect(launchThread,SIGNAL(finished(Problem*,Result*)),this,SLOT(onProblemFinished(Problem*,Result*))); connect(launchThread,SIGNAL(finished(Problem*,Result*)),this,SIGNAL(problemFinished(Problem*,Result*))); // store thread-problem _problemsThreads.insert(launchedProblem,launchThread); // start problem if(useSeparateThread) launchThread->start(); else launchThread->run(); return launchThread; } }
/*! * \brief Collect all log. * \param jvmti [in] JVMTI environment object. * \param env [in] JNI environment object. * \param cause [in] Invoke function cause.<br> * E.g. ResourceExhausted, Signal, Interval. * \param nowTime [in] Log collect time. * \param archivePath [out] Archive file path. * \param pathLen [in] Max size of paramter"archivePath". * \return Value is zero, if process is succeed.<br /> * Value is error number a.k.a. "errno", if process is failure. */ int TLogManager::collectAllLog(jvmtiEnv *jvmti, JNIEnv *env, TInvokeCause cause, TMSecTime nowTime, char *archivePath, size_t pathLen) { /* Variable for process result. */ int result = 0; /* Working directory path. */ char *basePath = NULL; /* Archive file path. */ char *uniqArcName = NULL; /* Make directory. */ result = createTempDir(&basePath, conf->LogDir()->get()); if (unlikely(result != 0)) { logger->printWarnMsg("Failure create working directory."); return result; } try { /* Create enviroment report file. */ result = makeEnvironFile(basePath, cause, nowTime); if (unlikely(result != 0)) { logger->printWarnMsg("Failure create enviroment file."); /* If raise disk full error. */ if (unlikely(isRaisedDiskFull(result))) { throw 1; } } /* Copy many files. */ result = copyInfoFiles(basePath); /* If raise disk full error. */ if (unlikely(isRaisedDiskFull(result))) { throw 1; } /* Create thread dump file. */ result = makeThreadDumpFile(jvmti, env, basePath, cause, nowTime); if (unlikely(result != 0)) { logger->printWarnMsg("Failure thread dumping."); /* If raise disk full error. */ if (unlikely(isRaisedDiskFull(result))) { throw 1; } } /* Copy gc log file. */ result = copyGCLogFile(basePath); if (unlikely(result != 0)) { logger->printWarnMsgWithErrno("Could not copy GC log."); /* If raise disk full error. */ if (unlikely(isRaisedDiskFull(result))) { throw 1; } } /* Create socket owner file. */ result = makeSocketOwnerFile(basePath); if (unlikely(result != 0)) { logger->printWarnMsgWithErrno("Could not create socket owner file."); /* If raise disk full error. */ if (unlikely(isRaisedDiskFull(result))) { throw 1; } } } catch (...) { ; /* Failed collect files by disk full. */ } if (likely(result == 0)) { /* * Set value mean failed to create archive, * For if failed to get "archiveMutex" mutex. */ result = -1; /* Get mutex. */ ENTER_PTHREAD_SECTION(&archiveMutex) { /* Create archive file name. */ uniqArcName = createArchiveName(nowTime); if (unlikely(uniqArcName == NULL)) { /* Failure make archive uniq name. */ logger->printWarnMsg("Failure create archive name."); } else { /* Execute archive. */ arcMaker->setTarget(basePath); result = arcMaker->doArchive(env, uniqArcName); /* If failure create archive file. */ if (unlikely(result != 0)) { /* Execute archive to use jniArchiver. */ jniArchiver->setTarget(basePath); result = jniArchiver->doArchive(env, uniqArcName); } } } /* Release mutex. */ EXIT_PTHREAD_SECTION(&archiveMutex) /* If failure create archive file yet. */ if (unlikely(result != 0)) { logger->printWarnMsg("Failure create archive file."); } }
/** * Test that we can start up fuse_dfs and do some stuff. */ int main(int argc, char **argv) { int ret, pret, status; pid_t fusePid; const char *mntPoint; char mntTmp[PATH_MAX] = ""; struct NativeMiniDfsCluster* tlhCluster; struct NativeMiniDfsConf conf = { .doFormat = 1, }; mntPoint = getenv("TLH_FUSE_MNT_POINT"); if (!mntPoint) { if (createTempDir(mntTmp, sizeof(mntTmp), 0755)) { fprintf(stderr, "FUSE_TEST: failed to create temporary directory for " "fuse mount point.\n"); ret = EXIT_FAILURE; goto done; } fprintf(stderr, "FUSE_TEST: creating mount point at '%s'\n", mntTmp); mntPoint = mntTmp; } if (verifyFuseWorkload()) { fprintf(stderr, "FUSE_TEST: failed to verify fuse workload on " "local FS.\n"); ret = EXIT_FAILURE; goto done_rmdir; } tlhCluster = nmdCreate(&conf); if (!tlhCluster) { ret = EXIT_FAILURE; goto done_rmdir; } if (nmdWaitClusterUp(tlhCluster)) { ret = EXIT_FAILURE; goto done_nmd_shutdown; } ret = spawnFuseServer(argv[0], tlhCluster, mntPoint, &fusePid); if (ret) { fprintf(stderr, "FUSE_TEST: spawnFuseServer failed with error " "code %d\n", ret); ret = EXIT_FAILURE; goto done_nmd_shutdown; } ret = waitForMount(mntPoint, 20); if (ret) { fprintf(stderr, "FUSE_TEST: waitForMount(%s) failed with error " "code %d\n", mntPoint, ret); cleanupFuse(mntPoint); ret = EXIT_FAILURE; goto done_nmd_shutdown; } ret = runFuseWorkload(mntPoint, "test"); if (ret) { fprintf(stderr, "FUSE_TEST: runFuseWorkload failed with error " "code %d\n", ret); cleanupFuse(mntPoint); ret = EXIT_FAILURE; goto done_nmd_shutdown; } if (cleanupFuse(mntPoint)) { fprintf(stderr, "FUSE_TEST: fuserMount -u %s failed with error " "code %d\n", mntPoint, ret); ret = EXIT_FAILURE; goto done_nmd_shutdown; } alarm(120); pret = waitpid(fusePid, &status, 0); if (pret != fusePid) { ret = errno; fprintf(stderr, "FUSE_TEST: failed to wait for fusePid %d: " "returned %d: error %d (%s)\n", fusePid, pret, ret, strerror(ret)); ret = EXIT_FAILURE; goto done_nmd_shutdown; } if (WIFEXITED(status)) { ret = WEXITSTATUS(status); if (ret) { fprintf(stderr, "FUSE_TEST: fuse exited with failure status " "%d!\n", ret); ret = EXIT_FAILURE; goto done_nmd_shutdown; } } else if (WIFSIGNALED(status)) { ret = WTERMSIG(status); if (ret != SIGTERM) { fprintf(stderr, "FUSE_TEST: fuse exited with unexpected " "signal %d!\n", ret); ret = EXIT_FAILURE; goto done_nmd_shutdown; } } else { fprintf(stderr, "FUSE_TEST: fusermount exited with unknown exit type\n"); ret = EXIT_FAILURE; goto done_nmd_shutdown; } ret = EXIT_SUCCESS; done_nmd_shutdown: EXPECT_ZERO(nmdShutdown(tlhCluster)); nmdFree(tlhCluster); done_rmdir: if (mntTmp[0]) { rmdir(mntTmp); } done: if (ret == EXIT_SUCCESS) { fprintf(stderr, "FUSE_TEST: SUCCESS.\n"); } else { fprintf(stderr, "FUSE_TEST: FAILURE!\n"); } return ret; }