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


Java ColumnListMutation.putColumn方法代码示例

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


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

示例1: addPoint

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的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: createInstanceEntry

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的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

示例3: updateRow

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的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

示例4: updateColumn

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的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

示例5: writeMetadata

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的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

示例6: doWrite

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的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

示例7: storeCompactedDeltas

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的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

示例8: commit

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的package包/类
@Override
public void commit(List<History> historyList, Object rowKey) {
    if (historyList != null && !historyList.isEmpty()) {
        ColumnListMutation<UUID> historyMutation = _mutation.withRow(_columnFamily, (ByteBuffer)rowKey);
        for (History history : historyList) {
            historyMutation.putColumn(history.getChangeId(),
                    _changeEncoder.encodeHistory(history),
                    Ttls.toSeconds(_auditStore.getHistoryTtl(), 1, null));
        }
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:12,代码来源:AstyanaxAuditBatchPersister.java

示例9: persist

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的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

示例10: getLock

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的package包/类
private void getLock(RaigadInstance instance) throws Exception {
    String choosingkey = getChoosingKey(instance);
    MutationBatch m = bootKeyspace.prepareMutationBatch();
    ColumnListMutation<String> clm = m.withRow(CF_LOCKS, choosingkey);

    // Expire in 6 sec
    clm.putColumn(instance.getInstanceId(), instance.getInstanceId(), new Integer(6));
    m.execute();
    int count = bootKeyspace.prepareQuery(CF_LOCKS).getKey(choosingkey).getCount().execute().getResult();
    if (count > 1) {
        // Need to delete my entry
        m.withRow(CF_LOCKS, choosingkey).deleteColumn(instance.getInstanceId());
        m.execute();
        throw new Exception(String.format("More than 1 contender for lock %s %d", choosingkey, count));
    }

    String lockKey = getLockingKey(instance);
    OperationResult<ColumnList<String>> result = bootKeyspace.prepareQuery(CF_LOCKS).getKey(lockKey).execute();
    if (result.getResult().size() > 0 && !result.getResult().getColumnByIndex(0).getName().equals(instance.getInstanceId())) {
        throw new Exception(String.format("Lock already taken %s", lockKey));
    }

    clm = m.withRow(CF_LOCKS, lockKey);
    clm.putColumn(instance.getInstanceId(), instance.getInstanceId(), new Integer(600));
    m.execute();
    Thread.sleep(100);
    result = bootKeyspace.prepareQuery(CF_LOCKS).getKey(lockKey).execute();
    if (result.getResult().size() == 1 && result.getResult().getColumnByIndex(0).getName().equals(instance.getInstanceId())) {
        logger.info("Got lock " + lockKey);
        return;
    }
    else {
        throw new Exception(String.format("Cannot insert lock %s", lockKey));
    }
}
 
开发者ID:Netflix,项目名称:Raigad,代码行数:36,代码来源:InstanceDataDAOCassandra.java

示例11: putShardState

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的package包/类
@Override
public void putShardState(int shard, Map<Granularity, Map<Integer, UpdateStamp>> slotTimes) throws IOException {
    AstyanaxIO astyanaxIO = AstyanaxIO.singleton();
    Timer.Context ctx = Instrumentation.getWriteTimerContext(CassandraModel.CF_METRICS_STATE_NAME);
    try {
        MutationBatch mutationBatch = astyanaxIO.getKeyspace().prepareMutationBatch();
        ColumnListMutation<SlotState> mutation = mutationBatch.withRow(CassandraModel.CF_METRICS_STATE, (long)shard);
        for (Map.Entry<Granularity, Map<Integer, UpdateStamp>> granEntry : slotTimes.entrySet()) {
            Granularity g = granEntry.getKey();
            for (Map.Entry<Integer, UpdateStamp> entry : granEntry.getValue().entrySet()) {
                // granularity,slot,state
                SlotState slotState = new SlotState(g, entry.getKey(), entry.getValue().getState());
                mutation.putColumn(slotState, entry.getValue().getTimestamp());
                /*
                  Note: this method used to set the timestamp of the Cassandra column to entry.getValue().getTimestamp() * 1000, i.e. the collection time.
                  That implementation was changed because it could cause delayed metrics not to rollup.
                  Consider you are getting out of order metrics M1 and M2, with collection times T1 and T2 with T2>T1, belonging to same slot
                  Assume M2 arrives first. The slot gets marked active and rolled up and the state is set as Rolled. Now, assume M1 arrives. We update the slot state to active,
                  set the slot timestamp to T1, and while persisting we set it, we set the column timestamp to be T1*1000, but because the T1 < T2, Cassandra wasn't updating it.
                 */
            }
        }
        if (!mutationBatch.isEmpty())
            try {
                mutationBatch.execute();
            } catch (ConnectionException e) {
                Instrumentation.markWriteError(e);
                LOG.error("Error persisting shard state", e);
                throw new IOException(e);
            }
    } finally {
        ctx.stop();
    }
}
 
开发者ID:rackerlabs,项目名称:blueflood,代码行数:35,代码来源:AShardStateIO.java

示例12: exportToDatabase

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的package包/类
private void exportToDatabase(ColumnListMutation<String> mutator) {
	/**
	 * POSTPONED | WAITING
	 */
	int ttl = TTL_WAITING;
	
	if (delete_after_completed && isThisStatus(JobStatus.DONE, JobStatus.CANCELED)) {
		/**
		 * Short ttl if Broker is closed before it can delete this.
		 */
		ttl = TTL_DELETE_AFTER_COMPLETED;
	} else if (isThisStatus(JobStatus.TOO_OLD, JobStatus.CANCELED, JobStatus.STOPPED, JobStatus.ERROR, JobStatus.TOO_LONG_DURATION)) {
		ttl = TTL_TROUBLES;
	} else if (isThisStatus(JobStatus.PREPARING)) {
		ttl = TTL_PREPARING;
	} else if (isThisStatus(JobStatus.DONE)) {
		ttl = TTL_DONE;
	} else if (isThisStatus(JobStatus.PROCESSING)) {
		ttl = TTL_PROCESSING;
	}
	
	mutator.putColumn("context_class", context.getClass().getName(), ttl);
	mutator.putColumn("status", status.name(), ttl);
	mutator.putColumn("creator_hostname", instance_status_creator_hostname, ttl);
	mutator.putColumn("expiration_date", expiration_date, ttl);
	mutator.putColumn("update_date", update_date, ttl);
	mutator.putColumn("delete_after_completed", delete_after_completed, ttl);
	/**
	 * Workaround for Cassandra index select bug.
	 */
	mutator.putColumn("indexingdebug", 1, ttl);
	mutator.putColumn("source", MyDMAM.gson_kit.getGson().toJson(this), ttl);
	
	if (Loggers.Job.isTraceEnabled()) {
		Loggers.Job.trace("Prepare export to db job:\t" + toString() + " with ttl " + ttl);
	}
	
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:39,代码来源:JobNG.java

示例13: run

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的package包/类
@Override
protected Void run() throws Exception {
    MutationBatch m = keyspace.prepareMutationBatch().setConsistencyLevel(ConsistencyLevel.CL_QUORUM);

    // Setting columns in a standard column
    ColumnListMutation<String> cm = m.withRow(columnFamily, rowKey);
    for (String key : attributes.keySet()) {
        Object o = attributes.get(key);
        if (o != null) {
            // unfortunately the 'putColumn' method does not nicely figure
            // out what type the Object is so we need to do it manually
            if (o instanceof String) {
                cm.putColumn(key, (String) o, ttlSeconds);
            } else if (o instanceof Boolean) {
                cm.putColumn(key, (Boolean) o, ttlSeconds);
            } else if (o instanceof Integer) {
                cm.putColumn(key, (Integer) o, ttlSeconds);
            } else if (o instanceof Long) {
                cm.putColumn(key, (Long) o, ttlSeconds);
            } else if (o instanceof Double) {
                cm.putColumn(key, (Double) o, ttlSeconds);
            } else if (o instanceof Date) {
                cm.putColumn(key, (Date) o, ttlSeconds);
            } else if (o instanceof byte[]) {
                cm.putColumn(key, (byte[]) o, ttlSeconds);
            } else if (o instanceof ByteBuffer) {
                cm.putColumn(key, (ByteBuffer) o, ttlSeconds);
            } else {
                throw new IllegalArgumentException("Unsupported object instance type: "
                        + o.getClass().getSimpleName());
            }
        }
    }
    m.execute();
    return null;
}
 
开发者ID:Netflix,项目名称:Nicobar,代码行数:37,代码来源:HystrixCassandraPut.java

示例14: putBlockedDeltaColumn

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的package包/类
private void putBlockedDeltaColumn(ColumnListMutation mutation, UUID changeId, ByteBuffer encodedDelta) {
    List<ByteBuffer> blocks = _daoUtils.getDeltaBlocks(encodedDelta);
    for (int i = 0; i < blocks.size(); i++) {
        mutation.putColumn(new DeltaKey(changeId, i), blocks.get(i));
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:7,代码来源:AstyanaxDataWriterDAO.java

示例15: insertMetrics

import com.netflix.astyanax.ColumnListMutation; //导入方法依赖的package包/类
public void insertMetrics(Collection<IMetric> metrics, ColumnFamily cf, boolean isRecordingDelayedMetrics, Clock clock) throws ConnectionException {
    Timer.Context ctx = Instrumentation.getWriteTimerContext(cf.getName());
    Multimap<Locator, IMetric> map = asMultimap(metrics);
    MutationBatch batch = keyspace.prepareMutationBatch();
    try {
        for (Locator locator : map.keySet()) {
            ColumnListMutation<Long> mutation = batch.withRow(cf, locator);
            
            for (IMetric metric : map.get(locator)) {

                mutation.putColumn(
                            metric.getCollectionTime(),
                            metric.getMetricValue(),
                            (AbstractSerializer) (Serializers.serializerFor(metric.getMetricValue().getClass())),
                            metric.getTtlInSeconds());
                if (cf.getName().equals(CassandraModel.CF_METRICS_PREAGGREGATED_FULL_NAME)) {
                        Instrumentation.markFullResPreaggregatedMetricWritten();
                }

                if (isRecordingDelayedMetrics) {
                    //retaining the same conditional logic that was used to perform insertLocator(locator, batch).
                    insertLocatorIfDelayed(metric, batch, clock);
                }
            }
            
            if (!LocatorCache.getInstance().isLocatorCurrentInBatchLayer(locator)) {
                insertLocator(locator, batch);
                LocatorCache.getInstance().setLocatorCurrentInBatchLayer(locator);
            }
        }
        try {
            batch.execute();
        } catch (ConnectionException e) {
            Instrumentation.markWriteError(e);
            log.error("Connection exception persisting data", e);
            throw e;
        }
    } finally {
        ctx.stop();
    }
}
 
开发者ID:rackerlabs,项目名称:blueflood,代码行数:42,代码来源:AstyanaxWriter.java


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