【问题标题】:Cassandra Trigger java.lang.AbstractMethodErrorCassandra 触发器 java.lang.AbstractMethodError
【发布时间】:2016-05-24 23:34:29
【问题描述】:

嘿,我尝试使用 Casssandra 触发器执行第一步。触发器应该只获取突变并将其写入一个简单的 .txt 文件,仅此而已。 每次我做一个 isert 我得到以下错误: java.lang.AbstractMethodError: org.apache.cassandra.triggers.invertedindex.augment(Lorg/apache/cassandra/db/partitions/Partition;)Ljava/util/Collection

代码来自我在互联网上找到的一个示例。

public class invertedindex implements ITrigger

{ // private static final Logger logger = LoggerFactory.getLogger(invertedindex.class); 私有属性属性 = loadProperties(); //私有对象数组;

public void augment(ByteBuffer key, ColumnFamily update) throws IOException
{


        PrintWriter pWriter = null; 
        //long millis2;

       // List<RowMutation> mutations = new ArrayList<>();

        String indexKeySpace = properties.getProperty("keyspace");
        String indexColumnFamily = properties.getProperty("table");
        for (IColumn cell : update)
        {
            // Skip the row marker and other empty values, since they lead to an empty key.
            if (cell.value().remaining() > 0)
            {
                pWriter = new PrintWriter(new BufferedWriter(new FileWriter("log_trigger_test.txt",true)));
                RowMutation mutation = new RowMutation(indexKeySpace, cell.value());
               // mutation.add(properties.getProperty("columnfamily"), cell.name(), cell.value(), System.currentTimeMillis();
               // mutations.add(mutation);
               // mutation.addColumnOrSuperColumn(arg0, arg1);
                //System.out.println((mutation.toString()));
                pWriter.println((mutation.toString()));

            }
        }
        pWriter.close();
       // return mutations;

    }

private static Properties loadProperties()
{
    Properties properties = new Properties();
    InputStream stream = invertedindex.class.getClassLoader().getResourceAsStream("invertedindex.properties");
    try
    {
        properties.load(stream);
    }
    catch (Exception e)
    {
        throw new RuntimeException(e);
    }
    finally
    {
        FileUtils.closeQuietly(stream);
    }

    return properties;
}

}

我在这里做错了什么?还有关于 Casssandra 触发器的更多信息吗?我只发现了一些旧东西?

【问题讨论】:

    标签: java triggers cassandra


    【解决方案1】:

    看起来您正在使用 Cassandra 3.x,但为 pre-3.x 编写了触发器。您的触发器应该实现:

        public Collection<Mutation> augment(Partition update);
    

    方法。

    查看触发器示例here,了解如何实现 3.x 触发器。

    【讨论】:

    • 这非常有用,但是你知道用新的 3.x 方法来获取所有修改过的单元格/列吗?
    猜你喜欢
    • 2014-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-26
    • 2015-11-21
    • 2013-03-08
    • 1970-01-01
    相关资源
    最近更新 更多