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

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

Error detected: there should be only one thread listening to the multiexchange queue.
TODO: change this. Make refactor in the invocationthread. Change remotethreadpool to achieve this behavior.
AInvocationThread <- InvocationTHread

<- MultiInvocationTHread

File size: 1.7 KB
Line 
1package omq.common.broker;
2
3import java.io.IOException;
4import java.util.Properties;
5import java.util.Set;
6
7import omq.exception.RemoteException;
8import omq.exception.RetryException;
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
23        @Override
24        public Set<String> getRemoteObjects() {
25                return getBroker().getRemoteObjs().keySet();
26        }
27
28        @Override
29        public void spawnObject(String reference, String className, Properties env) throws Exception {
30                RemoteObject remote = (RemoteObject) Class.forName(className).newInstance();
31                getBroker().bind(reference, remote, env);
32        }
33
34        @Override
35        public void spawnObject(String reference, String className) throws Exception {
36                RemoteObject remote = (RemoteObject) Class.forName(className).newInstance();
37                getBroker().bind(reference, remote);
38        }
39
40        @Override
41        public void deleteObject(String reference) throws RemoteException, IOException {
42                getBroker().unbind(reference);
43        }
44
45        @Override
46        public boolean hasObject(String reference) throws RetryException {
47                return getBroker().getRemoteObjs().containsKey(reference);
48        }
49
50        @Override
51        public HasObject hasObjectInfo(String reference) throws RetryException {
52                System.out.println("Hola soc un broker"+ getRef() + ", "+getUID()+ ", fil: "+Thread.currentThread().getId());
53                if (getBroker().getRemoteObjs().containsKey(reference)) {
54                        RemoteObject r = getBroker().getRemoteObjs().get(reference);
55                        int numThreads = r.getPool().getWorkers().size();
56                        return new HasObject(this.getUID(), reference, true, numThreads);
57                }
58                return new HasObject(this.getUID(), reference, false, 0);
59        }
60
61}
Note: See TracBrowser for help on using the repository browser.