public String getKeyspace() throws InvalidRequestException { if (keyspace == null) throw new InvalidRequestException("No keyspace has been specified. USE a keyspace, or explicitly specify keyspace.tablename"); return keyspace; }
public String getKeyspace() throws InvalidRequestException { if (keyspace == null) throw new InvalidRequestException("No keyspace has been specified. USE a keyspace, or explicitly specify keyspace.tablename"); return keyspace; }
/** * Returns an <code>InvalidRequestException</code> with the specified message. * * @param messageTemplate the template used to build the error message * @param messageArgs the message arguments * @return an <code>InvalidRequestException</code> with the specified message. */ public static InvalidRequestException invalidRequest(String messageTemplate, Object... messageArgs) { return new InvalidRequestException(String.format(messageTemplate, messageArgs)); }
public void validateCounterForWrite(CFMetaData metadata) throws InvalidRequestException { if (this == ConsistencyLevel.ANY) throw new InvalidRequestException("Consistency level ANY is not yet supported for counter table " + metadata.cfName); if (isSerialConsistency()) throw new InvalidRequestException("Counter operations are inherently non-serializable"); }
private void requireNetworkTopologyStrategy(String keyspaceName) throws InvalidRequestException { AbstractReplicationStrategy strategy = Keyspace.open(keyspaceName).getReplicationStrategy(); if (!(strategy instanceof NetworkTopologyStrategy)) throw new InvalidRequestException(String.format("consistency level %s not compatible with replication strategy (%s)", this, strategy.getClass().getName())); } }
public Prepared prepare(ClientState clientState) throws InvalidRequestException { if (new HashSet<>(argNames).size() != argNames.size()) throw new InvalidRequestException(String.format("duplicate argument names for given function %s with argument names %s", functionName, argNames)); argTypes = new ArrayList<>(argRawTypes.size()); for (CQL3Type.Raw rawType : argRawTypes) argTypes.add(prepareType("arguments", rawType)); returnType = prepareType("return type", rawReturnType); return super.prepare(clientState); }
public InValue bind(QueryOptions options) throws InvalidRequestException { ByteBuffer value = options.getValues().get(bindIndex); if (value == ByteBufferUtil.UNSET_BYTE_BUFFER) throw new InvalidRequestException(String.format("Invalid unset value for %s", receiver.name)); return value == null ? null : InValue.fromSerialized(value, (ListType)receiver.type, options); } }
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException { if (!(receiver.type instanceof ListType)) throw new InvalidRequestException(String.format("Invalid list literal for %s of type %s", receiver.name, receiver.type.asCQL3Type())); ColumnSpecification valueSpec = Lists.valueSpecOf(receiver); for (Term.Raw rt : elements) { if (!rt.testAssignment(keyspace, valueSpec).isAssignable()) throw new InvalidRequestException(String.format("Invalid list literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type())); } }
public void validate(ClientState state) throws UnauthorizedException, InvalidRequestException { state.ensureNotAnonymous(); if ((grantee != null) && !DatabaseDescriptor.getRoleManager().isExistingRole(grantee)) throw new InvalidRequestException(String.format("%s doesn't exist", grantee)); }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to delete a single key in a frozen map"; Term.Terminal key = t.bind(params.options); if (key == null) throw new InvalidRequestException("Invalid null map key"); if (key == Constants.UNSET_VALUE) throw new InvalidRequestException("Invalid unset map key"); params.addTombstone(column, CellPath.create(key.get(params.options.getProtocolVersion()))); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { ByteBuffer bytes = t.bindAndGet(params.options); if (bytes == null) throw new InvalidRequestException("Invalid null value for counter increment"); if (bytes == ByteBufferUtil.UNSET_BYTE_BUFFER) return; long increment = ByteBufferUtil.toLong(bytes); params.addCounter(column, increment); } }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to delete a single key in a frozen map"; Term.Terminal key = t.bind(params.options); if (key == null) throw new InvalidRequestException("Invalid null map key"); if (key == Constants.UNSET_VALUE) throw new InvalidRequestException("Invalid unset map key"); params.addTombstone(column, CellPath.create(key.get(params.options.getProtocolVersion()))); } }
public static Value fromSerialized(ByteBuffer bytes, TupleType type) { ByteBuffer[] values = type.split(bytes); if (values.length > type.size()) { throw new InvalidRequestException(String.format( "Tuple value contained too many fields (expected %s, got %s)", type.size(), values.length)); } return new Value(type.split(bytes)); }
private AbstractType<?> prepareType(String typeName, CQL3Type.Raw rawType) { if (rawType.isFrozen()) throw new InvalidRequestException(String.format("The function %s should not be frozen; remove the frozen<> modifier", typeName)); // UDT are not supported non frozen but we do not allow the frozen keyword for argument. So for the moment we // freeze them here if (!rawType.canBeNonFrozen()) rawType.freeze(); AbstractType<?> type = rawType.prepare(functionName.keyspace).getType(); return type; } }
private AbstractType<?> prepareType(String typeName, CQL3Type.Raw rawType) { if (rawType.isFrozen()) throw new InvalidRequestException(String.format("The function %s should not be frozen; remove the frozen<> modifier", typeName)); // UDT are not supported non frozen but we do not allow the frozen keyword for argument. So for the moment we // freeze them here if (!rawType.canBeNonFrozen()) rawType.freeze(); AbstractType<?> type = rawType.prepare(functionName.keyspace).getType(); return type; }
@Override public void prepareKeyspace(ClientState state) throws InvalidRequestException { if (!name.hasKeyspace()) name.setKeyspace(state.getKeyspace()); if (name.getKeyspace() == null) throw new InvalidRequestException("You need to be logged in a keyspace or use a fully qualified user type name"); }
public Event.SchemaChange announceMigration(QueryState queryState, boolean isLocalOnly) throws RequestValidationException { KeyspaceMetadata oldKsm = Schema.instance.getKSMetaData(name); // In the (very) unlikely case the keyspace was dropped since validate() if (oldKsm == null) throw new InvalidRequestException("Unknown keyspace " + name); KeyspaceMetadata newKsm = oldKsm.withSwapped(attrs.asAlteredKeyspaceParams(oldKsm.params)); MigrationManager.announceKeyspaceUpdate(newKsm, isLocalOnly); return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, keyspace()); } }
@Override public void prepareKeyspace(ClientState state) throws InvalidRequestException { if (!functionName.hasKeyspace() && state.getRawKeyspace() != null) functionName = new FunctionName(state.getKeyspace(), functionName.name); if (!functionName.hasKeyspace()) throw new InvalidRequestException("Functions must be fully qualified with a keyspace name if a keyspace is not set for the session"); ThriftValidation.validateKeyspaceNotSystem(functionName.keyspace); }
public void execute(DecoratedKey partitionKey, UpdateParameters params) throws InvalidRequestException { assert column.type.isMultiCell() : "Attempted to delete a single element in a frozen set"; Term.Terminal elt = t.bind(params.options); if (elt == null) throw new InvalidRequestException("Invalid null set element"); params.addTombstone(column, CellPath.create(elt.get(params.options.getProtocolVersion()))); } }
public Event.SchemaChange announceMigration(QueryState queryState, boolean isLocalOnly) throws RequestValidationException { KeyspaceMetadata oldKsm = Schema.instance.getKSMetaData(name); // In the (very) unlikely case the keyspace was dropped since validate() if (oldKsm == null) throw new InvalidRequestException("Unknown keyspace " + name); KeyspaceMetadata newKsm = oldKsm.withSwapped(attrs.asAlteredKeyspaceParams(oldKsm.params)); MigrationManager.announceKeyspaceUpdate(newKsm, isLocalOnly); return new Event.SchemaChange(Event.SchemaChange.Change.UPDATED, keyspace()); } }