private synchronized ResultsFuture<?> isOpen() throws CommunicationException, InvalidSessionException, TeiidComponentException { if (this.closed) { throw new CommunicationException(JDBCPlugin.Event.TEIID20023, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20023)); } return logon.ping(); }
private synchronized ResultsFuture<?> isOpen() throws CommunicationException, InvalidSessionException, TeiidComponentException { if (this.closed) { throw new CommunicationException(JDBCPlugin.Event.TEIID20023, JDBCPlugin.Util.gs(JDBCPlugin.Event.TEIID20023)); } return logon.ping(); }
@Override public boolean isOpen(long msToTest) { if (shutdown) { return false; } try { ResultsFuture<?> result = this.getService(ILogon.class).ping(); result.get(msToTest, TimeUnit.MILLISECONDS); } catch (Exception e) { return false; } return true; }
@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 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); } }
@Test(expected=CommunicationException.class) public void testImmediateFail() throws Exception { SocketServerConnection connection = createConnection(new CommunicationException()); ILogon logon = connection.getService(ILogon.class); logon.ping(); }
/** * Since the original instance is still open, this will be a transparent retry */ @Test public void testRetry() throws Exception { SocketServerConnection connection = createConnection(new SingleInstanceCommunicationException()); connection.setFailOver(true); connection.setFailOverPingInterval(50); ILogon logon = connection.getService(ILogon.class); Thread.sleep(70); logon.ping(); }
@Test(expected=CommunicationException.class) public void testImmediateFail1() throws Exception { SocketServerConnection connection = createConnection(new CommunicationException()); connection.setFailOver(true); ILogon logon = connection.getService(ILogon.class); logon.ping(); }