-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerImplementation.java
More file actions
40 lines (33 loc) · 1.02 KB
/
ServerImplementation.java
File metadata and controls
40 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package Main;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class ServerImplementation extends UnicastRemoteObject implements MasterServer{
private static final long serialVersionUID = 1L;
Master master;
String bindName;
public ServerImplementation(Master myMaster, String bindName) throws RemoteException {
super();
master = myMaster;
this.bindName = bindName;
}
public void runServer(){
try {
System.setSecurityManager(new SecurityManager());
Naming.rebind(bindName, this);
System.out.println("Service registered");
} catch (RemoteException | MalformedURLException e) {
e.printStackTrace();
}
}
public Object remoteHandleOneJob(Job job) throws RemoteException{
return master.handleOneJob(job);
}
public void remotePushJob(Job job) throws RemoteException {
master.handleNewJob(job);
}
public Object getResponse(Job job) throws RemoteException {
return master.getResponse(job.getId());
}
}