cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marko Dinic <hacker.ma...@gmail.com>
Subject com/datastax/driver/core/policies/LoadBalancingPolicy
Date Thu, 04 Jun 2015 11:35:57 GMT
Hello everyone,

I'm new to Cassandra and I'm trying to use it as input for Hadoop.

For some reason I'm getting the following exception while trying to use
Cassandra as input to Hadoop

    Exception in thread "main" java.lang.NoClassDefFoundError:
com/datastax/driver/core/policies/LoadBalancingPolicy

Here is the code

    public class CDriver extends Configured implements Tool{

    public static void main(String[] args) throws IOException,
InterruptedException, ClassNotFoundException, Exception
    {
        Configuration conf = new Configuration();

        ToolRunner.run(new CDriver(), args);
    }

    @Override
    public int run(String[] args) throws Exception {

        String output = args[0];

        Configuration conf = super.getConf();

        Job job = new Job(conf);

        job.setJarByClass(CDriver.class);
        job.setJobName("Cassandra as input");

        ConfigHelper.setInputInitialAddress(conf, "127.0.0.1");
        ConfigHelper.setInputColumnFamily(conf, "basketball", "nba");
        ConfigHelper.setInputPartitioner(conf, "Murmur3Partitioner");
        CqlConfigHelper.setInputCQLPageRowSize(conf, "3");
        job.setInputFormatClass(CqlInputFormat.class);

        FileOutputFormat.setOutputPath(job, new Path(output));

        job.setMapperClass(CMapper.class);
        job.setReducerClass(CReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(IntWritable.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);

        job.waitForCompletion(true);

        return 0;
    }
}

It goes off on the following line

    CqlConfigHelper.setInputCQLPageRowSize(conf, "3");

And here are the Maven dependencies:

        <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.nissatech</groupId>
        <artifactId>TestingCassandra</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <maven.compiler.source>1.7</maven.compiler.source>
            <maven.compiler.target>1.7</maven.compiler.target>
        </properties>
        <dependencies>
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-core</artifactId>
                <version>1.2.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.cassandra</groupId>
                <artifactId>cassandra-all</artifactId>
                <version>2.1.5</version>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>

<mainClass>com.nissatech.testingcassandra.CDriver</mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>
                                jar-with-dependencies
                            </descriptorRef>
                        </descriptorRefs>
                    </configuration>
                    <executions>
                        <execution>
                            <id>make-assembly</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>
Can anyone explain what is the problem? I have Cassandra running on
localhost.

When I tried adding this dependency additionally

         <dependency>
            <groupId>com.datastax.cassandra</groupId>
            <artifactId>cassandra-driver-mapping</artifactId>
            <version>2.1.5</version>
          </dependency>

I've got the following exception while running from NetBeans

Exception in thread "main" java.lang.UnsupportedOperationException: you
must set the keyspace and columnfamily with setInputColumnFamily()

While when running in pseudo-distributed mode I get the same exception like
before.

I'm really confused, everything seems ok, but it doesn't work. What seems
to be the problem?

-- 
Marko

Mime
View raw message