0

I'm trying to use CQLSSTableWriter by following the simple example given in the Cassandra blog.

My project dependencies are:

compile 'org.codehaus.groovy:groovy-all:2.3.11'
compile 'com.datastax.cassandra:cassandra-driver-core:2.1.9'
compile 'org.apache.cassandra:cassandra-all:2.2.4'

testCompile group: 'junit', name: 'junit', version: '4.11'

Here is my code:

Application.groovy

package com.example

import org.apache.cassandra.io.sstable.CQLSSTableWriter

class Application {


    public static void main(String[] args) {

        def schema = """create table example.new_table (
            name ascii,
            value ascii
            PRIMARY KEY (name));"""

        def insert = """INSERT INTO example.new_table
                       (name, value)
                      VALUES ( ?, ? )"""

        def outputDir = "/Users/me/datadump"

        def writer = CQLSSTableWriter.builder()
                .inDirectory(outputDir)
                .forTable(schema)
                .using(insert)
                .build()


        writer.close()
    }
}

This code results in the following exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.apache.cassandra.cql3.QueryProcessor.getStatement(QueryProcessor.java:491)
    at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.getStatement(CQLSSTableWriter.java:514)
    at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.forTable(CQLSSTableWriter.java:361)
    at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder$forTable$0.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at com.example.Application.main(Application.groovy:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.RuntimeException: java.net.UnknownHostException: COMP: COMP: nodename nor servname provided, or not known
    at org.apache.cassandra.utils.FBUtilities.getLocalAddress(FBUtilities.java:136)
    at org.apache.cassandra.tracing.Tracing.<init>(Tracing.java:81)
    at org.apache.cassandra.tracing.Tracing.<clinit>(Tracing.java:87)
    ... 13 more
Caused by: java.net.UnknownHostException: COMP: COMP: nodename nor servname provided, or not known
    at java.net.InetAddress.getLocalHost(InetAddress.java:1475)
    at org.apache.cassandra.utils.FBUtilities.getLocalAddress(FBUtilities.java:131)
    ... 15 more
Caused by: java.net.UnknownHostException: COMP: nodename nor servname provided, or not known
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1295)
    at java.net.InetAddress.getLocalHost(InetAddress.java:1471)
    ... 16 more

Process finished with exit code 1

All the examples of using CQLSSTableWriter look pretty much exactly like my code. Do I have a version conflict with my dependencies? I'm thinking maybe because the exception is telling me that it can't even load the Tracing class.

FGreg
  • 14,110
  • 10
  • 68
  • 110

1 Answers1

0

Followed the suggestion found here https://stackoverflow.com/a/1881967/953327 which solves the immediate problem.

I needed to add an entry to my /etc/hosts file.

Community
  • 1
  • 1
FGreg
  • 14,110
  • 10
  • 68
  • 110
  • While this solves the posted exception; it seems like it should not be necessary for me to accomplish the given task. – FGreg Jan 26 '16 at 00:28