Пример #1
0
bool
Starter::holdJob(char const *hold_reason,int hold_code,int hold_subcode,bool soft)
{
	if( !s_is_dc ) {
		return false;  // this starter does not support putting jobs on hold
	}
	if( m_hold_job_cb ) {
		dprintf(D_ALWAYS,"holdJob() called when operation already in progress (starter pid %d).\n", s_pid);
		return true;
	}

	classy_counted_ptr<DCStarter> starter = new DCStarter(getIpAddr());
	classy_counted_ptr<StarterHoldJobMsg> msg = new StarterHoldJobMsg(hold_reason,hold_code,hold_subcode,soft);

	m_hold_job_cb = new DCMsgCallback( (DCMsgCallback::CppFunction)&Starter::holdJobCallback, this );

	msg->setCallback( m_hold_job_cb );

	starter->sendMsg(msg.get());

	if( soft ) {
		startSoftkillTimeout();
	}
	else {
		startKillTimer();
	}

	return true;
}
Пример #2
0
bool
makeScheddAdHashKey (AdNameHashKey &hk, const ClassAd *ad )
{

	// get the name of the schedd
	if ( !adLookup( "Schedd", ad, ATTR_NAME, ATTR_MACHINE, hk.name ) ) {
		return false;
	}
	
	// this may be a submittor ad.  if so, we also want to append the
	// schedd name to the hash.  this will fix problems were submittor
	// ads will clobber one another if the more than one schedd runs
	// on the same IP address submitting into the same pool.
	// -Todd Tannenbaum <*****@*****.**> 2/2005
	MyString	tmp;
	if ( adLookup( "Schedd", ad, ATTR_SCHEDD_NAME, NULL, tmp, false ) ) {
		hk.name += tmp;
	}

	// get the IP and port of the schedd 
	// As of 7.5.0, we look for MyAddress.  Prior to that, we did not,
	// so new schedds must continue to send StartdIpAddr to remain
	// compatible with old collectors.
	if ( !getIpAddr( "Schedd", ad, ATTR_MY_ADDRESS, ATTR_SCHEDD_IP_ADDR,
					 hk.ip_addr ) ) {
		return false;
	}

	return true;
}
Пример #3
0
 int UdpSocket::create(String interface, Address::ADDRESS_TYPE iptype, unsigned short port) {
     char buffer[sizeof(sockaddr_in6)];
     
     memset(buffer, 0, sizeof(sizeof(sockaddr_in6)));
     
     if (interface.equals("ANY", true) || getIpAddr(interface, iptype, buffer)) {
         int fd = socket((iptype==Address::IPV4 ? AF_INET : AF_INET6), SOCK_DGRAM, 0);
         
         if (iptype==Address::IPV4) {
             
             ((sockaddr_in*)buffer)->sin_family = AF_INET;
             ((sockaddr_in*)buffer)->sin_port = htons(port);
             
             if (interface.equals("ANY", true))
                 ((sockaddr_in*)buffer)->sin_addr.s_addr = INADDR_ANY;
             
         } else {
             ((sockaddr_in6*)buffer)->sin6_family = AF_INET6;
             ((sockaddr_in6*)buffer)->sin6_port = htons(port);
             
             if (interface.equals("ANY", true))
                 ((sockaddr_in6*)buffer)->sin6_addr = in6addr_any;
         }
         
         if (bind(fd, (struct sockaddr *)buffer, iptype==Address::IPV4 ? sizeof(sockaddr_in) : sizeof(sockaddr_in6)) == 0) {
             return fd;
         }
     }
     return 0;
 }
Пример #4
0
bool
makeLicenseAdHashKey (AdNameHashKey &hk, const ClassAd *ad )
{

	// get the name of the license
	if ( !adLookup( "License", ad, ATTR_NAME, ATTR_MACHINE, hk.name ) ) {
		return false;
	}
	
	// get the IP and port of the startd 
	if ( !getIpAddr( "License", ad, ATTR_MY_ADDRESS, NULL, hk.ip_addr ) ) {
		return false;
	}

	return true;
}
Пример #5
0
// functions to make the hashkeys ...
// make hashkeys from the obtained ad
bool
makeStartdAdHashKey (AdNameHashKey &hk, const ClassAd *ad )
{

	// get the name of the startd;
	// this gets complicated with ID
	if ( !adLookup( "Start", ad, ATTR_NAME, NULL, hk.name, false ) ) {
		logWarning( "Start", ATTR_NAME, ATTR_MACHINE, ATTR_SLOT_ID );

		// Get the machine name; if it's not there, give up
		if ( !adLookup( "Start", ad, ATTR_MACHINE, NULL, hk.name, false ) ) {
			logError( "Start", ATTR_NAME, ATTR_MACHINE );
			return false;
		}
		// Finally, if there is a slot ID, append it.
		int	slot;
		if (ad->LookupInteger( ATTR_SLOT_ID, slot)) {
			hk.name += ":";
			hk.name += IntToStr( slot );
		}
		else if (param_boolean("ALLOW_VM_CRUFT", false) &&
				 ad->LookupInteger(ATTR_VIRTUAL_MACHINE_ID, slot)) {
			hk.name += ":";
			hk.name += IntToStr( slot );
		}
	}

	hk.ip_addr = "";
	// As of 7.5.0, we look for MyAddress.  Prior to that, we did not,
	// so new startds must continue to send StartdIpAddr to remain
	// compatible with old collectors.
	if ( !getIpAddr( "Start", ad, ATTR_MY_ADDRESS, ATTR_STARTD_IP_ADDR,
					 hk.ip_addr ) ) {
		dprintf (D_FULLDEBUG,
				 "StartAd: No IP address in classAd from %s\n",
				 hk.name.Value() );
	}

	return true;
}
Пример #6
0
int main() {

	int listenSocket, connectSocket, socketFlags, ret, clientSize;
	struct sockaddr_in myAddress, clientAddress;
	int i,j, bytes, numBytes, pid;
	server_topology = NULL;

	log_init();
        getIpAddr();	
	//server_topology = (struct Head_Node*)calloc(1, sizeof(struct Head_Node));
	
	payloadBuf *packet;
	int rc;
	
	clientSize = sizeof(clientAddress);

	//Create a listening socket..
	if((listenSocket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printf("Error creating server socket. Dying ...\n");
		return 0;
	}
	printf("Socket Created\n");
	
	//Init the sockaddr structure..
	memset(&myAddress, 0, sizeof(myAddress));
	myAddress.sin_family	  = AF_INET;
	myAddress.sin_addr.s_addr = INADDR_ANY;
	myAddress.sin_port	  = htons(MY_PORT);
	
	
	//Now bind the socket..
	if((bind(listenSocket, (struct sockaddr *)&myAddress, sizeof(myAddress))) < 0) {
		printf("Error binding socket. Dying...\n");		
		return 0;
	}

	printf("Bind Created\n");
	
	//Listen on the socket for incoming connections..	
	if((listen(listenSocket, 10)) < 0) {
		printf("Error listening on socket. Dying...\n");
		return 0;
	}
	
	printf("Now listening\n");
	for(;;) {
		if ((connectSocket = accept(listenSocket, (struct sockaddr*)&clientAddress, &clientSize)) < 0) {
			printf("Error accepting connection. Dying...\n");
			return 0;
		} 
		
		printf("Before printing\n");
		
		
		printf("\nClient %d.%d.%d.%d connected\n", 
				(clientAddress.sin_addr.s_addr & 0xFF),  
				(clientAddress.sin_addr.s_addr & 0xFF00) >> 8,  
				(clientAddress.sin_addr.s_addr & 0xFF0000) >> 16,  
				(clientAddress.sin_addr.s_addr & 0xFF000000) >> 24 
			);
		
		//A client has connected.
		//I need to tell the topology to the client
		
		printf("Calling Message Decode\n");	
		rc = message_decode(connectSocket, &packet);
		printf("After message decode\n");
		if(rc == RC_SUCCESS)
			processPacket(connectSocket, packet);	
	
		
		//Now I need to tell other that a new node is about to join. 
		//First tell the nodes neigbors	
		close(connectSocket);
		
	}	
}