Package org.apache.cassandra.thrift

Examples of org.apache.cassandra.thrift.InvalidRequestException


        {
            announceMigration();
        }
        catch (ConfigurationException e)
        {
            InvalidRequestException ex = new InvalidRequestException(e.toString());
            ex.initCause(e);
            throw ex;
        }
        validateSchemaIsSettled();
        return null;
    }
View Full Code Here


            if (updatedCfm != null)
                break;
        }

        if (updatedCfm == null)
            throw new InvalidRequestException("Index '" + indexName + "' could not be found in any of the column families of keyspace '" + keyspace() + "'");

        MigrationManager.announceColumnFamilyUpdate(updatedCfm);
    }
View Full Code Here

    public List<IMutation> getMutations(ClientState clientState, List<ByteBuffer> variables) throws InvalidRequestException
    {
        // Check key
        List<Term> keys = processedKeys.get(cfDef.key.name);
        if (keys == null || keys.isEmpty())
            throw new InvalidRequestException(String.format("Missing mandatory PRIMARY KEY part %s", cfDef.key.name));

        ColumnNameBuilder builder = cfDef.getColumnNameBuilder();
        CFDefinition.Name firstEmpty = null;
        for (CFDefinition.Name name : cfDef.columns.values())
        {
            List<Term> values = processedKeys.get(name.name);
            if (values == null || values.isEmpty())
            {
                firstEmpty = name;
                // For composites, we must either have all component or none
                if (cfDef.isComposite && builder.componentCount() != 0)
                    throw new InvalidRequestException(String.format("Missing mandatory PRIMARY KEY part %s", name));
            }
            else if (firstEmpty != null)
            {
                throw new InvalidRequestException(String.format("Missing PRIMARY KEY part %s since %s is set", firstEmpty, name));
            }
            else
            {
                assert values.size() == 1; // We only allow IN for keys so far
                builder.add(values.get(0), Relation.Type.EQ, variables);
View Full Code Here

        {
            for (ColumnIdentifier column : columns)
            {
                CFDefinition.Name name = cfDef.get(column);
                if (name == null)
                    throw new InvalidRequestException(String.format("Unknown identifier %s", column));

                // For compact, we only have one value except the key, so the only form of DELETE that make sense is without a column
                // list. However, we support having the value name for coherence with the static/sparse case
                if (name.kind != CFDefinition.Name.Kind.COLUMN_METADATA && name.kind != CFDefinition.Name.Kind.VALUE_ALIAS)
                    throw new InvalidRequestException(String.format("Invalid identifier %s for deletion (should not be a PRIMARY KEY part)", column));
            }

            if (cfDef.isCompact)
            {
                    ByteBuffer columnName = builder.build();
View Full Code Here

        // Mutating oldCfm directly would be bad so cloning.
        CFMetaData cfm = oldCfm.clone();
        CFDefinition cfDef = oldCfm.getCfDef();

        if (cfDef.isComposite)
            throw new InvalidRequestException("Secondary indexes are not (yet) supported on tables with composite PRIMARY KEY");

        for (ColumnDefinition cd : cfm.getColumn_metadata().values())
        {
            if (cd.name.equals(columnName.key))
            {
                if (cd.getIndexType() != null)
                    throw new InvalidRequestException("Index already exists");
                if (logger.isDebugEnabled())
                    logger.debug("Updating column {} definition for index {}", columnName, indexName);
                cd.setIndexType(IndexType.KEYS, Collections.<String, String>emptyMap());
                cd.setIndexName(indexName);
                columnExists = true;
                break;
            }
        }
        if (!columnExists)
        {
            CFDefinition.Name name = cfDef.get(columnName);
            if (name != null)
            {
                switch (name.kind)
                {
                    case KEY_ALIAS:
                    case COLUMN_ALIAS:
                        throw new InvalidRequestException(String.format("Cannot create index on PRIMARY KEY part %s", columnName));
                    case VALUE_ALIAS:
                        throw new InvalidRequestException(String.format("Cannot create index on column %s of compact CF", columnName));
                }
            }
            throw new InvalidRequestException("No column definition found for column " + columnName);
        }

        cfm.addDefaultIndexNames();
        MigrationManager.announceColumnFamilyUpdate(cfm);
    }
View Full Code Here

    public List<IMutation> getMutations(ClientState clientState, List<ByteBuffer> variables) throws InvalidRequestException
    {
        // Check key
        List<Term> keys = processedKeys.get(cfDef.key.name);
        if (keys == null || keys.isEmpty())
            throw new InvalidRequestException(String.format("Missing mandatory PRIMARY KEY part %s", cfDef.key));

        ColumnNameBuilder builder = cfDef.getColumnNameBuilder();
        CFDefinition.Name firstEmpty = null;
        for (CFDefinition.Name name : cfDef.columns.values())
        {
            List<Term> values = processedKeys.get(name.name);
            if (values == null || values.isEmpty())
            {
                firstEmpty = name;
                // For sparse, we must have all components
                if (cfDef.isComposite && !cfDef.isCompact)
                    throw new InvalidRequestException(String.format("Missing mandatory PRIMARY KEY part %s", name));
            }
            else if (firstEmpty != null)
            {
                throw new InvalidRequestException(String.format("Missing PRIMARY KEY part %s since %s is set", firstEmpty.name, name.name));
            }
            else
            {
                assert values.size() == 1; // We only allow IN for row keys so far
                builder.add(values.get(0), Relation.Type.EQ, variables);
View Full Code Here

        ColumnFamily cf = rm.addOrGet(cfDef.cfm.cfName);

        if (cfDef.isCompact)
        {
            if (builder.componentCount() == 0)
                throw new InvalidRequestException(String.format("Missing PRIMARY KEY part %s", cfDef.columns.values().iterator().next()));

            Operation value = processedColumns.get(cfDef.value.name);
            if (value == null)
                throw new InvalidRequestException(String.format("Missing mandatory column %s", cfDef.value));
            hasCounterColumn = addToMutation(clientState, cf, builder.build(), cfDef.value, value, variables);
        }
        else
        {
            for (CFDefinition.Name name : cfDef.metadata.values())
View Full Code Here

            return false;
        }
        else
        {
            if (!valueDef.name.equals(value.ident))
                throw new InvalidRequestException("Only expressions like X = X + <long> are supported.");

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

            if (value.type == Operation.Type.MINUS)
            {
                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(columnFamily(), null, colName), val);
            return true;
View Full Code Here

            {
                if (!column.getValue().isUnary())
                    hasCommutativeOperation = true;

                if (hasCommutativeOperation && column.getValue().isUnary())
                    throw new InvalidRequestException("Mix of commutative and non-commutative operations is not allowed.");
            }
        }

        // Deal here with the keyspace overwrite thingy to avoid mistake
        CFMetaData metadata = validateColumnFamily(keyspace(), columnFamily(), hasCommutativeOperation);
        if (hasCommutativeOperation)
            validateCommutativeForWrite(metadata, cLevel);

        cfDef = metadata.getCfDef();

        if (columns == null)
        {
            // Created from an INSERT
            // Don't hate, validate.
            if (columnNames.size() != columnValues.size())
                throw new InvalidRequestException("unmatched column names/values");
            if (columnNames.size() < 1)
                throw new InvalidRequestException("no columns specified for INSERT");

            for (int i = 0; i < columnNames.size(); i++)
            {
                CFDefinition.Name name = cfDef.get(columnNames.get(i));
                if (name == null)
                    throw new InvalidRequestException(String.format("Unknown identifier %s", columnNames.get(i)));

                Term value = columnValues.get(i);
                if (value.isBindMarker())
                    boundNames[value.bindIndex] = name;

                switch (name.kind)
                {
                    case KEY_ALIAS:
                    case COLUMN_ALIAS:
                        if (processedKeys.containsKey(name.name))
                            throw new InvalidRequestException(String.format("Multiple definition found for PRIMARY KEY part %s", name));
                        processedKeys.put(name.name, Collections.singletonList(value));
                        break;
                    case VALUE_ALIAS:
                    case COLUMN_METADATA:
                        if (processedColumns.containsKey(name.name))
                            throw new InvalidRequestException(String.format("Multiple definition found for column %s", name));
                        processedColumns.put(name.name, new Operation(value));
                        break;
                }
            }
        }
        else
        {
            // Created from an UPDATE
            for (Map.Entry<ColumnIdentifier, Operation> entry : columns.entrySet())
            {
                CFDefinition.Name name = cfDef.get(entry.getKey());
                if (name == null)
                    throw new InvalidRequestException(String.format("Unknown identifier %s", entry.getKey()));

                switch (name.kind)
                {
                    case KEY_ALIAS:
                    case COLUMN_ALIAS:
                        throw new InvalidRequestException(String.format("PRIMARY KEY part %s found in SET part", entry.getKey()));
                    case VALUE_ALIAS:
                    case COLUMN_METADATA:
                        if (processedColumns.containsKey(name.name))
                            throw new InvalidRequestException(String.format("Multiple definition found for column %s", name));
                        Operation op = entry.getValue();
                        if (op.value.isBindMarker())
                            boundNames[op.value.bindIndex] = name;
                        processedColumns.put(name.name, op);
                        break;
View Full Code Here

    {
        for (Relation rel : keys)
        {
            CFDefinition.Name name = cfDef.get(rel.getEntity());
            if (name == null)
                throw new InvalidRequestException(String.format("Unknown key identifier %s", rel.getEntity()));

            switch (name.kind)
            {
                case KEY_ALIAS:
                case COLUMN_ALIAS:
                    List<Term> values;
                    if (rel.operator() == Relation.Type.EQ)
                        values = Collections.singletonList(rel.getValue());
                    else if (name.kind == CFDefinition.Name.Kind.KEY_ALIAS && rel.operator() == Relation.Type.IN)
                        values = rel.getInValues();
                    else
                        throw new InvalidRequestException(String.format("Invalid operator %s for key %s", rel.operator(), rel.getEntity()));

                    if (processed.containsKey(name.name))
                        throw new InvalidRequestException(String.format("Multiple definition found for PRIMARY KEY part %s", name));
                    for (Term value : values)
                        if (value.isBindMarker())
                            names[value.bindIndex] = name;
                    processed.put(name.name, values);
                    break;
                case VALUE_ALIAS:
                case COLUMN_METADATA:
                    throw new InvalidRequestException(String.format("PRIMARY KEY part %s found in SET part", rel.getEntity()));
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.thrift.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.