Package com.netflix.astyanax.thrift.ddl

Examples of com.netflix.astyanax.thrift.ddl.ThriftKeyspaceDefinitionImpl


        return executeOperation(
                new AbstractKeyspaceOperationImpl<KeyspaceDefinition>(
                        tracerFactory.newTracer(CassandraOperationType.DESCRIBE_KEYSPACE), getKeyspaceName()) {
                    @Override
                    public KeyspaceDefinition internalExecute(Cassandra.Client client, ConnectionContext context) throws Exception {
                        return new ThriftKeyspaceDefinitionImpl(client.describe_keyspace(getKeyspaceName()));
                    }
                }, getConfig().getRetryPolicy().duplicate());
    }
View Full Code Here


    @Override
    public OperationResult<SchemaChangeResult> createKeyspace(
            final Map<String, Object> options,
            final Map<ColumnFamily, Map<String, Object>> cfs) throws ConnectionException {
       
        ThriftKeyspaceDefinitionImpl ksDef = toThriftKeyspaceDefinition(options);
        for (Entry<ColumnFamily, Map<String, Object>> cf : cfs.entrySet()) {
            ksDef.addColumnFamily(toThriftColumnFamilyDefinition(cf.getValue(), cf.getKey()));
        }
       
        ksDef.setName(getKeyspaceName());

        return internalCreateKeyspace(ksDef.getThriftKeyspaceDefinition());
    }   
View Full Code Here

    /**
     * Convert a Map of options to an internal thrift keyspace definition
     * @param options
     */
    private ThriftKeyspaceDefinitionImpl toThriftKeyspaceDefinition(final Map<String, Object> options) {
        ThriftKeyspaceDefinitionImpl def = new ThriftKeyspaceDefinitionImpl();
       
        Map<String, Object> internalOptions = Maps.newHashMap();
        if (options != null)
            internalOptions.putAll(options);
       
        if (internalOptions.containsKey("name") && !internalOptions.get("name").equals(getKeyspaceName())) {
            throw new RuntimeException(
                    String.format("'name' attribute must match keyspace name. Expected '%s' but got '%s'",
                                  getKeyspaceName(), internalOptions.get("name")));
        }
        else {
            internalOptions.put("name", getKeyspaceName());
        }
       
        def.setFields(internalOptions);
       
        return def;
    }
View Full Code Here

        KeyspaceDefinition ksDef = this.describeKeyspace();
        if (ksDef == null)
            throw new NotFoundException(String.format("Keyspace '%s' not found", getKeyspaceName()));
       
        Properties props = new Properties();
        ThriftKeyspaceDefinitionImpl thriftKsDef = (ThriftKeyspaceDefinitionImpl)ksDef;
        try {
            for (Entry<Object, Object> prop : thriftKsDef.getProperties().entrySet()) {
                props.setProperty((String)prop.getKey(), (String) prop.getValue());
            }
        } catch (Exception e) {
            LOG.error(String.format("Error fetching properties for keyspace '%s'", getKeyspaceName()));
        }
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.thrift.ddl.ThriftKeyspaceDefinitionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.