1 10 package org.jgap.distr; 11 12 import java.io.*; 13 import org.jgap.util.*; 14 15 22 public abstract class Master { 23 24 private final static String CVS_REVISION = "$Revision: 1.11 $"; 25 26 29 private MasterInfo m_masterinfo; 30 31 34 private RequestDispatcher m_dispatcher; 35 36 39 private WorkerListener m_workerListener; 40 41 51 public Master(final RequestDispatcher a_dispatcher, 52 final WorkerListener a_workerListener) 53 throws Exception { 54 m_dispatcher = a_dispatcher; 55 m_workerListener = a_workerListener; 56 m_masterinfo = new MasterInfo(); 57 m_masterinfo.m_IPAddress = NetworkKit.getLocalIPAddress(); 58 m_masterinfo.m_name = NetworkKit.getLocalHostName(); 59 } 60 61 69 public abstract void start() 70 throws Exception ; 71 72 75 public void stop() { 76 m_workerListener.stop(); 77 81 } 82 83 89 public MasterInfo getMasterInfo() { 90 return m_masterinfo; 91 } 92 93 99 public void sendToWorker(final IWorker a_worker, 100 final WorkerCommand a_command) 101 throws IOException { 102 103 m_dispatcher.dispatch(a_worker, a_command); 104 } 105 106 113 public RequestDispatcher getDispatcher() { 114 return m_dispatcher; 115 } 116 117 123 public WorkerListener getWorkerListener() { 124 return m_workerListener; 125 } 126 127 } 128 | Popular Tags |