private SnappyException failoverExhausted(Set<HostAddress> failedServers, Throwable cause) { final ArrayList<HostAddress> locators = this.locators; return ThriftExceptionUtil.newSnappyException( SQLState.DATA_CONTAINER_CLOSED, cause, failedServers != null ? failedServers.toString() : null, locators.get(0), " {failed after trying all available servers: " + controlHostSet + (locators.size() > 1 ? ", secondary-locators=" + locators.subList( 1, locators.size()) : "") + (cause instanceof TException ? " with: " + ThriftExceptionUtil.getExceptionString(cause) + '}' : "}")); } }
private SnappyException unexpectedError(Throwable t, HostAddress host) { this.controlHost = null; if (this.controlLocator != null) { this.controlLocator.getOutputProtocol().getTransport().close(); this.controlLocator = null; } return ThriftExceptionUtil.newSnappyException(SQLState.JAVA_EXCEPTION, t, host != null ? host.toString() : null, t.getClass(), t.getMessage()); }
SnappyException newSnappyExceptionForConnectionClose(HostConnection source, Set<HostAddress> failedServers, boolean createNewConnection, Throwable cause) { // if cause is a node failure exception then return it if (cause instanceof SnappyException) { SnappyException se = (SnappyException)cause; SnappyExceptionData seData = se.getExceptionData(); if (SQLState.GFXD_NODE_SHUTDOWN_PREFIX.equals(seData.getSqlState()) || SQLState.DATA_CONTAINER_CLOSED.equals(seData.getSqlState())) { if (createNewConnection) { tryCreateNewConnection(source, failedServers, cause); } return se; } } return ThriftExceptionUtil.newSnappyException( SQLState.NO_CURRENT_CONNECTION, cause, source != null ? source.hostAddr.toString() : null); }
Exception newExceptionForNodeFailure(HostConnection expectedSource, String op, int isolationLevel, Throwable cause, boolean snappyException) { final HostConnection source = this.currentHostConnection; String opNode = op + " {current node = " + source + '}'; if (isolationLevel == Connection.TRANSACTION_NONE) { // throw X0Z01 for this case String err = expectedSource + (cause instanceof TException ? " {caused by: " + ThriftExceptionUtil.getExceptionString(cause) + '}' : ""); return snappyException ? ThriftExceptionUtil.newSnappyException( SQLState.GFXD_NODE_SHUTDOWN, cause, source != null ? source.hostAddr.toString() : null, err, op) : ThriftExceptionUtil.newSQLException(SQLState.GFXD_NODE_SHUTDOWN, cause, err, opNode); } else { // throw 40XD0 for this case String err = " operation=" + opNode + (cause instanceof TException ? " caused by: " + ThriftExceptionUtil.getExceptionString(cause) : ""); return snappyException ? ThriftExceptionUtil.newSnappyException( SQLState.DATA_CONTAINER_CLOSED, cause, source != null ? source.hostAddr.toString() : null, expectedSource, err) : ThriftExceptionUtil.newSQLException(SQLState.DATA_CONTAINER_CLOSED, cause, expectedSource, err); } }
throw ThriftExceptionUtil.newSnappyException( SQLState.LOCK_TIMEOUT, null, source.toString());
return controlService; } else { throw ThriftExceptionUtil.newSnappyException( SQLState.DRDA_CONNECTION_TERMINATED, null, hostAddr != null ? hostAddr.toString() : null,
public void closeStatement(final HostConnection source, long stmtId, long lockTimeoutMillis) throws SnappyException { if (source == null || stmtId == snappydataConstants.INVALID_ID) { return; } if (SanityManager.TraceClientStatement) { final long ns = System.nanoTime(); SanityManager.DEBUG_PRINT_COMPACT("closeStatement_S", null, source.connId, source.token, ns, true, null); } if (!acquireLock(lockTimeoutMillis)) { throw ThriftExceptionUtil.newSnappyException( SQLState.LOCK_TIMEOUT, null, source.toString()); } try { // check if node has failed sometime before checkUnexpectedNodeFailure(source, "closeStatement"); this.clientService.closeStatement(stmtId, source.token); if (SanityManager.TraceClientStatement) { final long ns = System.nanoTime(); SanityManager.DEBUG_PRINT_COMPACT("closeStatement_E", null, source.connId, source.token, ns, false, null); } } catch (Throwable t) { // no failover should be attempted and node failures ignored handleException(t, null, false, true, true, "closeStatement"); } finally { super.unlock(); } }
public void closeResultSet(final HostConnection source, long cursorId, long lockTimeoutMillis) throws SnappyException { if (source == null || cursorId == snappydataConstants.INVALID_ID) { return; } if (SanityManager.TraceClientStatement) { final long ns = System.nanoTime(); SanityManager.DEBUG_PRINT_COMPACT("closeResultSet_S", null, source.connId, source.token, ns, true, null); } if (!acquireLock(lockTimeoutMillis)) { throw ThriftExceptionUtil.newSnappyException( SQLState.LOCK_TIMEOUT, null, source.toString()); } try { // check if node has failed sometime before checkUnexpectedNodeFailure(source, "closeResultSet"); this.clientService.closeResultSet(cursorId, source.token); if (SanityManager.TraceClientStatement) { final long ns = System.nanoTime(); SanityManager.DEBUG_PRINT_COMPACT("closeResultSet_E", null, source.connId, source.token, ns, false, null); } } catch (Throwable t) { // no failover should be attempted and node failures ignored handleException(t, null, false, true, true, "closeResultSet"); } finally { super.unlock(); } }
if (t instanceof TApplicationException) { throw ThriftExceptionUtil.newSnappyException( SQLState.DATA_UNEXPECTED_EXCEPTION, t, source != null ? source.hostAddr.toString() : null); throw ThriftExceptionUtil.newSnappyException(SQLState.JAVA_EXCEPTION, t, sourceAddr != null ? sourceAddr.toString() : null, t.getClass(), t.getMessage());