0

Astyanaxを使用して単純なCql3クエリを実行しようとしましたが、エラーが発生し続けます。

目的は、cql3を使用してAstyanaxを介して単純なテーブルを作成することです。

public class SomeTest {

private AstyanaxContext<Keyspace> astyanaxContext;
private Keyspace keyspace;

private static String CREATE_TABLE_QUERY = "CREATE TABLE top_items (\n" +
        "  categoryName varchar,\n" +
        "  type varchar,\n" +
        "  baseItemId int,\n" +
        "  margin float,\n" +
        "  ds timestamp,\n" +
        "  PRIMARY KEY (categoryName, ds)\n" +
        ");";

@Before
public void setUp() {
    try {
        this.astyanaxContext = new AstyanaxContext.Builder()
                .forCluster("ClusterName")
                .forKeyspace("new_examples")
                .withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.NONE).setCqlVersion("3.0.0"))
                .withConnectionPoolConfiguration(
                        new ConnectionPoolConfigurationImpl("MyConnectionPool").setMaxConnsPerHost(1).setPort(9160)
                                .setSeeds("localhost:9160")).withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
                .buildKeyspace(ThriftFamilyFactory.getInstance());

        this.astyanaxContext.start();
        this.keyspace = this.astyanaxContext.getEntity();
        // Using simple strategy
        keyspace.createKeyspace(ImmutableMap.<String, Object>builder()
                .put("strategy_options", ImmutableMap.<String, Object>builder()
                        .put("replication_factor", "1")
                        .build())
                .put("strategy_class",     "SimpleStrategy")
                .build()
        );

        // test the connection
        this.keyspace.describeKeyspace();
    } catch (Throwable e) {
        throw new RuntimeException("Failed to prepare CassandraBolt", e);
    }
}

@Test
public void testWrite() throws ConnectionException {
    ColumnFamily<String, String> CQL3_CF = ColumnFamily.newColumnFamily(
            "Cql3CF",
            StringSerializer.get(),
            StringSerializer.get());

    OperationResult<CqlResult<String, String>> result;
    result = keyspace
            .prepareQuery(CQL3_CF)
            .withCql(CREATE_TABLE_QUERY)
            .execute();
}
}

テストを実行すると、このスタックトレースが取得されます

java.lang.NoSuchMethodError: org.apache.thrift.meta_data.FieldValueMetaData.<init>(BZ)V
at org.apache.cassandra.thrift.Cassandra$execute_cql_query_args.<clinit>(Cassandra.java:32588)
at org.apache.cassandra.thrift.Cassandra$Client.send_execute_cql_query(Cassandra.java:1393)
at org.apache.cassandra.thrift.Cassandra$Client.execute_cql_query(Cassandra.java:1387)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6$1.internalExecute(ThriftColumnFamilyQueryImpl.java:699)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6$1.internalExecute(ThriftColumnFamilyQueryImpl.java:696)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:55)
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:27)
at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$1.execute(ThriftSyncConnectionFactoryImpl.java:136)
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:69)
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:248)
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$6.execute(ThriftColumnFamilyQueryImpl.java:694)
at storage.cassandra.daos.SomeTest.testWrite(SomeTest.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
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.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.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:76)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

「com.netflix.astyanax」%「astyanax」%「1.56.18」を使用しています。

助けてください。

4

1 に答える 1

1

AstyanaxはCassandra1.2または1.2.1を適切にサポートしていないようです(7日前にリリースされた1.56.24でもありません...)。代わりにjava-driverを試すことができます。まだリリースされていませんが、私がテストした限りでは問題なく動作します。 https://github.com/datastax/java-driver

于 2013-02-01T19:04:34.853 に答える