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


Java MutationBatch.execute方法代码示例

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


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

示例1: put

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
public void put(Buffer stream, Callback<Boolean> callback) {
    MutationBatch m = keyspace.prepareMutationBatch();
    BufferIterator it = stream.iterator();
    while (it.hasNext()) {
        Buffer keyView = it.next();
        Buffer valueView = it.next();
        if (valueView != null) {
            m.withRow(MWG, keyView.data()).putColumn(0, valueView.data());
        }
    }
    try {
        @SuppressWarnings("unused")
        OperationResult<Void> result = m.execute();
        callback.on(true);
    } catch (ConnectionException e) {
        callback.on(false);
    }
}
 
开发者ID:datathings,项目名称:greycat,代码行数:20,代码来源:CassandraStorage.java

示例2: 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

示例3: insertDataToDB

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public void insertDataToDB(String rowKey, String entity, String category, 
                           String sentiment, String time, String text, String count, String entityInfo, boolean isDynamicSearch) throws ConnectionException, InterruptedException, ExecutionException {

  MutationBatch mb = GlobalVariables.KS_AST.prepareMutationBatch();//The mutator is not thread safe
  ColumnFamily<String, String> CF_AST;
  if (isDynamicSearch) {
    CF_AST = CF_AST_DYNA;
  } else {
    CF_AST = CF_AST_BACK;
  }

  mb.withRow(CF_AST, rowKey)
  .putColumn("entity", entity)
  .putColumn("category", category)
  .putColumn("sentiment", sentiment)
  .putColumn("time", time)
  .putColumn("text", text)
  .putColumn("count", count)
  .putColumn("entityInfo", entityInfo);

  // no asynchronous feature
  @SuppressWarnings("unused")
  OperationResult<Void> result = mb.execute();
}
 
开发者ID:faustineinsun,项目名称:WiseCrowdRec,代码行数:25,代码来源:AstyanaxCassandraManipulator.java

示例4: executeBatch

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
private long executeBatch(final List<Mutation> mutations) throws ConnectionException {
    long startTime = System.nanoTime();

    MutationBatch batch = keyspace
            .prepareMutationBatch()
            .withAtomicBatch(false)
            .withConsistencyLevel(ConsistencyLevel.CL_ONE);

    for (Mutation aMutation : mutations) {
        batch.withRow(DefaultModel.model, aMutation.getIdentity())
                .putColumn(aMutation.getTimeStamp(), aMutation.getCommunication(), DefaultModel.valueSerializer, 0);
    }

    try {
        batch.execute();
    } catch (ConnectionException e) {
        logger.error("error inserting batch", e);
        throw e;
    }

    long timeSpan = (System.nanoTime() - startTime);

    return timeSpan;
}
 
开发者ID:cosh,项目名称:CassandraBenchmark,代码行数:25,代码来源:BatchRunnable.java

示例5: 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

示例6: handleTuple

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
public void handleTuple(ITuple tuple) {
  MutationBatch m = keyspace.prepareMutationBatch();
  if (! getProperties().containsKey(INCREMENT)){
    m.withRow(new ColumnFamily((String) properties.get(COLUMN_FAMILY),
          ByteBufferSerializer.get(),
          ByteBufferSerializer.get()), 
          (ByteBuffer) tuple.getField(ROW_KEY))
          .putColumn((ByteBuffer) tuple.getField(COLUMN), (ByteBuffer) tuple.getField(VALUE));
  } else {
    m.withRow(new ColumnFamily((String) properties.get(COLUMN_FAMILY),
            ByteBufferSerializer.get(),
            ByteBufferSerializer.get()), 
            (ByteBuffer) tuple.getField(ROW_KEY))
            .incrementCounterColumn((ByteBuffer) tuple.getField(COLUMN),((Number) tuple.getField(VALUE) ).longValue());
  }
  try {
    OperationResult<Void> result = m.execute();
  } catch (ConnectionException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }    
}
 
开发者ID:edwardcapriolo,项目名称:teknek-cassandra,代码行数:24,代码来源:CassandraOperator.java

示例7: removeJobsByKeys

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
/**
 * @param job_keys can be null or empty
 */
public static void removeJobsByKeys(Collection<String> job_keys) throws ConnectionException {
	if (job_keys == null) {
		return;
	}
	if (job_keys.isEmpty() == false) {
		return;
	}
	
	MutationBatch mutator = CassandraDb.prepareMutationBatch();
	job_keys.forEach(job_key -> {
		mutator.withRow(CF_QUEUE, job_key).delete();
	});
	mutator.execute();
	return;
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:19,代码来源:JobNG.java

示例8: 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

示例9: deleteRow

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
public void deleteRow(String key) throws PaasException {
    invariant();
    
    MutationBatch mb = keyspace.prepareMutationBatch();
    mb.withRow(this.columnFamily, serializers.keyAsByteBuffer(key)).delete();
    
    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,代码行数:17,代码来源:AstyanaxThriftDataTableResource.java

示例10: alterJobsByStatus

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public static JsonObject alterJobsByStatus(JobStatus status, AlterJobOrderName order) throws ConnectionException {
	JsonObject result = new JsonObject();
	
	int count = 1;
	while (count > 0) {
		Loggers.Manager.debug("alterJobsByStatus loop IndexQuery/MutationBatch (" + count + ")");
		
		MutationBatch mutator = CassandraDb.prepareMutationBatch();
		IndexQuery<String, String> index_query = keyspace.prepareQuery(CF_QUEUE).searchWithIndex();
		index_query.addExpression().whereColumn("status").equals().value(status.name());
		index_query.withColumnSlice("source");
		
		OperationResult<Rows<String, String>> rows = index_query.execute();
		count = 0;
		for (Row<String, String> row : rows.getResult()) {
			count++;
			alterJobsFromJson(row.getKey(), row.getColumns(), mutator, order, result);
		}
		mutator.execute();
	}
	
	return result;
}
 
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:24,代码来源:JobNG.java

示例11: 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

示例12: doWriteContent

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
protected void doWriteContent(Content content, @Nullable Content previous) {
    try {
        long id = content.getId().longValue();

        MutationBatch batch = keyspace.prepareMutationBatch();
        batch.setConsistencyLevel(writeConsistency);

        marshaller.marshallInto(
                content.getId(),
                batch.withRow(mainCf, id),
                content,
                java.util.Optional.ofNullable(previous),
                true
        );

        batch.mergeShallow(aliasIndex.mutateAliases(content, previous));
        batch.execute();

        log.trace("Written content id " + id);
    } catch (Exception e) {
        throw new CassandraPersistenceException(content.toString(), e);
    }
}
 
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:25,代码来源:AstyanaxCassandraContentStore.java

示例13: deleteEntries

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public boolean deleteEntries(List<String> keys) {
    List<NormalizedKey> normalizedKeys = keyNormalizer.normalizeKeys(keys);
    MutationBatch mb = keyspace.prepareMutationBatch();
    for (NormalizedKey key : normalizedKeys) {
        mb.withRow(columnFamily, key.get()).delete();
    }
    try {
        mb.execute();
    } catch (ConnectionException ce) {
        log.error(ce);
        return false;
    }
    return true;

}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:16,代码来源:AstyanaxRepoConnection.java

示例14: deleteEntry

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public boolean deleteEntry(String key) {
    NormalizedKey normalizedKey = keyNormalizer.normalizeKey(key);
    MutationBatch mb = keyspace.prepareMutationBatch();
    mb.withRow(columnFamily, normalizedKey.get()).delete();

    try {
        mb.execute();
    } catch (ConnectionException ce) {
        log.error(ce);
        return false;
    }
    return true;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:14,代码来源:AstyanaxRepoConnection.java

示例15: dropPoints

import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public Boolean dropPoints(String key, List<String> columns) {
    MutationBatch m = keyspace.prepareMutationBatch();
    for (String columnName : columns) {
        m.withRow(columnFamily, key).deleteColumn(columnName);
    }

    try {
        m.execute();
    } catch (ConnectionException ce) {
        throw RaptureExceptionFactory.create(HttpURLConnection.HTTP_INTERNAL_ERROR, messageCatalog.getMessage("DbCommsError"), ce);
    }
    return true;
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:14,代码来源:AstyanaxSeriesConnection.java


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