Package org.apache.cassandra.exceptions

Examples of org.apache.cassandra.exceptions.InvalidRequestException


        }

        public static Collection set(ParsedType t) throws InvalidRequestException
        {
            if (t.isCollection())
                throw new InvalidRequestException("set type cannot contain another collection");

            return new Collection(SetType.getInstance(t.getType()));
        }
View Full Code Here


        super.validate(state);
        ThriftValidation.validateKeyspaceNotSystem(name);

        // keyspace name
        if (!name.matches("\\w+"))
            throw new InvalidRequestException(String.format("\"%s\" is not a valid keyspace name", name));
        if (name.length() > Schema.NAME_LENGTH)
            throw new InvalidRequestException(String.format("Keyspace names shouldn't be more than %s characters long (got \"%s\")", Schema.NAME_LENGTH, name));

        attrs.validate();

        if (attrs.getReplicationStrategyClass() == null)
            throw new ConfigurationException("Missing mandatory replication strategy class");
View Full Code Here

    }

    public static void doAppendFromPrepared(ColumnFamily cf, ColumnNameBuilder builder, ListType validator, Term values, UpdateParameters params) throws InvalidRequestException
    {
        if (!values.isBindMarker())
            throw new InvalidRequestException("Can't apply operation on column with " + validator + " type.");

        try
        {
            List<?> l = validator.compose(params.variables.get(values.bindIndex));

            for (int i = 0; i < l.size(); i++)
            {
                ColumnNameBuilder b = i == l.size() - 1 ? builder : builder.copy();
                ByteBuffer uuid = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes());
                ByteBuffer name = b.add(uuid).build();
                cf.addColumn(params.makeColumn(name, validator.valueComparator().decompose(l.get(i))));
            }
        }
        catch (MarshalException e)
        {
            throw new InvalidRequestException(e.getMessage());
        }
    }
View Full Code Here

    }

    public static void doPrependFromPrepared(ColumnFamily cf, ColumnNameBuilder builder, ListType validator, Term values, UpdateParameters params) throws InvalidRequestException
    {
        if (!values.isBindMarker())
            throw new InvalidRequestException("Can't apply operation on column with " + validator + " type.");

        long time = REFERENCE_TIME - (System.currentTimeMillis() - REFERENCE_TIME);

        try
        {
            List<?> l = validator.compose(params.variables.get(values.bindIndex));

            for (int i = 0; i < l.size(); i++)
            {
                ColumnNameBuilder b = i == l.size() - 1 ? builder : builder.copy();
                PrecisionTime pt = getNextTime(time);
                ByteBuffer uuid = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(pt.millis, pt.nanos));
                ByteBuffer name = b.add(uuid).build();
                cf.addColumn(params.makeColumn(name, validator.valueComparator().decompose(l.get(i))));
            }
        }
        catch (MarshalException e)
        {
            throw new InvalidRequestException(e.getMessage());
        }
    }
View Full Code Here

    }

    public static void doDiscardFromPrepared(ColumnFamily cf, ColumnNameBuilder builder, ListType validator, Term values, UpdateParameters params, List<Pair<ByteBuffer, IColumn>> list) throws InvalidRequestException
    {
        if (!values.isBindMarker())
            throw new InvalidRequestException("Can't apply operation on column with " + validator + " type.");

        if (list == null)
            return;

        try
        {
            List<?> l = validator.compose(params.variables.get(values.bindIndex));

            Set<ByteBuffer> toDiscard = new HashSet<ByteBuffer>();
            for (Object elt : l)
                toDiscard.add(validator.valueComparator().decompose(elt));

            for (Pair<ByteBuffer, IColumn> p : list)
            {
                IColumn c = p.right;
                if (toDiscard.contains(c.value()))
                    cf.addColumn(params.makeTombstone(c.name()));
            }
        }
        catch (MarshalException e)
        {
            throw new InvalidRequestException(e.getMessage());
        }
    }
View Full Code Here

            MapOperation.Put(values.get(0), values.get(1)).addBoundNames(column, boundNames);
            return;
        }

        if (!(column.type instanceof ListType))
            throw new InvalidRequestException(String.format("Invalid operation, %s is not of list type", column.name));

        ListType lt = (ListType)column.type;
        if (kind == Kind.SET_IDX)
        {
            assert values.size() == 2;
View Full Code Here

    private int validateListIdx(Term value, List<Pair<ByteBuffer, IColumn>> list) throws InvalidRequestException
    {
        try
        {
            if (value.getType() != Term.Type.INTEGER)
                throw new InvalidRequestException(String.format("Invalid argument %s for %s, must be an integer.", value.getText(), getType()));

            int idx = Integer.parseInt(value.getText());
            if (list == null || list.size() <= idx)
                throw new InvalidRequestException(String.format("Invalid index %d, list has size %d", idx, list == null ? 0 : list.size()));

            return idx;
        }
        catch (NumberFormatException e)
        {
View Full Code Here

    }

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

        // if a keyspace is omitted when GRANT/REVOKE ON TABLE <table>, we need to correct the resource.
        resource = maybeCorrectResource(resource, state);
        if (!resource.exists())
            throw new InvalidRequestException(String.format("%s doesn't exist", resource));
    }
View Full Code Here

                throw new AssertionError("a marker Term was encountered with no index value");

            ByteBuffer value = variables.get(bindIndex);
            // We don't yet support null values in prepared statements
            if (value == null)
                throw new InvalidRequestException("Invalid null value for prepared variable " + bindIndex);
            validator.validate(value);
            return value;
        }
        catch (MarshalException e)
        {
            throw new InvalidRequestException(e.getMessage());
        }
    }
View Full Code Here

    public void validate(ClientState state) throws InvalidRequestException
    {
        // a check to ensure the existence of the user isn't being leaked by user existence check.
        if (username != null && !Auth.isExistingUser(username))
            throw new InvalidRequestException(String.format("User %s doesn't exist", username));

        if (resource != null)
        {
            resource = maybeCorrectResource(resource, state);
            if (!resource.exists())
                throw new InvalidRequestException(String.format("%s doesn't exist", resource));
        }
    }
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.