/** * Sets the default fetch size to use for SELECT queries. * * <p>The fetch size set through this method will be use for queries that don't explicitly have a * fetch size, i.e. when {@link Statement#getFetchSize} is less or equal to 0. * * @param fetchSize the new fetch size to set as default. It must be strictly positive but you can * use {@code Integer.MAX_VALUE} to disable paging. * @return this {@code QueryOptions} instance. * @throws IllegalArgumentException if {@code fetchSize <e; 0}. * @throws UnsupportedFeatureException if version 1 of the native protocol is in use and {@code * fetchSize != Integer.MAX_VALUE} as paging is not supported by version 1 of the protocol. * See {@link Cluster.Builder#withProtocolVersion} for more details on protocol versions. */ public QueryOptions setFetchSize(int fetchSize) { if (fetchSize <= 0) throw new IllegalArgumentException("Invalid fetchSize, should be > 0, got " + fetchSize); ProtocolVersion version = manager == null ? null : manager.protocolVersion(); if (fetchSize != Integer.MAX_VALUE && version == ProtocolVersion.V1) throw new UnsupportedFeatureException(version, "Paging is not supported"); this.fetchSize = fetchSize; return this; }
@Test(groups = "short") public void should_throw_ufe_when_protocol_version_lesser_than_4() throws Exception { try { Cluster v3cluster = register( Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withProtocolVersion(V3) .build()) .init(); Session v3session = v3cluster.connect(); Statement statement = new SimpleStatement("SELECT c2 FROM t1 where c1 = ?", 1); statement.setOutgoingPayload(payload1); v3session.execute(statement); fail("Should not send custom payloads with protocol V3"); } catch (UnsupportedFeatureException e) { assertThat(e.getMessage()) .isEqualTo( "Unsupported feature with the native protocol V3 (which is currently in use): Custom payloads are only supported since native protocol V4"); } }
if (customPayload != null) { if (protocolVersion.compareTo(ProtocolVersion.V4) < 0) throw new UnsupportedFeatureException( protocolVersion, "Custom payloads are only supported since native protocol V4"); flags.add(Frame.Header.Flag.CUSTOM_PAYLOAD);
@Test(groups = "short") public void should_throw_ufe_when_protocol_version_lesser_than_4() throws Exception { try { Cluster v3cluster = register( Cluster.builder() .addContactPoints(getContactPoints()) .withPort(ccm().getBinaryPort()) .withProtocolVersion(V3) .build()) .init(); Session v3session = v3cluster.connect(); Statement statement = new SimpleStatement("SELECT c2 FROM t1 where c1 = ?", 1); statement.setOutgoingPayload(payload1); v3session.execute(statement); fail("Should not send custom payloads with protocol V3"); } catch (UnsupportedFeatureException e) { assertThat(e.getMessage()) .isEqualTo( "Unsupported feature with the native protocol V3 (which is currently in use): Custom payloads are only supported since native protocol V4"); } }
if (protocolVersion.compareTo(ProtocolVersion.V3) < 0 && statement instanceof BatchStatement) { if (serialConsistency != null) throw new UnsupportedFeatureException( protocolVersion, "Serial consistency on batch statements is not supported"); } else if (serialConsistency == null) throw new UnsupportedFeatureException( protocolVersion, "Custom payloads are only supported since native protocol V4"); throw new UnsupportedFeatureException(protocolVersion, "Paging is not supported"); } else if (fetchSize <= 0) { fetchSize = configuration().getQueryOptions().getFetchSize(); throw new UnsupportedFeatureException(protocolVersion, "Binary values are not supported"); throw new UnsupportedFeatureException(protocolVersion, "Named values are not supported"); throw new UnsupportedFeatureException( protocolVersion, "Protocol level batching is not supported");
/** * Sets the default fetch size to use for SELECT queries. * <p/> * The fetch size set through this method will be use for queries * that don't explicitly have a fetch size, i.e. when {@link Statement#getFetchSize} * is less or equal to 0. * * @param fetchSize the new fetch size to set as default. It must be * strictly positive but you can use {@code Integer.MAX_VALUE} to disable * paging. * @return this {@code QueryOptions} instance. * @throws IllegalArgumentException if {@code fetchSize <e; 0}. * @throws UnsupportedFeatureException if version 1 of the native protocol is in * use and {@code fetchSize != Integer.MAX_VALUE} as paging is not supported by * version 1 of the protocol. See {@link Cluster.Builder#withProtocolVersion} * for more details on protocol versions. */ public QueryOptions setFetchSize(int fetchSize) { if (fetchSize <= 0) throw new IllegalArgumentException("Invalid fetchSize, should be > 0, got " + fetchSize); ProtocolVersion version = manager == null ? null : manager.protocolVersion(); if (fetchSize != Integer.MAX_VALUE && version == ProtocolVersion.V1) throw new UnsupportedFeatureException(version, "Paging is not supported"); this.fetchSize = fetchSize; return this; }
/** * Sets the default fetch size to use for SELECT queries. * <p/> * The fetch size set through this method will be use for queries * that don't explicitly have a fetch size, i.e. when {@link Statement#getFetchSize} * is less or equal to 0. * * @param fetchSize the new fetch size to set as default. It must be * strictly positive but you can use {@code Integer.MAX_VALUE} to disable * paging. * @return this {@code QueryOptions} instance. * @throws IllegalArgumentException if {@code fetchSize <e; 0}. * @throws UnsupportedFeatureException if version 1 of the native protocol is in * use and {@code fetchSize != Integer.MAX_VALUE} as paging is not supported by * version 1 of the protocol. See {@link Cluster.Builder#withProtocolVersion} * for more details on protocol versions. */ public QueryOptions setFetchSize(int fetchSize) { if (fetchSize <= 0) throw new IllegalArgumentException("Invalid fetchSize, should be > 0, got " + fetchSize); ProtocolVersion version = manager == null ? null : manager.protocolVersion(); if (fetchSize != Integer.MAX_VALUE && version == ProtocolVersion.V1) throw new UnsupportedFeatureException(version, "Paging is not supported"); this.fetchSize = fetchSize; return this; }
/** * Sets the default fetch size to use for SELECT queries. * <p/> * The fetch size set through this method will be use for queries * that don't explicitly have a fetch size, i.e. when {@link Statement#getFetchSize} * is less or equal to 0. * * @param fetchSize the new fetch size to set as default. It must be * strictly positive but you can use {@code Integer.MAX_VALUE} to disable * paging. * @return this {@code QueryOptions} instance. * @throws IllegalArgumentException if {@code fetchSize <e; 0}. * @throws UnsupportedFeatureException if version 1 of the native protocol is in * use and {@code fetchSize != Integer.MAX_VALUE} as paging is not supported by * version 1 of the protocol. See {@link Cluster.Builder#withProtocolVersion} * for more details on protocol versions. */ public QueryOptions setFetchSize(int fetchSize) { if (fetchSize <= 0) throw new IllegalArgumentException("Invalid fetchSize, should be > 0, got " + fetchSize); ProtocolVersion version = manager == null ? null : manager.protocolVersion(); if (fetchSize != Integer.MAX_VALUE && version == ProtocolVersion.V1) throw new UnsupportedFeatureException(version, "Paging is not supported"); this.fetchSize = fetchSize; return this; }
/** * Sets the default fetch size to use for SELECT queries. * <p> * The fetch size set through this method will be use for queries * that don't explicitly have a fetch size, i.e. when {@link Statement#getFetchSize} * is less or equal to 0. * * @param fetchSize the new fetch size to set as default. It must be * strictly positive but you can use {@code Integer.MAX_VALUE} to disable * paging. * @return this {@code QueryOptions} instance. * * @throws IllegalArgumentException if {@code fetchSize <e; 0}. * @throws UnsupportedFeatureException if version 1 of the native protocol is in * use and {@code fetchSize != Integer.MAX_VALUE} as paging is not supported by * version 1 of the protocol. See {@link Cluster.Builder#withProtocolVersion} * for more details on protocol versions. */ public QueryOptions setFetchSize(int fetchSize) { if (fetchSize <= 0) throw new IllegalArgumentException("Invalid fetchSize, should be > 0, got " + fetchSize); int version = manager == null ? -1 : manager.protocolVersion(); if (fetchSize != Integer.MAX_VALUE && version == 1) throw new UnsupportedFeatureException("Paging is not supported"); this.fetchSize = fetchSize; return this; }
if (customPayload != null) { if (protocolVersion.compareTo(ProtocolVersion.V4) < 0) throw new UnsupportedFeatureException( protocolVersion, "Custom payloads are only supported since native protocol V4");
if (customPayload != null) { if (protocolVersion.compareTo(ProtocolVersion.V4) < 0) throw new UnsupportedFeatureException( protocolVersion, "Custom payloads are only supported since native protocol V4");
if (customPayload != null) { if (protocolVersion.compareTo(ProtocolVersion.V4) < 0) throw new UnsupportedFeatureException( protocolVersion, "Custom payloads are only supported since native protocol V4");
fetchSize = -1; else if (fetchSize != Integer.MAX_VALUE) throw new UnsupportedFeatureException("Paging is not supported"); } else if (fetchSize <= 0) { fetchSize = configuration().getQueryOptions().getFetchSize(); throw new UnsupportedFeatureException("Binary values are not supported"); throw new UnsupportedFeatureException("Protocol level batching is not supported");
if (protocolVersion.compareTo(ProtocolVersion.V3) < 0 && statement instanceof BatchStatement) { if (serialConsistency != null) throw new UnsupportedFeatureException(protocolVersion, "Serial consistency on batch statements is not supported"); } else if (serialConsistency == null) serialConsistency = configuration().getQueryOptions().getSerialConsistencyLevel(); throw new UnsupportedFeatureException(protocolVersion, "Custom payloads are only supported since native protocol V4"); fetchSize = -1; else if (fetchSize != Integer.MAX_VALUE) throw new UnsupportedFeatureException(protocolVersion, "Paging is not supported"); } else if (fetchSize <= 0) { fetchSize = configuration().getQueryOptions().getFetchSize(); throw new UnsupportedFeatureException(protocolVersion, "Binary values are not supported"); throw new UnsupportedFeatureException(protocolVersion, "Named values are not supported"); throw new UnsupportedFeatureException(protocolVersion, "Protocol level batching is not supported");
if (protocolVersion.compareTo(ProtocolVersion.V3) < 0 && statement instanceof BatchStatement) { if (serialConsistency != null) throw new UnsupportedFeatureException(protocolVersion, "Serial consistency on batch statements is not supported"); } else if (serialConsistency == null) serialConsistency = configuration().getQueryOptions().getSerialConsistencyLevel(); throw new UnsupportedFeatureException(protocolVersion, "Custom payloads are only supported since native protocol V4"); fetchSize = -1; else if (fetchSize != Integer.MAX_VALUE) throw new UnsupportedFeatureException(protocolVersion, "Paging is not supported"); } else if (fetchSize <= 0) { fetchSize = configuration().getQueryOptions().getFetchSize(); throw new UnsupportedFeatureException(protocolVersion, "Binary values are not supported"); throw new UnsupportedFeatureException(protocolVersion, "Named values are not supported"); throw new UnsupportedFeatureException(protocolVersion, "Protocol level batching is not supported");
if (protocolVersion.compareTo(ProtocolVersion.V3) < 0 && statement instanceof BatchStatement) { if (serialConsistency != null) throw new UnsupportedFeatureException(protocolVersion, "Serial consistency on batch statements is not supported"); } else if (serialConsistency == null) serialConsistency = configuration().getQueryOptions().getSerialConsistencyLevel(); throw new UnsupportedFeatureException(protocolVersion, "Custom payloads are only supported since native protocol V4"); fetchSize = -1; else if (fetchSize != Integer.MAX_VALUE) throw new UnsupportedFeatureException(protocolVersion, "Paging is not supported"); } else if (fetchSize <= 0) { fetchSize = configuration().getQueryOptions().getFetchSize(); throw new UnsupportedFeatureException(protocolVersion, "Binary values are not supported"); throw new UnsupportedFeatureException(protocolVersion, "Named values are not supported"); throw new UnsupportedFeatureException(protocolVersion, "Protocol level batching is not supported");