Package org.apache.phoenix.exception

Examples of org.apache.phoenix.exception.SQLExceptionCode


        exceptions[i] = new SequenceNotFoundException(
            key.getSchemaName(), key.getSequenceName());
      } else {
        boolean increaseSeq = info.incrementBy > 0;
        if (info.limitReached) {
          SQLExceptionCode code = increaseSeq ? SQLExceptionCode.SEQUENCE_VAL_REACHED_MAX_VALUE
              : SQLExceptionCode.SEQUENCE_VAL_REACHED_MIN_VALUE;
          exceptions[i] = new SQLExceptionInfo.Builder(code).build().buildException();
        } else {
          values[i] = info.sequenceValue;
          info.sequenceValue += info.incrementBy * info.cacheSize;
 
View Full Code Here


        } else {
            // Not a DoNotRetryIOException, IOException or SQLException. Map the exception type to a general SQLException
            // and construct the error message so it can be reconstruct on the client side.
            //
            // If no mapping exists, rethrow it as a generic exception.
            SQLExceptionCode code = errorcodeMap.get(t.getClass());
            if (code == null) {
                throw new DoNotRetryIOException(msg + ": " + t.getMessage(), t);
            } else {
                throw new DoNotRetryIOException(constructSQLErrorMessage(code, t, msg), t);
            }
View Full Code Here

          if (message != null) {
            // If the message matches the standard pattern, recover the SQLException and throw it.
            Matcher matcher = PATTERN.matcher(t.getLocalizedMessage());
            if (matcher.find()) {
                int statusCode = Integer.parseInt(matcher.group(1));
                SQLExceptionCode code;
                try {
                    code = SQLExceptionCode.fromErrorCode(statusCode);
                } catch (SQLException e) {
                    return e;
                }
View Full Code Here

            if (cycle) {
              // reset currentValue of the Sequence row to minValue/maxValue
              currentValue = increasingSeq ? minValue : maxValue;
            }
            else {
              SQLExceptionCode code = increasingSeq ? SQLExceptionCode.SEQUENCE_VAL_REACHED_MAX_VALUE
                  : SQLExceptionCode.SEQUENCE_VAL_REACHED_MIN_VALUE;
              return getErrorResult(row, maxTimestamp, code.getErrorCode());
            }
          }
                 
                  // check if the limit was reached
          limitReached = SequenceUtil.checkIfLimitReached(currentValue, minValue, maxValue, incrementBy, cacheSize);
View Full Code Here

public class SchemaUtilTest {

    @Test
    public void testExceptionCode() throws Exception {
        SQLExceptionCode code = SQLExceptionCode.fromErrorCode(SQLExceptionCode.AGGREGATE_IN_GROUP_BY.getErrorCode());
        assertEquals(SQLExceptionCode.AGGREGATE_IN_GROUP_BY, code);
    }
View Full Code Here

        if (value.limitReached) {          
            if (value.cycle) {
                value.limitReached=false;
                throw EMPTY_SEQUENCE_CACHE_EXCEPTION;
            } else {
                SQLExceptionCode code =
                        increasingSeq ? SQLExceptionCode.SEQUENCE_VAL_REACHED_MAX_VALUE
                                : SQLExceptionCode.SEQUENCE_VAL_REACHED_MIN_VALUE;
                throw SequenceUtil.getException(this.key.getSchemaName(),
                    this.key.getSequenceName(), code);
            }
View Full Code Here

        // In that case, we might get an error that a curr value was done on a sequence
        // before a next val was. Not sure how to prevent that.
        if (result.raw().length == 1) {
            KeyValue errorKV = result.raw()[0];
            int errorCode = PDataType.INTEGER.getCodec().decodeInt(errorKV.getBuffer(), errorKV.getValueOffset(), SortOrder.getDefault());
            SQLExceptionCode code = SQLExceptionCode.fromErrorCode(errorCode);
            // TODO: We could have the server return the timestamps of the
            // delete markers and we could insert them here, but this seems
            // like overkill.
            // if (code == SQLExceptionCode.SEQUENCE_UNDEFINED) {
            // }
View Full Code Here

            if (value == null) {
                throw new EmptySequenceCacheException(key.getSchemaName(),key.getSequenceName());
            }
            return true;
        }
        SQLExceptionCode code = SQLExceptionCode.fromErrorCode(statusCode);
        // TODO: We could have the server return the timestamps of the
        // delete markers and we could insert them here, but this seems
        // like overkill.
        // if (code == SQLExceptionCode.SEQUENCE_UNDEFINED) {
        // }
View Full Code Here

        if (statusCode == 0) {  // Success - add sequence value and return timestamp
            SequenceValue value = new SequenceValue(timestamp, minValue, maxValue, cycle);
            insertSequenceValue(value);
            return timestamp;
        }
        SQLExceptionCode code = SQLExceptionCode.fromErrorCode(statusCode);
        throw new SQLExceptionInfo.Builder(code)
            .setSchemaName(key.getSchemaName())
            .setTableName(key.getSequenceName())
            .build().buildException();
    }
View Full Code Here

    public long dropSequence(Result result) throws SQLException {
        KeyValue statusKV = result.raw()[0];
        long timestamp = statusKV.getTimestamp();
        int statusCode = PDataType.INTEGER.getCodec().decodeInt(statusKV.getBuffer(), statusKV.getValueOffset(), SortOrder.getDefault());
        SQLExceptionCode code = statusCode == 0 ? null : SQLExceptionCode.fromErrorCode(statusCode);
        if (code == null) {
            // Insert delete marker so that point-in-time sequences work
            insertSequenceValue(new SequenceValue(timestamp, true));
            return timestamp;
        }
View Full Code Here

TOP

Related Classes of org.apache.phoenix.exception.SQLExceptionCode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.