Триггер Кассандры java.lang.AbstractMethodError

Эй, я пытаюсь сделать первые шаги с триггером 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? Я нашел только некоторые старые вещи?


person Emlon    schedule 24.05.2016    source источник


Ответы (1)


Похоже, вы используете Cassandra 3.x, но написали триггер для версий до 3.x. Ваш триггер должен реализовывать:

    public Collection<Mutation> augment(Partition update);

метод.

Взгляните на пример триггера здесь, чтобы узнать, как реализовать 3. х триггер.

person mikea    schedule 24.05.2016
comment
Это очень полезно, но знаете ли вы о новом способе 3.x получить все измененные ячейки/столбцы? - person im2kul; 07.02.2018