Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this master.cs file.


HTML
public class Master
  {

      internal BufferedReader br;
      internal long volume;
      internal int velocity;
      internal string data; //variety
      internal long mmemory; //master memory
      internal int mLowEnd;
      internal int mHighEnd;
      internal long mCpuCap; // master cpu memory
      internal int mcLowEnd;
      internal int mcHighEnd;
      internal int noOfSlaves; //slaves
      internal long smemorycap; //slave memory
      internal int sLowEnd;
      internal int sHighEnd;
      internal int sRandom;
      internal int sClustered;
      internal long sCpuCap; // slave cpu memory
      internal int scLowEnd;
      internal int scHighEnd;
      internal int scRandom;
      internal int scClustered;
      internal long startTime;
      internal long endTime;

      internal Master()
  {
      try
      {
          br = new BufferedReader(new InputStreamReader(System.in));

      }
      catch (Exception e)
      {
          Console.WriteLine(e);
      }

  }

      public virtual void readInput()
      {
          try
          {
              Console.WriteLine("Volume (enter the volume of the bigdata in TB):");
              volume = Convert.ToInt64(br.readLine());
              Console.WriteLine("Velocity (enter the velocity of the bigdata in bps):");
              velocity = Convert.ToInt32(br.readLine());
              Console.WriteLine("Variety (enter the mix of the bigdata, the format to be determined by you):");
              data = br.readLine();
              Console.WriteLine("Master node memory (enter the memory capacity range of the master node in increments of 10GB)");
              mmemory = Convert.ToInt64(br.readLine());

              Console.WriteLine("Enter the low end in GB:");
              mLowEnd = Convert.ToInt32(br.readLine());
              Console.WriteLine("Enter the high end in GB:");
              mHighEnd = Convert.ToInt32(br.readLine());
              Console.WriteLine("Master node CPU (enter the CPU capacity range of the master node in increments of 10GHz)");
              mCpuCap = Convert.ToInt64(br.readLine());
              Console.WriteLine("Enter the low end in GHz:");
              mcHighEnd = Convert.ToInt32(br.readLine());
              Console.WriteLine("Enter the high end in GHz:");
              mcLowEnd = Convert.ToInt32(br.readLine());
              Console.WriteLine("Enter the number of slave nodes (1 - n):");
              noOfSlaves = Convert.ToInt32(br.readLine());

              Console.WriteLine("Enter the connectivity (enter 1 to n for 1:1 to 1:n connectivity, respectively):");
              Console.WriteLine("Enter the memory capacity range of the slave nodes in increments of 10GB Enter the low end in GB:");
              smemorycap = Convert.ToInt64(br.readLine());
              Console.WriteLine("Enter the low end in GB:");
              sLowEnd = Convert.ToInt32(br.readLine());
              Console.WriteLine("Enter the high end in GB:");
              sHighEnd = Convert.ToInt32(br.readLine());
              Console.WriteLine("Enter the memory capacity distribution (r for random, c for clustered):");
              Console.WriteLine("random");
              sRandom = Convert.ToInt32(br.readLine());
              Console.WriteLine("clustered");
              sClustered = Convert.ToInt32(br.readLine());
              Console.WriteLine("Enter the CPU capacity range of the slave nodes in increments of 10GHz");
              sCpuCap = Convert.ToInt64(br.readLine());
              Console.WriteLine("Enter the low end in GHz:");
              scLowEnd = Convert.ToInt32(br.readLine());
              Console.WriteLine("Enter the high end in GHz:");
              scHighEnd = Convert.ToInt32(br.readLine());

              Console.WriteLine("Enter the CPU capacity distribution (r for random, c for clustered):");
              Console.WriteLine("random");
              scRandom = Convert.ToInt32(br.readLine());
              Console.WriteLine("clustered");
              scClustered = Convert.ToInt32(br.readLine());

          }
          catch (Exception e)
          {
              Console.WriteLine(e);
          }

      }

      public virtual void simulation()
      {

          try
          {
              startTime = DateTimeHelperClass.CurrentUnixTimeMillis();

              string[] newFile = SplitFile.splitFile(new File(data), 2);

              Console.WriteLine("Slaves connected in sequencial");
              NewFileSplit nfs = new NewFileSplit();
              nfs.fileSplit(newFile[0], noOfSlaves / 2);

              Console.WriteLine("Slaves connected in Parllel");
              Filesplit fs = new Filesplit();
              fs.fileSplit(newFile[1], noOfSlaves - (noOfSlaves / 2));
              int fileCount = 0;
              for (int i = 0; i < noOfSlaves - (noOfSlaves / 2); i++)
              {

                  MyThread m = new MyThread(newFile[1] + "_" + ++fileCount, noOfSlaves - (noOfSlaves / 2));
                  m.Start();

              }


          }
          catch (Exception e)
          {
              Console.WriteLine(e);
          }


      }

      public virtual void viewOutput()
      {
          try
          {


              Console.WriteLine("Volume: ....." + volume);
              Console.WriteLine("Velocity: ....." + velocity);
              Console.WriteLine("Master node memory low end: ....." + mLowEnd);
              Console.WriteLine("Master node memory high end: ....." + mHighEnd);
              Console.WriteLine("Master node CPU low end: ....." + mcLowEnd);
              Console.WriteLine("Master node CPU high end: ....." + mcHighEnd);
              Console.WriteLine("Number of slave nodes: ....." + noOfSlaves);
              Console.WriteLine("Connectivity: 1:.....");
              Console.WriteLine("Slave node memory capacity low end: ....." + sLowEnd);
              Console.WriteLine("Slave node memory capacity high end: ....." + sHighEnd);
              Console.WriteLine("Slave node memory capacity distribution: ....." + sRandom + ", " + sClustered);
              Console.WriteLine("Slave node CPU capacity low end: ....." + sLowEnd);
              Console.WriteLine("Slave node CPU capacity high end: ....." + scHighEnd);
              Console.WriteLine("Slave node CPU capacity distribution: ....." + scRandom + ", " + scClustered);
              endTime = DateTimeHelperClass.CurrentUnixTimeMillis();

          }
          catch (Exception e)
          {
              Console.WriteLine(e);
          }
      }

      public virtual void calculataThroughPut()
      {
          try
          {
              Thread.Sleep(5000);
              // System.out.println("Throughput (conventional):");
              double throughput = endTime - startTime;
              double throughputCon = 300;
              Console.WriteLine("ThroughPut (conventional)" + throughputCon);
              Console.WriteLine("Throughput (bigdata):" + throughput);
              Console.WriteLine("Speedup factor ((Thput_Bigdata  - Thput_conv)/Thput_conv):   ");
              double result = ((throughput - throughputCon) / throughputCon);
              Console.Write(result);
          }
          catch (Exception e)
          {
              Console.WriteLine(e);
          }
      }

      public static void Main(string[] args)
      {
          Master m = new Master();

          Thread.Sleep(10000);

          m.readInput();
          m.simulation();
          m.viewOutput();
          m.calculataThroughPut();

      }

Mythread.cs file is


HTML
using System;
using System.Threading;
using System.Runtime.Remoting;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/// 
/// <summary>
/// @author Laxman
/// </summary>

public class MyThread : System.Threading.Thread
{

	internal string filepath = "";
	internal int noOfSlaves = 0;

	//public MyThread(string filepath, int size)
	//{
		//this.filepath = filepath;
		//this.noOfSlaves = size;
      //}

	public virtual void run()
	{
		File f = new File(filepath);
		try
		{
			MasterInt m = new MasterImp();
			m.updateSize(f.length());
			m.setFile(filepath, noOfSlaves);
			Naming.rebind("master", m);
			string[] command = new string[] {"cmd.exe", "/C", "Start", "c://src//slave.bat"};
			Runtime r = Runtime.Runtime;
			try
			{
				Process p = r.exec(command);
				p.waitFor();
			}
			catch (Exception e)
			{
				Console.WriteLine(e);
			}

		}
		catch (Exception)
		{

		}

        

	}
}
 please help me.
Posted
Comments
Ron Beyer 5-Nov-13 16:37pm    
You really need to stop downloading Java code, pasting it into the C# editor and expecting it to run. There are a lot of concepts here that are very different (you don't derive a C# class from Thread), you should pick up a book and read it before diving into advanced methods like threading.
Sergey Alexandrovich Kryukov 5-Nov-13 18:36pm    
What, really? where? It does not sound like a productive activity... :-)
Of course, your advice is just what a doctor have prescribed... :-)
—SA
Sergey Alexandrovich Kryukov 6-Nov-13 1:57am    
Now I see what you mean. This is becoming a real abuse. This is the new one:
http://www.codeproject.com/Questions/678760/I-want-Split-file-in-twoparts-using-Stream-reader.

I decided to credit your comment above and even quote it, to support your idea, in response to this "question". This is impossible.

—SA
Ron Beyer 6-Nov-13 8:25am    
Thanks!
Sergey Alexandrovich Kryukov 6-Nov-13 9:02am    
No, thank you!
—SA

1 solution

Not surprisingly MS has a nice tutorial on threading: Threading Tutorial[^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Nov-13 18:34pm    
What a surprise! A 5.
—SA
Espen Harlinn 6-Nov-13 15:33pm    
Thank you, Sergey :-)
Joezer BH 6-Nov-13 2:25am    
I'd link him to a later version (than this link's archaic 2003 code),
But sure, a 5!
Espen Harlinn 6-Nov-13 15:34pm    
Thanks :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900