Created
February 1, 2012 18:18
-
-
Save itissid/1718436 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.my.project; | |
import java.util.Iterator; | |
import org.apache.cassandra.thrift.Cassandra.Client; | |
import com.netflix.astyanax.AstyanaxContext; | |
import com.netflix.astyanax.Keyspace; | |
import com.netflix.astyanax.connectionpool.ConnectionPool; | |
import com.netflix.astyanax.connectionpool.NodeDiscoveryType; | |
import com.netflix.astyanax.connectionpool.OperationResult; | |
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; | |
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl; | |
import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor; | |
import com.netflix.astyanax.impl.AstyanaxConfigurationImpl; | |
import com.netflix.astyanax.model.ColumnFamily; | |
import com.netflix.astyanax.model.CqlResult; | |
import com.netflix.astyanax.model.Row; | |
import com.netflix.astyanax.serializers.StringSerializer; | |
import com.netflix.astyanax.shallows.EmptyKeyspaceTracerFactory; | |
import com.netflix.astyanax.thrift.ThriftFamilyFactory; | |
import com.netflix.astyanax.thrift.ThriftKeyspaceImpl; | |
public class MyMigration { | |
public void doMigration(){ | |
AstyanaxContext<Keyspace> keyspace = new AstyanaxContext.Builder() | |
.forCluster("Test Cluster") | |
.forKeyspace("XYZService") | |
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl() | |
.setDiscoveryType(NodeDiscoveryType.NONE) | |
) | |
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool") | |
.setPort(9160) | |
.setMaxConnsPerHost(1) | |
.setSeeds("localhost:9160") | |
) | |
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor()) | |
.buildKeyspace(ThriftFamilyFactory.getInstance());// EXCEPTION CAUGHT HERE... | |
ColumnFamily<String, String> cf= new ColumnFamily("NewCF", new StringSerializer(), new StringSerializer()); | |
Keyspace k = new ThriftKeyspaceImpl(keyspace.getKeyspaceName(), (ConnectionPool<Client>) keyspace.getConnectionPool(), keyspace.getAstyanaxConfiguration(), EmptyKeyspaceTracerFactory.instance); | |
try { | |
OperationResult<CqlResult<String, String>> result | |
= k.prepareQuery(cf).withCql("CREATE COLUMNFAMILY users ( KEY varchar PRIMARY KEY, password varchar);") | |
.execute(); | |
for (Iterator<Row<String, String>> iterator = result.getResult().getRows().iterator(); iterator.hasNext();) { | |
Row<String, String> type = iterator.next(); | |
} | |
} catch (ConnectionException e) { | |
} | |
} | |
} | |
========SEPARATE TEST CLASS==== | |
package com.my.project; | |
import org.junit.Test; | |
import com.my.project.MyMigration; | |
public class TestMigration { | |
@Test | |
public void testMigration(){ | |
MyMigration km = new MyMigration(); | |
km.doMigration(); | |
} | |
} | |
=================TRACE===================== | |
java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.expireAfterWrite(JLjava/util/concurrent/TimeUnit;)Lcom/google/common/collect/MapMaker; from class com.netflix.astyanax.thrift.ThriftKeyspaceImpl | |
at com.netflix.astyanax.thrift.ThriftKeyspaceImpl.<init>(ThriftKeyspaceImpl.java:75) | |
at com.netflix.astyanax.thrift.ThriftFamilyFactory.createKeyspace(ThriftFamilyFactory.java:28) | |
at com.netflix.astyanax.AstyanaxContext$Builder.buildKeyspace(AstyanaxContext.java:136) | |
at com.my.project.migration.MyMigration.doMigration(MyMigration.java:39) | |
at com.my.project.altnode.TestMigration.testMigration(TestMigration.java:11) | |
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:616) | |
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) | |
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) | |
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) | |
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) | |
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) | |
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) | |
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) | |
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) | |
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) | |
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) | |
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) | |
at org.junit.runners.ParentRunner.run(ParentRunner.java:300) | |
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) | |
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) | |
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment