/** * this remote server creates registry at giver Localhost and port number,then registers serve * object on the registry. * * @param args */ public static void main(String[] args) { Registry aRegistry; try { String RMIPortNum = args[0]; int processID = Integer.parseInt(args[1]); int processCount = Integer.parseInt(args[2]); Process exportedProcess = new Process(processCount, processID, RMIPortNum); aRegistry = LocateRegistry.createRegistry(Integer.parseInt(RMIPortNum)); aRegistry.rebind("server", exportedProcess); System.out.println("Process is Up and Running..."); exportedProcess.requestResolver(); System.out.println("Press Enter when all Process are running"); Scanner sc = new Scanner(System.in); sc.nextLine(); exportedProcess.criticalSectionSeeker(); exportedProcess.criticalSectionExecutor(); exportedProcess.run(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void run() throws FaultException, ExitingException { if (ExecutionThread.currentThread().isKilled()) { return; } boolean keepRun = true; int i = 0; while (keepRun && i < pairs.length) { final CPPair pair = pairs[i]; if (pair.condition().evaluate().boolValue()) { keepRun = false; pair.process().run(); } i++; } // No valid condition found, run the else process if (keepRun && elseProcess != null) { elseProcess.run(); } }