public String nextSlobrokSpec() { checkUpdate(); if (idx < slobroks.length) { return slobroks[idx++]; } idx = 0; return null; }
/** * Create a new MirrorAPI using the given Supervisor and slobrok * connect specs. * * @param orb the Supervisor to use * @param slobroks slobrok connect spec list */ public Mirror(Supervisor orb, SlobrokList slobroks) { this(orb, slobroks, new BackOff()); }
/** * Returns the current slobroks config as an array of connection spec strings. * * @return The slobroks config. */ public SlobrokList getSlobroks() { return new SlobrokList(slobroks); }
/** * Updates the list of matching recipients by querying the extern slobrok. */ private void update() { int upd = mirror.updates(); if (generation != upd) { generation = upd; recipients.clear(); Mirror.Entry[] arr = mirror.lookup(pattern); for (Mirror.Entry entry : arr) { recipients.add(Hop.parse(entry.getSpec() + session)); } } }
@Override public boolean waitUntilReady(double seconds) { for (int i = 0; i < seconds * 100; ++i) { if (mirror.ready()) { return true; } try { Thread.sleep(10); } catch (InterruptedException e) { // empty } } return false; }
@Override public Entry[] lookup(String pattern) { ArrayList<Entry> found = new ArrayList<>(); char[] p = pattern.toCharArray(); for (Entry specEntry : specs) { if (match(specEntry.getNameArray(), p)) { found.add(specEntry); } } return found.toArray(new Entry[found.size()]); }
@Override public void registerSession(String session) { register.registerName(identity.getServicePrefix() + "/" + session); }
public void invoke(Request req) { handleRpcList(req); } })
public void invoke(Request req) { handleRpcUnreg(req); } })
public SlobrokList() { this.internal = new Internal(); }
@Override public String toString() { return internal.toString(); }
public void setup(String[] slobroks) { internal.setup(slobroks); }
public int length() { return internal.length(); }
public void run() { handleUpdate(); } });
public void run() { handleShutdown(); } });
public void run() { checkForUpdate(); } });
public void run() { handleShutdown(); } });
@Override public void unregisterSession(String session) { register.unregisterName(identity.getServicePrefix() + "/" + session); }
public boolean contains(String slobrok) { checkUpdate(); for (String s : slobroks) { if (s == slobrok) return true; } return false; }
/** * Create a new Register using the given Supervisor, slobrok * connect specs, hostname and port * * @param orb the Supervisor to use * @param slobroks slobrok connect spec list * @param spec the Spec representing hostname and port for this host */ public Register(Supervisor orb, SlobrokList slobroks, Spec spec) { this(orb, slobroks, spec, new BackOff()); }