Exemplo n.º 1
0
void
invalidate_ads() {
	ClassAd cmd_ad;
	SetMyTypeName( cmd_ad, QUERY_ADTYPE );
	SetTargetTypeName( cmd_ad, MASTER_ADTYPE );
	
	MyString line;
	std::string escaped_name;
	char* default_name = ::strnewp(MasterName);
	if(!default_name) {
		default_name = default_daemon_name();
	}
	
	EscapeAdStringValue( default_name, escaped_name );
	line.formatstr( "( TARGET.%s == \"%s\" )", ATTR_NAME, escaped_name.c_str() );
	cmd_ad.AssignExpr( ATTR_REQUIREMENTS, line.Value() );
	cmd_ad.Assign( ATTR_NAME, default_name );
	cmd_ad.Assign( ATTR_MY_ADDRESS, daemonCore->publicNetworkIpAddr());
	daemonCore->sendUpdates( INVALIDATE_MASTER_ADS, &cmd_ad, NULL, false );
	delete [] default_name;
}
Exemplo n.º 2
0
void
init_classad()
{
	if( ad ) delete( ad );
	ad = new ClassAd();

	SetMyTypeName(*ad, MASTER_ADTYPE);
	SetTargetTypeName(*ad, "");

	if (MasterName) {
		ad->Assign(ATTR_NAME, MasterName);
	} else {
		char* default_name = default_daemon_name();
		if( ! default_name ) {
			EXCEPT( "default_daemon_name() returned NULL" );
		}
		ad->Assign(ATTR_NAME, default_name);
		delete [] default_name;
	}

#if !defined(WIN32)
	ad->Assign(ATTR_REAL_UID, (int)getuid());
#endif
}
Exemplo n.º 3
0
void
JobQueueDBManager::config(bool reconfig) 
{
	char *tmp;
	MyString sql_str;
	int bndcnt = 0;
	const char *data_arr[3];
	QuillAttrDataType   data_typ[3];

	if (param_boolean("QUILL_ENABLED", false) == false) {
		EXCEPT("Quill++ is currently disabled. Please set QUILL_ENABLED to "
			   "TRUE if you want this functionality and read the manual "
			   "about this feature since it requires other attributes to be "
			   "set properly.");
	}

		//bail out if no SPOOL variable is defined since its used to 
		//figure out the location of the job_queue.log file
	char *spool = param("SPOOL");
	if(!spool) {
		EXCEPT("No SPOOL variable found in config file\n");
	}
  
	jobQueueLogFile = (char *) malloc(_POSIX_PATH_MAX * sizeof(char));
	snprintf(jobQueueLogFile,_POSIX_PATH_MAX * sizeof(char), 
			 "%s/job_queue.log", spool);

		/*
		  Here we try to read the database parameters in config
		  the db ip address format is <ipaddress:port> 
		*/
	dt = getConfigDBType();

	jobQueueDBIpAddress = param("QUILL_DB_IP_ADDR");

	jobQueueDBName = param("QUILL_DB_NAME");

	jobQueueDBUser = param("QUILL_DB_USER");
  	
	jobQueueDBConn = getDBConnStr(jobQueueDBIpAddress,
								  jobQueueDBName,
								  jobQueueDBUser,
								  spool);
								  
	dprintf(D_ALWAYS, "Using Job Queue File %s\n", jobQueueLogFile);

	dprintf(D_ALWAYS, "Using Database Type = Postgres\n");
	dprintf(D_ALWAYS, "Using Database IpAddress = %s\n", 
			jobQueueDBIpAddress?jobQueueDBIpAddress:"");
	dprintf(D_ALWAYS, "Using Database Name = %s\n", 
			jobQueueDBName?jobQueueDBName:"");
	dprintf(D_ALWAYS, "Using Database User = %s\n", 
			jobQueueDBUser?jobQueueDBUser:"");

	if(spool) {
		free(spool);
		spool = NULL;
	}

		// this function is also called when condor_reconfig is issued
		// and so we dont want to recreate all essential objects
	if(!reconfig) {
		prober = new ClassAdLogProber();
		caLogParser = new ClassAdLogParser();

		switch (dt) {				
		case T_PGSQL:
			DBObj = new PGSQLDatabase(jobQueueDBConn);
			break;
		default:
			break;;
		}

		xactState = NOT_IN_XACT;

		QuillErrCode ret_st;

		ret_st = DBObj->connectDB();
		if (ret_st == QUILL_FAILURE) {
			displayErrorMsg("config: unable to connect to DB--- ERROR");
			EXCEPT("config: unable to connect to DB\n");
		}

			/* the following will also throw an exception if the schema 
			   version is not correct */
		DBObj->assertSchemaVersion();
		
		tmp = param( "SCHEDD_NAME" );
		if( tmp ) {
			scheddname = build_valid_daemon_name( tmp );
			dprintf(D_FULLDEBUG, "scheddname %s built from param value %s\n", 
					scheddname, tmp);
			free(tmp);

		} else {
			scheddname = default_daemon_name();
			dprintf(D_FULLDEBUG, "scheddname built from default daemon name: %s\n", scheddname);
		}

		{
				/* create an entry in jobqueuepollinginfo if this schedd is the 
				 * first time being logged to database
				 */
			sql_str.formatstr("INSERT INTO jobqueuepollinginfo (scheddname, last_file_mtime, last_file_size) SELECT '%s', 0, 0 FROM dummy_single_row_table WHERE NOT EXISTS (SELECT * FROM jobqueuepollinginfo WHERE scheddname = '%s')", scheddname, scheddname);
		
			ret_st = DBObj->execCommand(sql_str.Value());
			if (ret_st == QUILL_FAILURE) {
				dprintf(D_ALWAYS, "Insert JobQueuePollInfo --- ERROR [SQL] %s\n", 
						sql_str.Value());
			}			
		}

		{
				/* create an entry in currency table if this schedd is the first
				 * time being logged to database 
				 */
			sql_str.formatstr("INSERT INTO currencies (datasource) SELECT '%s' FROM dummy_single_row_table WHERE NOT EXISTS (SELECT * FROM currencies WHERE datasource = '%s')", scheddname, scheddname);

			ret_st = DBObj->execCommand(sql_str.Value());
			if (ret_st == QUILL_FAILURE) {
				dprintf(D_ALWAYS, "Insert Currency --- ERROR [SQL] %s\n", sql_str.Value());
			}
		}
		
		ret_st = DBObj->commitTransaction();
		if (ret_st == QUILL_FAILURE) {
			dprintf(D_ALWAYS, "Commit transaction failed in JobQueueDBManager::config\n");
		}

		if (param_boolean("QUILL_MAINTAIN_DB_CONN", true) == false) {
			ret_st = DBObj->disconnectDB();
			if (ret_st == QUILL_FAILURE) {
				dprintf(D_ALWAYS, "JobQueueDBManager:config: unable to disconnect database --- ERROR\n");
			}	
		}
	}

		//this function assumes that certain members have been initialized
		// (specifically prober and caLogParser) and so the order is important.
	setJobQueueFileName(jobQueueLogFile);
}
Exemplo n.º 4
0
void
DBMSManager::config() {
    char *name = param("DBMSMANAGER_NAME");
    if(name) {
        char *valid_name = build_valid_daemon_name(name);
        m_name = valid_name;
        free(name);
        delete [] valid_name;
    }
    else {
        char *default_name = default_daemon_name();
        if(default_name) {
            m_name = default_name;
            delete [] default_name;
        }
    }

    InitPublicAd();

    int update_interval = param_integer("UPDATE_INTERVAL", 60);
    if(m_public_ad_update_interval != update_interval) {
        m_public_ad_update_interval = update_interval;

        if(m_public_ad_update_timer >= 0) {
            daemonCore->Cancel_Timer(m_public_ad_update_timer);
            m_public_ad_update_timer = -1;
        }
        dprintf(D_FULLDEBUG, "Setting update interval to %d\n",
                m_public_ad_update_interval);
        m_public_ad_update_timer = daemonCore->Register_Timer(
                                       0,
                                       m_public_ad_update_interval,
                                       (TimerHandlercpp)&DBMSManager::TimerHandler_UpdateCollector,
                                       "DBMSManager::TimerHandler_UpdateCollector",
                                       this);
    }

    /* register the database purging callback */
    int purge_interval = param_integer("DATABASE_PURGE_INTERVAL", 86400); // 24 hours

    if(m_database_purge_interval != purge_interval) {
        m_database_purge_interval = purge_interval;

        if(m_database_purge_timer >= 0) {
            daemonCore->Cancel_Timer(m_database_purge_timer);
            m_database_purge_timer = -1;
        }
        dprintf(D_FULLDEBUG, "Setting database purge interval to %d\n",
                m_database_purge_interval);
        m_database_purge_timer = daemonCore->Register_Timer(
                                     0,
                                     m_database_purge_interval,
                                     (TimerHandlercpp)&DBMSManager::TimerHandler_PurgeDatabase,
                                     "DBMSManager::TimerHandler_PurgeDatabase",
                                     this);
    }

    /* register the database reindexing callback */
    int reindex_interval = param_integer("DATABASE_REINDEX_INTERVAL", 86400); // 24 hours

    if(m_database_reindex_interval != reindex_interval) {
        m_database_reindex_interval = reindex_interval;

        if(m_database_reindex_timer >= 0) {
            daemonCore->Cancel_Timer(m_database_reindex_timer);
            m_database_reindex_timer = -1;
        }
        dprintf(D_FULLDEBUG, "Setting database reindex interval to %d\n",
                m_database_reindex_interval);
        m_database_reindex_timer = daemonCore->Register_Timer(
                                       0,
                                       m_database_reindex_interval,
                                       (TimerHandlercpp)&DBMSManager::TimerHandler_ReindexDatabase,
                                       "DBMSManager::TimerHandler_ReindexDatabase",
                                       this);
    }

}