活动架构更改时发生Cassandra异常
对于我们的项目,我们需要实时模式更改。为了这些目的,我们创建了测试。它在cassandra中添加和删除表<代码>我在datastax驱动程序中使用了10个线程。但是我在一些线程中遇到了这个异常 线程“thread-7”中的异常 com.datastax.driver.core.exceptions.NoHostAvailableException:所有 尝试查询的主机失败(尝试:localhost/127.0.0.1 (com.datastax.driver.core.exceptions.DriverException:运行期间超时 阅读) 卡桑德拉还活着。我仍然可以执行抛出cqlsh的查询。 线程不会失败。线程可以添加表,然后突然记录此异常并再次添加表。异常可以在一个线程中出现多次。 每个线程都有自己的会话 望着卡桑德拉·亚马尔的:活动架构更改时发生Cassandra异常,cassandra,Cassandra,对于我们的项目,我们需要实时模式更改。为了这些目的,我们创建了测试。它在cassandra中添加和删除表我在datastax驱动程序中使用了10个线程。但是我在一些线程中遇到了这个异常 线程“thread-7”中的异常 com.datastax.driver.core.exceptions.NoHostAvailableException:所有 尝试查询的主机失败(尝试:localhost/127.0.0.1 (com.datastax.driver.core.exceptions.Driver
concurrent_writes and reads = 32
在cassandra-env.sh中增加MAX\u HEAP\u SIZE和HEAP\u NEWSIZE对我没有帮助
卡桑德拉版本2.0.7
有人能建议怎么处理吗
public class AddTableThread extends Thread {
private Cluster cluster;
private Session session;
private final String KEYSPACE = "cas";
private final String HOST = "localhost";
private final int PORT = 9042;
private boolean isRunning = true;
// counter for the added tables
private int i = 0;
// Number of the tables that thread has to add
private int fin = -2;
public AddTableThread() {
connect();
}
public AddTableThread setTablesCount(int f) {
this.fin = f;
System.out.println(this.getName() + " : must add " + fin + " tables");
return this;
}
@Override
public void run() {
System.out.println(this.getName() + " : starting thread \n");
while (isRunning) {
String name = createName();
try {
session.execute(createTableQuery(name));
System.out.println(this.getName() + " : table is created "
+ name);
i++;
} catch (com.datastax.driver.core.exceptions.NoHostAvailableException e) {
System.out
.println("\n\n" + this.getName() + "!!!!FAILED!!!!!!");
System.out.println(this.getName() + " : added " + i + " tables");
System.out.println(this.getName() + " : table " + name
+ " wasn't added");
}
try {
Thread.sleep((new Random().nextInt(5000)));
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (i == fin) {
isRunning = false;
}
}
close();
log();
}
// creates query that creates table in keyspace with name tableName
private String createTableQuery(String tableName) {
return "CREATE TABLE cas." + tableName
+ "(id timeuuid PRIMARY KEY, text varchar, value int);";
}
public void finish() {
isRunning = false;
}
private void log() {
System.out.println("\n" + this.getName() + " : finish");
System.out.println(this.getName() + " : added " + i + " tables");
System.out.println("_____________________\n");
}
// generates unique table name
private String createName() {
return "cf_" + UUIDGen.getTimeUUID().toString().replace("-", "_");
}
private void connect() {
SocketOptions so = new SocketOptions();
so.setConnectTimeoutMillis(20000);
so.setReadTimeoutMillis(20000);
cluster = Cluster.builder().withSocketOptions(so).addContactPoint(HOST)
.withPort(PORT).build();
session = cluster.connect(KEYSPACE);
}
private void close() {
session.close();
cluster.close();
}
}
创造需要时间。因此,尝试增加:
读取请求超时时间单位:5000
及
请求超时(单位:10000)
并尝试取消注释
rpc_最大线程数:2048
尝试使用这些参数。我只是尝试使用这些参数,但这对我没有帮助。请问:datastax驱动程序是否对连接超时、读取超时进行了一些配置设置,。。?试着朝这个方向看。可能客户端在从Cassandra读取响应之前断开连接。每个线程都连接到Cassandra线程。但是,它会在异常之后创建表。为什么会话仍然有效?我构建了具有connectTimeOut 20s和相同readTimeout的集群。首先,我认为一切都好。但是当添加了太多的表时,错误会重复出现。我清除了db并增加了线程的数量。异常再次出现。。。好像是内存错误,请把你的源代码发到某个地方。Tanya,我对你的代码没有任何问题。所以,我不知道该给你什么建议。也许你需要试试别的司机。。。阿斯蒂亚纳克斯,赫克托,。。我对您的代码进行了非常小的更改,并使用了Cassandra 2.0.6。您可以从这里下载所有内容(IntelliJ IDEA项目和Cassandra):Tanya,您找到解决方案了吗。我们也面临同样的问题。