public ServiceException rethrow(String msg) { ServiceException exn = new ServiceException(msg, this); exn.fillInStackTrace(); return exn; } }
@Override public ServiceRefAmp delegate() { throw new ServiceException(L.l("Pod root does not have a delegate")); }
private RuntimeException error(String msg, Object ...args) { return new ServiceException(L.l(msg, args)); }
@Override public void subscribe(ResultStream<T> subscriber) { Objects.requireNonNull(subscriber); if (subscriber.isCancelled()) { throw new ServiceException(L.l("Subscriber is closed")); } _subscriberList.add(subscriber); cleanSubscribers(); }
@Override public void consume(ResultStream<T> subscriber) { Objects.requireNonNull(subscriber); if (subscriber.isCancelled()) { throw new ServiceException(L.l("Subscriber is closed")); } _subscriberList.add(subscriber); cleanSubscribers(); }
throw new ServiceException(L.l("method {0}.{1} must return void", method.getDeclaringClass().getName(), method.getName())); throw new ServiceException(L.l("method {0}.{1} must have zero arguments", method.getDeclaringClass().getName(), method.getName())); throw e; } catch (Exception e) { throw new ServiceException(e);
@Override public void query(HeadersAmp headers, ResultChain<?> result, StubAmp actor, Object []args) { Object bean = actor.bean(); if (log.isLoggable(Level.FINER)) { log.finest("amp-send to stream " + name() + "[" + bean + "] " + toList(args)); } ServiceException exn = new ServiceException(L.l(bean + "." + name() + " is a stream method")); exn.fillInStackTrace(); result.fail(exn); }
@Override public void query(HeadersAmp headers, ResultChain<?> result, StubAmp actor, Object []args) { Object bean = actor.bean(); if (log.isLoggable(Level.FINER)) { log.finest("amp-send to stream " + name() + "[" + bean + "] " + toList(args)); } ServiceException exn = new ServiceException(L.l(bean + "." + name() + " is a stream method")); exn.fillInStackTrace(); result.fail(exn); }
@Override public void query(HeadersAmp headers, ResultChain<?> result, StubAmp actor, Object []args) { Object bean = actor.bean(); if (log.isLoggable(Level.FINER)) { log.finest("amp-send to stream " + name() + "[" + bean + "] " + toList(args)); } ServiceException exn = new ServiceException(L.l(bean + "." + name() + " is a stream method")); exn.fillInStackTrace(); result.fail(exn); }
@Override public JournalAmp openPeer(String name, String peerName) { JournalSystem system = JournalSystem.getCurrent(); JournalStream peerJournal = null; if (system != null) { peerJournal = system.openPeerJournal(name, peerName); } if (peerJournal != null) { return new JournalImpl(peerJournal); // , -1, -1); } else { throw new ServiceException(L.l("Peer journals are not supported on this system.")); } } }
@Override public JournalAmp open(String name) // , int maxCount, long timeout) { JournalSystem system = JournalSystem.getCurrent(); /* if (maxCount < 0) { maxCount = _maxCount; } if (timeout < 0) { timeout = _timeout; } */ if (system != null) { return new JournalImpl(system.openJournal(name)); // , maxCount, timeout); } else { throw new ServiceException(L.l("Journals are not supported on this system.")); } }
} catch (ArrayIndexOutOfBoundsException e) { if (args.length != parameters().length) { throw new ServiceException(L.l("{0} in {1} called with invalid argument length ({2}).", name(), actor, args.length));
/** * Subscribe a callback to a location. */ public void subscriber(String path, @Pin ServiceRefAmp serviceRef, Result<? super Cancel> result) { if (path.isEmpty()) { result.fail(new ServiceException(L.l("Invalid event location '{0}'", path))); return; } String address = address(path); EventNodeAsset node = lookupPubSubNode(address); Cancel cancel = node.subscribeImpl(serviceRef); result.ok(cancel); }
/** * Consume a callback to a location. */ public void consumer(String path, @Pin ServiceRefAmp serviceRef, Result<? super Cancel> result) { if (path.isEmpty()) { result.fail(new ServiceException(L.l("Invalid event location '{0}'", path))); return; } String address = address(path); EventNodeAsset node = lookupPubSubNode(address); Cancel cancel = node.consumeImpl(serviceRef); result.ok(cancel); }
public ServiceRefAmp getActiveService(int hash) { ServiceRefAmp serviceRefRoot = _podRoot.getActiveService(hash); if (serviceRefRoot == null) { throw new ServiceException(L.l("Pod {0} does not have an active server.", address())); } ServiceRefActive serviceRefActive = _serviceRefActive; if (serviceRefActive != null) { ServiceRefAmp serviceRef = serviceRefActive.getService(serviceRefRoot); if (serviceRef != null) { return serviceRef; } } // baratine/8331 ServiceRefAmp serviceRef = (ServiceRefAmp) serviceRefRoot.onLookup(_path); Objects.requireNonNull(serviceRef); _serviceRefActive = new ServiceRefActive(serviceRefRoot, serviceRef); // serviceRef.start(); return serviceRef; }
public void switchToHmtp(boolean isUnidir) { try { WriteStreamOld out = getOutputStream(); /* if (isUnidir) out.write(HmuxRequest.HMUX_TO_UNIDIR_HMTP); else out.write(HmuxRequest.HMUX_SWITCH_TO_HMTP); */ out.write(0); out.write(1); boolean isAdmin = true; out.write(isAdmin ? 1 : 0); out.flush(); } catch (IOException e) { throw new ServiceException(e); } }
throw new ServiceException("WebSocket handshake failed for " + this);
/** * Distributed update table. All owning nodes will get a request. */ @Override public void update(Result<Integer> result, int nodeIndex, String sql, Object[] args) { NodePodAmp node = _podKraken.getNode(nodeIndex); for (int i = 0; i < node.serverCount(); i++) { ServerBartender server = node.server(i); if (server != null && server.isUp()) { ClusterServiceKraken proxy = _podKraken.getProxy(server); // XXX: failover proxy.update(result, nodeIndex, sql, args); return; } } RuntimeException exn = new ServiceException(L.l("update failed with no live servers")); exn.fillInStackTrace(); // XXX: fail result.fail(exn); }
@Override public void addRemoteWatch(byte[] key, int hash) { NodePodAmp node = _podKraken.getNode(hash); for (int i = 0; i < node.serverCount(); i++) { ServerBartender server = node.server(i); if (server == null) { } else if (server.equals(_serverSelf)) { return; } else if (server.isUp()) { ClusterServiceKraken proxy = _podKraken.getProxy(server); proxy.addWatch(_table.getKey(), key, _serverSelf.getId()); } } RuntimeException exn = new ServiceException(L.l("add watch failed with no live servers")); exn.fillInStackTrace(); // XXX: fail // Result.Adapter.failed(result, exn); }