我正在测试通过Hector与Cassandra数据库的连接。但是,当我运行Junit测试时,通常会收到以下消息:
java.lang.NoSuchFieldError:DEFAULT_MEMTABLE_THROUGHPUT_IN_MB
有人知道我做错了吗?
克里斯,谢谢你的帮助
-------------------------------------------------------------------------------
Test set: com.acolsolutions.trademaniac.CreateSchemaTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.287 sec <<< FAILURE!
testAddDropKeyspace(com.acolsolutions.trademaniac.CreateSchemaTest) Time elapsed: 0.218 sec <<< ERROR!
**java.lang.NoSuchFieldError: DEFAULT_MEMTABLE_THROUGHPUT_IN_MB**
at me.prettyprint.cassandra.service.ThriftCfDef.<init>(ThriftCfDef.java:119)
at me.prettyprint.hector.api.factory.HFactory.createColumnFamilyDefinition(HFactory.java:658)
at com.acolsolutions.trademaniac.CreateSchemaTest.testAddDropKeyspace(CreateSchemaTest.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:53)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:107)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:68)
代码如下:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.acolsolutions.trademaniac;
import org.junit.*;
import static org.junit.Assert.*;
import com.acolsolutions.trademaniac.migrations.Schema;
import java.net.UnknownHostException;
import java.util.Arrays;
import javassist.NotFoundException;
import me.prettyprint.cassandra.service.CassandraHostConfigurator;
import me.prettyprint.cassandra.service.ThriftCluster;
import me.prettyprint.cassandra.service.ThriftKsDef;
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
import me.prettyprint.hector.api.factory.HFactory;
import org.apache.thrift.TException;
import org.apache.thrift.transport.TTransportException;
/**
*
* @author charms
*/
public class CreateSchemaTest {
private ThriftCluster cassandraCluster;
private CassandraHostConfigurator cassandraHostConfigurator;
public CreateSchemaTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Before
public void setupCase() throws TTransportException, TException, IllegalArgumentException,
NotFoundException, UnknownHostException, Exception {
cassandraHostConfigurator = new CassandraHostConfigurator("localhost:9160");
cassandraCluster = new ThriftCluster("Test Cluster", cassandraHostConfigurator);
}
@After
public void tearDown() {
}
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
// @Test
// public void hello() {}
@Test
public void testAddDropKeyspace() throws Exception {
ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition("DynKeyspace", "DynCf");
cassandraCluster.addKeyspace(
new ThriftKsDef("DynKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef)));
String ksid2 = cassandraCluster.dropKeyspace("DynKeyspace");
assertNotNull(ksid2);
// Now let's wait for schema agreement.
cassandraCluster.addKeyspace(new ThriftKsDef("DynKeyspace", "org.apache.cassandra.locator.SimpleStrategy", 1, Arrays.asList(cfDef)), true);
ksid2 = cassandraCluster.dropKeyspace("DynKeyspace", true);
assertNotNull(ksid2);
}
}
似乎您正在使用Hector和Cassandra的不兼容版本。在最近的版本中,用于调整内存刷新的参数(例如DEFAULT_MEMTABLE_THROUGHPUT_IN_MB)已更改,以简化调整过程。如果您可以准确地告诉我们您使用的是哪种版本的Hector和Cassandra,事情可能会变得更加清晰…
我们一直在使用Spark RDD API(Spark 2.0)来处理在Cassandra.Note中建模的数据,这些数据在Cassandra中建模以实现高效的读写。 然而,现在还有SparkSQLAPI,Spark DataFrame API,它也是一种替代的数据访问方法-http://spark.apache.org/docs/latest/sql-programming-guide.html
对于我的应用程序的操作监视,我正在寻找类似于常用的“SQL连接验证”查询的东西 (顺便说一句:CQL甚至不接受“select1”作为有效查询。)
我使用的是spring数据cassandra,需要使用jpa映射一个字段,在cassandra中,该字段的类型为
我们运行的cassandra集群有3个节点,复制因子为2。 我们的nodejs服务器是查询这个集群的唯一地方。 是否有其他任何地方的参数设置可能导致不一致的查询? cassandra v2.2.4 nodejs驱动程序v3.0.0 编辑-添加我正在做的事情的示例: 1)检查用户名是否被占用 2)创建用户
我用Spring Data Cassandra 2.2.1开发了一个新的应用程序,想在Cassandra 2.1.9服务器上运行它(旧的,我知道)。但是我们得到了错误 Spring数据卡桑德拉手册声称Spring数据2.2.1至少需要卡桑德拉2.1,所以这应该有效,但它没有。我们包含的唯一特定于卡桑德拉的依赖项是 我怎样才能让这个工作?
我有这个代码: 我得到以下异常: 所有主机尝试查询失败(已尝试:/127.0.0.1:9042(com.datastax.driver.core.TransportException:[/127.0.0.1:9042]无法连接)),堆栈跟踪:com.datastax.driver.core.exceptions.NoHostAvailableException:所有主机尝试查询失败(已尝试:/12