Beispiel #1
0
/**
 * test1	Allocate a server and do lots of other things
 *
  */
static int
test1()
{
SERVER   *server;
int     result;
char    *status;

        /* Server tests */
        ss_dfprintf(stderr,
                    "testserver : creating server called MyServer"); 
        server = server_alloc("MyServer", "HTTPD", 9876);
        skygw_log_sync_all();

        //ss_info_dassert(NULL != service, "New server with valid protocol and port must not be null");
        //ss_info_dassert(0 != service_isvalid(service), "Service must be valid after creation");

        ss_dfprintf(stderr, "\t..done\nTest Parameter for Server.");
        ss_info_dassert(NULL == serverGetParameter(server, "name"), "Parameter should be null when not set");
        serverAddParameter(server, "name", "value");
        skygw_log_sync_all();
        ss_info_dassert(0 == strcmp("value", serverGetParameter(server, "name")), "Parameter should be returned correctly");
        ss_dfprintf(stderr, "\t..done\nTesting Unique Name for Server.");
        ss_info_dassert(NULL == server_find_by_unique_name("uniquename"), "Should not find non-existent unique name.");
        server_set_unique_name(server, "uniquename");
        skygw_log_sync_all();
        ss_info_dassert(server == server_find_by_unique_name("uniquename"), "Should find by unique name.");
        ss_dfprintf(stderr, "\t..done\nTesting Status Setting for Server.");
        status = server_status(server);
        skygw_log_sync_all();
        ss_info_dassert(0 == strcmp("Running", status), "Status of Server should be Running by default.");
        if (NULL != status) free(status);
        server_set_status(server, SERVER_MASTER);
        status = server_status(server);
        skygw_log_sync_all();
        ss_info_dassert(0 == strcmp("Master, Running", status), "Should find correct status.");
        server_clear_status(server, SERVER_MASTER);		
		free(status);
        status = server_status(server);
        skygw_log_sync_all();
        ss_info_dassert(0 == strcmp("Running", status), "Status of Server should be Running after master status cleared.");
        if (NULL != status) free(status);
        ss_dfprintf(stderr, "\t..done\nRun Prints for Server and all Servers.");
        printServer(server);
        printAllServers();
        skygw_log_sync_all();
        ss_dfprintf(stderr, "\t..done\nFreeing Server.");
        ss_info_dassert(0 != server_free(server), "Free should succeed");
        ss_dfprintf(stderr, "\t..done\n");
	return 0;
        
}
Beispiel #2
0
/**
 * Print all servers
 *
 * Designed to be called within a debugger session in order
 * to display all active servers within the gateway
 */
void
printAllServers()
{
SERVER	*ptr;

	spinlock_acquire(&server_spin);
	ptr = allServers;
	while (ptr)
	{
		printServer(ptr);
		ptr = ptr->next;
	}
	spinlock_release(&server_spin);
}
Beispiel #3
0
/**
 * Print all servers
 *
 * Designed to be called within a debugger session in order
 * to display all active servers within the gateway
 */
void
printAllServers()
{
    SERVER *server;

    spinlock_acquire(&server_spin);
    server = allServers;
    while (server)
    {
        printServer(server);
        server = server->next;
    }
    spinlock_release(&server_spin);
}
Beispiel #4
0
void
prettyPrint (ClassAdList &adList, TrackTotals *totals)
{
	ppOption pps = using_print_format ? PP_CUSTOM : ppStyle;
	ClassAd	*ad;
	int     classad_index;
	int     last_classad_index;
	bool    fPrintHeadings = pm.has_headings() || (pm_head.Length() > 0);

	classad_index = 0;
	last_classad_index = adList.Length() - 1;
	adList.Open();
	while ((ad = adList.Next())) {
		if (!wantOnlyTotals) {
			switch (pps) {
			  case PP_STARTD_NORMAL:
				if (absentMode) {
					printStartdAbsent (ad, (classad_index == 0));
				} else if( offlineMode ) {
					printStartdOffline( ad, (classad_index == 0));
				} else {
					printStartdNormal (ad, (classad_index == 0));
				}
				break;

			  case PP_STARTD_SERVER:
				printServer (ad, (classad_index == 0));
				break;

			  case PP_STARTD_RUN:
				printRun (ad, (classad_index == 0));
				break;

			  case PP_STARTD_COD:
				printCOD (ad);
				break;

			  case PP_STARTD_STATE:
				printState(ad, (classad_index == 0));
				break;

#ifdef HAVE_EXT_POSTGRESQL
			  case PP_QUILL_NORMAL:
				printQuillNormal (ad);
				break;
#endif /* HAVE_EXT_POSTGRESQL */

			  case PP_SCHEDD_NORMAL:
				printScheddNormal (ad, (classad_index == 0));
				break;

			  case PP_NEGOTIATOR_NORMAL:
				printNegotiatorNormal (ad, (classad_index == 0));
				break;


			  case PP_SCHEDD_SUBMITTORS:
				printScheddSubmittors (ad, (classad_index == 0));
				break;

			  case PP_VERBOSE:
				printVerbose (ad);
				break;

			  case PP_XML:
				printXML (ad, (classad_index == 0),
					(classad_index == last_classad_index));
				break;

			  case PP_MASTER_NORMAL:
				printMasterNormal(ad, (classad_index == 0));
				break;

			  case PP_COLLECTOR_NORMAL:
				printCollectorNormal(ad, (classad_index == 0));
				break;

			  case PP_CKPT_SRVR_NORMAL:
				printCkptSrvrNormal(ad, (classad_index == 0));
				break;

			  case PP_STORAGE_NORMAL:
				printStorageNormal(ad, (classad_index == 0));
				break;

			  case PP_GRID_NORMAL:
				printGridNormal(ad, (classad_index == 0));
				break;

			  case PP_GENERIC_NORMAL:
			  case PP_GENERIC:
			  case PP_ANY_NORMAL:
				printAnyNormal(ad, (classad_index == 0));
				break;

			  case PP_CUSTOM:
				  // hack: print a single item to a string, then discard the string
				  // this makes sure that the headings line up correctly over the first
				  // line of data.
				if (fPrintHeadings) {
					std::string tmp;
					pm.display(tmp, ad, targetAd);
					if (pm.has_headings()) {
						if ( ! (pmHeadFoot & HF_NOHEADER))
							pm.display_Headings(stdout);
					} else {
						pm.display_Headings(stdout, pm_head);
					}
					fPrintHeadings = false;
				}
				printCustom (ad);
				break;

			  case PP_NOTSET:
				fprintf (stderr, "Error:  pretty printing set to PP_NOTSET.\n");
				exit (1);

			  default:
				fprintf (stderr, "Error:  Unknown pretty print option.\n");
				exit (1);			
			}
		}
		classad_index++;
		totals->update(ad);
	}
	adList.Close();

	// if there are no ads to print, but the user wanted XML output,
	// then print out the XML header and footer, so that naive XML
	// parsers won't get confused.
	if ( PP_XML == pps && 0 == classad_index ) {
		printXML (NULL, true, true);
	}

	// if totals are required, display totals
	if (adList.MyLength() > 0 && totals) totals->displayTotals(stdout, 20);
}