hector-client / hector Goto Github PK
View Code? Open in Web Editor NEWa high level client for cassandra
Home Page: http://prettyprint.me/2010/02/23/hector-a-java-cassandra-client/
License: MIT License
a high level client for cassandra
Home Page: http://prettyprint.me/2010/02/23/hector-a-java-cassandra-client/
License: MIT License
See this discussion on the Cassandra mailing list:
http://markmail.org/thread/uah6b4gxjxgic7co
It's recommended that Cassandra clients default to using microseconds for the column timestamps. Currently, Hector appears to be using System.currentTimeMillis() as the timestamp. While Java doesn't provide a way to get microseconds, the value in System.currentTimeMillis() should be multiplied by 1000 before being used as a timestamp for compatibility.
In KeyspaceImpl.getRangeSlice, the result is put into a HashMap, thus we loose the iteration order of the Range.
The result should be put into a LinkedHashMap
(note : remove diff)
There should only be one connection pool per host.
However, hector creates two. one of the pools is by dns host name and the other is by ip address.
See example below.
PoolNames = ( 192.168.252.61(192.168.252.61):9160, cass61.nydc1.outbrain.com(192.168.252.61):9160 );
In your comment to the bug I reported you mentioned cassandra 0.6. The git master branch is for cassandra 0.5. Is there a version for cassandra 0.6?
The default hectorLog4j.xml file uses the "org.perf4j.TimingLogger" logger. Unfortunately the use of this conflicts with others who might be using perf4j, and forces them to use their own Logger.
A better idea might be to use "me.prettyprint.hector.TimingLogger" for the logger name and make Hector internal code use that instead.
When calling client.getKeyspace('Keyspace1'), working with the keyspace, then returning the client to the pool via pool.releaseClient(client), If then restarting the cassandra server, and try get the pool, client and keyspace again as above, it will fail each time with the following exception below.
org.apache.thrift.transport.TTransportException: Cannot write to null outputStream
at org.apache.thrift.transport.TIOStreamTransport.write(TIOStreamTransport.java:137)
at org.apache.thrift.protocol.TBinaryProtocol.writeI32(TBinaryProtocol.java:152)
at org.apache.thrift.protocol.TBinaryProtocol.writeMessageBegin(TBinaryProtocol.java:80)
at org.apache.cassandra.service.Cassandra$Client.send_describe_keyspace(Cassandra.java:747)
at org.apache.cassandra.service.Cassandra$Client.describe_keyspace(Cassandra.java:741)
at me.prettyprint.cassandra.service.CassandraClientImpl.getKeyspace(CassandraClientImpl.java:123)
at me.prettyprint.cassandra.service.CassandraClientImpl.getKeyspace(CassandraClientImpl.java:106)
The reason for this was that my assumption was that if one connection to host x failed, then all connections to this host will fail, so there's no point trying to reconnet to the same host.
In the case of a ring that has many hosts (in your case there is only one, but usually cassandra has many hosts in a ring) this would result in a connection to a new and different host from the ring.
In your case, as you demonstrated, it's indeed possible that a connection to x fails, but another, new connection, to the same host x will succeed. I'll get this fix in the code, just have to watch out for infinite connection retry loops...
The 1st getSuperColumn() method returns null when the key is not found. However the 2nd getSuperColumn() method does not return null. This is due to the use of get_slice() which does not throw NotFoundException, but instead returns an empty list.
In the function:
public SuperColumn getSuperColumn(final String key, final ColumnPath columnPath,final boolean reversed, final int size)
The list returned from get_slice() should be checked to see if it is empty.
if (cosc.isEmpty()) { return null; }
Sometimes it's negative...
NumActive = -621;
WTF?
This is a small enhancement request:
Maletas to hector-dev
Can we set the timeout programmatically instead of using an env.
variable?
Carlos
There are some cases where getPackage() on the Class file can return a null, so the constructor for JmxMonitor() throws an uncaught NullPointerException. This can occur should hector/Cassandra be used within a GridGain job. Solution is to include a catch for a NPE in the error chain, as well as check for a null response from a getPackage() method call.
Currently the provided example DAO's are a good starting point for learning the basics of Hector and Cassandra. More advanced DAO objects that persist primitive data types would be useful. This would give users an example of how to persist and read data from the different data types.
Move operateWithFailover and operateWithFailoverSingleIteration from KeyspaceImpl to CassandraClientImpl. Leave keyspace with a clear skelton to package the thrift api.
If the users don't want to use KeyspaceImpl, they can use CassandraClientImpl still.
Mishail to hector-dev:
Why Hector internally uses cassandra.get_slice() inside of its
KeyspaceImpl.getSuperColumn() instead of just cassandra.get()?
Moreover, current implementation of KeyspaceImpl.getSuperColumn()
will always return not-null result, even if no such SuperColumn
exist (http://github.com/rantav/hector/blob/0.6.0/src/main/java/me/
prettyprint/cassandra/service/KeyspaceImpl.java#L305). That's not what
I expect...
mvn test is ok, but ant test is not, for example in 0.5.1 or 0.6.0
$ git co 0.6.0
$ ant test
Buildfile: build.xml
compile:
[mkdir] Created dir: /Users/ran/dev/cassandra/hector/target/classes
[javac] Compiling 20 source files to /Users/ran/dev/cassandra/hector/target/classes
compile-tests:
[mkdir] Created dir: /Users/ran/dev/cassandra/hector/target/test-classes
[javac] Compiling 6 source files to /Users/ran/dev/cassandra/hector/target/test-classes
[copy] Copying 3 files to /Users/ran/dev/cassandra/hector/target/test-classes
test:
[mkdir] Created dir: /Users/ran/dev/cassandra/hector/target/test-reports
[junit] java.util.zip.ZipException: error in opening zip file
[junit] at java.util.zip.ZipFile.open(Native Method)
[junit] at java.util.zip.ZipFile.(ZipFile.java:114)
[junit] at java.util.zip.ZipFile.(ZipFile.java:131)
[junit] at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1028)
[junit] at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.findNextResource(AntClassLoader.java:147)
[junit] at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.(AntClassLoader.java:109)
[junit] at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:975)
[junit] at java.lang.ClassLoader.getResources(ClassLoader.java:1078)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.checkForkedPath(JUnitTask.java:1126)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeAsForked(JUnitTask.java:1013)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:834)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1785)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:785)
[junit] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[junit] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[junit] at java.lang.reflect.Method.invoke(Method.java:597)
[junit] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[junit] at org.apache.tools.ant.Task.perform(Task.java:348)
[junit] at org.apache.tools.ant.Target.execute(Target.java:357)
[junit] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[junit] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
[junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
[junit] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
[junit] at org.apache.tools.ant.Main.runBuild(Main.java:758)
[junit] at org.apache.tools.ant.Main.startAnt(Main.java:217)
[junit] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[junit] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
[junit] Running me.prettyprint.cassandra.dao.ExampleDaoTest
[junit] Testsuite: me.prettyprint.cassandra.dao.ExampleDaoTest
[junit] Running me.prettyprint.cassandra.dao.ExampleDaoTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
BUILD FAILED
/Users/ran/dev/cassandra/hector/build.xml:123: Test me.prettyprint.cassandra.dao.ExampleDaoTest failed (crashed)
Total time: 4 seconds
For example CassandraClientImpl.getKeyspace will fail fast if the server it connected to is down.
Have to search the code if there are more calls like that
The hectorLog4j.xml file and the code that loads it should be provided in documentation as "You may want to do this to configure Log4j..." and absolutely not steal the perf4j logger the way that it does.
The effect of the current code is to steal the perf4j logger from any previous configuration, meaning that no other components in the application that load before Hector can use perf4j.
It is bad practice in general to short-circuit or override the discovery and loading mechanisms of a common platform library, e.g., Log4j...
from Patricio Echagüe on hector-users:
CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator("localhost:9170,localhost:9171,localhost:9172");
cassandraHostConfigurator.setMaxActive(20);
cassandraHostConfigurator.setMaxIdle(5);
cassandraHostConfigurator.setCassandraThriftSocketTimeout(3000);
cassandraHostConfigurator.setMaxWaitTimeWhenExhausted(4000);
cassandraHostConfigurator.setExhaustedPolicy(ExhaustedPolicy.WHEN_EXHAUSTED_GROW);
CassandraClientPool cassandraClientPool = CassandraClientPoolFactory.INSTANCE.createNew(cassandraHostConfigurator);
to create the pool with the know host at that point in time.
Later, a new Cassandra node is added to the ring. The code below shows that when a new node is added, the CassandraClientPoolByHost does not exist and so it is created by calling new CassandraClientPoolByHostImpl(cassandraHost, this, clientMonitor);
But that line does not include the already created CassandraHostConfigurator to create the CassandraClient in the same way.
public CassandraClientPoolByHost getPool(CassandraHost cassandraHost) {
CassandraClientPoolByHost pool = pools.get(cassandraHost);
if (pool == null) {
synchronized (pools) {
pool = pools.get(cassandraHost);
if (pool == null) {
pool = new CassandraClientPoolByHostImpl(cassandraHost, this, clientMonitor);
pools.put(cassandraHost, pool);
log.debug("GenerigObjectPool created: {} {}", pool, pool.hashCode());
}
}
}
return pool;
}
A workaround I see is to re-create the pools again but that involves to remove all the existing ones and create them again (which is not good to me).
Am I missing anything in this picture?
Is there any way to tell CassandraClientPoolFactory that there is a new host and the clients should be created in the same way than the existing ones?
We are using Hector 0.6 and the Command support.
I am testing failover logic using the ExampleClient.
(1) In KeySpaceImpl.operateWithFailoverSingleIteration(), the client that is being written to has gone down.
(2) This causes a TTransportException to be thrown. This is the first attempt, so isFirst=true, and therefore we call skipToNextHost( isRetrySameHostAgain=true ).
(3) In skipToNextHost () the current client connection is invalidated.
(4) Since isRetrySameHostAgain=true, we then try to create a client to the failed host again!
(5) This of course fails, and throws a TException which is caught in operateWithFailover() and ultimately re-thrown back out to ExampleClient.
(6) If I run it in the debugger and manually set isFirst=false to force skipToNextHost() to be called with isRetrySameHostAgain=false, the retry logic works as expected.
CassandraClientPoolFactory has a createNew() method that takes a CassandraHostConfigurator, but the CassandraClientPoolFactory private constructor calls the noargs createNew() method. So I guess this means that if I want to do the following:
CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.createNew( config );
to create a pool with an initialized CassandraHostConfigurator, unfortunately I will end up with 2 pools, one auto-created by the CassandraClientPoolFactory constructor, and one created by me.
I noticed that the 0.6 branch does not have the refactorings for CassandraHost. Are you planning to add those?
Currently hector uses the default thrift transport mechanism (non-framed).
It'd be nice to expose this as a configuration option so users may choose to use framed/non-framed.
I am running the mvn build and get the following error:
/Users/ender/JavaProjects/hector/src/main/java/me/prettyprint/cassandra/service/JmxMonitor.java:[27,63] illegal reference to static field from initializer
The line it's complaining about is:
private final Logger log = LoggerFactory.getLogger(JmxMonitor.class);
What I don't understand is that in eclipse there are no errors with the exact same code!
me.prettyprint.cassandra.service.JmxMonitor.java declares imports on
org.apache.log4j.xml.DOMConfigurator as well as
org.slf4j.Logger, org.slf4j.LoggerFactory.
the import on log4j prevents the usage of other slf4j backends then log4j.
It would be a huge enhancement if this dstatic dependency was replaced by some other means.
Need to do a few more checks and setup the msg accordingly for the exception to indicate specifics. Otherwise a bad value in the column_path will look like a configuration error.
I am trying to insert the data using hector client. Using only one host in the pool ie. localhost. like as follows
CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.get();
client = pool.borrowClient("localhost", 9160);
global = client.getKeyspace(keyspace, ConsistencyLevel.ONE);
After some(5-6) iterations of insertions of data (every 5 min insertion of about 40 MB of data), the program starts emitting this
10/06/27 09:55:28 WARN service.FailoverOperator: Got a TTransportException from localhost. Num of retries: 1
10/06/27 09:55:28 INFO service.FailoverOperator: Skipping to next host. Current host is: localhost
10/06/27 09:55:28 INFO service.FailoverOperator: Skipped host. New host is: localhost
I couldnt understand the reason for this, when im using only device in the pool. If i remove the ConsistencyLevel.ONE, then the error starts from the first iteration itself.
The same program through Thrift runs without any problems. Actually, i just modified the thrift program and replaced the calls to thrift api to corresponding Hector calls.
Thanks
Atul
I download 0.6.0 branch. ant javadoc, it report 1 error.
In PoolKey, in the constructor, there is a call to InetAddress#getHostName, which will perform a reverse name lookup. In my setup there is no DNS to resolve the ipaddresses so this will take several seconds and then return the ipaddress iself. Since a PoolKey is created at every call to borrowClient and releaseClient this will make the pool very slow, in fact unusable, if there is no DNS capable to resolve ipaddresses to names.
in KeyspaceImpl.java:86,
int size = (columnMap == null ? 0 : columnMap.size())
+ (columnMap == null ? 0 : columnMap.size());
should be:
int size = (columnMap == null ? 0 : columnMap.size())
+ (superColumnMap== null ? 0 : superColumnMap.size());
I plan to use perf4j to allow different performance metrics for the client operations:
Reads/sec
Writes/sec
Read mean time, write mean time
read max time, write max time
and maybe more...
For code that doesn't use the hector API, it would be nice if the same connection pool could be used - ie. a pool for Cassandra.Client rather than CassandraClient
Thus we cannot retrieve superColumn versions of get_range_slices
I have 2 node cluster ( node1, node2)
Here is hector pool string node2:9160,node1:9160.
node1 is seed for node1 and node2 in storage-conf.xml
when node 2 ( non-seed) down, application with hector client working without any issues.
when node 1( SEED) down , application is not working even NON-SEED node2 is up and active.
Is there anything wrong in server configuration? I am not sure what is the significance of it in the context of hector?
*_hector tried to connect node1(SEED NODE) ( even node2 first in host url ), it's down, failed with connection refused as expected._
2010-06-03 12:05:03,829 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolFactory:? - Creating a new CassandraClientPool...
2010-06-03 12:05:03,847 INFO [http-thread-pool-8080-(1)] JmxMonitor:? - Registering JMX me.prettyprint.cassandra.service:ServiceType=hector,MonitorType=hector
2010-06-03 12:05:03,914 INFO [http-thread-pool-8080-(1)] CassandraClientPoolImpl:? - Creating a CassandraClientPool
2010-06-03 12:05:03,915 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolFactory:? - CassandraClientPool was created: me.prettyprint.cassandra.service.CassandraClientPoolImpl@6d5bd16
2010-06-03 12:05:03,956 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolByHostImpl:? - Creating new connection pool for NODE1:9160
2010-06-03 12:05:03,986 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolImpl:? - GenerigObjectPool created: CassandraClientPoolImplNODE1:9160 364089744
2010-06-03 12:05:03,986 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolByHostImpl:? - Borrowing client from CassandraClientPoolImplNODE1:9160 (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:03,987 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolByHostImpl:? - Just before borrow: CassandraClientPoolImplNODE1:9160&maxActive=50&maxIdle=-1&blockedThreadCount=1&liveClientsFromPool.size=0&numActive=0&numIdle=0
2010-06-03 12:05:03,987 DEBUG [http-thread-pool-8080-(1)] CassandraClientFactory:? - Creating a new client... (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:03,993 DEBUG [http-thread-pool-8080-(1)] CassandraClientFactory:? - Creating a new thrift connection to NODE1:9160
2010-06-03 12:05:04,029 ERROR [http-thread-pool-8080-(1)] CassandraClientFactory:? - Unable to open transport to NODE1:9160
org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused
at org.apache.thrift.transport.TSocket.open(TSocket.java:185)
at me.prettyprint.cassandra.service.CassandraClientFactory.createThriftClient(CassandraClientFactory.java:89)
at me.prettyprint.cassandra.service.CassandraClientFactory.create(CassandraClientFactory.java:71)
at me.prettyprint.cassandra.service.CassandraClientFactory.makeObject(CassandraClientFactory.java:141)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1148)
at me.prettyprint.cassandra.service.CassandraClientPoolByHostImpl.borrowClient(CassandraClientPoolByHostImpl.java:80)
at me.prettyprint.cassandra.service.CassandraClientPoolImpl.borrowClient(CassandraClientPoolImpl.java:67)
at me.prettyprint.cassandra.service.CassandraClientPoolImpl.borrowClient(CassandraClientPoolImpl.java:194)
at me.prettyprint.cassandra.service.CassandraClientPoolImpl.borrowClient(CassandraClientPoolImpl.java:203)
*_NODE1 DOWN, so hector tried with NODE2, created new pool, but failed with unavailable option_
2010-06-03 12:05:04,035 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolByHostImpl:? - Creating new connection pool for NODE2:9160
2010-06-03 12:05:04,035 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolImpl:? - GenerigObjectPool created: CassandraClientPoolImplNODE2:9160 932954559
2010-06-03 12:05:04,035 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolByHostImpl:? - Borrowing client from CassandraClientPoolImplNODE2:9160 (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:04,035 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolByHostImpl:? - Just before borrow: CassandraClientPoolImplNODE2:9160&maxActive=50&maxIdle=-1&blockedThreadCount=1&liveClientsFromPool.size=0&numActive=0&numIdle=0
2010-06-03 12:05:04,036 DEBUG [http-thread-pool-8080-(1)] CassandraClientFactory:? - Creating a new client... (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:04,036 DEBUG [http-thread-pool-8080-(1)] CassandraClientFactory:? - Creating a new thrift connection to NODE2:9160
2010-06-03 12:05:04,076 DEBUG [http-thread-pool-8080-(1)] CassandraClientFactory:? - Creating client CassandraClientNODE2:9160-1 (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:04,077 DEBUG [http-thread-pool-8080-(1)] CassandraClientFactory:? - New client created: CassandraClientNODE2:9160-1 (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:04,079 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolByHostImpl:? - Client CassandraClientNODE2:9160-1 successfully borrowed from CassandraClientPoolImplNODE2:9160 (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:04,229 INFO [http-thread-pool-8080-(1)] CassandraClientImpl:? - token start: 153984762184366390623300505107853950634 end: 73962258418603180567554371891923303524 host: NODE2
2010-06-03 12:05:04,229 INFO [http-thread-pool-8080-(1)] CassandraClientImpl:? - token start: 73962258418603180567554371891923303524 end: 153984762184366390623300505107853950634 host: NODE1
2010-06-03 12:05:04,231 INFO [http-thread-pool-8080-(1)] CassandraClientImpl:? - token start: 153984762184366390623300505107853950634 end: 73962258418603180567554371891923303524 host: NODE2
2010-06-03 12:05:04,231 INFO [http-thread-pool-8080-(1)] CassandraClientImpl:? - token start: 73962258418603180567554371891923303524 end: 153984762184366390623300505107853950634 host: NODE1
2010-06-03 12:05:04,255 DEBUG [http-thread-pool-8080-(1)] FailoverOperator:? - Performing operation on NODE2; retries: 2
2010-06-03 12:05:04,299 WARN [http-thread-pool-8080-(1)] FailoverOperator:? - Got a UnavailableException from NODE2. Num of retries: 2 (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:04,299 INFO [http-thread-pool-8080-(1)] FailoverOperator:? - Skipping to next host (thread=http-thread-pool-8080-(1)). Current host is: NODE2
2010-06-03 12:05:04,299 INFO [http-thread-pool-8080-(1)] FailoverOperator:? - Invalidating client CassandraClientNODE2:9160-1 (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:04,300 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolByHostImpl:? - Invalidating client CassandraClientNODE2:9160-1
2010-06-03 12:05:04,300 DEBUG [http-thread-pool-8080-(1)] CassandraClientFactory:? - Closing client CassandraClientNODE2:9160-1 (thread=http-thread-pool-8080-(1))
2010-06-03 12:05:04,300 DEBUG [http-thread-pool-8080-(1)] CassandraClientFactory:? - Closing client CassandraClientNODE2:9160-1
2010-06-03 12:05:04,300 DEBUG [http-thread-pool-8080-(1)] CassandraClientPoolByHostImpl:? - Client has been destroyed: CassandraClientNODE2:9160-1 (thread=http-thread-pool-8080-(1))
I am not it's client issue or server issue? any suggestions on configuration?
Thanks.
Sam
This is both to encapsulate the transport (avro vs. thrift: see issue 31) as well as provide for a more sane approach to dealing with between 4 and 7 exceptions possible depending on what portion of the API is called. The converted exceptions should all extend RuntimeException.
See how JdbcOperations translates all the JDBC exception crud in SpringFramework for a good example of this:
http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/jdbc/core/JdbcOperations.html
Are there any plans to add support for get_range_slices() and batch_mutate() to the KeySpace object?
I have a simple client based on the example for loading data. It runs for a period of time and then I get:
10/05/10 22:13:50 WARN service.FailoverOperator: Got a TimedOutException from node14. Num of retries: 13
10/05/10 22:13:50 INFO service.FailoverOperator: Skipping to next host. Current host is: node14
10/05/10 22:13:50 INFO service.FailoverOperator: Skipped host. New host is: node14
10/05/10 22:13:51 WARN service.FailoverOperator: Got a TTransportException from node14. Num of retries: 13
10/05/10 22:13:51 INFO service.FailoverOperator: Skipping to next host. Current host is: node14
10/05/10 22:13:51 INFO service.FailoverOperator: Skipped host. New host is: node14
This repeats many times, and then:
10/05/10 22:19:51 ERROR service.CassandraClientFactory: Unable to open transport to 192.168.0.10:9160org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused at org.apache.thrift.transport.TSocket.open(TSocket.java:185) at me.prettyprint.cassandra.service.CassandraClientFactory.createThriftClient(CassandraClientFactory.java:87) at me.prettyprint.cassandra.service.CassandraClientFactory.create(CassandraClientFactory.java:71) at me.prettyprint.cassandra.service.CassandraClientFactory.makeObject(CassandraClientFactory.java:139)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1148)
at me.prettyprint.cassandra.service.CassandraClientPoolByHostImpl.borrowClient(CassandraClientPoolByHostImpl.java:78)
at me.prettyprint.cassandra.service.CassandraClientPoolImpl.borrowClient(CassandraClientPoolImpl.java:64)
at me.prettyprint.cassandra.service.FailoverOperator.skipToNextHost(FailoverOperator.java:219)
at me.prettyprint.cassandra.service.FailoverOperator.operateSingleIteration(FailoverOperator.java:173)
at me.prettyprint.cassandra.service.FailoverOperator.operate(FailoverOperator.java:84)
at me.prettyprint.cassandra.service.KeyspaceImpl.operateWithFailover(KeyspaceImpl.java:151)
at me.prettyprint.cassandra.service.KeyspaceImpl.insert(KeyspaceImpl.java:323)
at LoadClueList.main(LoadClueList.java:143)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at org.apache.thrift.transport.TSocket.open(TSocket.java:180)
... 12 more
10/05/10 22:19:51 WARN service.FailoverOperator: Skip-host failed
me.prettyprint.cassandra.service.SkipHostException: org.apache.thrift.transport.TTransportException: Unable to open transport to 192.168.0.10:9160 , java.net.ConnectException: Connection refused
at me.prettyprint.cassandra.service.FailoverOperator.skipToNextHost(FailoverOperator.java:225)
at me.prettyprint.cassandra.service.FailoverOperator.operateSingleIteration(FailoverOperator.java:173)
at me.prettyprint.cassandra.service.FailoverOperator.operate(FailoverOperator.java:84)
at me.prettyprint.cassandra.service.KeyspaceImpl.operateWithFailover(KeyspaceImpl.java:151)
at me.prettyprint.cassandra.service.KeyspaceImpl.insert(KeyspaceImpl.java:323)
at LoadClueList.main(LoadClueList.java:143)
Caused by: org.apache.thrift.transport.TTransportException: Unable to open transport to 192.168.0.10:9160 , java.net.ConnectException: Connection refused
at me.prettyprint.cassandra.service.CassandraClientFactory.createThriftClient(CassandraClientFactory.java:93)
at me.prettyprint.cassandra.service.CassandraClientFactory.create(CassandraClientFactory.java:71)
at me.prettyprint.cassandra.service.CassandraClientFactory.makeObject(CassandraClientFactory.java:139)
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1148)
at me.prettyprint.cassandra.service.CassandraClientPoolByHostImpl.borrowClient(CassandraClientPoolByHostImpl.java:78)
at me.prettyprint.cassandra.service.CassandraClientPoolImpl.borrowClient(CassandraClientPoolImpl.java:64)
at me.prettyprint.cassandra.service.FailoverOperator.skipToNextHost(FailoverOperator.java:219)
... 5 more
Caused by: org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused
at org.apache.thrift.transport.TSocket.open(TSocket.java:185)
at me.prettyprint.cassandra.service.CassandraClientFactory.createThriftClient(CassandraClientFactory.java:87)
... 11 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at org.apache.thrift.transport.TSocket.open(TSocket.java:180)
... 12 more
and so forth.
My HEAD is dce2ade.
When failing over the the next host, if there's a long list of available hosts, any host may be chosen by the client as a failed over host. This could mean that the host is in a different datacenter.
An improvement this this is to choose the host based in shortest IP distance, e.g. prefer host in the same subnet.
Even better is a pluggable EndPointSnitch
I haven't successfully been able to use this. Could you post an example of turning a long into a string that will work with LongType and the operations you've exposed?
As cassandra is leaning to support both thrift and avro, in hecotr we need to remove external deps on thrift and wrap all types with a hector type, so for example a column would be
me.prettyprint.cassandra.model.Column
This includes exceptions as well
Hi.
In interface Keyspace you have method void insert(java.lang.String s, org.apache.cassandra.thrift.ColumnPath columnPath, byte[] bytes).
And it would be nice to have method insert(byte[] key, .....
It's matter in case using UUIDs as keys. (http://wiki.apache.org/cassandra/FAQ#working_with_timeuuid_in_java).
I can't explain much here (english is not native) but hoping you undestand :)
I have a need for an asynchronous api to cassandra. I have a large number of operations that I need to complete in a fixed amount of time and performing them serially is not fast enough. Each operation in parallel would need to use a separate connection from a pool.
system dependencies break pom inclusion. I'm currently using the following (horrible) shell code to prepare hector (assuming hector is checked out to hector/)
mvn install:install-file -Dpackaging=jar -DgroupId=libthrift -DartifactId=libthrift -Dversion=917130 -Dfile=hector/lib/libthrift-r917130.jar mvn install:install-file -Dpackaging=jar -DgroupId=org.apache.cassandra -DartifactId=cassandra -Dversion=0.6.0 -Dfile=hector/lib/apache-cassandra-0.6.0.jar mvn install:install-file -Dpackaging=jar -DgroupId=org.cliffc.high_scale_lib -DartifactId=high-scale-lib -Dversion=1.0.0 -Dfile=hector/lib/high-scale-lib.jar mvn install:install-file -Dpackaging=jar -DgroupId=com.reardencommerce -DartifactId=clhm-production -Dversion=1.0.0 -Dfile=hector/lib/clhm-production.jar mvn install:install-file -Dpackaging=jar -DgroupId=org.apache.cassandra -DartifactId=cassandra-javautils -Dfile=hector/lib/cassandra-javautils.jar -Dversion=1.0.0 sed -i -e 's:system::' -e 's:.*::' hector/pom.xml
This makes local includes possible, especially
me.prettyprint hector 0.6.0-14
The install:install-file lines should be trivial as a shell/bat file, and would highly simplify the import of hector.
AuthenticationRequest missing?
I can't seem to find where to specify my credentials when using hector. Is Hector not compatible with Cassandra 0.6's AuthenticationRequest?
Cassandra 0.6.0 adds new meta methods that may be (should be) used instead of using the generic meta call getStringProperty
For example: describe_ring
We currently default to DCQUOROM which uses ALL under the hood as it is not yet implemented. The following thread discusses this:
http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/Questions-while-evaluating-Cassandra-td4660754.html
apparently using the embedded server and writing to it will wait forever while trying to updateKnownHosts in the keyspace constructor.
I am trying retrieve all the columns of a certain columnfamily for a certain key. However the if I don't set any Column for the columnfamily, the following call will fail.
Can you tell me how to workaround this?
Thanks.
private void valideColumnPath(ColumnPath columnPath) throws InvalidRequestException {
String cf = columnPath.getColumn_family();
Map<String, String> cfdefine;
if ((cfdefine = keyspaceDesc.get(cf)) != null) {
if (cfdefine.get(CF_TYPE).equals(CF_TYPE_STANDARD) && columnPath.getColumn() != null) {
// if the column family is a standard column
return;
} else if (cfdefine.get(CF_TYPE).equals(CF_TYPE_SUPER)
&& columnPath.getSuper_column() != null && columnPath.getColumn() != null) {
// if the column family is a super column and also give the super_column
// name
return;
}
}
throw new InvalidRequestException("The specified column family does not exist: " + cf);
}
In my tests, I use DNS name as cassandra uris. For example
cass1:9160,
pool.borrowClient(new String[] {"cass1:9160", "cass2:9160",
"cass3:9160"});
After getting some errors communicating with Cassanrda,
KeyspaceImpl.skipToNextHost is eventually called, but it will add new
connection to ip address.
So finally my pool will be composed of twice connection per host :
192.168.5.73(192.168.5.73):
9160=CassandraClientPoolImpl192.168.5.73:9160, cass1(192.168.5.73):
9160=CassandraClientPoolImplcass1:9160
and so on for cass2 and cass3.
I would suggest to be consistent to not open twice the connections to
a host.
Kind regards,
Benoit.
The call to cassandra.describe_keyspace is at CassandraClientImpl.getKeyspace()
This is a "meta" call, which is invoked once per keyspace before any other operation on that keyspace is performed.
This call, if unsuccessful, will not use the failover policy used by all other read/write operations.
It should.
Hi Ran,
My company is building an MMO for kids and we are using Cassandra as the data store.
Until quite recently we used http://code.google.com/p/cassandra-java-client/ as the Cassandra client but have since moved to Hector.
With Hector, though not with the old client, we are experiencing a problem whereby after about 20 mins of running when we borrow CassandraClients from the pool they come back in the closed state.
I am using the jars from http://github.com/downloads/rantav/hector/hector-0.6.0-8.zip.
I don't understand why this should be happening because inspecting the code I see you use PoolableObjectFactory and the CassandraClientFactory checks whether the client isClosed or hasErrors in the validateObject method and so presumably if this fails a new client would be requested.
Our webserver(s) holds a static instance of the pool and then within individual requests calls pool.BorrowClient(host, port); With a try/finally we release the client back to the pool at the end of every request.
Have you any idea what the problem might be and has anyone else reported a similar problem?
Thanks,
Matt
Just noticed this while eyeballing the list of dependencies. Same group, artifact, and version, so one can go.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.