ProxyKrakenRef(ServerBartender server, ServiceRef serviceRef) { _server = server; _serviceRef = serviceRef; _proxy = _serviceRef.as(ClusterServiceKraken.class); }
@Override public BfsFileSync lookup(String path) { if (path == null || path.equals("")) { return null; } String name = path.substring(1); TableKraken table = _tableManager.getTable(name); if (table == null) { return null; } ProcKrakenDebugTable debugTable = new ProcKrakenDebugTable(name); ServiceRef serviceRef = ServiceRef.current(); return serviceRef.pin(debugTable) .as(FileServiceBind.class); }
/** * Starts service if not already started, calls service method marked with @OnInit. * Terminal call after which configuration should be complete and service started. * * @return instance of ServiceRef for this service * @see OnInit */ default ServiceRef start() { return ref().start(); }
/** * Lookup a child service in the ServiceManager with a relative path. * <p> * The lookup is a convenience method based on the ServiceManager's lookup. * * @param path a relative path to the service. */ default ServiceRef service(String path) { if (!path.startsWith("/")) { throw new IllegalArgumentException(path + " must start with '/'"); } return services().service(address() + path); }
@Override public BfsFileSync lookup(String path) { if (path == null || path.equals("")) { return null; } String name = path.substring(1); PodBartender pod = _bartender.findActivePod(name); if (pod == null) { return null; } return _serviceRef.pin(new ProcPodBartender(pod)).as(FileServiceBind.class); }
@Override public void onActive() { _isReplay = false; if (_isActive) { return; } _isActive = true; _serviceSelf = ServiceRef.current(); if (_journalDelay > 0) { Services manager = _serviceSelf.services(); _timerService = manager.service("timer:").as(Timers.class); Consumer<Cancel> startSave = h->startSave(); _startSaveRef = (Consumer<Cancel>) _serviceSelf.pin(startSave).as(Consumer.class); } super.onActive(); startSave(); }
static ServiceRefAmp current() { return (ServiceRefAmp) ServiceRef.current(); }
@OnInit public void onInit(Result<Void> result) { _self = ServiceRef.current().service(_id).as(RabbitPipeImpl.class); try { _config = RabbitConfig.from(_c, _id); if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "onInit: " + _id + ", " + _config); } connect(); result.ok(null); } catch (Exception e) { _logger.log(Level.WARNING, "onInit: cannot connect, " + _id + ", " + _config, e); result.fail(e); } }
@OnInit public void onInit() throws Exception { String address = ServiceRef.current().address() + _id; _logger.log(Level.CONFIG, "onInit: id=" + _id + ", service address=" + address); _jdbcConfig = JdbcConfig.from(_config, address); _logger.log(Level.CONFIG, "onInit: config=" + _jdbcConfig); Properties props = new Properties(); if (_jdbcConfig.user() != null) { props.setProperty("user", _jdbcConfig.user()); if (_jdbcConfig.pass() != null) { props.setProperty("password", _jdbcConfig.pass()); } } Supplier<JdbcConnection> supplier = new ConnectionSupplier(_jdbcConfig.url(), props, _jdbcConfig.testQueryBefore(), _jdbcConfig.testQueryAfter()); ServiceBuilder builder = Services.current().newService(JdbcConnection.class, supplier); ServiceRef ref = builder.workers(_jdbcConfig.poolSize()).start(); _conn = ref.as(JdbcConnection.class); }
@Override public void run() { try { //while (! _client.isClosed() && wsEndpointReader.onRead()) { while (_client.readFrame()) { ServiceRef.flushOutbox(); if (_is.fillBuffer() <= 0) { break; } } } catch (Exception e) { log.log(Level.WARNING, e.toString(), e); } finally { _client.close(); } } }
@Override public void init(ServicesBuilder manager) { //ServicesAmp managerAmp = (ServicesAmp) manager; EventServiceRamp eventsScheme = new EventServiceRamp("event:"); ServiceRef eventsRef = manager.service(eventsScheme) .address("event:") .ref(); EventServerImpl eventsPod = eventsScheme.getEventServer(); ServiceRefAmp eventsPodRef = (ServiceRefAmp) eventsRef.pin(eventsPod); //eventsPodRef.bind("pod://" + EventsPodServerRamp.PATH); eventsPodRef.bind("local://" + EventServerImpl.PATH); eventsRef.start(); } }
ServiceRef.flushOutbox(); state = dispatchRequest(); break; ServiceRef.flushOutbox(); state = processPoll(); break; ServiceRef.flushOutbox(); tailState = state; return tailState; ServiceRef.flushOutboxAndExecuteLast(); tailState = state; return tailState; _state = state; tailState = state; ServiceRef.flushOutboxAndExecuteLast(); close(); tailState = _state; ServiceRef.flushOutboxAndExecuteLast(); System.out.println("FREE: " + this); return tailState; System.out.println("UNKNOWN-STATE: " + state + " " + this); _state = tailState = StateConnection.DESTROY; ServiceRef.flushOutbox();
ServiceRef.flushOutboxAndExecuteLast();
@Override public String toString() { return (getClass().getSimpleName() + "[" + _serviceRef.address() + "," + _method.name() + "," + _id + "]"); } }
ServiceRef parentRef = inbox.serviceRef(); Object childLookup = parentRef.service(_keyPath);
private WatchTable getWatchTable(HashMap<TableKraken,WatchTable> map, TableKraken table) { WatchTable watchTable = map.get(table); if (watchTable == null) { watchTable = new WatchTable(table); TableListener listener = _serviceRef.pin(watchTable) .as(TableListener.class); table.addListener(listener); map.put(table, watchTable); } return watchTable; }
@OnActive public void onStart() { _serviceRef = ServiceRef.current(); }