public ExternalSlobrokPolicy(Map<String, String> param) { super(param); String conf = param.get("config"); if (conf != null) { configSources = conf.split(","); } String slbrk = param.get("slobroks"); if (slbrk != null) { slobroks = new SlobrokList(); slobroks.setup(slbrk.split(",")); } if (slobroks != null || configSources != null) { needAsynchronousInitialization(); } }
public String nextSlobrokSpec() { checkUpdate(); if (idx < slobroks.length) { return slobroks[idx++]; } idx = 0; return null; }
/** * Returns the current slobroks config as an array of connection spec strings. * * @return The slobroks config. */ public SlobrokList getSlobroks() { return new SlobrokList(slobroks); }
@Override public void configure(SlobroksConfig config) { String[] list = new String[config.slobrok().size()]; for(int i = 0; i < config.slobrok().size(); i++) { list[i] = config.slobrok(i).connectionspec(); } slobroks.setup(list); }
return; // current request still in progress if (target != null && ! slobroks.contains(currSlobrok)) { log.log(Level.INFO, "RPC server " + mySpec + ": Slobrok server " + currSlobrok + " removed, will disconnect"); target.close(); currSlobrok = slobroks.nextSlobrokSpec(); if (currSlobrok == null) { double delay = backOff.get();
if (target != null && ! slobroks.contains(currSlobrok)) { target.close(); target = null; currSlobrok = slobroks.nextSlobrokSpec(); if (currSlobrok == null) { double delay = backOff.get();
@Override public synchronized void configure(SlobroksConfig config) { String[] slist = new String[config.slobrok().size()]; for(int i = 0; i < config.slobrok().size(); i++) { slist[i] = config.slobrok(i).connectionspec(); } if (slobroks == null) { slobroks = new SlobrokList(); } slobroks.setup(slist); if (mirror == null) { mirror = new Mirror(orb, slobroks); } }
public boolean contains(String slobrok) { checkUpdate(); for (String s : slobroks) { if (s == slobrok) return true; } return false; }
/** * Constructs a new instance of this policy. The argument given is the connection spec to the slobrok to use for * resolving recipients, as well as the pattern to use when querying. This constructor does _not_ wait for the * mirror to become ready. * * @param arg The slobrok connection spec. */ public ExternPolicy(String arg) { if (arg == null || arg.length() == 0) { error = "Expected parameter, got empty string."; return; } String[] args = arg.split(";", 2); if (args.length != 2 || args[0].length() == 0 || args[1].length() == 0) { error = "Expected parameter on the form '<spec>;<pattern>', got '" + arg + "'."; return; } int pos = args[1].lastIndexOf('/'); if (pos < 0) { error = "Expected pattern on the form '<service>/<session>', got '" + args[1] + "'."; return; } SlobrokList slobroks = new SlobrokList(); slobroks.setup(args[0].split(",")); pattern = args[1]; session = pattern.substring(pos); orb = new Supervisor(new Transport()); mirror = new Mirror(orb, slobroks); error = null; }
/** * The container has no rpc methods, but we still need an RPC sever * to register in Slobrok to enable orchestration */ private Register registerInSlobrok(SlobroksConfig slobrokConfig, QrConfig qrConfig) { if ( ! qrConfig.rpc().enabled()) return null; // 1. Set up RPC server supervisor = new Supervisor(new Transport()); Spec listenSpec = new Spec(qrConfig.rpc().port()); try { acceptor = supervisor.listen(listenSpec); } catch (ListenFailedException e) { throw new RuntimeException("Could not create rpc server listening on " + listenSpec, e); } // 2. Register it in slobrok SlobrokList slobrokList = new SlobrokList(); slobrokList.setup(slobrokConfig.slobrok().stream().map(SlobroksConfig.Slobrok::connectionspec).toArray(String[]::new)); Spec mySpec = new Spec(HostName.getLocalhost(), acceptor.port()); slobrokRegistrator = new Register(supervisor, slobrokList, mySpec); slobrokRegistrator.registerName(qrConfig.rpc().slobrokId()); log.log(LogLevel.INFO, "Registered name '" + qrConfig.rpc().slobrokId() + "' at " + mySpec + " with: " + slobrokList); return slobrokRegistrator; }