Package org.scale7.cassandra.pelops

Examples of org.scale7.cassandra.pelops.Selector


        if (invertedIndexingApplicable)
        {
            String indexColumnFamily = CassandraIndexHelper.getInvertedIndexTableName(entityMetadata.getTableName());

            Mutator mutator = pelopsClient.getMutator();

            List<ThriftRow> indexThriftyRows = ((PelopsDataHandler) cdHandler).toIndexThriftRow(node.getData(),
                    entityMetadata, indexColumnFamily);

            for (ThriftRow thriftRow : indexThriftyRows)
            {

                List<Column> thriftColumns = thriftRow.getColumns();
                List<SuperColumn> thriftSuperColumns = thriftRow.getSuperColumns();
                if (thriftColumns != null && !thriftColumns.isEmpty())
                {
                    // Bytes.fromL
                    mutator.writeColumns(thriftRow.getColumnFamilyName(), Bytes.fromByteBuffer(CassandraUtilities
                            .toBytes(thriftRow.getId(), thriftRow.getId().getClass())), Arrays.asList(thriftRow
                            .getColumns().toArray(new Column[0])));
                }

                if (thriftSuperColumns != null && !thriftSuperColumns.isEmpty())
                {
                    for (SuperColumn sc : thriftSuperColumns)
                    {
                        mutator.writeSubColumns(thriftRow.getColumnFamilyName(), Bytes
                                .fromByteBuffer(CassandraUtilities.toBytes(thriftRow.getId(), thriftRow.getId()
                                        .getClass())), Bytes.fromByteArray(sc.getName()), sc.getColumns());
                    }
                }
            }
            mutator.execute(consistencyLevel);
            indexThriftyRows = null;
        }
    }
View Full Code Here


     * @param mutator
     */
    public void deleteColumn(String indexColumnFamily, String rowKey, byte[] superColumnName, String persistenceUnit,
            ConsistencyLevel consistencyLevel, byte[] columnName)
    {
        Mutator mutator = pelopsClient.getMutator();
        mutator.deleteColumn(indexColumnFamily, rowKey, Bytes.fromByteArray(superColumnName));
        mutator.execute(consistencyLevel);
    }
View Full Code Here

    /**
     * Persists records into Join Table
     */
    public void persistJoinTable(JoinTableData joinTableData)
    {
        Mutator mutator = clientFactory.getMutator(pool);

        String joinTableName = joinTableData.getJoinTableName();
        String invJoinColumnName = joinTableData.getInverseJoinColumnName();
        Map<Object, Set<Object>> joinTableRecords = joinTableData.getJoinTableRecords();
        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                joinTableData.getEntityClass());

        if (isCql3Enabled(entityMetadata))
        {
            Cassandra.Client conn = null;
            Object pooledConnection = null;
            pooledConnection = getConnection();
            conn = (org.apache.cassandra.thrift.Cassandra.Client) getConnection(pooledConnection);
            persistJoinTableByCql(joinTableData, conn);
        }
        else
        {
            for (Object key : joinTableRecords.keySet())
            {
                Set<Object> values = joinTableRecords.get(key);

                List<Column> columns = new ArrayList<Column>();

                Class columnType = null;
                for (Object value : values)
                {
                    Column column = new Column();
                    column.setName(PropertyAccessorFactory.STRING.toBytes(invJoinColumnName
                            + Constants.JOIN_COLUMN_NAME_SEPARATOR + value.toString()));
                    column.setValue(PropertyAccessorHelper.getBytes(value));
                    column.setTimestamp(generator.getTimestamp());
                    columnType = value.getClass();
                    columns.add(column);
                }

                createIndexesOnColumns(entityMetadata, joinTableName, columns, columnType);

                mutator.writeColumns(joinTableName, Bytes.fromByteArray(PropertyAccessorHelper.getBytes(key)),
                        Arrays.asList(columns.toArray(new Column[0])));
            }
        }
        if (log.isInfoEnabled())
        {
            log.info(" Persisted data with join table column family {}", joinTableData.getJoinTableName());
        }
        mutator.execute(getConsistencyLevel());
    }
View Full Code Here

                if (tf.getColumnFamilyName().equals(metadata.getTableName()))
                {
                    addRelationsToThriftRow(metadata, tf, rlHolders);
                }
                Mutator mutator = clientFactory.getMutator(pool);
                if (metadata.isCounterColumnType())
                {
                    if (log.isInfoEnabled())
                    {
                        log.info("Persisting counter column family record for row key {}", tf.getId());
                    }
                    List<CounterColumn> thriftCounterColumns = tf.getCounterColumns();
                    List<CounterSuperColumn> thriftCounterSuperColumns = tf.getCounterSuperColumns();
                    if (thriftCounterColumns != null && !thriftCounterColumns.isEmpty())
                    {
                        mutator.writeCounterColumns(tf.getColumnFamilyName(),
                                Bytes.fromByteBuffer(CassandraUtilities.toBytes(tf.getId(), tf.getId().getClass())),
                                Arrays.asList(tf.getCounterColumns().toArray(new CounterColumn[0])));
                    }

                    if (thriftCounterSuperColumns != null && !thriftCounterSuperColumns.isEmpty())
                    {
                        for (CounterSuperColumn sc : thriftCounterSuperColumns)
                        {
                            mutator.writeSubCounterColumns(
                                    tf.getColumnFamilyName(),
                                    Bytes.fromByteBuffer(CassandraUtilities.toBytes(tf.getId(), tf.getId().getClass())),
                                    Bytes.fromByteArray(sc.getName()), sc.getColumns());
                        }
                    }
                }
                else
                {
                    List<Column> thriftColumns = tf.getColumns();
                    List<SuperColumn> thriftSuperColumns = tf.getSuperColumns();
                    if (thriftColumns != null && !thriftColumns.isEmpty())
                    {
                        // Bytes.from
                        mutator.writeColumns(tf.getColumnFamilyName(),
                                Bytes.fromByteBuffer(CassandraUtilities.toBytes(tf.getId(), tf.getId().getClass())),
                                tf.getColumns());
                    }

                    if (thriftSuperColumns != null && !thriftSuperColumns.isEmpty())
                    {
                        for (SuperColumn sc : thriftSuperColumns)
                        {
                            if (log.isInfoEnabled())
                            {
                                log.info("Persisting super column family record for row key {}", tf.getId());
                            }

                            mutator.writeSubColumns(
                                    tf.getColumnFamilyName(),
                                    Bytes.fromByteBuffer(CassandraUtilities.toBytes(tf.getId(), tf.getId().getClass())),
                                    Bytes.fromByteArray(sc.getName()), sc.getColumns());
                        }
                    }
                }
                mutator.execute(getConsistencyLevel());
            }
            tfRows = null;
            if (isTtlPerRequest())
            {
                getTtlValues().clear();
View Full Code Here

     * {@inheritDoc}.
     */
    @Override
    public Mutator createMutator() {
        validateKeyspaceSet();
        return new Mutator(this);
    }
View Full Code Here

     * {@inheritDoc}.
     */
    @Override
    public Mutator createMutator(long timestamp, boolean deleteIfNull) {
        validateKeyspaceSet();
        return new Mutator(this, timestamp, deleteIfNull);
    }
View Full Code Here

    }

    @Override
    public Mutator createMutator(long timestamp, boolean deleteIfNull, int ttl) {
        validateKeyspaceSet();
        return new Mutator(this, timestamp, this.getOperandPolicy().isDeleteIfNull(), ttl);
    }
View Full Code Here

     * @param cluster the cluster this pool is pooling connections to
     * @param keyspace the keyspace this pool is for
     * @see #CommonsBackedPool(org.scale7.cassandra.pelops.Cluster, String, org.scale7.cassandra.pelops.pool.CommonsBackedPool.Policy,org.scale7.cassandra.pelops.OperandPolicy, org.scale7.cassandra.pelops.pool.CommonsBackedPool.INodeSelectionStrategy, org.scale7.cassandra.pelops.pool.CommonsBackedPool.INodeSuspensionStrategy, org.scale7.cassandra.pelops.pool.CommonsBackedPool.IConnectionValidator)
     */
    public CommonsBackedPool(Cluster cluster, String keyspace) {
        this(cluster, keyspace, new Policy(cluster), new OperandPolicy());
    }
View Full Code Here

        if (keyspace == null) throw new IllegalArgumentException("keyspace is a required argument");
        this.cluster = cluster;
        this.keyspace = keyspace;
       
        this.policy = policy != null ? policy : new Policy(cluster);
        this.operandPolicy = operandPolicy != null ? operandPolicy : new OperandPolicy();

        logger.info("Initialising pool configuration policy: {}", this.policy.toString());

        this.nodeSelectionStrategy = nodeSelectionStrategy != null ? nodeSelectionStrategy : new LeastLoadedNodeSelectionStrategy();
        logger.info("Initialising pool node selection strategy: {}", this.nodeSelectionStrategy);
View Full Code Here

     * Tests the factory bean works as expected when operand or pool policy instances are provided.
     * @throws Exception if an error occurs
     */
    @Test
    public void testAfterProperties() throws Exception {
        OperandPolicy operandPolicy = new OperandPolicy();
        CommonsBackedPool.Policy policy = new CommonsBackedPool.Policy();
        LeastLoadedNodeSelectionStrategy nodeSelectionStrategy = new LeastLoadedNodeSelectionStrategy();
        NoOpNodeSuspensionStrategy nodeSuspensionStrategy = new NoOpNodeSuspensionStrategy();
        NoOpConnectionValidator connectionValidator = new NoOpConnectionValidator();

View Full Code Here

TOP

Related Classes of org.scale7.cassandra.pelops.Selector

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.