当前位置: 首页>>代码示例>>Java>>正文


Java AstyanaxContext.start方法代码示例

本文整理汇总了Java中com.netflix.astyanax.AstyanaxContext.start方法的典型用法代码示例。如果您正苦于以下问题:Java AstyanaxContext.start方法的具体用法?Java AstyanaxContext.start怎么用?Java AstyanaxContext.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.netflix.astyanax.AstyanaxContext的用法示例。


在下文中一共展示了AstyanaxContext.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContext

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
private Keyspace getContext(final byte[] table) {
  Keyspace keyspace = keyspaces.get(table);
  if (keyspace == null) {
    synchronized (keyspaces) {
      // avoid race conditions where another thread put the client
      keyspace = keyspaces.get(table);
      AstyanaxContext<Keyspace> context = contexts.get(table);
      if (context != null) {
        LOG.warn("Context wasn't null for new keyspace " + Bytes.pretty(table));
      }
      context = new AstyanaxContext.Builder()
        .forCluster("localhost")
        .forKeyspace(new String(table))
        .withAstyanaxConfiguration(ast_config)
        .withConnectionPoolConfiguration(pool)
        .withConnectionPoolMonitor(monitor)
        .buildKeyspace(ThriftFamilyFactory.getInstance());
      contexts.put(table, context);
      context.start();
      
      keyspace = context.getClient();
      keyspaces.put(table, keyspace);
    }
  }
  return keyspace;
}
 
开发者ID:OpenTSDB,项目名称:asynccassandra,代码行数:27,代码来源:HBaseClient.java

示例2: setupAstyanaxContext

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
private Keyspace setupAstyanaxContext(String clusterName)
{
    AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
            .forCluster(clusterName)
            .forKeyspace("CrawlerKS")
            .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
                            .setDiscoveryType(NodeDiscoveryType.NONE)
                            .setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE)
            )
            .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("CassandraPool")
                            .setPort(9160)
                            .setMaxConnsPerHost(3)
                            .setSeeds("127.0.0.1:9160")
            )
            .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
            .buildKeyspace(ThriftFamilyFactory.getInstance());


    context.start();
    return context.getClient();
}
 
开发者ID:Esquive,项目名称:iticrawler,代码行数:22,代码来源:StorageCluster.java

示例3: deleteCassandraKeySpace

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
public static void deleteCassandraKeySpace(String cassandraConnString, String keySpace) throws Exception {

        try {
            AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
                    .forCluster("ClusterName")
                    .forKeyspace(keySpace)
                    .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
                                    .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
                    )
                    .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
                                    .setMaxConnsPerHost(1)
                                    .setSeeds(cassandraConnString)
                    )
                    .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
                    .buildKeyspace(ThriftFamilyFactory.getInstance());

            context.start();
            Keyspace keyspace = context.getClient();
            keyspace.dropKeyspace();
            context.shutdown();
        } catch (BadRequestException e) {
            LOG.warn("Could not delete cassandra keyspace, assuming it does not exist.", e);
        }
    }
 
开发者ID:Parth-Brahmbhatt,项目名称:storm-smoke-test,代码行数:25,代码来源:CleanupUtils.java

示例4: getConnection

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
/**
 * Creates connection to Cassandra
 */
public static Keyspace getConnection() {
    final AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
            .forCluster("ClusterName")
            .forKeyspace(KEYSPACE_NAME)
            .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
                    .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
            )
            .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
                    .setPort(9160)
                    .setMaxConnsPerHost(1)
                    .setSeeds("127.0.0.1:9160")
                    .setSocketTimeout(60000)
            )
            .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
                    .setCqlVersion("3.0.0")
                    .setTargetCassandraVersion("1.2")
            )
            .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
            .buildKeyspace(ThriftFamilyFactory.getInstance());

    context.start();
    return context.getClient();
}
 
开发者ID:Benky,项目名称:webdav-cassandra,代码行数:27,代码来源:CassandraUtils.java

示例5: setProperties

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
@Override
public void setProperties(Map<String, Object> properties) {
  super.setProperties(properties);
  AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
  .forCluster("ClusterName")
  .forKeyspace((String) properties.get(KEYSPACE))
  .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()      
      .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
  )
  .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
      .setPort((int)properties.get(PORT))
      .setMaxConnsPerHost(1)
      .setSeeds((String) properties.get(HOST_LIST))
  )
  .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
  .buildKeyspace(ThriftFamilyFactory.getInstance() );
  context.start();
  
  keyspace = context.getEntity(); 
}
 
开发者ID:edwardcapriolo,项目名称:teknek-cassandra,代码行数:21,代码来源:CassandraOperator.java

示例6: TimedGroupByEngine

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
public TimedGroupByEngine(String ks, int port, String hostlist){
  AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
  .forCluster("ClusterName")
  .forKeyspace(ks)
  .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()      
      .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
  )
  .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
      .setPort(port)
      .setMaxConnsPerHost(1)
      .setSeeds(hostlist)
  )
  .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
  .buildKeyspace(ThriftFamilyFactory.getInstance() );
  context.start();
  keyspace = context.getEntity();
}
 
开发者ID:edwardcapriolo,项目名称:teknek-cassandra,代码行数:18,代码来源:TimedGroupByEngine.java

示例7: setProperties

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
@Override
public void setProperties(Map<String, Object> properties) {
  super.setProperties(properties);
  AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
  .forCluster("ClusterName")
  .forKeyspace((String) properties.get(KEYSPACE))
  .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()      
      .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
  )
  .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
      .setPort((int)properties.get(PORT))
      .setMaxConnsPerHost(1)
      .setSeeds((String) properties.get(HOST_LIST))
  )
  .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
  .buildKeyspace(ThriftFamilyFactory.getInstance() );
  context.start();
  batchSize = (Integer) properties.get(BATCH_SIZE);
  keyspace = context.getEntity();
  m = keyspace.prepareMutationBatch();
}
 
开发者ID:edwardcapriolo,项目名称:teknek-cassandra,代码行数:22,代码来源:CassandraBatchingOperator.java

示例8: setup

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
@Before
public void setup() {
	AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
			.forCluster("Test Cluster")
			.forKeyspace(KS)
			.withAstyanaxConfiguration(
					new AstyanaxConfigurationImpl()
							.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
			.withConnectionPoolConfiguration(
					new ConnectionPoolConfigurationImpl("MyConnectionPool")
							.setPort(9160).setMaxConnsPerHost(1)
							.setSeeds("127.0.0.1:9160"))
			.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
			.buildKeyspace(ThriftFamilyFactory.getInstance());

	context.start();
	keyspace = context.getClient();
}
 
开发者ID:Netflix,项目名称:staash,代码行数:19,代码来源:TestChunking.java

示例9: connect

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
private static AstyanaxContext<Keyspace> connect(String host, int port, String keyspace, int threads, NodeDiscoveryType discovery) {
    AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
                    .forKeyspace(keyspace)
            .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
                .setDiscoveryType(discovery)
                .setRetryPolicy(new RetryNTimes(10)))
                
            .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl(host + ":" + keyspace)
                    .setMaxConns(threads * 2)
                    .setSeeds(host)
                    .setPort(port)
                    .setRetryBackoffStrategy(new FixedRetryBackoffStrategy(1000, 1000)))
            .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
            .buildKeyspace(ThriftFamilyFactory.getInstance());
    context.start();
    return context;
}
 
开发者ID:rackerlabs,项目名称:blueflood,代码行数:18,代码来源:Migration.java

示例10: reconfigure

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
private void reconfigure() throws ConnectionException {

        String seeds = MultiValueConfigLoader.getConfig("CASSANDRA-" + getInstanceName() + ".seeds", "localhost");
        String clusterName = MultiValueConfigLoader.getConfig("CASSANDRA-" + getInstanceName() + ".clusterName", "Test Cluster");
        
        ConsistencyLevel readCL = ConsistencyLevel.CL_ONE;
        ConsistencyLevel writeCL = ConsistencyLevel.CL_ONE;
        if(config.containsKey(CassandraConstants.READ_CONSISTENCY)) {
            readCL = ConsistencyLevel.valueOf(config.get(CassandraConstants.READ_CONSISTENCY));
        }
        
        if(config.containsKey(CassandraConstants.WRITE_CONSISTENCY)) {
            writeCL = ConsistencyLevel.valueOf(config.get(CassandraConstants.WRITE_CONSISTENCY));
        }

        AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
                .forCluster(clusterName)
                .forKeyspace(blobKSName)
                .withAstyanaxConfiguration(
                        new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE).setDefaultReadConsistencyLevel(readCL).setDefaultWriteConsistencyLevel(writeCL))
                .withConnectionPoolConfiguration(
                        new ConnectionPoolConfigurationImpl("astyanaxConnectionPool").setPort(9160).setMaxConnsPerHost(1).setSeeds(seeds))
                .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()).buildKeyspace(ThriftFamilyFactory.getInstance());

        context.start();
        keyspace = context.getClient();

        createSchema();

        chunkedProvider = new CassandraChunkedStorageProvider(keyspace, blobCF);
    }
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:32,代码来源:CassandraBlobStore.java

示例11: initConnection

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
private void initConnection(String clusterName, String seeds) {
    log.info(String.format("Connecting to Cassandra at %s:%s", clusterName, seeds));
    AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
            .forCluster(clusterName)
            .forKeyspace(keyspaceName)
            .withAstyanaxConfiguration(
                    new AstyanaxConfigurationImpl().setRetryPolicy(new ExponentialBackoff(retryDelay, numberOfRetries))
                            .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE).setDefaultReadConsistencyLevel(readCL)
                            .setDefaultWriteConsistencyLevel(writeCL))
            .withConnectionPoolConfiguration(
                    new ConnectionPoolConfigurationImpl("astyanaxConnectionPool").setPort(9160).setMaxConnsPerHost(connectionPoolSize).setSeeds(seeds))
            .withConnectionPoolMonitor(new CountingConnectionPoolMonitor()).buildKeyspace(ThriftFamilyFactory.getInstance());
    context.start();
    keyspace = context.getClient();
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:16,代码来源:AstyanaxCassandraBase.java

示例12: setupCassandraKeySpace

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
public static void setupCassandraKeySpace(String cassandraConnectionString, String keySpaceName,
                                          String columnFamily) throws ConnectionException {

    try {
        AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
                .forCluster("ClusterName")
                .forKeyspace(keySpaceName)
                .withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
                                .setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
                )
                .withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("MyConnectionPool")
                                .setMaxConnsPerHost(1)
                                .setSeeds(cassandraConnectionString)
                )
                .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
                .buildKeyspace(ThriftFamilyFactory.getInstance());

        context.start();
        Keyspace keyspace = context.getClient();

        // Using simple strategy
        keyspace.createKeyspace(ImmutableMap.<String, Object>builder()
                        .put("strategy_options", ImmutableMap.<String, Object>builder()
                                .put("replication_factor", "1")
                                .build())
                        .put("strategy_class", "SimpleStrategy")
                        .build()
        );

        ColumnFamily<String, String> CF_STANDARD1 = ColumnFamily.newColumnFamily(columnFamily,
                StringSerializer.get(), StringSerializer.get());

        keyspace.createColumnFamily(CF_STANDARD1, null);
        context.shutdown();
    } catch(BadRequestException e) {
        LOG.warn("could not setup cassandra keyspace , assuming keyspace already exists.", e);
    }
}
 
开发者ID:Parth-Brahmbhatt,项目名称:storm-smoke-test,代码行数:39,代码来源:SetupUtils.java

示例13: createCacheLoader

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
CacheLoader<KeyspaceKey, AstyanaxContext<Keyspace>> createCacheLoader(final AstyanaxConfiguration astyanaxConfiguration,
                                                                      final ConnectionPoolConfiguration connectionPoolConfiguration,
                                                                      final KeyspaceConnectionPoolMonitorFactory connectionPoolMonitorFactory,
                                                                      final ClusterHostSupplierFactory clusterHostSupplierFactory,
                                                                      final KeyspaceInitializer keyspaceInitializer) {
    return new CacheLoader<KeyspaceKey, AstyanaxContext<Keyspace>>() {
        @Override
        public AstyanaxContext<Keyspace> load(KeyspaceKey key) throws Exception {
            Supplier<List<Host>> hostSupplier = clusterHostSupplierFactory.createHostSupplier(key.getClusterName());
            if (hostSupplier != null) {
              hostSupplier.get();
              ((ConnectionPoolConfigurationImpl) connectionPoolConfiguration).setSeeds(null);
            }
            AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
                    .forCluster(key.getClusterName())
                    .forKeyspace(key.getKeyspaceName())
                    .withAstyanaxConfiguration(astyanaxConfiguration)
                    .withConnectionPoolConfiguration(connectionPoolConfiguration)
                    .withConnectionPoolMonitor(connectionPoolMonitorFactory.createMonitorForKeyspace(key.getClusterName(), key.getKeyspaceName()))
                    .withHostSupplier(hostSupplier)
                    .buildKeyspace(ThriftFamilyFactory.getInstance());
            context.start();
            keyspaceInitializer.initKeyspace(context.getClient());
            return context;
        }
    };
}
 
开发者ID:spinnaker,项目名称:kork,代码行数:28,代码来源:DefaultAstyanaxKeyspaceFactory.java

示例14: provideKeyspace

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
@Provides
    @Named("astmetaks")
    @Singleton
    Keyspace provideKeyspace() {
         AstyanaxContext<Keyspace> keyspaceContext = new AstyanaxContext.Builder()
        .forCluster("test cluster")
        .forKeyspace(MetaConstants.META_KEY_SPACE)
        .withAstyanaxConfiguration(
                new AstyanaxConfigurationImpl()
                        .setDiscoveryType(
                                NodeDiscoveryType.NONE)
                        .setConnectionPoolType(
                                ConnectionPoolType.ROUND_ROBIN)
                        .setTargetCassandraVersion("1.2")
                        .setCqlVersion("3.0.0"))
//                        .withHostSupplier(hs.getSupplier(clustername))
        .withConnectionPoolConfiguration(
                new ConnectionPoolConfigurationImpl("localpool"
                        + "_" + MetaConstants.META_KEY_SPACE)
                        .setSocketTimeout(30000)
                        .setMaxTimeoutWhenExhausted(20000)
                        .setMaxConnsPerHost(3).setInitConnsPerHost(1)
                        .setSeeds("localhost"+":"+"9160"))  //uncomment for localhost
//        .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
        .buildKeyspace(ThriftFamilyFactory.getInstance());
        keyspaceContext.start();
        Keyspace keyspace;
        keyspace = keyspaceContext.getClient();
        return keyspace;
    }
 
开发者ID:Netflix,项目名称:staash,代码行数:31,代码来源:TestStaashModule.java

示例15: provideKeyspace

import com.netflix.astyanax.AstyanaxContext; //导入方法依赖的package包/类
@Provides
@Named("astmetaks")
Keyspace provideKeyspace(@Named("staash.metacluster") String clustername,EurekaAstyanaxHostSupplier hs) {
    String clusterNameOnly = "";
    String[] clusterinfo = clustername.split(":");
    if (clusterinfo != null && clusterinfo.length == 2) {
        clusterNameOnly = clusterinfo[0];
    } else {
        clusterNameOnly = clustername;
    }
    AstyanaxContext<Keyspace> keyspaceContext = new AstyanaxContext.Builder()
    .forCluster(clusterNameOnly)
    .forKeyspace(MetaConstants.META_KEY_SPACE)
    .withAstyanaxConfiguration(
            new AstyanaxConfigurationImpl()
                    .setDiscoveryType(
                            NodeDiscoveryType.RING_DESCRIBE)
                    .setConnectionPoolType(
                            ConnectionPoolType.TOKEN_AWARE)
                    .setDiscoveryDelayInSeconds(60)
                    .setTargetCassandraVersion("1.2")
                    .setCqlVersion("3.0.0"))
                    .withHostSupplier(hs.getSupplier(clustername))
    .withConnectionPoolConfiguration(
            new ConnectionPoolConfigurationImpl(clusterNameOnly
                    + "_" + MetaConstants.META_KEY_SPACE)
                    .setSocketTimeout(11000)
                    .setConnectTimeout(2000)
                    .setMaxConnsPerHost(10).setInitConnsPerHost(3))
    .withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
    .buildKeyspace(ThriftFamilyFactory.getInstance());
    keyspaceContext.start();
    Keyspace keyspace;
    keyspace = keyspaceContext.getClient();
    return keyspace;
}
 
开发者ID:Netflix,项目名称:staash,代码行数:37,代码来源:PaasPropertiesModule.java


注:本文中的com.netflix.astyanax.AstyanaxContext.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。