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


Java KeyspaceDefinition类代码示例

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


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

示例1: newPlacement

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
@Override
public Placement newPlacement(String placement) throws ConnectionException {
    String[] parsed = PlacementUtil.parsePlacement(placement);
    String keyspaceName = parsed[0];
    String cfPrefix = parsed[1];

    CassandraKeyspace keyspace = _keyspaceMap.get(keyspaceName);
    if (keyspace == null) {
        throw new UnknownPlacementException(format(
                "Placement string refers to unknown or non-local Cassandra keyspace: %s", keyspaceName), placement);
    }

    KeyspaceDefinition keyspaceDef = keyspace.getAstyanaxKeyspace().describeKeyspace();
    ColumnFamily<ByteBuffer,Composite> columnFamily = getColumnFamily(keyspaceDef, cfPrefix, "blob", placement,
            new SpecificCompositeSerializer(CompositeType.getInstance(Arrays.<AbstractType<?>>asList(
                    AsciiType.instance, IntegerType.instance))));

    return new BlobPlacement(placement, keyspace, columnFamily);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:20,代码来源:BlobPlacementFactory.java

示例2: getColumnFamily

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
protected <C> ColumnFamily<ByteBuffer, C> getColumnFamily(KeyspaceDefinition keyspaceDef,
                                                          String prefix, String suffix, String placement,
                                                          Serializer<C> columnSerializer) throws IllegalArgumentException {
    // Create the column family object.  It must be keyed by a ByteBuffer because that's what
    // the AstyanaxTable.getRowKey() method returns.
    ColumnFamily<ByteBuffer, C> cf = new ColumnFamily<>(prefix + "_" + suffix,
            ByteBufferSerializer.get(), columnSerializer);

    // Verify that the column family exists in the Cassandra schema.
    ColumnFamilyDefinition cfDef = keyspaceDef.getColumnFamily(cf.getName());
    if (cfDef == null) {
        throw new UnknownPlacementException(format(
                "Placement string '%s' refers to unknown Cassandra %s column family in keyspace '%s': %s",
                placement, suffix, keyspaceDef.getName(), cf.getName()), placement);
    }
    return cf;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:18,代码来源:AbstractPlacementFactory.java

示例3: newPlacement

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
@Override
public Placement newPlacement(String placement) throws ConnectionException {
    String[] parsed = PlacementUtil.parsePlacement(placement);
    String keyspaceName = parsed[0];
    String cfPrefix = parsed[1];

    CassandraKeyspace keyspace = _keyspaceMap.get(keyspaceName);
    if (keyspace == null) {
        throw new UnknownPlacementException(format(
                "Placement string refers to unknown or non-local Cassandra keyspace: %s", keyspaceName), placement);
    }

    KeyspaceDefinition keyspaceDef = keyspace.getAstyanaxKeyspace().describeKeyspace();
    AnnotatedCompositeSerializer<DeltaKey> deltaKeySerializer  = new AnnotatedCompositeSerializer<DeltaKey>(DeltaKey.class);

    // DDL's are not actually configurable due to the way we abstract the names from the placements here.
    // In the future, we should either phase out the DDL config or change the implementation here to conform to it.
    ColumnFamily<ByteBuffer, UUID> deltaCf = getColumnFamily(keyspaceDef, cfPrefix, "delta", placement, TimeUUIDSerializer.get());
    ColumnFamily<ByteBuffer, DeltaKey> blockedDeltaCf = getColumnFamily(keyspaceDef, cfPrefix, "delta_v2", placement, deltaKeySerializer);
    ColumnFamily<ByteBuffer, UUID> auditCf = getColumnFamily(keyspaceDef, cfPrefix, "audit", placement, TimeUUIDSerializer.get());
    ColumnFamily<ByteBuffer, UUID> deltaHistoryCf = getColumnFamily(keyspaceDef, cfPrefix, "history", placement, TimeUUIDSerializer.get());

    // Calculate the data centers on demand since they may change in a live system.
    return new DeltaPlacement(placement, keyspace, deltaCf, blockedDeltaCf, auditCf, deltaHistoryCf);
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:26,代码来源:DeltaPlacementFactory.java

示例4: CassandraReplication

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
public CassandraReplication(KeyspaceDefinition keyspaceDefinition) {
    _networkTopology = keyspaceDefinition.getStrategyClass().endsWith("NetworkTopologyStrategy");

    if (_networkTopology) {
        // This algorithm should match the NetworkTopologyStrategy.getReplicationFactor() method.
        // Strategy options is a Map of data center name -> replication factor.
        int replicationFactor = 0;
        ImmutableMap.Builder<String, Integer> dataCenterBuilder = ImmutableMap.builder();
        for (Map.Entry<String, String> option : keyspaceDefinition.getStrategyOptions().entrySet()) {
            String dataCenter = option.getKey();
            int repFactor = Integer.parseInt(option.getValue());
            replicationFactor += repFactor;
            dataCenterBuilder.put(dataCenter, repFactor);
        }
        _replicationFactor = replicationFactor;
        _replicationFactorByDataCenter = dataCenterBuilder.build();
    } else {
        // SimpleStrategy and OldNetworkTopologyStrategy both require a 'replication_factor' setting
        _replicationFactor = Integer.parseInt(keyspaceDefinition.getStrategyOptions().get("replication_factor"));
        _replicationFactorByDataCenter = ImmutableMap.of();
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:23,代码来源:CassandraReplication.java

示例5: getCompressionOptions

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
@Override
public Map<String, String> getCompressionOptions(String cf) throws BackendException {
    try {
        Keyspace k = keyspaceContext.getClient();

        KeyspaceDefinition kdef = k.describeKeyspace();

        if (null == kdef) {
            throw new PermanentBackendException("Keyspace " + k.getKeyspaceName() + " is undefined");
        }

        ColumnFamilyDefinition cfdef = kdef.getColumnFamily(cf);

        if (null == cfdef) {
            throw new PermanentBackendException("Column family " + cf + " is undefined");
        }

        return cfdef.getCompressionOptions();
    } catch (ConnectionException e) {
        throw new PermanentBackendException(e);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:23,代码来源:AstyanaxStoreManager.java

示例6: clearImpl

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
public void clearImpl() throws ConnectionException {
	Cluster cluster = columnFamilies.getCluster();
	String keyspaceName = columnFamilies.getKeyspaceName();
	if (log.isInfoEnabled())
		log.info("Clearing keyspace="+keyspaceName+" in cassandra");
	List<KeyspaceDefinition> keyspaces = cluster.describeKeyspaces();
	KeyspaceDefinition ourDef = null;
	for(KeyspaceDefinition kDef : keyspaces) {
		if(keyspaceName.equalsIgnoreCase(kDef.getName())) {
			ourDef = kDef;
			break;
		}
	}
	
	cluster.dropKeyspace(keyspaceName);
	OperationResult<SchemaChangeResult> result = cluster.addKeyspace(ourDef);
	
	columnFamilies.waitForNodesToBeUpToDate(result, 300000);
}
 
开发者ID:guci314,项目名称:playorm,代码行数:20,代码来源:CassandraSession.java

示例7: createLocksKeyspace

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
private void createLocksKeyspace() throws ConnectionException {

        try {
            KeyspaceDefinition keyspaceDefinition = keyspace.describeKeyspace();
            if ( keyspaceDefinition != null ) {
                logger.info("Keyspace {} already exists", keyspace.getKeyspaceName());
                return;
            }
        } catch (ConnectionException ce){
            logger.debug( "Received a NotFoundException when attempting to describe keyspace.  It does not exist" );
        }

        ImmutableMap.Builder<String, Object> strategyOptions = getKeySpaceProps();
        ImmutableMap<String, Object> options =
            ImmutableMap.<String, Object>builder().put("strategy_class", cassandraFig.getLocksKeyspaceStrategy())
                .put("strategy_options", strategyOptions.build()).build();

        keyspace.createKeyspace(options);
        logger.info("Keyspace {} created with options {}",  keyspace.getKeyspaceName(), options.toString());

    }
 
开发者ID:apache,项目名称:usergrid,代码行数:22,代码来源:AstyanaxLockManagerImpl.java

示例8: testAndCreateColumnFamilyDef

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
/**
 * Check if the column family exists.  If it dosn't create it
 */
private void testAndCreateColumnFamilyDef( MultiTenantColumnFamilyDefinition columnFamily )
        throws ConnectionException {
    final KeyspaceDefinition keyspaceDefinition = keyspace.describeKeyspace();

    final ColumnFamilyDefinition existing =
            keyspaceDefinition.getColumnFamily( columnFamily.getColumnFamily().getName() );

    if ( existing != null ) {
        logger.info("Not creating columnfamily {}, it already exists.", columnFamily.getColumnFamily().getName());
        return;
    }

    keyspace.createColumnFamily( columnFamily.getColumnFamily(), columnFamily.getOptions() );

    // the CF def creation uses Asytanax, so manually check the schema agreement
    astyanaxWaitForSchemaAgreement();

    logger.info( "Created column family {}", columnFamily.getColumnFamily().getName() );

}
 
开发者ID:apache,项目名称:usergrid,代码行数:24,代码来源:MigrationManagerImpl.java

示例9: getKeyspacesForDataCenter

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
@Override
public Collection<String> getKeyspacesForDataCenter(String cassandraDataCenter) {
    Set<String> keyspaces = Sets.newHashSet();
    for (Map.Entry<String, CassandraKeyspace> entry : _keyspaceMap.entrySet()) {
        KeyspaceDefinition keyspaceDefinition = describe(entry.getValue());
        if (replicatesTo(keyspaceDefinition, cassandraDataCenter)) {
            keyspaces.add(entry.getKey());
        }
    }
    return keyspaces;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:12,代码来源:AstyanaxKeyspaceDiscovery.java

示例10: replicatesTo

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
private boolean replicatesTo(KeyspaceDefinition keyspaceDefinition, String dataCenter) {
    if (keyspaceDefinition.getStrategyClass().endsWith("NetworkTopologyStrategy")) {
        String numReplicas = keyspaceDefinition.getStrategyOptions().get(dataCenter);
        return numReplicas != null && Integer.valueOf(numReplicas) != 0;
    }
    // Other strategies don't vary replication factor by data center.  Assume true.
    return true;
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:9,代码来源:AstyanaxKeyspaceDiscovery.java

示例11: describe

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
private KeyspaceDefinition describe(CassandraKeyspace keyspace) {
    try {
        return keyspace.getAstyanaxKeyspace().describeKeyspace();
    } catch (ConnectionException e) {
        throw Throwables.propagate(e);
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:AstyanaxKeyspaceDiscovery.java

示例12: getKeyspaceOptions

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
private MapStringToObject getKeyspaceOptions(KeyspaceDefinition keyspace) {
    MapStringToObject result = new MapStringToObject();
    for (FieldMetadata field : keyspace.getFieldsMetadata()) {
        result.put(field.getName(), keyspace.getFieldValue(field.getName()));
    }

    result.remove("CF_DEFS");
    return result;
}
 
开发者ID:Netflix,项目名称:staash,代码行数:10,代码来源:ClusterRefreshTask.java

示例13: getLocksColumnFamily

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
private ColumnFamily getLocksColumnFamily() {

        if ( columnFamily == null ) {

            columnFamily = ColumnFamily.newColumnFamily(
                CF_NAME, StringSerializer.get(), StringSerializer.get() );

            if ( logger.isDebugEnabled() ) {

                try {
                    final KeyspaceDefinition kd = keyspace.describeKeyspace();
                    final ColumnFamilyDefinition cfd = kd.getColumnFamily( columnFamily.getName() );
                    Map<String, Object> options = new HashMap<>( 1 );
                    options.put( "gc_grace_seconds", cfd.getGcGraceSeconds() );
                    options.put( "caching", cfd.getCaching() );
                    options.put( "compaction_strategy", cfd.getCompactionStrategy() );
                    options.put( "compaction_strategy_options", cfd.getCompactionStrategyOptions() );
                    logger.debug( "Locks column family {} exists with options: {}", cfd.getName(), options);

                } catch ( ConnectionException ce ) {
                    logger.warn("Error connecting to Cassandra for debug column family info", ce);
                }
            }
        }

        return columnFamily;
    }
 
开发者ID:apache,项目名称:usergrid,代码行数:28,代码来源:AstyanaxLockManagerImpl.java

示例14: findExistingColumnFamilies

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
private void findExistingColumnFamilies(KeyspaceDefinition keySpaceMeta) {
	List<ColumnFamilyDefinition> cfList = keySpaceMeta.getColumnFamilyList();
	for(ColumnFamilyDefinition def : cfList) {
		loadColumnFamilyImpl(def);
	}
}
 
开发者ID:guci314,项目名称:playorm,代码行数:7,代码来源:ColumnFamilyHelper.java

示例15: getAllKeyspaces

import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入依赖的package包/类
public static List<KeyspaceDefinition> getAllKeyspaces() throws ConnectionException {
	return cluster.describeKeyspaces();
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:4,代码来源:CassandraDb.java


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