private SnappyException internalException(String message) { SnappyExceptionData exData = new SnappyExceptionData(); exData.setReason(message); exData.setSqlState(SQLState.JAVA_EXCEPTION); exData.setErrorCode(ExceptionSeverity.NO_APPLICABLE_SEVERITY); return new SnappyException(exData, getServerInfo()); }
private SnappyExceptionData snappyWarning(SQLWarning warnings) throws SQLException { SnappyExceptionData warningData = new SnappyExceptionData( warnings.getMessage(), warnings.getErrorCode()) .setSqlState(warnings.getSQLState()); ArrayList<SnappyExceptionData> nextWarnings = null; SQLWarning next = warnings.getNextWarning(); if (next != null) { nextWarnings = new ArrayList<>(); do { nextWarnings.add(new SnappyExceptionData(next.getMessage(), next.getErrorCode()).setSqlState(next.getSQLState())); } while ((next = next.getNextWarning()) != null); } //SnappyExceptionData sqlw = new SnappyExceptionData(warningData); //sqlw.setNextWarnings(nextWarnings); if (nextWarnings != null) { warningData.setReason(warningData.getReason() + nextWarnings.toString()); } return warningData; }
public Object getFieldValue(_Fields field) { switch (field) { case REASON: return getReason(); case ERROR_CODE: return getErrorCode(); case SQL_STATE: return getSqlState(); case UPDATE_COUNTS: return getUpdateCounts(); } throw new IllegalStateException(); }
public static SQLWarning newSQLWarning(SnappyExceptionData payload, Throwable cause) { return new SQLWarning(payload.getReason(), payload.getSqlState(), payload.getErrorCode(), cause); }
case REASON: if (value == null) { unsetReason(); } else { setReason((String)value); unsetErrorCode(); } else { setErrorCode((Integer)value); unsetSqlState(); } else { setSqlState((String)value); unsetUpdateCounts(); } else { setUpdateCounts((List<Integer>)value);
if (payload.getSqlState() == null || payload.getSqlState().isEmpty()) { boolean foundValidPayload = false; while (iter.hasNext()) { SnappyExceptionData nextData = iter.next(); if (nextData.getSqlState() != null && nextData.getSqlState().length() > 0) { payload = nextData; iter.remove(); payload.setSqlState(SQLState.DATA_UNEXPECTED_EXCEPTION.substring(0, 5)); payload.setErrorCode(ExceptionSeverity.STATEMENT_SEVERITY); nextData.getSqlState())) { Throwable cause = sqle; while (cause.getCause() != null) { cause.initCause(new ServerException(nextData.getReason())); continue; } catch (IllegalStateException ignored) {
@Override public void read(org.apache.thrift.protocol.TProtocol prot, SnappyException struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.exceptionData = new SnappyExceptionData(); struct.exceptionData.read(iprot); struct.setExceptionDataIsSet(true); struct.serverInfo = iprot.readString(); struct.setServerInfoIsSet(true); BitSet incoming = iprot.readBitSet(1); if (incoming.get(0)) { { org.apache.thrift.protocol.TList _list125 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.nextExceptions = new ArrayList<SnappyExceptionData>(_list125.size); SnappyExceptionData _elem126; for (int _i127 = 0; _i127 < _list125.size; ++_i127) { _elem126 = new SnappyExceptionData(); _elem126.read(iprot); struct.nextExceptions.add(_elem126); } } struct.setNextExceptionsIsSet(true); } } }
final void setSourceConnection(RowSet rs) throws SnappyException { final HostConnection source = this.currentHostConnection; rs.setConnId(source.connId); rs.setToken(source.token); rs.setSource(source.hostAddr); // initialize finalizers for LOBs in the rows, if any final List<Row> rows = rs.rows; if (rows != null && rows.size() > 0) { // create LOBs for each row, if any try { for (Row row : rows) { row.initializeLobs(this); } } catch (SQLException sqle) { SnappyExceptionData data = new SnappyExceptionData(sqle.getMessage(), sqle.getErrorCode()).setSqlState(sqle.getSQLState()); SnappyException se = new SnappyException(data, source.toString()); se.initCause(sqle); throw se; } } }
SnappyExceptionData exData = new SnappyExceptionData(sqle.getMessage(), sqle.getErrorCode()).setSqlState(sqle.getSQLState()); if (sqle instanceof BatchUpdateException) { int[] updates = ((BatchUpdateException)sqle).getUpdateCounts(); updateCounts = Collections.emptyList(); exData.setUpdateCounts(updateCounts); nextExceptions = new ArrayList<>(); do { nextExceptions.add(new SnappyExceptionData(next.getMessage(), next.getErrorCode()).setSqlState(next.getSQLState())); } while ((next = next.getNextException()) != null); nextExceptions.add(new SnappyExceptionData(stack.toString(), ExceptionSeverity.STATEMENT_SEVERITY) .setSqlState(SQLState.SNAPPY_SERVER_STACK_INDICATOR)); se.setNextExceptions(nextExceptions); return se;
public SnappyExceptionData deepCopy() { return new SnappyExceptionData(this); }
SnappyException se = (SnappyException)t; SnappyExceptionData seData = se.getExceptionData(); String sqlState = seData.getSqlState(); NetConnection.FailoverStatus status; if ((status = NetConnection.getFailoverStatus(sqlState, seData.getErrorCode(), se)).isNone()) {
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); }
@Override public boolean equals(Object that) { if (that == null) return false; if (that instanceof SnappyExceptionData) return this.equals((SnappyExceptionData)that); return false; }
case 1: // EXCEPTION_DATA if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { struct.exceptionData = new SnappyExceptionData(); struct.exceptionData.read(iprot); struct.setExceptionDataIsSet(true); } else { for (int _i122 = 0; _i122 < _list120.size; ++_i122) _elem121 = new SnappyExceptionData(); _elem121.read(iprot); struct.nextExceptions.add(_elem121);
private XAException newXAException(SnappyException se) { XAException xae; SnappyExceptionData data = se.getExceptionData(); final String sqlState = data.getSqlState(); if (sqlState == null || sqlState.isEmpty()) { String message = data.getReason(); if (message != null) { xae = new XAException(message); xae.errorCode = data.getErrorCode(); } else { xae = new XAException(data.errorCode); } } else { xae = new XAException(XAException.XAER_RMERR); } xae.initCause(ThriftExceptionUtil.newSQLException(se)); return xae; }
final HostConnection hostConn = this.currentHostConnection; if (thisSource == null || hostConn == null || !thisSource.equals(hostConn)) { throw new SnappyException(new SnappyExceptionData("Incorrect host = " + thisSource + ", current = " + hostConn, 0).setSqlState( SQLState.LANG_UNEXPECTED_USER_EXCEPTION), null);
/** * Performs a deep copy on <i>other</i>. */ public SnappyException(SnappyException other) { if (other.isSetExceptionData()) { this.exceptionData = new SnappyExceptionData(other.exceptionData); } if (other.isSetServerInfo()) { this.serverInfo = other.serverInfo; } if (other.isSetNextExceptions()) { List<SnappyExceptionData> __this__nextExceptions = new ArrayList<SnappyExceptionData>(other.nextExceptions.size()); for (SnappyExceptionData other_element : other.nextExceptions) { __this__nextExceptions.add(new SnappyExceptionData(other_element)); } this.nextExceptions = __this__nextExceptions; } }
NetConnection.FailoverStatus status; if ((status = NetConnection.getFailoverStatus(se .getExceptionData().getSqlState(), se.getExceptionData() .getErrorCode(), se)).isNone()) { throw se; } else if (status == NetConnection.FailoverStatus.RETRY) {
se.getExceptionData().getSqlState())) { logger.warn("AUTH exception in bulkClose (continuing with other " + "close operations): " + se);
public boolean equals(SnappyException that) { if (that == null) return false; boolean this_present_exceptionData = true && this.isSetExceptionData(); boolean that_present_exceptionData = true && that.isSetExceptionData(); if (this_present_exceptionData || that_present_exceptionData) { if (!(this_present_exceptionData && that_present_exceptionData)) return false; if (!this.exceptionData.equals(that.exceptionData)) return false; } boolean this_present_serverInfo = true && this.isSetServerInfo(); boolean that_present_serverInfo = true && that.isSetServerInfo(); if (this_present_serverInfo || that_present_serverInfo) { if (!(this_present_serverInfo && that_present_serverInfo)) return false; if (!this.serverInfo.equals(that.serverInfo)) return false; } boolean this_present_nextExceptions = true && this.isSetNextExceptions(); boolean that_present_nextExceptions = true && that.isSetNextExceptions(); if (this_present_nextExceptions || that_present_nextExceptions) { if (!(this_present_nextExceptions && that_present_nextExceptions)) return false; if (!this.nextExceptions.equals(that.nextExceptions)) return false; } return true; }