0

Hey i try to do the first steps with Casssandra trigger. The trigger should only get the mutation and write it to a simple .txt file nothing more nothing less. Everytime i do an isert i get the following Error: java.lang.AbstractMethodError: org.apache.cassandra.triggers.invertedindex.augment(Lorg/apache/cassandra/db/partitions/Partition;)Ljava/util/Collection

The code is from a example i found in the internet.

public class invertedindex implements ITrigger

{ // private static final Logger logger = LoggerFactory.getLogger(invertedindex.class); private Properties properties = loadProperties(); //private Object array;

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;
}

}

What i am doing wrong here? And is there more information about Casssandra trigger anywere? I only found some old stuff?

1 Answer 1

1

It looks like you are using Cassandra 3.x but have written a trigger for pre-3.x. Your trigger should be implementing the:

    public Collection<Mutation> augment(Partition update);

method.

Take a look at the trigger example here for how to implement a 3.x trigger.

Sign up to request clarification or add additional context in comments.

1 Comment

This is very useful but do you know with the new 3.x way to fetch all the modified cells/columns?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.