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


Java MutationBatch.withRow方法代码示例

本文整理汇总了Java中com.netflix.astyanax.MutationBatch.withRow方法的典型用法代码示例。如果您正苦于以下问题:Java MutationBatch.withRow方法的具体用法?Java MutationBatch.withRow怎么用?Java MutationBatch.withRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.netflix.astyanax.MutationBatch的用法示例。


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

示例1: addPoint

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public void addPoint(String key, List<SeriesValue> values) {
    boolean nullKey = false;
    try {
        registerKey(key);
        MutationBatch m = keyspace.prepareMutationBatch();
        ColumnListMutation<String> mut = m.withRow(columnFamily, key);
        for (SeriesValue value : values) {
            if (value.getColumn() == null) nullKey = true;
            else mut.putColumn(value.getColumn(), SeriesValueCodec.encodeValue(value), null);
        }
        m.execute();
    } catch (ConnectionException ce) {
        throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, messageCatalog.getMessage("DbCommsError"), ce);
    } catch (UnsupportedEncodingException e) {
        throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, messageCatalog.getMessage("BadSeriesValue"), e);
    }
    if (nullKey) throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_BAD_REQUEST, messageCatalog.getMessage("BadKey"));
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:19,代码来源:AstyanaxSeriesConnection.java

示例2: deleteOldColumns

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
private void deleteOldColumns(AstyanaxTable table, String blobId, ColumnList<Composite> columns, long timestamp) {
    for (AstyanaxStorage storage : table.getWriteStorage()) {
        BlobPlacement placement = (BlobPlacement) storage.getPlacement();

        // Any columns with a timestamp older than the one we expect must be from an old version
        // of the blob.  This should be rare, but if it happens clean up and delete the old data.
        MutationBatch mutation = placement.getKeyspace().prepareMutationBatch(ConsistencyLevel.CL_ANY);
        ColumnListMutation<Composite> row = mutation.withRow(
                placement.getBlobColumnFamily(), storage.getRowKey(blobId));
        boolean found = false;
        for (Column<Composite> column : columns) {
            if (column.getTimestamp() < timestamp) {
                if (ColumnGroup.B.name().equals(column.getName().get(0, AsciiSerializer.get()))) {
                    int chunkId = column.getName().get(1, IntegerSerializer.get());
                    row.deleteColumn(getColumn(ColumnGroup.B, chunkId))
                            .deleteColumn(getColumn(ColumnGroup.Z, chunkId));
                    found = true;
                }
            }
        }
        if (found) {
            execute(mutation);
        }
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:26,代码来源:AstyanaxStorageProvider.java

示例3: createInstanceEntry

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public void createInstanceEntry(RaigadInstance instance) throws Exception {
    logger.info("Creating new instance entry");

    String key = getRowKey(instance);
    // If the key exists throw exception
    if (getInstance(instance.getApp(), instance.getDC(), instance.getId()) != null) {
        logger.info(String.format("Key already exists: %s", key));
        return;
    }

    // Grab the lock
    getLock(instance);

    MutationBatch mutationBatch = bootKeyspace.prepareMutationBatch();
    ColumnListMutation<String> columnListMutation = mutationBatch.withRow(CF_INSTANCES, key);
    columnListMutation.putColumn(CN_CLUSTER, instance.getApp(), null);
    columnListMutation.putColumn(CN_AZ, instance.getAvailabilityZone(), null);
    columnListMutation.putColumn(CN_INSTANCEID, instance.getInstanceId(), null);
    columnListMutation.putColumn(CN_HOSTNAME, instance.getHostName(), null);
    columnListMutation.putColumn(CN_IP, instance.getHostIP(), null);
    columnListMutation.putColumn(CN_LOCATION, instance.getDC(), null);
    columnListMutation.putColumn(CN_ASGNAME, instance.getAsg(), null);
    columnListMutation.putColumn(CN_UPDATETIME, TimeUUIDUtils.getUniqueTimeUUIDinMicros(), null);

    mutationBatch.execute();
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:27,代码来源:InstanceDataDAOCassandra.java

示例4: tagId

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
    public void tagId(String id, Map<String, String> tags) throws IndexerException  {
        MutationBatch mb = keyspace.prepareMutationBatch();
        
        ColumnListMutation<String> idRow = mb.withRow(dataCf, id);
        UUID uuid = TimeUUIDUtils.getUniqueTimeUUIDinMicros();
        for (Map.Entry<String, String> tag : tags.entrySet()) {
            String rowkey = tag.getKey() + "=" + tag.getValue();
            System.out.println("Rowkey: " + rowkey);
            mb.withRow(indexCf, tag.getKey() + "=" + tag.getValue())
              .putEmptyColumn(new IndexEntry(id, uuid));
//            idRow.putColumn(tag.getKey(), tag.getValue());
        }
        
        try {
            mb.execute();
        } catch (ConnectionException e) {
            throw new IndexerException("Failed to store tags : " + tags + " for id " + id, e);
        }
    }
 
开发者ID:Netflix,项目名称:staash,代码行数:21,代码来源:SimpleReverseIndexer.java

示例5: updateRow

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public void updateRow(String key, RowData rowData) throws PaasException {
    LOG.info("Update row: " + rowData.toString());
    invariant();
    
    MutationBatch mb = keyspace.prepareMutationBatch();
    if (rowData.hasSchemalessRows()) {
        ColumnListMutation<ByteBuffer> mbRow = mb.withRow(this.columnFamily, serializers.keyAsByteBuffer(key));
        for (Entry<String, Map<String, String>> row : rowData.getSrows().getRows().entrySet()) {
            for (Entry<String, String> column : row.getValue().entrySet()) {
                mbRow.putColumn(serializers.columnAsByteBuffer(column.getKey()),  
                                serializers.valueAsByteBuffer(column.getKey(), column.getValue()));
            }
        }
    }
    
    try {
        mb.execute();
    } catch (ConnectionException e) {
        throw new PaasException(
                String.format("Failed to update row '%s' in column family '%s.%s'" , 
                              key, this.keyspace.getKeyspaceName(), this.columnFamily.getName()),
                e);
    }
}
 
开发者ID:Netflix,项目名称:staash,代码行数:25,代码来源:AstyanaxThriftDataTableResource.java

示例6: updateColumn

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
public void updateColumn(String key, String column, String value) throws NotFoundException, PaasException {
    LOG.info("Update row");
    invariant();
    
    MutationBatch mb = keyspace.prepareMutationBatch();
    ColumnListMutation<ByteBuffer> mbRow = mb.withRow(this.columnFamily, serializers.keyAsByteBuffer(key));
    mbRow.putColumn(serializers.columnAsByteBuffer(column),  
                    serializers.valueAsByteBuffer(column, value));
    
    try {
        mb.execute();
    } catch (ConnectionException e) {
        throw new PaasException(
                String.format("Failed to update row '%s' in column family '%s.%s'" , 
                              key, this.keyspace.getKeyspaceName(), this.columnFamily.getName()),
                e);
    }
}
 
开发者ID:Netflix,项目名称:staash,代码行数:20,代码来源:AstyanaxThriftDataTableResource.java

示例7: deleteColumn

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
public void deleteColumn(String key, String column) throws PaasException {
    LOG.info("Update row");
    invariant();
    
    MutationBatch mb = keyspace.prepareMutationBatch();
    ColumnListMutation<ByteBuffer> mbRow = mb.withRow(this.columnFamily, serializers.keyAsByteBuffer(key));
    mbRow.deleteColumn(serializers.columnAsByteBuffer(column));
    try {
        mb.execute();
    } catch (ConnectionException e) {
        throw new PaasException(
                String.format("Failed to update row '%s' in column family '%s.%s'" , 
                              key, this.keyspace.getKeyspaceName(), this.columnFamily.getName()),
                e);
    }
}
 
开发者ID:Netflix,项目名称:staash,代码行数:18,代码来源:AstyanaxThriftDataTableResource.java

示例8: writeMetadata

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public void writeMetadata(Table<Locator, String, String> metaTable) throws ConnectionException {
    ColumnFamily cf = CassandraModel.CF_METRICS_METADATA;
    Timer.Context ctx = Instrumentation.getBatchWriteTimerContext(CassandraModel.CF_METRICS_METADATA_NAME);
    MutationBatch batch = keyspace.prepareMutationBatch();

    try {
        for (Locator locator : metaTable.rowKeySet()) {
            Map<String, String> metaRow = metaTable.row(locator);
            ColumnListMutation<String> mutation = batch.withRow(cf, locator);

            for (Map.Entry<String, String> meta : metaRow.entrySet()) {
                mutation.putColumn(meta.getKey(), meta.getValue(), StringMetadataSerializer.get(), null);
            }
        }
        try {
            batch.execute();
        } catch (ConnectionException e) {
            Instrumentation.markWriteError(e);
            log.error("Connection exception persisting metadata", e);
            throw e;
        }
    } finally {
        ctx.stop();
    }
}
 
开发者ID:rackerlabs,项目名称:blueflood,代码行数:26,代码来源:AstyanaxWriter.java

示例9: doWrite

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
protected void doWrite(Publisher source, List<ChannelSchedule> blocks) throws WriteException {
    try {
        MutationBatch batch = keyspace.prepareMutationBatch().withConsistencyLevel(writeCl);
        for (ChannelSchedule block : blocks) {
            ColumnListMutation<String> rowMutation = batch.withRow(cf, key(source, block));
            for (ItemAndBroadcast entry : block.getEntries()) {
                rowMutation.putColumn(
                        entry.getBroadcast().getSourceId(),
                        serializer.serialize(entry)
                );
            }
            rowMutation.putColumn(IDS_COL, Joiner.on(',').join(broadcastIds(block)));
            rowMutation.putColumn(UPDATED_COL, clock.now().toDate());
        }
        try {
            batch.execute();
        } catch (ConnectionException ce) {
            throw new WriteException(ce);
        }
    } catch (WriteException | RuntimeException e) {
        throw e;
    }
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:25,代码来源:AstyanaxCassandraScheduleStore.java

示例10: storeCompactedDeltas

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Timed (name = "bv.emodb.sorAstyanaxDataWriterDAO.storeCompactedDeltas", absolute = true)
@Override
public void storeCompactedDeltas(Table tbl, String key, List<History> audits, WriteConsistency consistency) {
    checkNotNull(tbl, "table");
    checkNotNull(key, "key");
    checkNotNull(audits, "audits");
    checkNotNull(consistency, "consistency");

    AstyanaxTable table = (AstyanaxTable) tbl;
    for (AstyanaxStorage storage : table.getWriteStorage()) {
        DeltaPlacement placement = (DeltaPlacement) storage.getPlacement();
        CassandraKeyspace keyspace = placement.getKeyspace();

        ByteBuffer rowKey = storage.getRowKey(key);

        MutationBatch mutation = keyspace.prepareMutationBatch(SorConsistencies.toAstyanax(consistency));
        ColumnListMutation<UUID> rowMutation = mutation.withRow(placement.getDeltaHistoryColumnFamily(), rowKey);

        for (History history : audits) {
            rowMutation.putColumn(history.getChangeId(),
                    _changeEncoder.encodeHistory(history),
                    Ttls.toSeconds(_auditStore.getHistoryTtl(), 1, null));
        }
        execute(mutation, "store %d compacted deltas for placement %s, table %s, key %s",
                audits.size(), placement.getName(), table.getName(), key);
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:28,代码来源:AstyanaxDataWriterDAO.java

示例11: removeColumns

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
private void removeColumns(Remove action, ColumnFamily cf, MutationBatch m) {
	ColumnListMutation row = m.withRow(cf, action.getRowKey());
	
	for(byte[] name : action.getColumns()) {
		row.deleteColumn(name);
	}
}
 
开发者ID:guci314,项目名称:playorm,代码行数:8,代码来源:CassandraSession.java

示例12: removeColumn

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
private void removeColumn(RemoveColumn action, MetaLookup mgr, MutationBatch m) {
	Info info = columnFamilies.fetchColumnFamilyInfo(action.getColFamily().getColumnFamily(), mgr);
	if(info == null)
		return; //if no cf exist/returned, nothing to do
	ColumnFamily cf = info.getColumnFamilyObj();
	ColumnListMutation row = m.withRow(cf, action.getRowKey());
	if(row == null)
		return;
	byte[] name = action.getColumn();
		row.deleteColumn(name);
}
 
开发者ID:guci314,项目名称:playorm,代码行数:12,代码来源:CassandraSession.java

示例13: persistIndex

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
private void persistIndex(PersistIndex action, MetaLookup mgr, MutationBatch m) {
	String indexCfName = action.getIndexCfName();
	Info info = columnFamilies.lookupOrCreate2(indexCfName, mgr);

	ColumnFamily cf = info.getColumnFamilyObj();
	ColumnListMutation colMutation = m.withRow(cf, action.getRowKey());
	Object toPersist = createObjectToUse(action, info);
	colMutation.putEmptyColumn(toPersist, action.getRowTtl());
}
 
开发者ID:guci314,项目名称:playorm,代码行数:10,代码来源:CassandraSession.java

示例14: removeIndex

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
private void removeIndex(RemoveIndex action, MetaLookup mgr, MutationBatch m) {
	String indexCfName = action.getIndexCfName();
	if (indexCfName.equalsIgnoreCase("BytesIndice"))
		return;
	Info info = columnFamilies.fetchColumnFamilyInfo(indexCfName, mgr);
	if(info == null)
		return; //nothing to do since it doesn't exist
	
	ColumnFamily cf = info.getColumnFamilyObj();
	ColumnListMutation colMutation = m.withRow(cf, action.getRowKey());
	Object toRemove = createObjectToUse(action, info);
	
	colMutation.deleteColumn(toRemove);
}
 
开发者ID:guci314,项目名称:playorm,代码行数:15,代码来源:CassandraSession.java

示例15: persist

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
private void persist(Persist action, MetaLookup ormSession, MutationBatch m) {
	Info info = columnFamilies.lookupOrCreate2(action.getColFamily().getColumnFamily(), ormSession);
	ColumnFamily cf = info.getColumnFamilyObj();
	
	ColumnListMutation colMutation = m.withRow(cf, action.getRowKey());
	
	for(Column col : action.getColumns()) {
		byte[] value = new byte[0];
		if(col.getValue() != null)
			value = col.getValue();

		colMutation.putColumn(col.getName(), value, col.getTtl());
	}
}
 
开发者ID:guci314,项目名称:playorm,代码行数:15,代码来源:CassandraSession.java


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