void Constraint::projectLB(Cost cost)
{
  if (cost == 0) return;
  if (ToulBar2::verbose >= 2) cout << "lower bound increased " << wcsp->getLb() << " -> " << wcsp->getLb()+cost << endl;
  wcsp->increaseLb(cost); // done before cluster LB because of #CSP (assuming a contradiction will occur here)
  if (wcsp->td) {
	if (ToulBar2::verbose >= 2) cout << " in cluster C" << getCluster() << " (from " << wcsp->td->getCluster(getCluster())->getLb() << " to " << wcsp->td->getCluster(getCluster())->getLb() + cost << ")" << endl;
	wcsp->td->getCluster(getCluster())->increaseLb(cost);
  }
}
Example #2
0
void
BaseShadow::holdJob( const char* reason, int hold_reason_code, int hold_reason_subcode )
{
	dprintf( D_ALWAYS, "Job %d.%d going into Hold state (code %d,%d): %s\n", 
			 getCluster(), getProc(), hold_reason_code, hold_reason_subcode,reason );

	if( ! jobAd ) {
		dprintf( D_ALWAYS, "In HoldJob() w/ NULL JobAd!" );
		DC_Exit( JOB_SHOULD_HOLD );
	}

		// cleanup this shadow (kill starters, etc)
	cleanUp( jobWantsGracefulRemoval() );

		// Put the reason in our job ad.
	jobAd->Assign( ATTR_HOLD_REASON, reason );
	jobAd->Assign( ATTR_HOLD_REASON_CODE, hold_reason_code );
	jobAd->Assign( ATTR_HOLD_REASON_SUBCODE, hold_reason_subcode );

		// try to send email (if the user wants it)
	emailHoldEvent( reason );

		// update the job queue for the attributes we care about
	if( !updateJobInQueue(U_HOLD) ) {
			// trouble!  TODO: should we do anything else?
		dprintf( D_ALWAYS, "Failed to update job queue!\n" );
	}

}
Example #3
0
void BaseShadow::removeJobPre( const char* reason )
{
	if( ! jobAd ) {
		dprintf( D_ALWAYS, "In removeJob() w/ NULL JobAd!" );
	}
	dprintf( D_ALWAYS, "Job %d.%d is being removed: %s\n", 
			 getCluster(), getProc(), reason );

	// cleanup this shadow (kill starters, etc)
	cleanUp( jobWantsGracefulRemoval() );

	// Put the reason in our job ad.
	int size = strlen( reason ) + strlen( ATTR_REMOVE_REASON ) + 4;
	char* buf = (char*)malloc( size * sizeof(char) );
	if( ! buf ) {
		EXCEPT( "Out of memory!" );
	}
	sprintf( buf, "%s=\"%s\"", ATTR_REMOVE_REASON, reason );
	jobAd->Insert( buf );
	free( buf );

	emailRemoveEvent( reason );

	// update the job ad in the queue with some important final
	// attributes so we know what happened to the job when using
	// condor_history...
	if( !updateJobInQueue(U_REMOVE) ) {
			// trouble!  TODO: should we do anything else?
		dprintf( D_ALWAYS, "Failed to update job queue!\n" );
	}
}
Example #4
0
void
MainWindow::getCluster(int i, int j)
{
    if (_cluster.size() > CRITICAL_CLUSTER_SIZE)
        return;

    cv::Point this_point = cv::Point(i, j);
    bool isIJInCluster = std::find(std::begin(_cluster), std::end(_cluster),
                                   this_point) != std::end(_cluster);
    if (isIJInCluster)
        return;

    _cluster.push_back(this_point);

    for (int k = -1; k <= 1; ++ k)
        for (int l = -1; l <= 1; ++ l) {
            if ((k == 0 && l == 0) ||
                (k == -1 && l == -1) ||
                (k == -1 && l ==  1) ||
                (k ==  1 && l ==  1) ||
                (k ==  1 && l == -1))
                continue;
            int newi = i + k;
            int newj = j + l;
            if (newi < 0 || newj < 0 ||
                newi > _dst.rows ||
                newj > _dst.cols)
                continue;
            if (_dst.at<uchar>(newi, newj) != 0)
                continue;
            getCluster(newi, newj);
        }
}
Example #5
0
RetOutcome FUMemory::retire(DInst *dinst)
{
  const Instruction *inst = dinst->getInst();
  /*
 #if(SESC_COW_TIME_PENDING)
  if(dinst->isExitInst){
   FUMemory* r = (FUMemory*) getCluster()->getResource(iFence);
    if ( r->waitingCommit()){
      return WaitForFence;
    }
    else
      r->commitSent();
    //fprintf(stderr,"thread %d memory request MemCommit\n",dinst->getContextId());
    EMemRequest::create(dinst, memorySystem, MemCommit);
	return Retired;
  }
#endif
*/
  if( inst->getSubCode() == iFetchOp ) {
    if (L1DCache->canAcceptStore(static_cast<PAddr>(dinst->getVaddr())) == false)
      return NoCacheSpace;
    FUStore* r = (FUStore*) getCluster()->getResource(iStore);
#ifdef TS_CHERRY
    dinst->setCanBeRecycled();
    dinst->setMemoryIssued();
#endif
    if ( r->waitingOnFence() == true)
      return WaitForFence;
    else
      r->storeSent();
    DMemRequest::create(dinst, memorySystem, MemWrite);
  }else if( inst->getSubCode() == iMemFence ) {
    ((FUStore*)(getCluster()->getResource(iStore)))->doFence();
    dinst->destroy();
  }else if( inst->getSubCode() == iAcquire ) {
    // TODO: Consistency in LDST
    dinst->destroy();
  } else {
    I( inst->getSubCode() == iRelease );
    // TODO: Consistency in LDST
    dinst->destroy();
  }

  return Retired;
}
bool getAllClusters(SocketEndpointArray &eps)
{
    Owned<IRemoteConnection> conn = querySDS().connect("/Environment/Software", myProcessSession(), RTM_LOCK_READ, SDS_CONNECT_TIMEOUT);
    if (!conn) 
        return false;
    IPropertyTree* root = conn->queryRoot();
    Owned<IPropertyTreeIterator> clusters= root->getElements("ThorCluster");
    if (clusters->first()) {
        do {
            IPropertyTree &cluster = clusters->query();
            if (!getCluster(cluster.queryProp("@name"),eps))
                ERRLOG("Cluster %s not found",cluster.queryProp("@name"));
        } while (clusters->next());
    }
    return eps.ordinality()!=0;
}
CVector CStreamSource::getVirtualPos() const
{
	if (getCluster() != 0)
	{
		// need to check the cluster status
		const CClusteredSound::CClusterSoundStatus *css = CAudioMixerUser::instance()->getClusteredSound()->getClusterSoundStatus(getCluster());
		if (css != 0)
		{
			// there is some data here, update the virtual position of the sound.
			float dist = (css->Position - getPos()).norm();
			CVector vpos(CAudioMixerUser::instance()->getListenPosVector() + css->Direction * (css->Dist + dist));
			vpos = _Position * (1-css->PosAlpha) + vpos*(css->PosAlpha);
			return vpos;
		}
	}

	return getPos();
}
Example #8
0
void
MainWindow::deleteTooSmallClusters()
{
    int height = _dst.rows;
    int width = _dst.cols;
    _progress->setMaximum(height);
    for (int i = 0; i < height; ++ i) {
        _progress->setValue(i);
        for (int j = 0; j < width; ++ j)
            if (_dst.at<uchar>(i, j) == 0) {
                _cluster.clear();
                getCluster(i, j);
                if (_cluster.size() < CRITICAL_CLUSTER_SIZE)
                    deleteCluster();
            }
    }
    _progress->setValue(_progress->maximum());
}
void BinaryConstraint::print(ostream& os)
{
    os << this << " BinaryConstraint(" << x->getName() << "," << y->getName() << ")";
    if (ToulBar2::weightedDegree)
        os << "/" << getConflictWeight();
    if (wcsp->getTreeDec())
        os << "   cluster: " << getCluster() << endl;
    else
        os << endl;
    if (ToulBar2::verbose >= 5) {
        for (EnumeratedVariable::iterator iterX = x->begin(); iterX != x->end(); ++iterX) {
            for (EnumeratedVariable::iterator iterY = y->begin(); iterY != y->end(); ++iterY) {
                os << " " << getCost(*iterX, *iterY);
            }
            os << endl;
        }
    }
}
Example #10
0
void
BaseShadow::mockTerminateJob( MyString exit_reason, 
		bool exited_by_signal, int exit_code, int exit_signal, 
		bool core_dumped )
{
	if (exit_reason == "") {
		exit_reason = "Exited normally";
	}
	
	dprintf( D_ALWAYS, "Mock terminating job %d.%d: "
			"exited_by_signal=%s, exit_code=%d OR exit_signal=%d, "
			"core_dumped=%s, exit_reason=\"%s\"\n", 
			 getCluster(),
			 getProc(), 
			 exited_by_signal ? "TRUE" : "FALSE",
			 exit_code,
			 exit_signal,
			 core_dumped ? "TRUE" : "FALSE",
			 exit_reason.Value());

	if( ! jobAd ) {
		dprintf(D_ALWAYS, "BaseShadow::mockTerminateJob(): NULL JobAd! "
			"Holding Job!");
		DC_Exit( JOB_SHOULD_HOLD );
	}

	// Insert the various exit attributes into our job ad.
	jobAd->Assign( ATTR_JOB_CORE_DUMPED, core_dumped );
	jobAd->Assign( ATTR_ON_EXIT_BY_SIGNAL, exited_by_signal );

	if (exited_by_signal) {
		jobAd->Assign( ATTR_ON_EXIT_SIGNAL, exit_signal );
	} else {
		jobAd->Assign( ATTR_ON_EXIT_CODE, exit_code );
	}

	jobAd->Assign( ATTR_EXIT_REASON, exit_reason );

		// update the job queue for the attributes we care about
	if( !updateJobInQueue(U_TERMINATE) ) {
			// trouble!  TODO: should we do anything else?
		dprintf( D_ALWAYS, "Failed to update job queue!\n" );
	}
}
Example #11
0
void
BaseShadow::evictJob( int reason )
{
	MyString from_where;
	MyString machine;
	if( getMachineName(machine) ) {
		from_where.formatstr(" from %s",machine.Value());
	}
	dprintf( D_ALWAYS, "Job %d.%d is being evicted%s\n",
			 getCluster(), getProc(), from_where.Value() );

	if( ! jobAd ) {
		dprintf( D_ALWAYS, "In evictJob() w/ NULL JobAd!" );
		DC_Exit( reason );
	}

		// cleanup this shadow (kill starters, etc)
	cleanUp( jobWantsGracefulRemoval() );

		// write stuff to user log:
	logEvictEvent( reason );

		// record the time we were vacated into the job ad 
	char buf[64];
	sprintf( buf, "%s = %d", ATTR_LAST_VACATE_TIME, (int)time(0) ); 
	jobAd->Insert( buf );

		// update the job ad in the queue with some important final
		// attributes so we know what happened to the job when using
		// condor_history...
	if( !updateJobInQueue(U_EVICT) ) {
			// trouble!  TODO: should we do anything else?
		dprintf( D_ALWAYS, "Failed to update job queue!\n" );
	}

		// does not return.
	DC_Exit( reason );
}
Example #12
0
void
BaseShadow::requeueJob( const char* reason )
{
	if( ! jobAd ) {
		dprintf( D_ALWAYS, "In requeueJob() w/ NULL JobAd!" );
	}
	dprintf( D_ALWAYS, 
			 "Job %d.%d is being put back in the job queue: %s\n", 
			 getCluster(), getProc(), reason );

		// cleanup this shadow (kill starters, etc)
	cleanUp();

		// Put the reason in our job ad.
	int size = strlen( reason ) + strlen( ATTR_REQUEUE_REASON ) + 4;
	char* buf = (char*)malloc( size * sizeof(char) );
	if( ! buf ) {
		EXCEPT( "Out of memory!" );
	}
	sprintf( buf, "%s=\"%s\"", ATTR_REQUEUE_REASON, reason );
	jobAd->Insert( buf );
	free( buf );

		// write stuff to user log:
	logRequeueEvent( reason );

		// update the job ad in the queue with some important final
		// attributes so we know what happened to the job when using
		// condor_history...
	if( !updateJobInQueue(U_REQUEUE) ) {
			// trouble!  TODO: should we do anything else?
		dprintf( D_ALWAYS, "Failed to update job queue!\n" );
	}

		// does not return.
	DC_Exit( JOB_SHOULD_REQUEUE );
}
Example #13
0
unsigned applyNodes(const char *grpip, ApplyMode mode, unsigned ver, bool isdali, bool quiet)
{
    SocketEndpointArray eps;
    if (isdali&&(stricmp(grpip,"all")==0)) {
        Owned<IRemoteConnection> conn = querySDS().connect("/Environment/Software", myProcessSession(), RTM_LOCK_READ, SDS_CONNECT_TIMEOUT);
        if (!conn) 
            return 0;
        IPropertyTree* root = conn->queryRoot();
        Owned<IPropertyTreeIterator> clusters= root->getElements("ThorCluster");
        unsigned ret = 0;
        if (clusters->first()) {
            do {
                IPropertyTree &cluster = clusters->query();
                ret += applyNodes(cluster.queryProp("@name"),mode,ver,true,quiet);
            } while (clusters->next());
        }
        return ret;
    }
    SocketEndpointArray result;
    StringAttrArray resultstr;
    if (!isdali||!getCluster(grpip,eps)) {
        SocketEndpoint ep(grpip);
        if (ep.isNull()) {
            ERRLOG("%s is not a group name or ip",grpip);
            return 0;
        }
        if (ep.port==0)
            ep.port = getDaliServixPort();
        eps.append(ep);
    }
    PointerIArrayOf<ISocket> sockets;
    unsigned to=10*1000;
    unsigned n=eps.ordinality();    // use approx log scale (timeout is long but only for failure situation)
    while (n>1) {
        n/=2;
        to+=10*1000;
    }
    if (!quiet&&(n>1))
        PROGLOG("Scanning %s...",grpip);
    multiConnect(eps,sockets,to);
    CriticalSection sect;
    class casyncfor: public CAsyncFor
    {
        SocketEndpointArray &eps;
        PointerIArrayOf<ISocket> &sockets;
        ApplyMode mode;
        unsigned ver;
        SocketEndpointArray &result;
        StringAttrArray &resultstr;
        CriticalSection &sect;
    public:
        casyncfor(ApplyMode _mode, unsigned _ver,SocketEndpointArray &_eps,PointerIArrayOf<ISocket> &_sockets,SocketEndpointArray &_result, StringAttrArray &_resultstr,CriticalSection &_sect) 
            : eps(_eps), sockets(_sockets), result(_result), resultstr(_resultstr), sect(_sect)
        { 
            mode = _mode;
            ver = _ver;
        }
        void Do(unsigned i)
        {
            ISocket *sock = sockets.item(i);
            StringBuffer epstr;
            SocketEndpoint ep = eps.item(i);
            ep.getUrlStr(epstr);
//          PROGLOG("T.1 %s %x",epstr.str(),(unsigned)sock);
            StringBuffer verstr;
            unsigned rver=0;
            if (sock) {
                rver = getRemoteVersion(sock, verstr);
                switch (mode) {
                case AMcheck:
                    if (rver!=0)
                        return;
                case AMver: {
                        CriticalBlock block(sect);
                        result.append(ep);
                        StringBuffer ln;
                        ln.append(rver).append(",\"").append(verstr).append('"');
                        resultstr.append(* new StringAttrItem(ln.str()));
                    }
                    return;
                case AMstopver:
                case AMcheckver: 
                case AMcheckvermajor: {
                    // compares versions up to the '-'
                        const char *rv = verstr.str();
                        const char *v = remoteServerVersionString();
                        if (mode!=AMcheckvermajor) {
                            while (*v&&(*v!='-')&&(*v==*rv)) {
                                v++;
                                rv++;
                            }
                        }
                        if ((*rv==*v)&&(rver==ver))
                            return;
                        while (*rv&&(*rv!='-'))
                            rv++;
                        verstr.setLength(rv-verstr.str());
                        if ((mode==AMcheckver)||(mode==AMcheckvermajor))
                            break;

                    }
                    // fall through
                case AMstop:
                    {
                        unsigned err = stopRemoteServer(sock);
                        if (err!=0) {
                            ERRLOG("Could not stop server on %s, %d returned",epstr.str(),err);
                            if (mode!=AMstopver)
                                return;     // even though failed to stop - still return code
                        }
                        else 
                            Sleep(1000); // let stop
                    }
                    break;
                default:
                    return;
                }
            }
            CriticalBlock block(sect);
            result.append(ep);
            if ((mode!=AMver)&&(mode!=AMcheckver)&&(mode!=AMcheckvermajor)&&(mode!=AMstopver))
                resultstr.append(* new StringAttrItem(""));
            else
                resultstr.append(* new StringAttrItem(verstr.str()));
        }
    } afor(mode,ver,eps,sockets,result,resultstr,sect);
    afor.For(eps.ordinality(), 10, false, true);
    if (result.ordinality()==0)
        return 0;
    switch (mode) {
    case AMstopver: 
    case AMcheckver: 
    case AMcheckvermajor: 
        if (!quiet) {
            StringBuffer epstr;
            ForEachItemIn(i,result) {
                result.item(i).getUrlStr(epstr.clear());
                StringAttrItem &attr = resultstr.item(i);
                if (attr.text.length()==0) 
                    ERRLOG("%s: %s not running DAFILESRV",grpip,epstr.str());
                else 
                    ERRLOG("%s: %s %s running DAFILESRV version %s",grpip,(mode==AMstopver)?"was":"is",epstr.str(),attr.text.get());
            }
            unsigned numok = eps.ordinality()-result.ordinality();
            if (mode==AMcheckvermajor)
                PROGLOG("%s: %d node%s running version %.1f of DAFILESRV",grpip,numok,(numok!=1)?"s":"",((double)FILESRV_VERSION)/10.0);
            else {
                StringBuffer vs;
                const char *v = remoteServerVersionString();
                while (*v&&(*v!='-'))
                    vs.append(*(v++));
                PROGLOG("%s: %d node%s running version %s of DAFILESRV",grpip,numok,(numok!=1)?"s":"",vs.str());
            }
        }
Example #14
0
void moveEntity(Entity *entity)
{
	bool doFullCollision = true;
	
	if ((entity->velocity.x == 0) && (entity->velocity.y == 0) && (entity->velocity.z == 0))
	{
		doFullCollision = (!(entity->flags & EF_WEIGHTLESS));
	}
	
	if (doFullCollision)
	{
		tracer->treatAllAsSolid = false;
		tracer->stepping = 0;
		
		entity->flags &= ~EF_ONGROUND;
		
		entity->oldPosition = entity->position;
		
		float moveSize = engine->getTimeDifference(TD_LOGIC);
		
		while (moveSize >= 1)
		{
			entity->prepareToMove(1);
			
			if (checkEntityToWorld(entity) == true)
			{
				entity->riding = NULL;
				
				if (checkEntityToOthers(entity) == true)
				{
					entity->position = tracer->currentPosition;
					
					if (tracer->stepping)
					{
						clipToFloor(entity);
					}
					
					entity->velocity = entity->realVelocity;
					
					switch (entity->entityType)
					{
						case ET_BLOB:
						case ET_BIOMECH:
							unitContentChanged((Unit*)entity);
							break;
							
						default:
							entity->contentType = tracer->outputContent;
							break;
					}
				}
				
				else
				{
					entity->flags |= EF_ONGROUND;
				}
			}
			
			else
			{
				correctAllSolid(entity);
			}
			
			moveSize--;
		}
		
		if (moveSize > 0)
		{
			entity->prepareToMove(moveSize);
			
			if (checkEntityToWorld(entity) == true)
			{
				entity->riding = NULL;
				
				if (checkEntityToOthers(entity) == true)
				{
					entity->position = tracer->currentPosition;
					
					if (tracer->stepping)
					{
						clipToFloor(entity);
					}
					
					entity->velocity = entity->realVelocity;
					
					switch (entity->entityType)
					{
						case ET_BLOB:
						case ET_BIOMECH:
							unitContentChanged((Unit*)entity);
							break;
							
						default:
							entity->contentType = tracer->outputContent;
							break;
					}
				}
				
				else
				{
					entity->flags |= EF_ONGROUND;
				}
			}
			
			else
			{
				correctAllSolid(entity);
			}
		}
	}
	
	doEntityGroundTrace(entity);
	doEntityRideObject(entity);
		
	if (doFullCollision)
	{
		if ((entity->flags & EF_ONGROUND) && (!(entity->flags & EF_BOUNCES) && (!(entity->flags & EF_WEIGHTLESS))))
		{
			entity->velocity.z = 0;
		}
		
		switch (entity->entityType)
		{
			case ET_BLOB:
			case ET_BIOMECH:
			case ET_NEUTRAL:
			case ET_LIFT:
			case ET_PUSHBLOCK:
			case ET_AUTOLIFT:
			case ET_BOSS:
			case ET_CAMERA:
			case ET_STRUCTURE:
				getCluster(entity);
				break;
			
			case ET_DECORATION:
			case ET_ITEM:
			case ET_WEAPON:
			case ET_SUPPLY_CRATE:
				if (!(entity->flags & EF_ONGROUND))
				{
					getCluster(entity);
				}
				break;
				
			case ET_BULLET:
			case ET_WEAK_STRUCTURE:
				entity->cluster = -1;
				break;
				
			default:
				#if DEV
				printf("Don't check this entity type's cluster! - %d\n", entity->entityType);
				exit(1);
				#endif
				break;
		}
	}
}
Example #15
0
void
BaseShadow::terminateJob( update_style_t kind ) // has a default argument of US_NORMAL
{
	int reason;
	bool signaled;
	MyString str;

	if( ! jobAd ) {
		dprintf( D_ALWAYS, "In terminateJob() w/ NULL JobAd!" );
	}

	/* The first thing we do is record that we are in a termination pending
		state. */
	if (kind == US_NORMAL) {
		str.formatstr("%s = TRUE", ATTR_TERMINATION_PENDING);
		jobAd->Insert(str.Value());
	}

	if (kind == US_TERMINATE_PENDING) {
		// In this case, the job had already completed once and the
		// status had been saved to the job queue, however, for
		// some reason, the shadow didn't exit with a good value and
		// the job had been requeued. When this style of update
		// is used, it is a shortcut from the very birth of the shadow
		// to here, and so there will not be a remote resource or
		// anything like that set up. In this situation, we just
		// want to write the log event and mail the user and exit
		// with a good exit code so the schedd removes the job from
		// the queue. If for some reason the logging fails once again,
		// the process continues to repeat. 
		// This means at least once semantics for the termination event
		// and user email, but at no time should the job actually execute
		// again.

		int exited_by_signal = FALSE;
		int exit_signal = 0;
		int exit_code = 0;

		getJobAdExitedBySignal(jobAd, exited_by_signal);
		if (exited_by_signal == TRUE) {
			getJobAdExitSignal(jobAd, exit_signal);
		} else {
			getJobAdExitCode(jobAd, exit_code);
		}

		if (exited_by_signal == TRUE) {
			reason = JOB_COREDUMPED;
			str.formatstr("%s = \"%s\"", ATTR_JOB_CORE_FILENAME, core_file_name);
			jobAd->Insert(str.Value());
		} else {
			reason = JOB_EXITED;
		}

		dprintf( D_ALWAYS, "Job %d.%d terminated: %s %d\n",
	 		getCluster(), getProc(), 
	 		exited_by_signal? "killed by signal" : "exited with status",
	 		exited_by_signal ? exit_signal : exit_code );
		
			// write stuff to user log, but get values from jobad
		logTerminateEvent( reason, kind );

			// email the user, but get values from jobad
		emailTerminateEvent( reason, kind );

		DC_Exit( reason );
	}

	// the default path when kind == US_NORMAL

	// cleanup this shadow (kill starters, etc)
	cleanUp();

	reason = getExitReason();
	signaled = exitedBySignal();

	/* also store the corefilename into the jobad so we can recover this 
		during a termination pending scenario. */
	if( reason == JOB_COREDUMPED ) {
		str.formatstr("%s = \"%s\"", ATTR_JOB_CORE_FILENAME, getCoreName());
		jobAd->Insert(str.Value());
	}

    // Update final Job committed time
    int last_ckpt_time = 0;
    jobAd->LookupInteger(ATTR_LAST_CKPT_TIME, last_ckpt_time);
    int current_start_time = 0;
    jobAd->LookupInteger(ATTR_JOB_CURRENT_START_DATE, current_start_time);
    int int_value = (last_ckpt_time > current_start_time) ?
                        last_ckpt_time : current_start_time;

    if( int_value > 0 ) {
        int job_committed_time = 0;
        jobAd->LookupInteger(ATTR_JOB_COMMITTED_TIME, job_committed_time);
		int delta = (int)time(NULL) - int_value;
        job_committed_time += delta;
        jobAd->Assign(ATTR_JOB_COMMITTED_TIME, job_committed_time);

		float slot_weight = 1;
		jobAd->LookupFloat(ATTR_JOB_MACHINE_ATTR_SLOT_WEIGHT0, slot_weight);
		float slot_time = 0;
		jobAd->LookupFloat(ATTR_COMMITTED_SLOT_TIME, slot_time);
		slot_time += slot_weight * delta;
		jobAd->Assign(ATTR_COMMITTED_SLOT_TIME, slot_time);
    }

	CommitSuspensionTime(jobAd);

	// update the job ad in the queue with some important final
	// attributes so we know what happened to the job when using
	// condor_history...
    if (m_num_cleanup_retries < 1 &&
        param_boolean("SHADOW_TEST_JOB_CLEANUP_RETRY", false)) {
		dprintf( D_ALWAYS,
				 "Testing Failure to perform final update to job queue!\n");
		retryJobCleanup();
		return;
    }
	if( !updateJobInQueue(U_TERMINATE) ) {
		dprintf( D_ALWAYS, 
				 "Failed to perform final update to job queue!\n");
		retryJobCleanup();
		return;
	}

	// Let's maximize the effectiveness of that queue synchronization and
	// only record the job as done if the update to the queue was successful.
	// If any of these next operations fail and the shadow exits with an
	// exit code which causes the job to get requeued, it will be in the
	// "terminate pending" state marked by the ATTR_TERMINATION_PENDING
	// attribute.

	dprintf( D_ALWAYS, "Job %d.%d terminated: %s %d\n",
	 	getCluster(), getProc(), 
	 	signaled ? "killed by signal" : "exited with status",
	 	signaled ? exitSignal() : exitCode() );

	// write stuff to user log:
	logTerminateEvent( reason );

	// email the user
	emailTerminateEvent( reason );

	if( reason == JOB_EXITED && claimIsClosing() ) {
			// Startd not accepting any more jobs on this claim.
			// We do this here to avoid having to treat this case
			// identically to JOB_EXITED in the code leading up to
			// this point.
		dprintf(D_FULLDEBUG,"Startd is closing claim, so no more jobs can be run on it.\n");
		reason = JOB_EXITED_AND_CLAIM_CLOSING;
	}

	// try to get a new job for this shadow
	if( recycleShadow(reason) ) {
		// recycleShadow delete's this, so we must return immediately
		return;
	}

	// does not return.
	DC_Exit( reason );
}
Example #16
0
void AdEdmLogAdapter::Expose(const string& log){
  server_index_ = (server_index_ + 1) % getCluster();
  //getManagerOneway(server_index_)->Expose(log);
  getManagerDatagram(server_index_)->Expose(log);
}
Example #17
0
static void makeCompoundEdge(graph_t * g, edge_t * e)
#endif
{
    graph_t *lh;		/* cluster containing head */
    graph_t *lt;		/* cluster containing tail */
    bezier *bez;		/* original Bezier for e */
    bezier *nbez;		/* new Bezier  for e */
    int starti = 0, endi = 0;	/* index of first and last control point */
    node_t *head;
    node_t *tail;
    boxf *bb;
    int i, j;
    int size;
    pointf pts[4];
    pointf p;
    int fixed;

    /* find head and tail target clusters, if defined */
#ifdef WITH_CGRAPH
    lh = getCluster(g, agget(e, "lhead"), clustMap);
    lt = getCluster(g, agget(e, "ltail"), clustMap);
#else
    lh = getCluster(g, agget(e, "lhead"));
    lt = getCluster(g, agget(e, "ltail"));
#endif
    if (!lt && !lh)
	return;
    if (!ED_spl(e)) return;

    /* at present, we only handle single spline case */
    if (ED_spl(e)->size > 1) {
	agerr(AGWARN, "%s -> %s: spline size > 1 not supported\n",
	      agnameof(agtail(e)), agnameof(aghead(e)));
	return;
    }
    bez = ED_spl(e)->list;
    size = bez->size;

    head = aghead(e);
    tail = agtail(e);

    /* allocate new Bezier */
    nbez = GNEW(bezier);
    nbez->eflag = bez->eflag;
    nbez->sflag = bez->sflag;

    /* if Bezier has four points, almost collinear,
     * make line - unimplemented optimization?
     */

    /* If head cluster defined, find first Bezier
     * crossing head cluster, and truncate spline to
     * box edge.
     * Otherwise, leave end alone.
     */
    fixed = 0;
    if (lh) {
	bb = &(GD_bb(lh));
	if (!inBoxf(ND_coord(head), bb)) {
	    agerr(AGWARN, "%s -> %s: head not inside head cluster %s\n",
		  agnameof(agtail(e)), agnameof(aghead(e)), agget(e, "lhead"));
	} else {
	    /* If first control point is in bb, degenerate case. Spline
	     * reduces to four points between the arrow head and the point 
	     * where the segment between the first control point and arrow head 
	     * crosses box.
	     */
	    if (inBoxf(bez->list[0], bb)) {
		if (inBoxf(ND_coord(tail), bb)) {
		    agerr(AGWARN,
			  "%s -> %s: tail is inside head cluster %s\n",
			  agnameof(agtail(e)), agnameof(aghead(e)), agget(e, "lhead"));
		} else {
		    assert(bez->sflag);	/* must be arrowhead on tail */
		    p = boxIntersectf(bez->list[0], bez->sp, bb);
		    bez->list[3] = p;
		    bez->list[1] = mid_pointf(p, bez->sp);
		    bez->list[0] = mid_pointf(bez->list[1], bez->sp);
		    bez->list[2] = mid_pointf(bez->list[1], p);
		    if (bez->eflag)
			endi = arrowEndClip(e, bez->list,
					 starti, 0, nbez, bez->eflag);
		    endi += 3;
		    fixed = 1;
		}
	    } else {
		for (endi = 0; endi < size - 1; endi += 3) {
		    if (splineIntersectf(&(bez->list[endi]), bb))
			break;
		}
		if (endi == size - 1) {	/* no intersection */
		    assert(bez->eflag);
		    nbez->ep = boxIntersectf(bez->ep, bez->list[endi], bb);
		} else {
		    if (bez->eflag)
			endi =
			    arrowEndClip(e, bez->list,
					 starti, endi, nbez, bez->eflag);
		    endi += 3;
		}
		fixed = 1;
	    }
	}
    }
    if (fixed == 0) {		/* if no lh, or something went wrong, use original head */
	endi = size - 1;
	if (bez->eflag)
	    nbez->ep = bez->ep;
    }

    /* If tail cluster defined, find last Bezier
     * crossing tail cluster, and truncate spline to
     * box edge.
     * Otherwise, leave end alone.
     */
    fixed = 0;
    if (lt) {
	bb = &(GD_bb(lt));
	if (!inBoxf(ND_coord(tail), bb)) {
	    agerr(AGWARN, "%s -> %s: tail not inside tail cluster %s\n",
		agnameof(agtail(e)), agnameof(aghead(e)), agget(e, "ltail"));
	} else {
	    /* If last control point is in bb, degenerate case. Spline
	     * reduces to four points between arrow head, and the point
	     * where the segment between the last control point and the 
	     * arrow head crosses box.
	     */
	    if (inBoxf(bez->list[endi], bb)) {
		if (inBoxf(ND_coord(head), bb)) {
		    agerr(AGWARN,
			"%s -> %s: head is inside tail cluster %s\n",
		  	agnameof(agtail(e)), agnameof(aghead(e)), agget(e, "ltail"));
		} else {
		    assert(bez->eflag);	/* must be arrowhead on head */
		    p = boxIntersectf(bez->list[endi], nbez->ep, bb);
		    starti = endi - 3;
		    bez->list[starti] = p;
		    bez->list[starti + 2] = mid_pointf(p, nbez->ep);
		    bez->list[starti + 3] = mid_pointf(bez->list[starti + 2], nbez->ep);
		    bez->list[starti + 1] = mid_pointf(bez->list[starti + 2], p);
		    if (bez->sflag)
			starti = arrowStartClip(e, bez->list, starti,
				endi - 3, nbez, bez->sflag);
		    fixed = 1;
		}
	    } else {
		for (starti = endi; starti > 0; starti -= 3) {
		    for (i = 0; i < 4; i++)
			pts[i] = bez->list[starti - i];
		    if (splineIntersectf(pts, bb)) {
			for (i = 0; i < 4; i++)
			    bez->list[starti - i] = pts[i];
			break;
		    }
		}
		if (starti == 0) {
		    assert(bez->sflag);
		    nbez->sp =
			boxIntersectf(bez->sp, bez->list[starti], bb);
		} else {
		    starti -= 3;
		    if (bez->sflag)
			starti = arrowStartClip(e, bez->list, starti,
				endi - 3, nbez, bez->sflag);
		}
		fixed = 1;
	    }
	}
    }
    if (fixed == 0) {		/* if no lt, or something went wrong, use original tail */
	/* Note: starti == 0 */
	if (bez->sflag)
	    nbez->sp = bez->sp;
    }

    /* complete Bezier, free garbage and attach new Bezier to edge 
     */
    nbez->size = endi - starti + 1;
    nbez->list = N_GNEW(nbez->size, pointf);
    for (i = 0, j = starti; i < nbez->size; i++, j++)
	nbez->list[i] = bez->list[j];
    free(bez->list);
    free(bez);
    ED_spl(e)->list = nbez;
}
Example #18
0
jfloat GraphiteLayoutShaper::shapeScriptRun(const SkPaint* paint, const UChar* chars,
        size_t count, bool isRTL, Vector<jfloat>* const outAdvances,
        Vector<jchar>* const outGlyphs, Vector<jfloat>* const outPos,
        jfloat startXPosition, uint32_t startScriptRun, size_t glyphBaseCount) {
    ALOGD("Shape Scrit Run with Graphite");
    SkTypeface *typeface = paint->getTypeface();
    mShapingGrFace = getCachedGrFace(typeface);

    unsigned int x_ppem;
    unsigned int y_ppem;
    int x_scale;
    int y_scale;
    getConversionFactor(x_ppem, y_ppem, x_scale, y_scale, paint);

    mShapingGrFont = gr_make_font_with_ops(x_ppem, paint, &GraphiteFontOps, mShapingGrFace);

    const uint16_t *charsScriptStart = chars ;
    const uint16_t *charsScriptEnd = chars + count;

    size_t numCP;
    char *pError;

    numCP = gr_count_unicode_characters(gr_utf16, charsScriptStart, charsScriptEnd, (const void **)(&pError));

#if DEBUG_GLYPHS
    ALOGD("Myanmar shape with Graphite, numCP = %d, grFont = %p, grFace = %p, pError = %p",
            numCP, mShapingGrFont, mShapingGrFace, pError);
#endif

    if(!mShapingGrFont || !mShapingGrFace || pError) {
        ALOGD("Invalid grFont is NULL, grFace is NULL or parse string error.");
        return 0.0;
    }

    mShapingSegment = gr_make_seg(mShapingGrFont, mShapingGrFace, 0, 0,
            gr_utf16, charsScriptStart, numCP, isRTL);
    cluster_t *clusters = getCluster(mShapingSegment, numCP);

#if DEBUG_GLYPHS
        ALOGD("Got from Graphite");
#endif

    const gr_slot *slot;
    size_t glyphIndex, clusterIndex = 0;
    jfloat totalFontRunAdvance = 0;
    for (slot = gr_seg_first_slot(mShapingSegment), glyphIndex = 0; slot;
            slot = gr_slot_next_in_segment(slot), ++ glyphIndex) {
#if DEBUG_GLYPHS
        ALOGD("         -- Glyph = %d, origin = (%f, %f), advance = (%f, %f)\n",
                gr_slot_gid(slot), gr_slot_origin_X(slot),
                gr_slot_origin_Y(slot),
                gr_slot_advance_X(slot, mShapingGrFace, mShapingGrFont),
                gr_slot_advance_Y(slot, mShapingGrFace, mShapingGrFont));
#endif
        if(glyphIndex == clusters[clusterIndex].base_glyph + clusters[clusterIndex].num_glyphs) {
            uint32_t clusterStart = clusters[clusterIndex].base_char + startScriptRun;
            jfloat startOrigin = outAdvances->itemAt(clusterStart);
            jfloat advance = gr_slot_origin_X(slot) - startOrigin;
            outAdvances->replaceAt(advance, clusterStart);

            ++ clusterIndex;
            clusterStart = clusters[clusterIndex].base_char + startScriptRun;
            outAdvances->replaceAt(gr_slot_origin_X(slot), clusterStart);
        }

        jfloat charRight = gr_slot_origin_X(slot) + gr_slot_advance_X(slot, mShapingGrFace, mShapingGrFont);
        if (charRight > totalFontRunAdvance) {
            totalFontRunAdvance = charRight;
        }

        jchar glyph = glyphBaseCount + gr_slot_gid(slot);
        outGlyphs->add(glyph);

        outPos->add(startXPosition + gr_slot_origin_X(slot));
        outPos->add(gr_slot_origin_Y(slot));
    }

    uint32_t clusterStart = clusters[clusterIndex].base_char + startScriptRun;
    jfloat startOrigin = outAdvances->itemAt(clusterStart);
    jfloat advance = totalFontRunAdvance - startOrigin;
    outAdvances->replaceAt(advance, clusterStart);

    if(mShapingSegment) {
        gr_seg_destroy(mShapingSegment);
        mShapingSegment = NULL;
    }

    if(mShapingGrFont) {
        gr_font_destroy(mShapingGrFont);
        mShapingGrFont = NULL;
    }
#if DEBUG_GLYPHS
    ALOGD("         -- totalFontRunAdvance = %f", totalFontRunAdvance);
#endif
    return totalFontRunAdvance;
}
void AdEdmSenderAdapter::Expose(Ice::Int user_id, Ice::Long adgroup_id, Ice::Int index){
  server_index_ = (server_index_ + 1) % getCluster();
  //getManagerOneway(server_index_)->Expose(log);
  getManagerDatagram(server_index_)->Expose(user_id, adgroup_id, index);
}