Beispiel #1
0
int
main (int argc, char **argv)
{
	int times = (argc > 1)?atoi(argv[1]):100;
	int i, random, port=0, index=0, numPorts = 0;
	struct timeval tv;
	dirxn d;
	PortAlloc *pa;
	int *portList;

	gettimeofday(&tv, NULL);
	srand48(tv.tv_sec);

	portList = calloc(times, sizeof(int));

	NetLogInit();
	NetLogOpen((struct sockaddr_in *)NULL, 0, NETLOG_TERMINAL);
	NETLOG_SETLEVEL(MFCE, NETLOG_DEBUG4);
	NETLOG_SETLEVELE(MFCE, NETLOG_DEBUGMASK|NETLOG_ERRORMASK);

	pa = initPortAllocation(2, 10);

	for (i = 0; i < times; i++) {
		random = (rand() % 100);
		d = ((rand() % 100) < 40) ? rx : tx ; 
		if (numPorts)
			index = rand() % numPorts;

		if (random < 70) {
			if ((random < 50) || (numPorts == 0)) {
				// get a new port
				port = 0;
			}
			else if (random < 70) {
				// choose an allocated port
				port = portList[index];	
			}

//			printf("allocating: port %d for %s\n", port, dirxn2str(d));
			if ((port = allocPort(pa, port, d)) > 0) {
				portList[numPorts] = port;
				numPorts++;
			}
//			else {
//				printf("allocPort failed - %s port %d\n", dirxn2str(d), port);
//			}
		} else if (numPorts) {
			// free this port
//			printf("freeing: port %d for %s\n", portList[index], dirxn2str(d));
			freePort(pa, portList[index], d);
		}

		printPorts(pa);
	}
	
	return 0;
}
Beispiel #2
0
void ModeGetNodes::printNodes(NodeType nodeType, NodeList* nodes, StringSet* unreachableNodes,
   uint16_t rootNodeID)
{
   for(NodeListIter iter = nodes->begin(); iter != nodes->end(); iter++)
   {
      Node* node = *iter;

      // print only string ID for clients, but numeric & string ID for servers
      std::cout << node->getTypedNodeID() << std::endl;

      if(cfgPrintFhgfsVersion)
         printFhgfsVersion(node);

      if(cfgPrintDetails)
      {
         printPorts(node);
         printNicList(node);
      }

      if(cfgCheckReachability)
         printReachability(node, unreachableNodes);

      if(cfgPrintConnRoute)
         printConnRoute(node, unreachableNodes);
   }

   if(cfgPrintDetails)
   {
      std::cout << std::endl;
      
      std::cout << "Number of nodes: " << nodes->size() << std::endl;
   
      if(rootNodeID)
         std::cout << "Root: " << rootNodeID << std::endl;
   }

}