Posts

4. To develop Token Ring distributed algorithm for leader election.

//Bully.java import java.io.InputStream; import java.io.PrintStream; import java.util.Scanner; public class Bully {     static boolean[] state = new boolean[5];     int coordinator;     public static void up(int up) {         if (state[up - 1]) {             System.out.println("process" + up + "is already up");         } else {             int i;             Bully.state[up - 1] = true;             System.out.println("process " + up + "held election");             for (i = up; i < 5; ++i) {                 System.out.println("election message sent from process" + up + "to process" + (i + 1));             }             for (i = up + 1; i <= 5; ++i) {                 if (!state[i - 1]) continue;                 System.out.println("alive message send from process" + i + "to process" + up);                 break;             }         }     }     public static void down(int down) {         if (!state[down

3. To develop any distributed application with CORBA program using JAVA IDL.

  Click here for step by step CORBA Program implementation

2. To develop any distributed application using Message Passing Interface (MPI).

Download  mpj-v0_44.tar.gz MPIDemo.java   import mpi.*; public class MPIDemo { public static void main(String[] args) throws Exception { MPI.Init(args); int rank=MPI.COMM_WORLD.Rank(); int size=MPI.COMM_WORLD.Size(); System.out.println("Hi, I am process"+rank+" And My Size is"+size); MPI.Finalize(); } } output swlab2@swlab2-ThinkCentre-M70e:~/MPI$ export MPJ_HOME=/home/swlab2/MPI/mpj-v0_44 swlab2@swlab2-ThinkCentre-M70e:~/MPI$ javac -cp /home/swlab2/MPI/mpj-v0_44/lib/mpj.jar MPIDemo.java swlab2@swlab2-ThinkCentre-M70e:~/MPI$ /home/swlab2/MPI/mpj-v0_44/bin/mpjrun.sh -np 4 MPIDemo MPJ Express (0.44) is started in the multicore configuration Hi, I am process3 And My Size is4 Hi, I am process2 And My Size is4 Hi, I am process1 And My Size is4 Hi, I am process0 And My Size is4

1. To develop any distributed application through implementing client-server communication programs based on Java Sockets and RMI techniques.

 /*Assignment No:-01 Title: Design a distributed application which consist of a server and client using threads. */ //MyClient.java import java.net.*; import java.io.*; public class MyClient { public static void main (String args[]) { int n,ch,ch1,fact; String st,st1,st2,first,last;  try { Socket s = new Socket(args[0], 2001); DataInputStream in = new DataInputStream( s.getInputStream()); DataOutputStream out =new DataOutputStream( s.getOutputStream()); BufferedReader object = new BufferedReader(new InputStreamReader(System.in)); do  {  System.out.println("1.Factorial\n2.Adddition of digits\n3.String operations\n4.Exit\nEnter ur choice:");  ch= Integer.parseInt(object.readLine()); out.writeUTF(Integer.toString(ch)); switch(ch) { case 1: System.out.println("Enter a number="); n=Integer.parseInt(object.readLine());  out.writeUTF(Integer.toString(n)); fact=Integer.parseInt(in.readUTF()); System.out.println("Factorial of "+n+"is "+fact) ;  break; cas