Package com.netflix.astyanax

Examples of com.netflix.astyanax.MutationBatch


    @Override
    public void delete(K id) throws PersistenceException {
        try {
            if (verbose)
                LOG.info(String.format("%s : Deleting id '%s'", columnFamily.getName(), id));
            MutationBatch mb = getMutationBatch();
            mb.withRow(columnFamily, id).delete();
            if (autoCommit)
                mb.execute();
        } catch(Exception e) {
            throw new PersistenceException("failed to delete entity " + id, e);
        }
    }
View Full Code Here


            if (verbose)
                LOG.info(String.format("%s : Removing entity '%s'", columnFamily.getName(), entity));
           
            lifecycleHandler.onPreRemove(entity);
            id = entityMapper.getEntityId(entity);
            MutationBatch mb = getMutationBatch();
            entityMapper.fillMutationBatchForDelete(mb, columnFamily, entity);
            if (autoCommit)
                mb.execute();
            lifecycleHandler.onPostRemove(entity);
        } catch(Exception e) {
            throw new PersistenceException("failed to delete entity " + id, e);
        }
    }
View Full Code Here

    /**
     * @inheritDoc
     */
    @Override
    public void delete(Collection<K> ids) throws PersistenceException {
        MutationBatch mb = getMutationBatch();       
        try {
            if (verbose)
                LOG.info(String.format("%s : Delete ids '%s'", columnFamily.getName(), ids.toString()));
            for (K id : ids) {
                mb.withRow(columnFamily, id).delete();
            }
            if (autoCommit)
                mb.execute();
        } catch(Exception e) {
            throw new PersistenceException("failed to delete entities " + ids, e);
        }
    }
View Full Code Here

                                                                      // all
                                                                      // just
                                                                      // Class
                                                                      // anyway

        MutationBatch mutationBatch = keyspace.prepareMutationBatch();
        mutationBatch.withRow(columnFamily,
                mapping.getIdValue(item, idFieldClass)).delete();
        mutationBatch.execute();
    }
View Full Code Here

        }
    }

    @Override
    public void remove(Collection<T> entities) throws PersistenceException {
        MutationBatch mb = getMutationBatch();       
        try {
            for (T entity : entities) {
                lifecycleHandler.onPreRemove(entity);
                if (verbose)
                    LOG.info(String.format("%s : Deleting '%s'", columnFamily.getName(), entity));
                entityMapper.fillMutationBatchForDelete(mb, columnFamily, entity);
            }
            mb.execute();
            for (T entity : entities) {
                lifecycleHandler.onPostRemove(entity);
            }
        } catch(Exception e) {
            throw new PersistenceException("failed to delete entities ", e);
View Full Code Here

    /**
     * @inheritDoc
     */
    @Override
    public void put(Collection<T> entities) throws PersistenceException {
        MutationBatch mb = getMutationBatch();       
        try {
            for (T entity : entities) {
                lifecycleHandler.onPrePersist(entity);
                if (verbose)
                    LOG.info(String.format("%s : Writing '%s'", columnFamily.getName(), entity));
                entityMapper.fillMutationBatch(mb, columnFamily, entity);          
            }
            if (autoCommit)
                mb.execute();
           
            for (T entity : entities) {
                lifecycleHandler.onPostPersist(entity);
            }

View Full Code Here

                                                                      // all
                                                                      // just
                                                                      // Class
                                                                      // anyway

        MutationBatch mutationBatch = keyspace.prepareMutationBatch();
        ColumnListMutation<String> columnListMutation = mutationBatch.withRow(
                columnFamily, mapping.getIdValue(item, idFieldClass));
        mapping.fillMutation(item, columnListMutation);

        mutationBatch.execute();
    }
View Full Code Here

    @Override
    public void commit() throws PersistenceException {
        if (verbose)
            LOG.info(String.format("%s : Commit mutation", columnFamily.getName()));
       
        MutationBatch mb = getMutationBatch();
        if (mb != null) {
            try {
                mb.execute();
            } catch (ConnectionException e) {
                throw new PersistenceException("Failed to commit mutation batch", e);
            }
        }
        else {
View Full Code Here

        Assert.assertNull(column);
    }
   
    @Test
    public void testFunctionalQuery() throws Exception {
      MutationBatch m = keyspace.prepareMutationBatch();

        for (char keyName = 'A'; keyName <= 'Z'; keyName++) {
            String rowKey = Character.toString(keyName);
            ColumnListMutation<String> cfmStandard = m.withRow(CF_STANDARD1, rowKey);
            for (char cName = 'a'; cName <= 'z'; cName++) {
                cfmStandard.putColumn(Character.toString(cName),
                        (int) (cName - 'a') + 1, null);
            }
            m.withCaching(true);
            m.execute();
            m.discardMutations();
        }
       
        OperationResult<ColumnList<String>> r1 = keyspace
                .prepareQuery(CF_STANDARD1).getKey("A").execute();
        Assert.assertTrue(26 <= r1.getResult().size());
View Full Code Here

    }

    @Test
    public void testHasValue() throws Exception {

      MutationBatch m = keyspace.prepareMutationBatch();
      m.withRow(CF_USER_INFO, "acct1234")
      .putColumn("firstname", "john", null)
      .putColumn("lastname", "smith", null)
      .putColumn("address", "555 Elm St", null)
      .putColumn("age", 30, null)
      .putEmptyColumn("empty");

      m.execute();
      ColumnList<String> response = keyspace.prepareQuery(CF_USER_INFO).getRow("acct1234").execute().getResult();
      Assert.assertEquals("firstname", response.getColumnByName("firstname").getName());
      Assert.assertEquals("firstname", response.getColumnByName("firstname").getName());
      Assert.assertEquals("john", response.getColumnByName("firstname").getStringValue());
      Assert.assertEquals("john", response.getColumnByName("firstname").getStringValue());
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.MutationBatch

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.