Exemplo n.º 1
0
 Collector create_collector(LogLevel log_level)
 {
   std::lock_guard<std::mutex> lock(free_queue_mutex_);
   return Collector(log_level, free_queue_, *this);
 }
Exemplo n.º 2
0
int
main( int argc, char** argv ) 
{
	char* host;
	ClassAd invalidate_ad;
	char line[256];
	Daemon Collector( DT_COLLECTOR);
	ReliSock* coll_sock;
	bool connect_error = true;

	config();

	MyName = argv[0];
	if( argc < 2 ) {
		usage();
	}
	
	if( ! argv[1] ) {
		usage();
	}
	host = get_full_hostname( argv[1] );
	if( ! host ) {
		fprintf( stderr, "%s: Unknown host %s\n", MyName, argv[1] );
		exit( 1 );
	}

	printf( "Trying %s\n", host );

	if( ! Collector.locate() ) {
		fprintf( stderr, "%s: ERROR, can't locate Central Manager!\n", 
				 MyName );
		exit( 1 );
	}

		// Set the correct types
    invalidate_ad.SetMyTypeName( QUERY_ADTYPE );
    invalidate_ad.SetTargetTypeName( STARTD_ADTYPE );

        // We only want to invalidate this slot.
    sprintf( line, "%s = %s == \"%s\"", ATTR_REQUIREMENTS, ATTR_MACHINE,  
             host );
    invalidate_ad.Insert( line );


	do {
		coll_sock = (ReliSock*)Collector.startCommand( INVALIDATE_STARTD_ADS );
		if( coll_sock ) {
			connect_error = false;
			break;
		}
	} while( Collector.nextValidCm() == true );
	if( connect_error == true ) {
		fprintf( stderr, "%s: ERROR: can't create TCP socket to %s\n", 
				 MyName, Collector.fullHostname() );
		exit( 1 );
	}

	coll_sock->encode();

	if( ! invalidate_ad.put(*coll_sock) ) {
		fprintf( stderr, "%s: ERROR: can't send classad!\n", MyName ); 
		delete coll_sock;
		exit( 1 );
	}

	if( ! coll_sock->end_of_message() ) {
		fprintf( stderr, "%s: ERROR: can't send EOM!\n", MyName ); 
		delete coll_sock;
		exit( 1 );
	}

	delete coll_sock;
	printf( "%s: Sent invalidate ad for %s to %s\n", MyName, host,
			Collector.fullHostname() );
	exit( 0 );
}