• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BadRequestException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApplicationsRequestScope类代码示例发布时间:2022-05-23
下一篇:
Java TestDataPublisher类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap