Ejemplo n.º 1
0
void JobListWidget::execDeleteJob(JobListWidgetItem *jobItem)
{
    if(!jobItem)
    {
        DEBUG << "Null JobListWidgetItem passed.";
        return;
    }

    JobPtr job = jobItem->job();

    QMessageBox::StandardButton confirm =
        QMessageBox::question(this, tr("Confirm action"),
                              tr("Are you sure you want to delete job \"%1\" "
                                 "(this cannot be undone)?")
                                  .arg(job->name()));
    if(confirm != QMessageBox::Yes)
        return;

    bool purgeArchives = false;
    if(!job->archives().isEmpty())
    {
        QMessageBox::StandardButton delArchives =
            QMessageBox::question(this, tr("Confirm action"),
                                  tr("Also delete %1 archives "
                                     "belonging to this job "
                                     "(this cannot be undone)?")
                                      .arg(job->archives().count()));
        if(delArchives == QMessageBox::Yes)
            purgeArchives = true;
    }
    emit deleteJob(job, purgeArchives);
    delete jobItem;
    emit countChanged(count(), visibleItemsCount());
}
Ejemplo n.º 2
0
void savePic () {

  if (gettimeofday(&end, NULL)) { //TODO a ver: clock_getres
    perror("gettimeofday");
    return;
  }
  timeval_subtract(&result, &end, &start);

  double timeWaited = result.tv_sec + (result.tv_usec / 1000000.0);
  printf("JM  (%i): Done! Time waited: %f.\n", myid, timeWaited);

//  for (int i = 0; i < NJOBS; i++)
//    fprintf(stderr,"JM  (%i): Number of iterations: %i\n", myid, *((int *) jobRes[i]->results[0]));



  printf("JM  (%i): Saving image.\n", myid);
  FILE *fd = fopen ("file.ppm", "w");
  if (fd == NULL) {
    fprintf (stderr,"Couldn't open 'file.ppm' for writing! Aborting...\n");
    exit (EXIT_FAILURE);
  }


  int *p;

  fprintf (fd, "P6\n%d %d\n255\n", WIDTH, HEIGHT);
  for (int j = 0; j < NJOBS; j++) {

    p = (int *) jobRes[j]->results[0];

    for (int i = 0; i < WIDTH*jobHeight; i++) {
      fputc(rgb[p[i]][0], fd);
      fputc(rgb[p[i]][1], fd);
      fputc(rgb[p[i]][2], fd);
    }
  }

  fclose (fd);


  printf("JM  (%i): All jobs done.\n", myid);

  for (int i = 0; i < NJOBS; i++) {
    deleteJob(job[i]);
    deleteResults(jobRes[i]);
  }



  pthread_mutex_lock(&end_mutex);
  program_over = true;
  pthread_cond_signal(&end_condition);
  pthread_mutex_unlock(&end_mutex);
}
Ejemplo n.º 3
0
void sig_handler(int sig)
{
    if(sig == SIGINT)
    {
        printf("\n");
        invokeShell();
        fflush(stdout);
    }
    if(sig == SIGTSTP)
    {
    //    pid_t pid = getpid();
      //  if(pid != SHELLPID )
        //{
          //  kill(pid,SIGKILL);
           // job[JOBCTR++].pid = pid;
            //     wait();
       // }
        printf("\n");
        invokeShell();
        fflush(stdout);
    }
    if(sig == SIGQUIT)
    {
        printf("\n");
        invokeShell();
        fflush(stdout);
    }
    if(sig == SIGCHLD)
    {
        union wait wstat;
        pid_t pid;

        while(1)
        {
            pid = wait3(&wstat,WNOHANG,(struct rusage *)NULL);
            if(pid == 0 )
                return;
            else if(pid == -1)
                return;
            else
            {
                fprintf(stderr,"\nProcess with PID : %d exited with return value: %d\n",pid,wstat.w_retcode);
                deleteJob(pid);
            }
        }
    }
}
Ejemplo n.º 4
0
void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window)
{
    if (!window) {
        // Stop will trigger syncBackCurrentValues so best to do it before
        // we delete m_job.
        stop();
        deleteJob();
        return;

    } else if (!m_controller && m_job) {
        m_controller = QQuickWindowPrivate::get(window)->animationController;
        if (window->openglContext())
            readyToAnimate();
        else
            connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitialized()));
    }
}
Ejemplo n.º 5
0
void QQuickAnimatorProxyJob::setWindow(QQuickWindow *window)
{
    if (!window) {
        stop();
        deleteJob();

        // Upon leaving a window, we reset the controller. This means that
        // animators will only enter the Starting phase and won't be making
        // calls to QQuickAnimatorController::startjob().
        m_controller = 0;

    } else if (!m_controller && m_job) {
        m_controller = QQuickWindowPrivate::get(window)->animationController;
        if (window->openglContext())
            readyToAnimate();
        else
            connect(window, SIGNAL(sceneGraphInitialized()), this, SLOT(sceneGraphInitialized()));
    }
}
Ejemplo n.º 6
0
void Logger::setStatus(const QString &id, const QString &name, const QString &status, const QString &message)
{
    QSqlQuery deleteJob( QString("DELETE FROM jobs WHERE id='%1';").arg(id) );
    if ( deleteJob.lastError().isValid() ) {
        qDebug() << "Error when executing query" << deleteJob.lastQuery();
        qDebug() << "Sql reports" << deleteJob.lastError();
    } else {
        QSqlQuery createStatus;
        createStatus.prepare("INSERT INTO jobs (id, name, status, description) VALUES (:job, :name, :status, :message);");
        createStatus.bindValue(":job", id);
        createStatus.bindValue(":name", name);
        createStatus.bindValue(":status", status);
        createStatus.bindValue(":message", message);
        if ( !createStatus.exec() ) {
            qDebug() << "Error when executing query" << createStatus.lastQuery();
            qDebug() << "Sql reports" << createStatus.lastError();
        }
    }
}
Ejemplo n.º 7
0
/**
 * @brief Handle a PSP_ACCOUNT_END message.
 *
 * This function will add extended accounting information to a
 * account end message.
 *
 * @param msg The message to handle.
 *
 * @return No return value.
 */
static void handleAccountEnd(DDTypedBufferMsg_t *msg)
{
    PStask_ID_t sender = msg->header.sender, logger, childTID;
    PSnodes_ID_t childNode;
    Client_t *client;
    Job_t *job;
    pid_t child;
    uint64_t avgRss, avgVsize, avgThrds, dummy;
    size_t used = 0;

    mdbg(PSACC_LOG_ACC_MSG, "%s(%s)\n", __func__, PSC_printTID(sender));

    PSP_getTypedMsgBuf(msg, &used, __func__, "logger", &logger, sizeof(logger));

    /* end msg from logger */
    if (sender == logger) {
	/* find the job */
	job = findJobByLogger(logger);
	if (!job) {
	    mlog("%s: job for logger %s not found\n", __func__,
		 PSC_printTID(logger));
	} else {
	    job->endTime = time(NULL);
	    job->complete = true;

	    if (job->childsExit < job->nrOfChilds) {
		mdbg(PSACC_LOG_VERBOSE, "%s: logger %s exited, but %i"
		     " children are still alive\n", __func__,
		     PSC_printTID(logger), job->nrOfChilds - job->childsExit);
	    }
	}
	return;
    }

    PSP_getTypedMsgBuf(msg, &used, __func__, "rank(skipped)", &dummy,
		       sizeof(int32_t));
    PSP_getTypedMsgBuf(msg, &used, __func__, "uid(skipped)", &dummy,
		       sizeof(uid_t));
    PSP_getTypedMsgBuf(msg, &used, __func__, "gid(skipped)", &dummy,
		       sizeof(gid_t));
    PSP_getTypedMsgBuf(msg, &used, __func__, "pid", &child, sizeof(child));

    /* calculate childs TaskID */
    childNode = PSC_getID(sender);
    childTID = PSC_getTID(childNode, child);

    /* find the child exiting */
    client = findClientByTID(childTID);
    if (!client) {
	if (!findHist(logger)) {
	    mlog("%s: end msg for unknown client %s from %s\n", __func__,
		 PSC_printTID(childTID), PSC_printTID(sender));
	}
	return;
    }
    if (client->type != ACC_CHILD_JOBSCRIPT && client->logger != logger) {
	mlog("%s: logger mismatch (%s/", __func__, PSC_printTID(logger));
	mlog("%s)\n", PSC_printTID(client->logger));
    }
    /* stop accounting of dead child */
    client->doAccounting = false;
    client->endTime = time(NULL);

    PSP_getTypedMsgBuf(msg, &used, __func__, "rusage",
		       &client->data.rusage, sizeof(client->data.rusage));
    PSP_getTypedMsgBuf(msg, &used, __func__, "pageSize",
		       &client->data.pageSize, sizeof(client->data.pageSize));
    PSP_getTypedMsgBuf(msg, &used, __func__, "walltime",
		       &client->walltime, sizeof(client->walltime));
    PSP_getTypedMsgBuf(msg, &used, __func__, "status",
		       &client->status, sizeof(client->status));

    mdbg(PSACC_LOG_VERBOSE, "%s: child rank %i pid %i logger %s uid %i"
	 " gid %i msg type %s finished\n", __func__, client->rank, child,
	 PSC_printTID(client->logger), client->uid, client->gid,
	 getAccountMsgType(msg->type));

    if (client->type == ACC_CHILD_JOBSCRIPT) return; /* drop message */

    /* Now add further information to the message */
    msg->header.len = offsetof(DDTypedBufferMsg_t, buf) + used;

    uint32_t one = 1;
    PSP_putTypedMsgBuf(msg, __func__, "extended info", &one, sizeof(one));
    PSP_putTypedMsgBuf(msg, __func__, "maxRss", &client->data.maxRss,
		       sizeof(client->data.maxRss));
    PSP_putTypedMsgBuf(msg, __func__, "maxVsize", &client->data.maxVsize,
		       sizeof(client->data.maxVsize));
    uint32_t myMaxThreads = client->data.maxThreads;
    PSP_putTypedMsgBuf(msg, __func__, "maxThreads", &myMaxThreads,
		       sizeof(myMaxThreads));
    PSP_putTypedMsgBuf(msg, __func__, "session", &client->data.session,
		       sizeof(client->data.session));

    /* add size of average used mem */
    if (client->data.avgRssTotal < 1 || client->data.avgRssCount < 1) {
	avgRss = 0;
    } else {
	avgRss = client->data.avgRssTotal / client->data.avgRssCount;
    }
    PSP_putTypedMsgBuf(msg, __func__, "avgRss", &avgRss, sizeof(avgRss));

    /* add size of average used vmem */
    if (client->data.avgVsizeTotal < 1 || client->data.avgVsizeCount < 1) {
	avgVsize = 0;
    } else {
	avgVsize = client->data.avgVsizeTotal / client->data.avgVsizeCount;
    }
    PSP_putTypedMsgBuf(msg, __func__, "avgVsize", &avgVsize, sizeof(avgVsize));

    /* add number of average threads */
    if (client->data.avgThreadsTotal < 1 || client->data.avgThreadsCount < 1) {
	avgThrds = 0;
    } else {
	avgThrds = client->data.avgThreadsTotal / client->data.avgThreadsCount;
    }
    PSP_putTypedMsgBuf(msg, __func__, "avgThrds", &avgThrds, sizeof(avgThrds));

    /* find the job */
    job = findJobByLogger(client->logger);
    if (!job) {
	mlog("%s: job for child %i not found\n", __func__, child);
    } else {
	job->childsExit++;
	if (job->childsExit >= job->nrOfChilds) {
	    /* all children exited */
	    if (globalCollectMode && PSC_getID(logger) != PSC_getMyID()) {
		forwardJobData(job, true);
		sendAggDataFinish(logger);
	    }

	    job->complete = true;
	    job->endTime = time(NULL);
	    mdbg(PSACC_LOG_VERBOSE, "%s: job complete [%i:%i]\n", __func__,
		 job->childsExit, job->nrOfChilds);

	    if (PSC_getID(job->logger) != PSC_getMyID()) {
		deleteJob(job->logger);
	    }
	}
    }
}
Ejemplo n.º 8
0
QQuickAnimatorProxyJob::~QQuickAnimatorProxyJob()
{
    deleteJob();
    if (m_controller)
        m_controller->proxyWasDestroyed(this);
}
Ejemplo n.º 9
0
QQuickAnimatorProxyJob::~QQuickAnimatorProxyJob()
{
    deleteJob();
}