/** * Rethrows an exception to record the full stack trace, both caller * and callee. */ @Override public ServiceExceptionConnect rethrow(String msg) { return new ServiceExceptionConnect(msg, this); }
@Override public void deliver(final MessageAmp msg, Outbox outbox) throws Exception { //outbox.setMessage(msg); try { msg.invoke(_inbox, _actor); } catch (ServiceExceptionConnect e) { if (log.isLoggable(Level.FINEST)) { log.log(Level.FINEST, e.toString(), e); } else { log.fine(e.toString()); } } catch (IllegalStateException e) { if (log.isLoggable(Level.FINE)) { log.log(Level.FINE, e.toString(), e); } } catch (Throwable e) { if (log.isLoggable(Level.FINER)) { log.log(Level.FINER, e.toString(), e); } else { log.fine(e.toString()); } } }
public static ServiceExceptionConnect createAndRethrow(String msg, Throwable exn) { if (exn instanceof ServiceExceptionConnect) { return ((ServiceExceptionConnect) exn).rethrow(msg); } else { return new ServiceExceptionConnect(msg, exn); } } }
private BaratineClient createHampClient(String address, int port, String userName, String password) { Objects.requireNonNull(address); /* if (address == null) { address = "127.0.0.1"; } */ String url = "http://" + address + ":" + port + "/hamp"; BaratineClient client = new BaratineClient(url, userName, password); try { //client.setVirtualHost("admin.resin"); // client.connect(userName, password); return client; } catch (ServiceExceptionConnect e) { throw new ServiceExceptionConnect(L.l("Connection to '{0}' failed for remote administration.\n Ensure the local server has started, or include --server and --port parameters to connect to a remote server.\n {1}", url, e.getMessage()), e); } catch (ServiceExceptionUnavailable e) { throw new ServiceExceptionUnavailable(L.l("Connection to '{0}' failed for remote administration because RemoteAdminService (HMTP) is not enabled.\n Ensure 'remote_admin_enable' is set true in resin.properties.\n {1}", url, e.getMessage()), e); } }
throw new ServiceExceptionConnect(L.l("Can't connect with closed client.")); throw new ServiceExceptionConnect(L.l("Can't connect to server {0}:{1}; invalid returned port {2}", host, port, dynPort));
throw new ServiceExceptionConnect(L.l("invalid status '{0}' when connecting to {1}", line, _uri)); throw new ServiceExceptionConnect(L.l("no status returned when connecting to {0}. protocol='{1}' line='{1}'", _uri, protocol, firstLine));
throw new ServiceExceptionConnect(L.l("{0} is not a known server in the network", server)); throw new ServiceExceptionConnect(L.l("{0} is not an active server in the network", server)); throw new ServiceExceptionConnect(L.l("Reconnect attempted before fail-timeout {0}ms to champ server {1}.\n", timeout, uri)); CurrentTime.currentTime()); throw new ServiceExceptionConnect(L.l("Can't connect to champ server {0}\n uri: {1}.\n {2}", server, uri, e.toString()),
@Override public OutAmp getOut(ChannelAmp channel) { try { String selfHostName = _selfHostName; ServerHeartbeat server = null; EndpointHampClient endpoint = new EndpointHampClient(_ampManager, server, selfHostName, channel); endpoint.setAuth(_user, _password); ClientBartenderWebSocket wsClient = new ClientBartenderWebSocket(_uri, endpoint); endpoint.setClient(wsClient); wsClient.connect(); return endpoint; } catch (ServiceException e) { throw e; } catch (Exception e) { throw new ServiceExceptionConnect(L.l("Can't connect to {0}\n {1}", _uri, e), e); } }