@Test(expected=CommunicationException.class) public void testImmediateFail() throws Exception { SocketServerConnection connection = createConnection(new CommunicationException()); ILogon logon = connection.getService(ILogon.class); logon.ping(); }
public <T> T getService(Class<T> iface) { return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface, PropertiesUtils.getBooleanProperty(connProps, TeiidURL.CONNECTION.ENCRYPT_REQUESTS, false)) { @Override protected SocketServerInstance getInstance() throws CommunicationException { if (failOver && System.currentTimeMillis() - lastPing > pingFailOverInterval) { try { ResultsFuture<?> future = selectServerInstance().getService(ILogon.class).ping(); future.get(); } catch (SingleInstanceCommunicationException e) { closeServerInstance(); } catch (CommunicationException e) { throw e; } catch (InvalidSessionException e) { disconnect(); closeServerInstance(); } catch (Exception e) { closeServerInstance(); } } lastPing = System.currentTimeMillis(); try { return selectServerInstance(); } catch (ConnectionException e) { throw new CommunicationException(e); } } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { return super.invoke(proxy, method, args); } catch (Exception e) { if (ExceptionUtil.getExceptionOfType(e, InvalidSessionException.class) != null) { disconnect(); } throw e; } } })); }
SocketServerConnection implements ServerConnection { public <T> T getService(Class<T> iface) { return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface, PropertiesUtils.getBooleanProperty(connProps, TeiidURL.CONNECTION.ENCRYPT_REQUESTS, false)) { @Override protected SocketServerInstance getInstance() throws CommunicationException { if (failOver && System.currentTimeMillis() - lastPing > pingFailOverInterval) { try { ResultsFuture<?> future = selectServerInstance().getService(ILogon.class).ping(); future.get(); } catch (SingleInstanceCommunicationException e) { closeServerInstance(); } catch (CommunicationException e) { throw e; } catch (InvalidSessionException e) { disconnect(); closeServerInstance(); } catch (Exception e) { closeServerInstance(); } } lastPing = System.currentTimeMillis(); try { return selectServerInstance(); } catch (ConnectionException e) { throw new CommunicationException(e); } } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { return super.invoke(proxy, method, args); } catch (Exception e) { if (ExceptionUtil.getExceptionOfType(e, InvalidSessionException.class) != null) { disconnect(); } throw e; } } })); } }
SocketServerConnection implements ServerConnection { public <T> T getService(Class<T> iface) { return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface, PropertiesUtils.getBooleanProperty(connProps, TeiidURL.CONNECTION.ENCRYPT_REQUESTS, false)) { @Override protected SocketServerInstance getInstance() throws CommunicationException { if (failOver && System.currentTimeMillis() - lastPing > pingFailOverInterval) { try { ResultsFuture<?> future = selectServerInstance().getService(ILogon.class).ping(); future.get(); } catch (SingleInstanceCommunicationException e) { closeServerInstance(); } catch (CommunicationException e) { throw e; } catch (InvalidSessionException e) { disconnect(); closeServerInstance(); } catch (Exception e) { closeServerInstance(); } } lastPing = System.currentTimeMillis(); try { return selectServerInstance(); } catch (ConnectionException e) { throw new CommunicationException(e); } } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { return super.invoke(proxy, method, args); } catch (Exception e) { if (ExceptionUtil.getExceptionOfType(e, InvalidSessionException.class) != null) { disconnect(); } throw e; } } })); } SocketServerConnection(
            SocketServerInstanceFactory connectionFactory, boolean secure,
            UrlServerDiscovery serverDiscovery, Properties connProps); }
SocketServerConnection implements ServerConnection { public <T> T getService(Class<T> iface) { return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface, PropertiesUtils.getBooleanProperty(connProps, TeiidURL.CONNECTION.ENCRYPT_REQUESTS, false)) { @Override protected SocketServerInstance getInstance() throws CommunicationException { if (failOver && System.currentTimeMillis() - lastPing > pingFailOverInterval) { try { ResultsFuture<?> future = selectServerInstance().getService(ILogon.class).ping(); future.get(); } catch (SingleInstanceCommunicationException e) { closeServerInstance(); } catch (CommunicationException e) { throw e; } catch (InvalidSessionException e) { disconnect(); closeServerInstance(); } catch (Exception e) { closeServerInstance(); } } lastPing = System.currentTimeMillis(); try { return selectServerInstance(); } catch (ConnectionException e) { throw new CommunicationException(e); } } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { return super.invoke(proxy, method, args); } catch (Exception e) { if (ExceptionUtil.getExceptionOfType(e, InvalidSessionException.class) != null) { disconnect(); } throw e; } } })); } SocketServerConnection(
            SocketServerInstanceFactory connectionFactory, boolean secure,
            UrlServerDiscovery serverDiscovery, Properties connProps); synchronized SocketServerInstance selectServerInstance(); static void updateConnectionProperties(Properties connectionProperties, InetAddress addr, boolean setMac, HostnameResolver resolver); T getService(Class<T> iface); synchronized void close(); boolean isOpen(long msToTest); LogonResult getLogonResult(); boolean isSameInstance(ServerConnection otherService); void setFailOver(boolean failOver); void setFailOverPingInterval(int pingFailOverInterval); @Override void authenticate(); @Override boolean supportsContinuous(); @Override boolean isLocal(); @Override String getServerVersion(); }
SocketServerConnection implements ServerConnection { public <T> T getService(Class<T> iface) { return iface.cast(Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] {iface}, new SocketServerInstanceImpl.RemoteInvocationHandler(iface, PropertiesUtils.getBooleanProperty(connProps, TeiidURL.CONNECTION.ENCRYPT_REQUESTS, false)) { @Override protected SocketServerInstance getInstance() throws CommunicationException { if (failOver && System.currentTimeMillis() - lastPing > pingFailOverInterval) { try { ResultsFuture<?> future = selectServerInstance().getService(ILogon.class).ping(); future.get(); } catch (SingleInstanceCommunicationException e) { closeServerInstance(); } catch (CommunicationException e) { throw e; } catch (InvalidSessionException e) { disconnect(); closeServerInstance(); } catch (Exception e) { closeServerInstance(); } } lastPing = System.currentTimeMillis(); try { return selectServerInstance(); } catch (ConnectionException e) { throw new CommunicationException(e); } } @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { return super.invoke(proxy, method, args); } catch (Exception e) { if (ExceptionUtil.getExceptionOfType(e, InvalidSessionException.class) != null) { disconnect(); } throw e; } } })); } SocketServerConnection(
            SocketServerInstanceFactory connectionFactory, boolean secure,
            UrlServerDiscovery serverDiscovery, Properties connProps); synchronized SocketServerInstance selectServerInstance(); static void updateConnectionProperties(Properties connectionProperties, InetAddress addr, boolean setMac, HostnameResolver resolver); T getService(Class<T> iface); synchronized void close(); boolean isOpen(long msToTest); LogonResult getLogonResult(); boolean isSameInstance(ServerConnection otherService); void setFailOver(boolean failOver); void setFailOverPingInterval(int pingFailOverInterval); @Override void authenticate(); @Override boolean supportsContinuous(); @Override boolean isLocal(); @Override String getServerVersion();  }