You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ee...@apache.org on 2009/09/07 21:16:50 UTC
svn commit: r812260 - in /incubator/cassandra/branches/cassandra-0.4: bin/
lib/ src/java/org/apache/cassandra/client/
test/unit/org/apache/cassandra/client/
test/unit/org/apache/cassandra/db/marshal/
test/unit/org/apache/cassandra/dht/
Author: eevans
Date: Mon Sep 7 19:16:50 2009
New Revision: 812260
URL: http://svn.apache.org/viewvc?rev=812260&view=rev
Log:
updated subversion properties (see: CASSANDRA-429)
Modified:
incubator/cassandra/branches/cassandra-0.4/bin/cassandra.bat (props changed)
incubator/cassandra/branches/cassandra-0.4/lib/libthrift-r808609.jar (props changed)
incubator/cassandra/branches/cassandra-0.4/lib/slf4j-api-1.5.8.jar (props changed)
incubator/cassandra/branches/cassandra-0.4/lib/slf4j-log4j12-1.5.8.jar (props changed)
incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/client/RingCache.java (contents, props changed)
incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/client/TestRingCache.java (contents, props changed)
incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/marshal/BytesTypeTest.java (props changed)
incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/dht/CollatingOrderPreservingPartitionerTest.java (props changed)
incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java (props changed)
Propchange: incubator/cassandra/branches/cassandra-0.4/bin/cassandra.bat
------------------------------------------------------------------------------
svn:eol-style = CRLF
Propchange: incubator/cassandra/branches/cassandra-0.4/lib/libthrift-r808609.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Propchange: incubator/cassandra/branches/cassandra-0.4/lib/slf4j-api-1.5.8.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Propchange: incubator/cassandra/branches/cassandra-0.4/lib/slf4j-log4j12-1.5.8.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/client/RingCache.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/client/RingCache.java?rev=812260&r1=812259&r2=812260&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/client/RingCache.java (original)
+++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/client/RingCache.java Mon Sep 7 19:16:50 2009
@@ -1,107 +1,107 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.client;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.dht.IPartitioner;
-import org.apache.cassandra.dht.Token;
-import org.apache.cassandra.locator.AbstractReplicationStrategy;
-import org.apache.cassandra.locator.TokenMetadata;
-import org.apache.cassandra.net.EndPoint;
-import org.apache.cassandra.service.Cassandra;
-import org.apache.cassandra.service.CassandraServer;
-import org.apache.cassandra.service.StorageService;
-import org.apache.log4j.Logger;
-import org.apache.thrift.TException;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.transport.TSocket;
-
-import flexjson.JSONTokener;
-
-/**
- * A class for caching the ring map at the client. For usage example, see
- * test/unit/org.apache.cassandra.client.TestRingCache.java.
- */
-public class RingCache
-{
- final private static Logger logger_ = Logger.getLogger(RingCache.class);
-
- private Set<String> seeds_ = new HashSet<String>();
- final private int port_=DatabaseDescriptor.getThriftPort();
- private volatile AbstractReplicationStrategy nodePicker_;
- final private static IPartitioner partitioner_ = DatabaseDescriptor.getPartitioner();
-
- public RingCache()
- {
- seeds_ = DatabaseDescriptor.getSeeds();
- refreshEndPointMap();
- }
-
- public void refreshEndPointMap()
- {
- for (String seed : seeds_)
- {
- try
- {
- TSocket socket = new TSocket(seed, port_);
- TBinaryProtocol binaryProtocol = new TBinaryProtocol(socket, false, false);
- Cassandra.Client client = new Cassandra.Client(binaryProtocol);
- socket.open();
-
- Map<String,String> tokenToHostMap = (Map<String,String>) new JSONTokener(client.get_string_property(CassandraServer.TOKEN_MAP)).nextValue();
-
- HashMap<Token, EndPoint> tokenEndpointMap = new HashMap<Token, EndPoint>();
- Map<EndPoint, Token> endpointTokenMap = new HashMap<EndPoint, Token>();
- for (Map.Entry<String,String> entry : tokenToHostMap.entrySet())
- {
- Token token = StorageService.getPartitioner().getTokenFactory().fromString(entry.getKey());
- String host = entry.getValue();
- tokenEndpointMap.put(token, new EndPoint(host, port_));
- endpointTokenMap.put(new EndPoint(host, port_), token);
- }
-
- TokenMetadata tokenMetadata = new TokenMetadata(tokenEndpointMap, endpointTokenMap, null);
- Class cls = DatabaseDescriptor.getReplicaPlacementStrategyClass();
- Class [] parameterTypes = new Class[] { TokenMetadata.class, IPartitioner.class, int.class, int.class};
- try
- {
- nodePicker_ = (AbstractReplicationStrategy) cls.getConstructor(parameterTypes).newInstance(tokenMetadata, partitioner_, DatabaseDescriptor.getReplicationFactor(), port_);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- break;
- }
- catch (TException e)
- {
- /* let the Exception go and try another seed. log this though */
- logger_.debug("Error contacting seed " + seed + " " + e.getMessage());
- }
- }
- }
-
- public EndPoint[] getEndPoint(String key)
- {
- return nodePicker_.getReadStorageEndPoints(partitioner_.getToken(key));
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cassandra.client;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.dht.IPartitioner;
+import org.apache.cassandra.dht.Token;
+import org.apache.cassandra.locator.AbstractReplicationStrategy;
+import org.apache.cassandra.locator.TokenMetadata;
+import org.apache.cassandra.net.EndPoint;
+import org.apache.cassandra.service.Cassandra;
+import org.apache.cassandra.service.CassandraServer;
+import org.apache.cassandra.service.StorageService;
+import org.apache.log4j.Logger;
+import org.apache.thrift.TException;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.transport.TSocket;
+
+import flexjson.JSONTokener;
+
+/**
+ * A class for caching the ring map at the client. For usage example, see
+ * test/unit/org.apache.cassandra.client.TestRingCache.java.
+ */
+public class RingCache
+{
+ final private static Logger logger_ = Logger.getLogger(RingCache.class);
+
+ private Set<String> seeds_ = new HashSet<String>();
+ final private int port_=DatabaseDescriptor.getThriftPort();
+ private volatile AbstractReplicationStrategy nodePicker_;
+ final private static IPartitioner partitioner_ = DatabaseDescriptor.getPartitioner();
+
+ public RingCache()
+ {
+ seeds_ = DatabaseDescriptor.getSeeds();
+ refreshEndPointMap();
+ }
+
+ public void refreshEndPointMap()
+ {
+ for (String seed : seeds_)
+ {
+ try
+ {
+ TSocket socket = new TSocket(seed, port_);
+ TBinaryProtocol binaryProtocol = new TBinaryProtocol(socket, false, false);
+ Cassandra.Client client = new Cassandra.Client(binaryProtocol);
+ socket.open();
+
+ Map<String,String> tokenToHostMap = (Map<String,String>) new JSONTokener(client.get_string_property(CassandraServer.TOKEN_MAP)).nextValue();
+
+ HashMap<Token, EndPoint> tokenEndpointMap = new HashMap<Token, EndPoint>();
+ Map<EndPoint, Token> endpointTokenMap = new HashMap<EndPoint, Token>();
+ for (Map.Entry<String,String> entry : tokenToHostMap.entrySet())
+ {
+ Token token = StorageService.getPartitioner().getTokenFactory().fromString(entry.getKey());
+ String host = entry.getValue();
+ tokenEndpointMap.put(token, new EndPoint(host, port_));
+ endpointTokenMap.put(new EndPoint(host, port_), token);
+ }
+
+ TokenMetadata tokenMetadata = new TokenMetadata(tokenEndpointMap, endpointTokenMap, null);
+ Class cls = DatabaseDescriptor.getReplicaPlacementStrategyClass();
+ Class [] parameterTypes = new Class[] { TokenMetadata.class, IPartitioner.class, int.class, int.class};
+ try
+ {
+ nodePicker_ = (AbstractReplicationStrategy) cls.getConstructor(parameterTypes).newInstance(tokenMetadata, partitioner_, DatabaseDescriptor.getReplicationFactor(), port_);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ break;
+ }
+ catch (TException e)
+ {
+ /* let the Exception go and try another seed. log this though */
+ logger_.debug("Error contacting seed " + seed + " " + e.getMessage());
+ }
+ }
+ }
+
+ public EndPoint[] getEndPoint(String key)
+ {
+ return nodePicker_.getReadStorageEndPoints(partitioner_.getToken(key));
+ }
+}
Propchange: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/client/RingCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/client/TestRingCache.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/client/TestRingCache.java?rev=812260&r1=812259&r2=812260&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/client/TestRingCache.java (original)
+++ incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/client/TestRingCache.java Mon Sep 7 19:16:50 2009
@@ -1,81 +1,81 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cassandra.client;
-
-import org.apache.cassandra.net.EndPoint;
-import org.apache.cassandra.service.Cassandra;
-import org.apache.cassandra.service.Column;
-import org.apache.cassandra.service.ColumnPath;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransport;
-
-/**
- * Sample code that uses RingCache in the client.
- */
-public class TestRingCache
-{
- private static RingCache ringCache;
- private static Cassandra.Client thriftClient;
-
- static
- {
- ringCache = new RingCache();
- }
-
- private static void setup(String server, int port) throws Exception
- {
- /* Establish a thrift connection to the cassandra instance */
- TSocket socket = new TSocket(server, port);
- TTransport transport;
- System.out.println(" connected to " + server + ":" + port + ".");
- transport = socket;
- TBinaryProtocol binaryProtocol = new TBinaryProtocol(transport, false, false);
- Cassandra.Client cassandraClient = new Cassandra.Client(binaryProtocol);
- transport.open();
- thriftClient = cassandraClient;
- }
-
- /**
- * usage: java -Dstorage-config="confpath" org.apache.cassandra.client.TestRingCache
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Throwable
- {
- String table = "Keyspace1";
- for (int nRows=1; nRows<10; nRows++)
- {
- String row = "row" + nRows;
- ColumnPath col = new ColumnPath("Standard1", null, "col1".getBytes());
-
- EndPoint endPoints[] = ringCache.getEndPoint(row);
- String hosts="";
- for (int i=0; i<endPoints.length; i++)
- hosts = hosts + ((i>0) ? "," : "") + endPoints[i].getHost();
- System.out.println("hosts with key " + row + " : " + hosts + "; choose " + endPoints[0].getHost());
-
- // now, read the row back directly from the host owning the row locally
- setup(endPoints[0].getHost(), endPoints[0].getPort());
- thriftClient.insert(table, row, col, "val1".getBytes(), 1, 1);
- Column column=thriftClient.get(table, row, col, 1).column;
- System.out.println("read row " + row + " " + new String(column.name) + ":" + new String(column.value) + ":" + column.timestamp);
- }
- System.exit(1);
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cassandra.client;
+
+import org.apache.cassandra.net.EndPoint;
+import org.apache.cassandra.service.Cassandra;
+import org.apache.cassandra.service.Column;
+import org.apache.cassandra.service.ColumnPath;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.transport.TSocket;
+import org.apache.thrift.transport.TTransport;
+
+/**
+ * Sample code that uses RingCache in the client.
+ */
+public class TestRingCache
+{
+ private static RingCache ringCache;
+ private static Cassandra.Client thriftClient;
+
+ static
+ {
+ ringCache = new RingCache();
+ }
+
+ private static void setup(String server, int port) throws Exception
+ {
+ /* Establish a thrift connection to the cassandra instance */
+ TSocket socket = new TSocket(server, port);
+ TTransport transport;
+ System.out.println(" connected to " + server + ":" + port + ".");
+ transport = socket;
+ TBinaryProtocol binaryProtocol = new TBinaryProtocol(transport, false, false);
+ Cassandra.Client cassandraClient = new Cassandra.Client(binaryProtocol);
+ transport.open();
+ thriftClient = cassandraClient;
+ }
+
+ /**
+ * usage: java -Dstorage-config="confpath" org.apache.cassandra.client.TestRingCache
+ * @param args
+ * @throws Exception
+ */
+ public static void main(String[] args) throws Throwable
+ {
+ String table = "Keyspace1";
+ for (int nRows=1; nRows<10; nRows++)
+ {
+ String row = "row" + nRows;
+ ColumnPath col = new ColumnPath("Standard1", null, "col1".getBytes());
+
+ EndPoint endPoints[] = ringCache.getEndPoint(row);
+ String hosts="";
+ for (int i=0; i<endPoints.length; i++)
+ hosts = hosts + ((i>0) ? "," : "") + endPoints[i].getHost();
+ System.out.println("hosts with key " + row + " : " + hosts + "; choose " + endPoints[0].getHost());
+
+ // now, read the row back directly from the host owning the row locally
+ setup(endPoints[0].getHost(), endPoints[0].getPort());
+ thriftClient.insert(table, row, col, "val1".getBytes(), 1, 1);
+ Column column=thriftClient.get(table, row, col, 1).column;
+ System.out.println("read row " + row + " " + new String(column.name) + ":" + new String(column.value) + ":" + column.timestamp);
+ }
+ System.exit(1);
+ }
+}
Propchange: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/client/TestRingCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/marshal/BytesTypeTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/dht/CollatingOrderPreservingPartitionerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native