Skip to content

Instantly share code, notes, and snippets.

View lyubent's full-sized avatar

Lyuben Todorov lyubent

View GitHub Profile
@lyubent
lyubent / addressPicking.java
Created April 2, 2013 16:05
Logic behind picking the address to be used for configuring cassandra.yaml
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
//init ip string as inet.getHostAddress might be null
String ip = "" + inetAddress.getHostAddress();
// VPN connection
if(netint.getName().contains("ppp") && !ip.equals("") && ip.length() < 16){
System.out.println("VPN InetAddress: " + ip);
return ip;
}
// Ethernet connection that is IPv4 and starts with 134 / 182 / 10 (private ip ranges)
if(netint.getName().contains("eth") && !ip.equals("") && ip.length() < 16
# Setup passwords for keystore / truststore
export STOREPASS=somePassword
# Cassandra server certificate
keytool -genkeypair -alias cassandra_external -keyalg RSA -keysize 1024 -dname "CN=cassandra_external, OU=SSL, O=CompanyName, C=CountryCode" -keystore cassandra_external.jks -storepass $STOREPASS -keypass $STOREPASS
keytool -exportcert -alias cassandra_external -file cassandra_external.crt -keystore cassandra_external.jks -storepass $STOREPASS
# Cassandra clients' certificate
keytool -genkeypair -alias cassandra_client -keyalg RSA -keysize 1024 -dname "CN=cassandra_client, OU=SSL, O=CompanyName, C=CountryCode" -keystore cassandra_client.jks -storepass $STOREPASS -keypass $STOREPASS
keytool -exportcert -alias cassandra_client -file cassandra_client.crt -keystore cassandra_client.jks -storepass $STOREPASS
# enable or disable client/server encryption.
client_encryption_options:
enabled: true
keystore: location/to/keystore
keystore_password: somePassword #the password specified in $STOREPASS
# For the purpose of the demo the default settings were used.
# More advanced defaults below:
protocol: TLS
algorithm: SunX509
store_type: JKS
AstyanaxContext<Keyspace> ctx = new AstyanaxContext.Builder()
.forKeyspace("MyKeyspace")
// Config parameters
.withConnectionPoolConfiguration(
new com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl("MyConnectionPool")
.setSeeds("127.0.0.1")
.setSSLConnectionContext(
new SSLConnectionContext(
"/path/to/certificate/cassandra_external_trust.jks",
"somePassword"))
java.util.concurrent.ExecutionException: java.lang.AssertionError
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
at java.util.concurrent.FutureTask.get(FutureTask.java:111)
at org.apache.cassandra.db.compaction.CompactionManager.performAllSSTableOperation(CompactionManager.java:229)
at org.apache.cassandra.db.compaction.CompactionManager.performAnticompaction(CompactionManager.java:284)
at org.apache.cassandra.db.ColumnFamilyStore.forceAntiCompaction(ColumnFamilyStore.java:1049)
at org.apache.cassandra.service.StorageService$4.runMayThrow(StorageService.java:2418)
at org.apache.cassandra.utils.WrappedRunnable.run(WrappedRunnable.java:28)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
public void doAntiCompaction(ColumnFamilyStore cfs, Collection<SSTableReader> sstables, Collection<Range<Token>> ranges) throws IOException
{
List<SSTableReader> repairedSSTables = new ArrayList<SSTableReader>();
if (ranges.isEmpty())
{
logger.info("Cannot anti-compact an empty range");
return;
}
int expectedBloomFilterSize = Math.max(cfs.metadata.getIndexInterval(), (int)(SSTableReader.getApproximateKeyCount(sstables,cfs.metadata)));
@lyubent
lyubent / gist:6404249
Last active December 22, 2015 02:38
Empty column in json created via sstable2json
// Data insterted using CQLSH
// Connected to Test Cluster at azgdWwx:9160.
// [cqlsh 4.0.1 | Cassandra 2.0.0-rc2-SNAPSHOT | CQL spec 3.1.1 | Thrift protocol 19.37.0]
// Use HELP for help.
// cqlsh> CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
// cqlsh> CREATE TABLE test.test (key varchar PRIMARY KEY, value varchar);
// cqlsh> INSERT INTO test.test (key, value) VALUES ('zi_key', 'example_value');
[
@lyubent
lyubent / gist:6429254
Created September 3, 2013 20:40
jira 4191 output for: ./nodetool cfstats system system_traces.sessions -i
lyubent:bin me$ ./nodetool cfstats system.local system.schema_columnfamilies system_traces
Keyspace: system_traces
Read Count: 0
Read Latency: NaN ms.
Write Count: 0
Write Latency: NaN ms.
Pending Tasks: 0
Column Family: sessions
SSTable count: 0
Space used (live): 0
@lyubent
lyubent / gist:6429293
Created September 3, 2013 20:42
Sample output for jira 4191: ./nodetool cfstats system system_traces.sessions -i
lyubent:bin me$ ./nodetool cfstats system system_traces.sessions -i
Keyspace: system_traces
Read Count: 0
Read Latency: NaN ms.
Write Count: 0
Write Latency: NaN ms.
Pending Tasks: 0
Column Family: events
SSTable count: 0
Space used (live): 0
@lyubent
lyubent / SSTableImport.java
Last active December 22, 2015 07:08
Adding an empty column (the row marker) @line 40 Output at the bottom.
/**
* Add columns to a column family.
*
* @param row the columns associated with a row
* @param superName name of the super column if any
* @param cfamily the column family to add columns to
*/
private void addColumnsToCF(List<?> row, ByteBuffer superName, ColumnFamily cfamily)
{
CFMetaData cfm = cfamily.metadata();