Merge branch cassandra-2.2 into cassandra-3.0

This commit is contained in:
Benjamin Lerer 2015-12-16 15:19:20 +01:00
commit 363e7bd716
8 changed files with 185 additions and 4 deletions

View File

@ -1,5 +1,6 @@
3.0.3
Merged from 2.2:
* Add new types to Stress (CASSANDRA-9556)
* Add property to allow listening on broadcast interface (CASSANDRA-9748)
* Fix regression in split size on CqlInputFormat (CASSANDRA-10835)
* Better handling of SSL connection errors inter-node (CASSANDRA-10816)

View File

@ -555,6 +555,14 @@ public class StressProfile implements Serializable
return new UUIDs(name, config);
case TIMEUUID:
return new TimeUUIDs(name, config);
case TINYINT:
return new TinyInts(name, config);
case SMALLINT:
return new SmallInts(name, config);
case TIME:
return new Times(name, config);
case DATE:
return new LocalDates(name, config);
case SET:
return new Sets(name, getGenerator(name, type.getTypeArguments().get(0), config), config);
case LIST:

View File

@ -0,0 +1,43 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.cassandra.stress.generate.values;
import com.datastax.driver.core.LocalDate;
import org.apache.cassandra.db.marshal.SimpleDateType;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
public class LocalDates extends Generator<Integer>
{
public LocalDates(String name, GeneratorConfig config)
{
super(SimpleDateType.instance, config, name, Integer.class);
}
public Integer generate()
{
return (int)identityDistribution.next();
}
}

View File

@ -0,0 +1,38 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.cassandra.stress.generate.values;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.ShortType;
public class SmallInts extends Generator<Short>
{
public SmallInts(String name, GeneratorConfig config)
{
super(ShortType.instance, config, name, Short.class);
}
public Short generate()
{
long seed = identityDistribution.next();
return (short)seed;
}
}

View File

@ -0,0 +1,37 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.cassandra.stress.generate.values;
import org.apache.cassandra.db.marshal.AbstractType;
import org.apache.cassandra.db.marshal.TimeType;
public class Times extends Generator<Long>
{
public Times(String name, GeneratorConfig config)
{
super(TimeType.instance, config, name, Long.class);
}
public Long generate()
{
return identityDistribution.next();
}
}

View File

@ -0,0 +1,45 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
package org.apache.cassandra.stress.generate.values;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.apache.cassandra.db.marshal.ByteType;
import org.apache.cassandra.db.marshal.DecimalType;
import org.apache.cassandra.db.marshal.IntegerType;
import org.apache.cassandra.db.marshal.ShortType;
import org.apache.cassandra.stress.generate.FasterRandom;
public class TinyInts extends Generator<Byte>
{
public TinyInts(String name, GeneratorConfig config)
{
super(ByteType.instance, config, name, Byte.class);
}
public Byte generate()
{
long seed = identityDistribution.next();
return (byte)seed;
}
}

View File

@ -28,15 +28,15 @@ import java.util.List;
import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.DataType;
import com.datastax.driver.core.LocalDate;
import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.ResultSet;
import org.apache.cassandra.db.ConsistencyLevel;
import org.apache.cassandra.stress.Operation;
import org.apache.cassandra.stress.generate.Row;
import org.apache.cassandra.stress.settings.StressSettings;
import org.apache.cassandra.stress.util.JavaDriverClient;
import org.apache.cassandra.stress.util.Timer;
import org.apache.cassandra.thrift.CqlResult;
import org.apache.cassandra.transport.SimpleClient;
public abstract class SchemaStatement extends Operation
@ -47,6 +47,7 @@ public abstract class SchemaStatement extends Operation
final ConsistencyLevel cl;
final int[] argumentIndex;
final Object[] bindBuffer;
final ColumnDefinitions definitions;
public SchemaStatement(Timer timer, StressSettings settings, DataSpec spec,
PreparedStatement statement, Integer thriftId, ConsistencyLevel cl)
@ -57,8 +58,9 @@ public abstract class SchemaStatement extends Operation
this.cl = cl;
argumentIndex = new int[statement.getVariables().size()];
bindBuffer = new Object[argumentIndex.length];
definitions = statement.getVariables();
int i = 0;
for (ColumnDefinitions.Definition definition : statement.getVariables())
for (ColumnDefinitions.Definition definition : definitions)
argumentIndex[i++] = spec.partitionGenerator.indexOf(definition.getName());
statement.setConsistencyLevel(JavaDriverClient.from(cl));
@ -68,7 +70,13 @@ public abstract class SchemaStatement extends Operation
{
for (int i = 0 ; i < argumentIndex.length ; i++)
{
bindBuffer[i] = row.get(argumentIndex[i]);
Object value = row.get(argumentIndex[i]);
if (definitions.getType(i).getName().equals(DataType.date().getName()))
{
// the java driver only accepts com.datastax.driver.core.LocalDate for CQL type "DATE"
value= LocalDate.fromDaysSinceEpoch((Integer) value);
}
bindBuffer[i] = value;
if (bindBuffer[i] == null && !spec.partitionGenerator.permitNulls(argumentIndex[i]))
throw new IllegalStateException();
}

View File

@ -115,6 +115,7 @@ public class JavaDriverClient
.withPort(port)
.withPoolingOptions(poolingOpts)
.withoutJMXReporting()
.withProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED)
.withoutMetrics(); // The driver uses metrics 3 with conflict with our version
if (whitelist != null)
clusterBuilder.withLoadBalancingPolicy(whitelist);