Example #1
0
		public static void Main (string[] args)
		{
			Console.WriteLine("Creating a worker object");
			Worker w = new Worker("localhost");
			w.registerFunction("wc", wctest);
			w.workLoop();
		}
Example #2
0
		public static void Main (string[] args)
		{
      		Random r = new Random(); 
			
			int numworkers = r.Next(15,30);
			int numclients = r.Next(50, 100);
			
			Thread[] clients = new Thread[numclients];
			Worker[] workers = new Worker[numworkers];
			
			Log.DebugFormat("Spawning {0} workers and {1} clients", numworkers, numclients);
						
			for(int i = 0; i < numworkers; i++)
			{
				Log.DebugFormat("Spawning worker #{0}", i);
				Worker w = new Worker("localhost");
				w.registerFunction("randomlength", randomlengthjob);
				w.workLoop();
				
				workers[i] = w;
			}
		
			for(int j = 0; j < numclients; j++) 
			{
				Thread t = new Thread(clientThread);
				t.Name = String.Format("Client #{0}", j);
				Log.DebugFormat("Spawning client #{0}", j);
				t.Start();
				
				clients[j] = t; 
			}
			
			
					
	    }
Example #3
0
		public void testWordCountIPv6()
		{
		    Worker w = new Worker("::1");
			w.registerFunction("wc", wctest);
			w.workLoop();
			
			Client c = new Client("::1");
			byte[] data = new ASCIIEncoding().GetBytes("zzz\nyyy\napple\nbaz\nfoo\nnarf\nquiddle\n");
			byte[] result = c.submitJob("wc", data);
		
			Assert.IsNotNull(result);
			
			int resultasint = BitConverter.ToInt32(result, 0);
			
			Assert.AreEqual(resultasint, 7);
			
			w.stopWorkLoop();			
		}
Example #4
0
    		public void testBackgroundJob()
    		{
      		Worker w = new Worker("localhost");
			w.registerFunction("bgtest", bgtest);
			w.workLoop();
			
			Client c = new Client("localhost"); 
			byte[] data = new ASCIIEncoding().GetBytes("");
			string jobhandle = c.submitJobInBackground("bgtest", data, Client.JobPriority.HIGH);
		
			while(!c.checkIsDone(jobhandle))
			{
				Console.WriteLine("Still not done!");
				Thread.Sleep(1500);
			}
			
			w.stopWorkLoop();
	    }
Example #5
0
    		public void testTimeout()
    		{
      		Worker w = new Worker("localhost");
			w.registerFunction("infinite", infinite);
			w.workLoop();
		
			
			DateTime start = DateTime.Now;
			Console.WriteLine("Started: {0}", start);
			
			Client c = new Client("localhost");
			byte[] data = new ASCIIEncoding().GetBytes("zzz\nyyy\napple\nbaz\nfoo\nnarf\nquiddle\n");
			c.submitJob("infinite", data);
			DateTime stop = DateTime.Now;
			
			Console.WriteLine("Connection died at {1}", stop);
						
			w.stopWorkLoop();
	    }
Example #6
0
    		public void testLoad()
    		{
      		Random r = new Random(); 
			
			int numworkers = r.Next(15,30);
			int numclients = r.Next(50, 100);
			
			Log.DebugFormat("Spawning {0} workers and {1} clients", numworkers, numclients);
			 
			for(int i = 0; i < numworkers; i++)
			{
				w = new Worker("localhost");
				w.registerFunction("randomlength", randomlengthjob);
				w.workLoop();
			}
		
			for(int j = 0; j < numclients; j++) 
			{
				Thread t = new Thread(clientThread);
				t.Name = String.Format("Client #{0}", j);
				t.Start();
			}
					
	    }
Example #7
0
		public Job(JobAssign ja, Worker w)
		{
			this.jobPacket = ja; 
			this.jobWorker = w; 
		}