Examples of TarantoolException


Examples of org.tarantool.core.exception.TarantoolException

        readFully(state.getPacketReadBuffer());
        state.unpack(cls);
        IntegerValue code = (IntegerValue) state.getHeader().get(Key.CODE);
        if (code.getInt() != 0) {
            RawValue error = (RawValue) state.getBody().get(Key.ERROR);
            throw new TarantoolException(code.getInt(), error.getString());
        }
        return state.getBody().get(Key.DATA);
    }
View Full Code Here

Examples of org.tarantool.core.exception.TarantoolException

  public Tuple put(int spaceNum, Tuple tuple, boolean insert, boolean replace) {
    Space space = spaces.get(spaceNum);

    if (space.getByValue(tuple) != null) {
      if (insert) {
        throw new TarantoolException(55, "Tuple already exists");
      }
      delete(spaceNum, space.toPK(tuple));
    } else if (replace) {
      throw new TarantoolException(49, "Tuple doesn't exist");
    }
    for (Index key : space.indexes.values()) {
      BigInteger secondaryKey = toKey(copy(tuple, key.fields));
      List<Tuple> collection = key.idx.get(secondaryKey);
      if (collection == null) {
View Full Code Here

Examples of org.tarantool.core.exception.TarantoolException

  }

  public Index getIndex(int spaceNum, int idx, Tuple t) {
    Index index = getIndexWithoutCheck(spaceNum, idx);
    if (t.size() != index.fields.length) {
      throw new TarantoolException(47, String.format("Key part count %d is greater than index part count %d", t.size(), 1));
    }
    return index;
  }
View Full Code Here

Examples of org.tarantool.core.exception.TarantoolException

  }

  public Index getIndexWithoutCheck(int spaceNum, int idx) {
    Space space = spaces.get(spaceNum);
    if (space == null) {
      throw new TarantoolException(52, String.format("Space %d is disabled", spaceNum));
    }

    Index index = space.indexes.get(idx);
    if (index == null) {
      throw new TarantoolException(53, String.format("No index #%u is defined in space %u", idx, spaceNum));
    }
    return index;
  }
View Full Code Here

Examples of org.tarantool.core.exception.TarantoolException

    } else if (op == Select.OP_CODE) {
      return executeSelect(request);
    } else if (op == Call.OP_CODE) {
      return executeCall(request);
    }
    throw new TarantoolException(2, String.format("Illegal parameters, %s", "Unknown operation " + op));
  }
View Full Code Here

Examples of org.tarantool.core.exception.TarantoolException

  private Response executeCall(Request request) {
    Call call = (Call) request;
    CallStub callStub = calls.get(call.getProcName());
    if (callStub == null) {
      throw new TarantoolException(50, String.format("Procedure '%s' is not defined", call.getProcName()));
    }
    Tuple args = Tuple.create(ByteBuffer.wrap(call.getBody()).order(ByteOrder.LITTLE_ENDIAN), ByteOrder.LITTLE_ENDIAN);
    return packResult(request, callStub.call(this, call.getProcName(), call.getFlags(), args), Call.OP_CODE);
  }
View Full Code Here

Examples of org.tarantool.core.exception.TarantoolException

    Space space = spaces.get(spaceNum);
    Index primary = space.indexes.get(0);
    Tuple stored = primary.getOne(tuple);
    if (stored != null) {
      if (stored.size() < fieldNo || fieldNo < 0) {
        throw new TarantoolException(54, String.format("Field %d was not found in the tuple", fieldNo));
      }
      if (up == Updates.ADD || up == Updates.AND || up == Updates.XOR || up == Updates.OR || up == Updates.MAX || up == Updates.SUB) {
        int storedFieldLength = stored.getBytes(fieldNo).length;
        if (storedFieldLength == 4) {
          stored.setInt(fieldNo, (int) arithmeticUpdate(up, stored.getInt(fieldNo), args.getInt(0)));
        } else if (storedFieldLength == 8) {
          stored.setLong(fieldNo, arithmeticUpdate(up, stored.getLong(fieldNo), args.getBytes(0).length == 4 ? args.getInt(0) : args.getLong(0)));
        } else {
          throw new TarantoolException(40, String.format("Field type does not match one required by operation: expected a %s", "NUM or NUM 64"));
        }

      } else if (up == Updates.DELETE) {
        stored = deleteField(fieldNo, stored);
        if (stored.size() < 2) {
          throw new TarantoolException(25, "UPDATE error: the new tuple has no fields");
        }
      } else if (up == Updates.INSERT) {
        stored = insertField(fieldNo, args, stored);
      } else if (up == Updates.SPLICE) {
        splice(fieldNo, args, stored);
View Full Code Here

Examples of org.tarantool.core.exception.TarantoolException

      List<Tuple> collection = idx.get(key);
      if (collection == null) {
        idx.put(key, collection = new ArrayList<Tuple>());
      }
      if (unique && collection.size() > 0) {
        throw new TarantoolException(56, "Duplicate key exists in a unique index");
      }
      collection.add(t);
    }
View Full Code Here

Examples of org.tarantool.core.exception.TarantoolException

   *            a {@link java.nio.ByteBuffer} object.
   */
  protected void handleErrorMessage(Response response, ByteBuffer body) {
    byte[] message = new byte[body.capacity() - 4];
    body.get(message);
    throw new TarantoolException(response.getRet(), new String(message).trim());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.