本文整理汇总了Java中com.netflix.astyanax.connectionpool.exceptions.BadRequestException类的典型用法代码示例。如果您正苦于以下问题:Java BadRequestException类的具体用法?Java BadRequestException怎么用?Java BadRequestException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BadRequestException类属于com.netflix.astyanax.connectionpool.exceptions包,在下文中一共展示了BadRequestException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createSchema
import com.netflix.astyanax.connectionpool.exceptions.BadRequestException; //导入依赖的package包/类
private void createSchema() throws ConnectionException {
boolean keyspaceExists = false;
try {
if (keyspace.describeKeyspace() != null) {
keyspaceExists = true;
}
} catch(BadRequestException e) {
// do nothing, keyspace does not exist
}
if(!keyspaceExists) {
keyspace.createKeyspace(ImmutableMap.<String, Object> builder()
.put("strategy_options", ImmutableMap.<String, Object> builder().put("replication_factor", "1").build())
.put("strategy_class", "SimpleStrategy").build());
}
if (keyspace.describeKeyspace().getColumnFamily(blobCFName) == null) {
keyspace.createColumnFamily(blobCF,
ImmutableMap.<String, Object> builder().put("key_validation_class", "UTF8Type").put("comparator_type", "UTF8Type").build());
}
}
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:22,代码来源:CassandraBlobStore.java
示例2: deleteCassandraKeySpace
import com.netflix.astyanax.connectionpool.exceptions.BadRequestException; //导入依赖的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
示例3: isSchemaMissing
import com.netflix.astyanax.connectionpool.exceptions.BadRequestException; //导入依赖的package包/类
/**
* Return true if the exception is an instance of a missing keysapce
* @param rethrowMessage The message to add to the exception if rethrown
* @param cassandraException The exception from cassandar
* @return
*/
public static void isSchemaMissing(final String rethrowMessage, final Exception cassandraException ) {
if ( cassandraException instanceof BadRequestException ) {
//check if it's b/c the keyspace is missing, if so
final String message = cassandraException.getMessage();
//no op, just swallow
if( (message.contains( "why:Keyspace" ) && message.contains( "does not exist" ))
|| message.contains("why:unconfigured columnfamily")){
return;
};
}
throw new RuntimeException( rethrowMessage, cassandraException );
}
开发者ID:apache,项目名称:usergrid,代码行数:23,代码来源:AstyanaxUtils.java
示例4: setupCassandraKeySpace
import com.netflix.astyanax.connectionpool.exceptions.BadRequestException; //导入依赖的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
示例5: verifyMagic
import com.netflix.astyanax.connectionpool.exceptions.BadRequestException; //导入依赖的package包/类
private static void verifyMagic(Keyspace keyspace) throws ConnectionException {
OperationResult<ColumnList<String>> result;
try {
result = keyspace.prepareQuery(CF_CONFIG)
.getKey(CONFIGURATION_MAGIC_KEY)
.execute();
} catch (BadRequestException e) {
throw new HumanReadableException("Artifact cache error during schema verification: %s",
e.getMessage());
}
Column<String> column = result.getResult().getColumnByName(CONFIGURATION_COLUMN_NAME);
if (column == null || !column.getStringValue().equals(CONFIGURATION_MAGIC_VALUE)) {
throw new HumanReadableException("Artifact cache schema mismatch");
}
}
开发者ID:saleehk,项目名称:buck-cutom,代码行数:16,代码来源:CassandraArtifactCache.java
示例6: isBootstrapping
import com.netflix.astyanax.connectionpool.exceptions.BadRequestException; //导入依赖的package包/类
public boolean isBootstrapping() {
if ( getCause() instanceof BadRequestException ) {
BadRequestException bre = (BadRequestException)getCause();
String msg = bre.getMessage();
if ( (msg.contains("Keyspace") && msg.contains( "does not exist" )) || msg.contains("unconfigured columnfamily")) {
return true;
}
}
return false;
}
开发者ID:apache,项目名称:usergrid,代码行数:11,代码来源:CollectionRuntimeException.java
注:本文中的com.netflix.astyanax.connectionpool.exceptions.BadRequestException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论