private ClusterId checkServer(ClusterId id, Address ad) { // Check if this server is allowed in the group ? ClusterId i = (ClusterId) idmap.get(ad); if (i == null) { i = id; idmap.put(ad, id); return id; } else if (i.equals(id)) { return id; } if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("Message ignored (server rejected)"); return null; }
/** * Get a cluster stub (stub of all equivalent objects). * @return <code>null<code> if not exported. */ ClusterStub getGlobal(Serializable key) throws RemoteException { if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("getGlobal(" + key + ")"); ClusterStub cs; cs = globalExports.getClusterStub(key); return cs; }
/** * Get only the standard stub registered in this instance of the DES. * @return <code>null<code> if not exported. */ Remote getLocal(Serializable key) { if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("getLocal(" + key + ")"); return (Remote) localExports.get(key); }
public synchronized void put( ClusterId serverId, Serializable key, Remote stub, int factor) throws RemoteException { ClusterStubData csd = (ClusterStubData) table.get(key); if (csd == null) { csd = new ClusterStubData(serverId, stub, factor); table.put(key, csd); } else if (!csd.setStub(serverId, stub, factor)) if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes( "Warning: Object registered in the cluster as two distinct types"); }
private void broadcast(Serializable msg) { ByteArrayOutputStream outs = new ByteArrayOutputStream(); try { MulticastOutputStream out = new MulticastOutputStream(outs); out.writeObject(msg); Message m = new Message(null, my_addr, outs.toByteArray()); chan.send(m); if (TraceCarol.isDebugCmiDes()) { TraceCarol.debugCmiDes("broadcast sent"); } } catch (Exception e) { if (TraceCarol.isDebugCmiDes()) { TraceCarol.debugCmiDes("when broadcasting " + e.toString()); } } }
public void run() { if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("Message dequeuer started"); Object msg; try { do { // Awful. why not checked by Receive() ? if (isInterrupted()) { break; } msg = chan.receive(0); if (msg == null) continue; else if (msg instanceof Message) receive((Message) msg); else if (msg instanceof View) viewAccepted((View) msg); else if (msg instanceof SuspectEvent); else if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes( "Received but not supported : " + msg.getClass()); } while (true); } catch (Exception e) { e.printStackTrace(); } if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("Message dequeuer finished."); } }
private void viewAccepted(View v2) { if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("New view accepted : " + v2); LinkedList newMembers = new LinkedList(); globalExports.zapExports(id); idmap.remove(a); if (TraceCarol.isDebugCmiDes()) { if (id == null) TraceCarol.debugCmiDes("Member " + a + " removed"); if (TraceCarol.isDebugCmiDes()) { while (newMembers.size() > 0) { Address a = (Address) newMembers.removeFirst();
boolean exportObject(Serializable key, Remote obj) throws RemoteException { if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes( "exportObject(" + key + ", " + obj.getClass().getName() + ")"); int factor; synchronized (localExports) { Object cur = localExports.get(key); if (cur != null) return false; localExports.put(key, obj); factor = Config.getLoadFactor(); globalExports.put(my_id, key, obj, factor); } broadcast(new ExportMsg(my_id, key, obj, factor)); return true; }
byte[] buf = m.getBuffer(); if (buf == null) { if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("buf == null"); o = null; o = in.readObject(); } catch (Exception e) { if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes(e.toString()); o = null; if (id == null) return; if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes( "Put message received from server " if (id == null) return; if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes( "Remove message received from server " globalExports.remove(id, rm.k); } else if (o instanceof RequestExportsMsg) { if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("sending local exports");
boolean unexportObject(Serializable key) { if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("unexportObject(" + key + ")"); synchronized (localExports) { Object cur = localExports.get(key); if (cur == null) return false; localExports.remove(key); globalExports.remove(my_id, key); } broadcast(new UnexportMsg(my_id, key)); return true; }
Thread.currentThread().getContextClassLoader()); mdq.start(); if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes("sending RequestExportsMsg"); broadcast(new RequestExportsMsg()); if (TraceCarol.isDebugCmiDes()) TraceCarol.debugCmiDes( "DistributedEquivSystem started on "