コード例 #1
0
bool
ClaimStartdMsg::readMsg( DCMessenger * /*messenger*/, Sock *sock ) {
	// Now, we set the timeout on the socket to 1 second.  Since we 
	// were called by as a Register_Socket callback, this should not 
	// block if things are working as expected.  
	// However, if the Startd wigged out and sent a 
	// partial int or some such, we cannot afford to block. -Todd 3/2000
	sock->timeout(1);

 	if( !sock->get(m_reply) ) {
		dprintf( failureDebugLevel(),
				 "Response problem from startd when requesting claim %s.\n",
				 description() );	
		sockFailed( sock );
		return false;
	}

	/* 
		Reply of 0 (OK) means claim accepted.
		Reply of 1 (NOT_OK) means claim rejected.
		Reply of 3 means claim accepted by a partitionable slot,
	      and the "leftovers" slot ad and claim id will be sent next.
	*/

	if( m_reply == OK ) {
			// no need to log success, because DCMsg::reportSuccess() will
	} else if( m_reply == NOT_OK ) {
		dprintf( failureDebugLevel(), "Request was NOT accepted for claim %s\n", description() );
	} else if( m_reply == 3 ) {
	 	if( !sock->get(m_leftover_claim_id) ||
			!m_leftover_startd_ad.initFromStream( *sock )  ) 
		{
			// failed to read leftover partitionable slot info
			dprintf( failureDebugLevel(),
				 "Failed to read paritionable slot leftover from startd - claim %s.\n",
				 description() );
			// treat this failure same as NOT_OK, since this startd is screwed
			m_reply = NOT_OK;
		} else {
			// successfully read leftover partitionable slot info
			m_have_leftovers = true;
			// change reply to OK cuz claim was a success
			m_reply = OK;
		}
	} else {
		dprintf( failureDebugLevel(), "Unknown reply from startd when requesting claim %s\n",description());
	}
		
	// end_of_message() is done by caller

	return true;
}
コード例 #2
0
ファイル: dc_startd.cpp プロジェクト: zzxuanyuan/htcondor
bool
ClaimStartdMsg::writeMsg( DCMessenger * /*messenger*/, Sock *sock ) {
		// save startd fqu for hole punching
	m_startd_fqu = sock->getFullyQualifiedUser();
	m_startd_ip_addr = sock->peer_ip_str();

		// Insert an attribute in the request ad to inform the
		// startd that this schedd is capable of understanding 
		// the newer protocol where the claim response may send
		// over any leftover resources from a partitionable slot.
	m_job_ad.Assign("_condor_SEND_LEFTOVERS",
		param_boolean("CLAIM_PARTITIONABLE_LEFTOVERS",true));

		// Insert an attribute in the request ad to inform the
		// startd that this schedd is capable of understanding
		// the newer protocol where the claim response may send
		// over the ad and claim id of the partner of a paired slot.
	m_job_ad.Assign("_condor_SEND_PAIRED_SLOT",
		param_boolean("CLAIM_PAIRED_SLOT",true));

	if( !sock->put_secret( m_claim_id.c_str() ) ||
	    !putClassAd( sock, m_job_ad ) ||
	    !sock->put( m_scheduler_addr.c_str() ) ||
	    !sock->put( m_alive_interval ) ||
		!this->putExtraClaims(sock))
	{
		dprintf(failureDebugLevel(),
				"Couldn't encode request claim to startd %s\n",
				description() );
		sockFailed( sock );
		return false;
	}
		// end_of_message() is done by caller
	return true;
}
コード例 #3
0
ファイル: dc_startd.cpp プロジェクト: zzxuanyuan/htcondor
bool
SwapClaimsMsg::writeMsg( DCMessenger * /*messenger*/, Sock *sock ) {

	if ( ! sock->put_secret(m_claim_id.c_str()) || ! putClassAd(sock, m_opts))
	{
		dprintf(failureDebugLevel(),
				"Couldn't encode claim swap request to startd %s\n",
				description() );
		sockFailed(sock);
		return false;
	}
		// end_of_message() is done by caller
	return true;
}
コード例 #4
0
ファイル: dc_startd.cpp プロジェクト: zzxuanyuan/htcondor
bool
SwapClaimsMsg::readMsg( DCMessenger * /*messenger*/, Sock *sock ) {
	// Now, we set the timeout on the socket to 1 second.  Since we
	// were called by as a Register_Socket callback, this should not
	// block if things are working as expected.
	// However, if the Startd wigged out and sent a
	// partial int or some such, we cannot afford to block.
	sock->timeout(1);

	if ( ! sock->get(m_reply)) {
		dprintf(failureDebugLevel(),
				"Response problem from startd when requesting claim swap %s.\n",
				description());	
		sockFailed( sock );
		return false;
	}

	/*
		Reply of 0 (OK) means swap happened
		Reply of 1 (NOT_OK) means swap rejected
		Reply of 4 (SWAP_CLAIM_ALREADY_SWAPPED) means swap did not happen because claim_id was already in slot_name
	*/

	if (m_reply == OK) {
			// no need to log success, because DCMsg::reportSuccess() will
	} else if (m_reply == NOT_OK) {
		dprintf(failureDebugLevel(), "Swap claims request NOT accepted for claim %s\n", description());
	} else if (m_reply == SWAP_CLAIM_ALREADY_SWAPPED) {
		dprintf(failureDebugLevel(), "Swap claims request reports that swap had already happened for claim %s\n", description());
	} else {
		dprintf(failureDebugLevel(), "Unknown reply from startd when swapping claims %s\n",description());
	}

	// end_of_message() is done by caller

	return true;
}