本文整理汇总了Java中com.netflix.astyanax.AstyanaxContext类的典型用法代码示例。如果您正苦于以下问题:Java AstyanaxContext类的具体用法?Java AstyanaxContext怎么用?Java AstyanaxContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AstyanaxContext类属于com.netflix.astyanax包,在下文中一共展示了AstyanaxContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: initialSetup
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
public void initialSetup() throws NotFoundException, InvalidRequestException, NoSuchFieldException, UnavailableException, IllegalAccessException, InstantiationException, ClassNotFoundException, TimedOutException, URISyntaxException, IOException, TException {
context = new AstyanaxContext.Builder()
.forCluster(_cluster) //"Test Cluster"
.forKeyspace(_keyspaceName)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl().setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl(_pool).setPort(_port).setMaxConnsPerHost(1).setSeeds(_host+":"+_port))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
context.start();
GlobalVariables.KS_AST = context.getClient();
CF_AST_BACK = ColumnFamily
.newColumnFamily(_columnFamilyNameBack,
StringSerializer.get(), // Key Serializer
StringSerializer.get()) ; // Column Serializer
CF_AST_DYNA = ColumnFamily
.newColumnFamily(_columnFamilyNameDyna,
StringSerializer.get(), // Key Serializer
StringSerializer.get()) ; // Column Serializer
this.cliSchema();
}
开发者ID:faustineinsun,项目名称:WiseCrowdRec,代码行数:25,代码来源:AstyanaxCassandraManipulator.java
示例4: 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
示例5: createCacheLoader
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
@Override
CacheLoader<DefaultAstyanaxKeyspaceFactory.KeyspaceKey, AstyanaxContext<Keyspace>> createCacheLoader(AstyanaxConfiguration astyanaxConfiguration,
ConnectionPoolConfiguration connectionPoolConfiguration,
KeyspaceConnectionPoolMonitorFactory connectionPoolMonitorFactory,
ClusterHostSupplierFactory hostSupplierFactory,
KeyspaceInitializer keyspaceInitializer) {
final CacheLoader<KeyspaceKey, AstyanaxContext<Keyspace>> delegate = super.createCacheLoader(astyanaxConfiguration, connectionPoolConfiguration, connectionPoolMonitorFactory, hostSupplierFactory, keyspaceInitializer);
return new CacheLoader<KeyspaceKey, AstyanaxContext<Keyspace>>() {
@Override
public AstyanaxContext<Keyspace> load(KeyspaceKey key) throws Exception {
createCount.incrementAndGet();
return delegate.load(key);
}
};
}
开发者ID:spinnaker,项目名称:kork,代码行数:17,代码来源:DefaultAstyanaxKeyspaceFactoryTest.java
示例6: 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
示例7: initWithThriftDriverWithEurekaHostsSupplier
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
private AstyanaxContext<Keyspace> initWithThriftDriverWithEurekaHostsSupplier() {
logger.info("Boot cluster (BOOT_CLUSTER) is {}, keyspace name (KS_NAME) is {}", BOOT_CLUSTER, KS_NAME);
return new AstyanaxContext.Builder()
.forCluster(BOOT_CLUSTER)
.forKeyspace(KS_NAME)
.withAstyanaxConfiguration(
new AstyanaxConfigurationImpl()
.setDiscoveryType(
NodeDiscoveryType.DISCOVERY_SERVICE))
.withConnectionPoolConfiguration(
new ConnectionPoolConfigurationImpl(
"MyConnectionPool")
.setMaxConnsPerHost(3)
.setPort(thriftPortForAstyanax))
.withHostSupplier(eurekaHostsSupplier.getSupplier(BOOT_CLUSTER))
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
}
开发者ID:Netflix,项目名称:Raigad,代码行数:21,代码来源:InstanceDataDAOCassandra.java
示例8: initWithThriftDriverWithExternalHostsSupplier
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
private AstyanaxContext<Keyspace> initWithThriftDriverWithExternalHostsSupplier() {
logger.info("Boot cluster (BOOT_CLUSTER) is {}, keyspace name (KS_NAME) is {}", BOOT_CLUSTER, KS_NAME);
return new AstyanaxContext.Builder()
.forCluster(BOOT_CLUSTER)
.forKeyspace(KS_NAME)
.withAstyanaxConfiguration(
new AstyanaxConfigurationImpl()
.setDiscoveryType(
NodeDiscoveryType.DISCOVERY_SERVICE)
.setConnectionPoolType(
ConnectionPoolType.ROUND_ROBIN))
.withConnectionPoolConfiguration(
new ConnectionPoolConfigurationImpl(
"MyConnectionPool")
.setMaxConnsPerHost(3)
.setPort(thriftPortForAstyanax))
.withHostSupplier(getSupplier())
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
}
开发者ID:Netflix,项目名称:Raigad,代码行数:23,代码来源:InstanceDataDAOCassandra.java
示例9: 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
示例10: 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
示例11: 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
示例12: CassandraArtifactCache
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
public CassandraArtifactCache(
String hosts,
int port,
int timeoutSeconds,
boolean doStore,
BuckEventBus buckEventBus)
throws ConnectionException {
this(timeoutSeconds, doStore, buckEventBus, new AstyanaxContext.Builder()
.forCluster(CLUSTER_NAME)
.forKeyspace(KEYSPACE_NAME)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setCqlVersion("3.0.0")
.setTargetCassandraVersion("1.2")
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl(POOL_NAME)
.setSeeds(hosts)
.setPort(port)
.setMaxConnsPerHost(1)
)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance()));
}
开发者ID:saleehk,项目名称:buck-cutom,代码行数:24,代码来源:CassandraArtifactCache.java
示例13: beforeClass
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
@BeforeClass
public static void beforeClass() {
astyanaxContext =
new AstyanaxContext.Builder()
.forKeyspace("timeSeriesKeyspace")
.withConnectionPoolConfiguration(
new ConnectionPoolConfigurationImpl("myCPConfig")
.setSeeds("localhost")
.setPort(9171))
.withAstyanaxConfiguration(
new AstyanaxConfigurationImpl()
.setConnectionPoolType(ConnectionPoolType.TOKEN_AWARE)
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE))
.buildKeyspace(ThriftFamilyFactory.getInstance());
keyspace = astyanaxContext.getClient();
astyanaxContext.start();
}
开发者ID:iZettle,项目名称:izettle-toolbox,代码行数:20,代码来源:TimeSeriesIT.java
示例14: 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
示例15: acquireCluster
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
@Override
public synchronized Cluster acquireCluster(ClusterKey clusterKey) {
String clusterName = clusterKey.getClusterName().toLowerCase();
Preconditions.checkNotNull(clusterName, "Invalid cluster name 'null'");
ClusterContextHolder holder = contextMap.get(clusterName);
if (holder == null) {
HostSupplierProvider hostSupplierProvider = hostSupplierProviders.get(clusterKey.getDiscoveryType());
Preconditions.checkNotNull(hostSupplierProvider, String.format("Unknown host supplier provider '%s' for cluster '%s'", clusterKey.getDiscoveryType(), clusterName));
AstyanaxContext<Cluster> context = new AstyanaxContext.Builder()
.forCluster(clusterName)
.withAstyanaxConfiguration(configurationProvider.get(clusterName))
.withConnectionPoolConfiguration(cpProvider.get(clusterName))
.withConnectionPoolMonitor(monitorProvider.get(clusterName))
.withHostSupplier(hostSupplierProvider.getSupplier(clusterName))
.buildCluster(ThriftFamilyFactory.getInstance());
holder = new ClusterContextHolder(context);
holder.start();
}
holder.addRef();
return holder.getKeyspace();
}
开发者ID:Netflix,项目名称:staash,代码行数:26,代码来源:DefaultAstyanaxClusterClientProvider.java
示例16: 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
示例17: AstyanaxCassandraScheduleStore
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
private AstyanaxCassandraScheduleStore(
AstyanaxContext<Keyspace> context,
String name,
ContentStore contentStore,
MessageSender<ScheduleUpdateMessage> messageSender,
Clock clock,
ConsistencyLevel readCl,
ConsistencyLevel writeCl,
MetricRegistry metricRegistry,
String metricPrefix
) {
super(contentStore, messageSender, metricRegistry, metricPrefix);
this.serializer = new ItemAndBroadcastSerializer(new ContentSerializer(new ContentSerializationVisitor()));
this.keyspace = context.getClient();
this.cf = ColumnFamily.newColumnFamily(
name,
StringSerializer.get(),
StringSerializer.get()
);
this.clock = clock;
this.readCl = readCl;
this.writeCl = writeCl;
}
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:24,代码来源:AstyanaxCassandraScheduleStore.java
示例18: AstyanaxCassandraContentStore
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
private AstyanaxCassandraContentStore(
AstyanaxContext<Keyspace> context,
String cfName,
ConsistencyLevel readConsistency,
ConsistencyLevel writeConsistency,
ContentHasher hasher,
IdGenerator idGenerator,
MessageSender<ResourceUpdatedMessage> sender,
EquivalenceGraphStore graphStore,
Clock clock,
MetricRegistry metricRegistry,
String metricPrefix
) {
super(hasher, idGenerator, sender, graphStore, clock, metricRegistry, metricPrefix);
this.keyspace = checkNotNull(context.getClient());
this.readConsistency = checkNotNull(readConsistency);
this.writeConsistency = checkNotNull(writeConsistency);
this.mainCf = ColumnFamily.newColumnFamily(checkNotNull(cfName),
LongSerializer.get(), StringSerializer.get()
);
this.aliasIndex = AliasIndex.create(keyspace, cfName + "_aliases");
}
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:24,代码来源:AstyanaxCassandraContentStore.java
示例19: CassandraTopicStore
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
public CassandraTopicStore(
AstyanaxContext<Keyspace> context,
String cfName,
ConsistencyLevel readCl,
ConsistencyLevel writeCl,
Equivalence<? super Topic> equivalence,
IdGenerator idGenerator,
MessageSender<ResourceUpdatedMessage> sender,
Clock clock,
MetricRegistry metricRegistry,
String metricPrefix
) {
super(idGenerator, equivalence, sender, clock, metricRegistry, metricPrefix);
this.keyspace = checkNotNull(context.getClient());
this.readConsistency = checkNotNull(readCl);
this.writeConsistency = checkNotNull(writeCl);
this.mainCf = ColumnFamily.newColumnFamily(checkNotNull(cfName),
LongSerializer.get(), StringSerializer.get()
);
this.aliasIndex = AliasIndex.create(keyspace, cfName + "_aliases");
}
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:22,代码来源:CassandraTopicStore.java
示例20: testCassandraContext
import com.netflix.astyanax.AstyanaxContext; //导入依赖的package包/类
public static AstyanaxContext<Keyspace> testCassandraContext() {
return new AstyanaxContext.Builder()
.forCluster(CLUSTER_NAME)
.forKeyspace(KEYSPACE_NAME)
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.RING_DESCRIBE)
.setConnectionPoolType(ConnectionPoolType.ROUND_ROBIN)
.setAsyncExecutor(Executors.newFixedThreadPool(
CLIENT_THREADS,
new ThreadFactoryBuilder().setDaemon(true)
.setNameFormat("astyanax-%d")
.build()
))
)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("Atlas")
.setPort(PORT)
.setMaxBlockedThreadsPerHost(CLIENT_THREADS)
.setMaxConnsPerHost(CLIENT_THREADS)
.setMaxConns(CLIENT_THREADS * 5)
.setConnectTimeout(CONNECTION_TIMEOUT)
.setSeeds(SEEDS)
)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
}
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:26,代码来源:CassandraHelper.java
注:本文中的com.netflix.astyanax.AstyanaxContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论