Skip to content

Commit

Permalink
update astyanax config, upgrade jackson verssion
Browse files Browse the repository at this point in the history
  • Loading branch information
toyangxia committed Apr 14, 2014
1 parent e524f85 commit 2d70a48
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion config/cmb.properties
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ cmb.cassandra.clusterUrl=localhost:9160
cmb.cassandra.readConsistencyLevel=QUORUM
cmb.cassandra.writeConsistencyLevel=QUORUM
cmb.cassandra.thriftSocketTimeOutMS=10000
cmb.cassandra.dataCenter=

cmb.astyanax.maxConnectionsPerNode=10
cmb.astyanax.connectionWaitTimeOutMS=2000
Expand All @@ -125,7 +126,6 @@ cmb.hector.balancingPolicy=RoundRobinBalancingPolicy

cmb.hector.autoDiscovery=true
cmb.hector.autoDiscoveryDelaySeconds=60
cmb.hector.autoDiscoveryDataCenter=
#cmb.hector.username=
#cmb.hector.password=

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.4.3</version>
<version>1.9.2</version>
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.5.1</version>
<version>1.9.2</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import com.comcast.cmb.common.util.CMBProperties;
import com.comcast.cmb.common.util.PersistenceException;
import com.comcast.cmb.common.util.ValueAccumulator.AccumulatorName;

import com.netflix.astyanax.AstyanaxContext;
import com.netflix.astyanax.ColumnListMutation;
import com.netflix.astyanax.Keyspace;
Expand All @@ -25,6 +24,7 @@
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.ConnectionPoolType;
import com.netflix.astyanax.connectionpool.impl.CountingConnectionPoolMonitor;
import com.netflix.astyanax.impl.AstyanaxConfigurationImpl;
import com.netflix.astyanax.model.Column;
Expand Down Expand Up @@ -72,21 +72,29 @@ private void initPersistence() {
keyspaceNames.add(CMBProperties.getInstance().getCNSKeyspace());
keyspaceNames.add(CMBProperties.getInstance().getCQSKeyspace());

String dataCenter = CMBProperties.getInstance().getCassandraDataCenter();

for (String k : keyspaceNames) {
//configure pool
ConnectionPoolConfigurationImpl connectionPoolConfiguration = new ConnectionPoolConfigurationImpl("CMBAstyananxConnectionPool")
.setMaxConnsPerHost(CMBProperties.getInstance().getAstyanaxMaxConnectionsPerNode())
.setSocketTimeout(CMBProperties.getInstance().getCassandraThriftSocketTimeOutMS())
.setConnectTimeout(CMBProperties.getInstance().getAstyanaxConnectionWaitTimeOutMS())
.setSeeds(AbstractDurablePersistence.CLUSTER_URL);

if (dataCenter != null && !dataCenter.equals("")) {
connectionPoolConfiguration.setLocalDatacenter(dataCenter);
}

AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster(CLUSTER_NAME)
.forKeyspace(k)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
.setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE)
.setDefaultReadConsistencyLevel(ConsistencyLevel.valueOf("CL_"+CMBProperties.getInstance().getReadConsistencyLevel()))
.setDefaultWriteConsistencyLevel(ConsistencyLevel.valueOf("CL_"+CMBProperties.getInstance().getWriteConsistencyLevel())))
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("CMBAstyananxConnectionPool")
.setMaxConnsPerHost(CMBProperties.getInstance().getAstyanaxMaxConnectionsPerNode())
.setSocketTimeout(CMBProperties.getInstance().getCassandraThriftSocketTimeOutMS())
.setConnectTimeout(CMBProperties.getInstance().getAstyanaxConnectionWaitTimeOutMS())
// .setLocalDatacenter("datacenter1")
.setSeeds(AbstractDurablePersistence.CLUSTER_URL))
.withConnectionPoolConfiguration(connectionPoolConfiguration)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private void initPersistence() {
cassandraHostConfigurator.setAutoDiscoverHosts(CMBProperties.getInstance().isHectorAutoDiscovery());
cassandraHostConfigurator.setAutoDiscoveryDelayInSeconds(CMBProperties.getInstance().getHectorAutoDiscoveryDelaySeconds());

String dataCenter = CMBProperties.getInstance().getHectorAutoDiscoveryDataCenter();
String dataCenter = CMBProperties.getInstance().getCassandraDataCenter();

if (dataCenter != null && !dataCenter.equals("")) {
cassandraHostConfigurator.setAutoDiscoveryDataCenter(dataCenter);
Expand Down
8 changes: 4 additions & 4 deletions src/com/comcast/cmb/common/util/CMBProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public enum IO_MODE {

private final boolean hectorAutoDiscovery;
private final int hectorAutoDiscoveryDelaySeconds;
private final String hectorAutoDiscoveryDataCenter;
private final String cassandraDataCenter;
private final Map<String, String> hectorCredentials;

private final String region;
Expand Down Expand Up @@ -252,7 +252,7 @@ private CMBProperties() {
cnsPublisherEnabled = Boolean.parseBoolean(props.getProperty("cmb.cns.publisherEnabled", "true"));
cnsPublisherMode = props.getProperty("cmb.cns.publisherMode", "Consumer,Producer");

hectorAutoDiscoveryDataCenter = props.getProperty("cmb.hector.autoDiscoveryDataCenter");
cassandraDataCenter = props.getProperty("cmb.cassandra.dataCenter");

cmbDataCenter = props.getProperty("cmb.dc.name", "default");

Expand Down Expand Up @@ -417,8 +417,8 @@ public boolean isCMBStatsEnabled() {
return cmbEnableStats;
}

public String getHectorAutoDiscoveryDataCenter() {
return hectorAutoDiscoveryDataCenter;
public String getCassandraDataCenter() {
return cassandraDataCenter;
}

public int getEndpointFailureCountToSuspensionThreshold() {
Expand Down

0 comments on commit 2d70a48

Please sign in to comment.