Package org.apache.cassandra.exceptions

Examples of org.apache.cassandra.exceptions.InvalidRequestException


            return variables.get(bindIndex);
        }
        catch (MarshalException e)
        {
            throw new InvalidRequestException(e.getMessage());
        }
    }
View Full Code Here


    public void validate(ClientState state) throws InvalidRequestException
    {
        opts.validate();

        if (superuser == null && opts.isEmpty())
            throw new InvalidRequestException("ALTER USER can't be empty");

        if (!Auth.isExistingUser(username))
            throw new InvalidRequestException(String.format("User %s doesn't exist", username));
    }
View Full Code Here

     * @throws InvalidRequestException if there is no ring information available about keyspace
     */
    public List<TokenRange> describeRing(String keyspace) throws InvalidRequestException
    {
        if (keyspace == null || !Schema.instance.getNonSystemTables().contains(keyspace))
            throw new InvalidRequestException("There is no ring for the keyspace: " + keyspace);

        List<TokenRange> ranges = new ArrayList<TokenRange>();
        Token.TokenFactory tf = getPartitioner().getTokenFactory();

        for (Map.Entry<Range<Token>, List<InetAddress>> entry : getRangeToAddressMap(keyspace).entrySet())
View Full Code Here

    }

    public void validate(ClientState state) throws InvalidRequestException
    {
        if (username.isEmpty())
            throw new InvalidRequestException("Username can't be an empty string");
        opts.validate();
        if (Auth.isExistingUser(username))
            throw new InvalidRequestException(String.format("User %s already exists", username));
    }
View Full Code Here

                    {
                        case SET:
                            SetOperation.doSetFromPrepared(cf, builder, (SetType)validator, preparedValue, params);
                            break;
                        case PREPARED_PLUS:
                            throw new InvalidRequestException("Unsupported syntax, cannot add to a prepared set");
                        case PLUS_PREPARED:
                            SetOperation.doAddFromPrepared(cf, builder, (SetType)validator, preparedValue, params);
                            break;
                        case MINUS_PREPARED:
                            SetOperation.doDiscardFromPrepared(cf, builder, (SetType)validator, preparedValue, params);
                            break;
                    }
                    break;
                case MAP:
                    switch (kind)
                    {
                        case SET:
                            MapOperation.doSetFromPrepared(cf, builder, (MapType)validator, preparedValue, params);
                            break;
                        case PREPARED_PLUS:
                            throw new InvalidRequestException("Unsupported syntax, cannot put to a prepared map");
                        case PLUS_PREPARED:
                            MapOperation.doPutFromPrepared(cf, builder, (MapType)validator, preparedValue, params);
                            break;
                        case MINUS_PREPARED:
                            throw new InvalidRequestException("Unsuppoted syntax, discard syntax for map not supported");
                    }
                    break;
            }
        }
        else
        {
            switch (kind)
            {
                case SET:
                    ColumnOperation.Set(preparedValue).execute(cf, builder, validator, params, null);
                    break;
                case PREPARED_PLUS:
                    throw new InvalidRequestException("Unsupported syntax for increment, must be of the form X = X + <value>");
                case PLUS_PREPARED:
                    ColumnOperation.CounterInc(preparedValue).execute(cf, builder, validator, params, null);
                    break;
                case MINUS_PREPARED:
                    ColumnOperation.CounterDec(preparedValue).execute(cf, builder, validator, params, null);
View Full Code Here

    }

    public void validate(ClientState state) throws InvalidRequestException
    {
        if (!Auth.isExistingUser(username))
            throw new InvalidRequestException(String.format("User %s doesn't exists", username));

        AuthenticatedUser user = state.getUser();
        if (user != null && user.getName().equals(username))
            throw new InvalidRequestException("Users aren't allowed to DROP themselves");
    }
View Full Code Here

        {
            val = ByteBufferUtil.toLong(value.getByteBuffer(LongType.instance, params.variables));
        }
        catch (NumberFormatException e)
        {
            throw new InvalidRequestException(String.format("'%s' is an invalid value, should be a long.", value.getText()));
        }

        if (kind == Kind.COUNTER_DEC)
        {
            if (val == Long.MIN_VALUE)
                throw new InvalidRequestException("The negation of " + val + " overflows supported integer precision (signed 8 bytes integer)");
            else
                val = -val;
        }

        cf.addCounter(new QueryPath(cf.metadata().cfName, null, builder.build()), val);
View Full Code Here

    {
        cfProps.validate();

        // Ensure that exactly one key has been specified.
        if (keyValidator.size() < 1)
            throw new InvalidRequestException("You must specify a PRIMARY KEY");
        else if (keyValidator.size() > 1)
            throw new InvalidRequestException("You may only specify one PRIMARY KEY");

        AbstractType<?> comparator;

        try
        {
            comparator = cfProps.getComparator();
        }
        catch (ConfigurationException e)
        {
            throw new InvalidRequestException(e.toString());
        }
        catch (SyntaxException e)
        {
            throw new InvalidRequestException(e.toString());
        }

        for (Map.Entry<Term, String> column : columns.entrySet())
        {
            ByteBuffer name = column.getKey().getByteBuffer(comparator, variables);

            if (keyAlias != null && keyAlias.equals(name))
                throw new InvalidRequestException("Invalid column name: "
                                                  + column.getKey().getText()
                                                  + ", because it equals to the key_alias.");

        }
    }
View Full Code Here

                AbstractType<?> validator = TypeParser.parse(validatorClassName);
                columnDefs.put(columnName, new ColumnDefinition(columnName, validator, null, null, null, null));
            }
            catch (ConfigurationException e)
            {
                InvalidRequestException ex = new InvalidRequestException(e.toString());
                ex.initCause(e);
                throw ex;
            }
            catch (SyntaxException e)
            {
                InvalidRequestException ex = new InvalidRequestException(e.toString());
                ex.initCause(e);
                throw ex;
            }
        }

        return columnDefs;
View Full Code Here

            if (keyAlias != null)
                newCFMD.keyAliases(Collections.<ByteBuffer>singletonList(keyAlias));
        }
        catch (ConfigurationException e)
        {
            throw new InvalidRequestException(e.toString());
        }
        catch (SyntaxException e)
        {
            throw new InvalidRequestException(e.toString());
        }
        return newCFMD;
    }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.exceptions.InvalidRequestException

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.