source: branches/supervisor/src/main/java/omq/common/broker/RemoteBrokerImpl.java @ 112

Last change on this file since 112 was 110, checked in by stoda, 11 years ago

Supervisor seems to work

File size: 1.8 KB
RevLine 
[91]1package omq.common.broker;
2
3import java.io.IOException;
4import java.util.Properties;
5import java.util.Set;
6
7import omq.exception.RemoteException;
[103]8import omq.exception.RetryException;
[91]9import omq.server.RemoteObject;
10
11/**
12 *
13 * @author Sergi Toda <sergi.toda@estudiants.urv.cat>
14 *
15 */
16public class RemoteBrokerImpl extends RemoteObject implements RemoteBroker {
17
18        /**
19         *
20         */
21        private static final long serialVersionUID = 1L;
22
[92]23        @Override
24        public Set<String> getRemoteObjects() {
25                return getBroker().getRemoteObjs().keySet();
[91]26        }
27
28        @Override
[92]29        public void spawnObject(String reference, String className, Properties env) throws Exception {
[110]30                System.out.println("SPAWN broker = " + this.getUID());
[92]31                RemoteObject remote = (RemoteObject) Class.forName(className).newInstance();
32                getBroker().bind(reference, remote, env);
[91]33        }
34
35        @Override
[92]36        public void spawnObject(String reference, String className) throws Exception {
[110]37                System.out.println("SPAWN broker = " + this.getUID());
[92]38                RemoteObject remote = (RemoteObject) Class.forName(className).newInstance();
39                getBroker().bind(reference, remote);
[91]40        }
41
42        @Override
43        public void deleteObject(String reference) throws RemoteException, IOException {
[92]44                getBroker().unbind(reference);
[91]45        }
46
47        @Override
[103]48        public boolean hasObject(String reference) throws RetryException {
[92]49                return getBroker().getRemoteObjs().containsKey(reference);
[91]50        }
51
[103]52        @Override
53        public HasObject hasObjectInfo(String reference) throws RetryException {
[110]54                System.out.println("Hola soc un broker" + getRef() + ", " + getUID() + ", fil: " + Thread.currentThread().getId());
[103]55                if (getBroker().getRemoteObjs().containsKey(reference)) {
56                        RemoteObject r = getBroker().getRemoteObjs().get(reference);
57                        int numThreads = r.getPool().getWorkers().size();
[107]58                        return new HasObject(this.getUID(), reference, true, numThreads);
[103]59                }
[107]60                return new HasObject(this.getUID(), reference, false, 0);
[103]61        }
62
[91]63}
Note: See TracBrowser for help on using the repository browser.