本文整理汇总了Java中me.prettyprint.hector.api.mutation.Mutator.execute方法的典型用法代码示例。如果您正苦于以下问题:Java Mutator.execute方法的具体用法?Java Mutator.execute怎么用?Java Mutator.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类me.prettyprint.hector.api.mutation.Mutator
的用法示例。
在下文中一共展示了Mutator.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: recordLicenses
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
protected void recordLicenses( String projectVersionMetadataKey, List<License> licenses )
{
if ( licenses == null || licenses.isEmpty() )
{
return;
}
Mutator<String> licenseMutator = this.licenseTemplate.createMutator();
for ( License license : licenses )
{
// we don't care about the key as the real used one with the projectVersionMetadata
String keyLicense = UUID.randomUUID().toString();
String cfLicense = cassandraArchivaManager.getLicenseFamilyName();
addInsertion( licenseMutator, keyLicense, cfLicense, "projectVersionMetadataModel.key",
projectVersionMetadataKey );
addInsertion( licenseMutator, keyLicense, cfLicense, NAME.toString(), license.getName() );
addInsertion( licenseMutator, keyLicense, cfLicense, URL.toString(), license.getUrl() );
}
licenseMutator.execute();
}
示例2: delete
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void delete(final K... keys) {
if (keys == null || keys.length == 0) {
return;
}
final Mutator<K> m = createMutator(_keyspace, _serializer_k);
for (final K key : keys) {
m.addDeletion(key, _cf_name, COLUMN_NAME, BYTE_SERIALIZER);
}
m.execute();
}
示例3: doAddRole
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
* Adds a role to the role store.
*/
@Override
public void doAddRole(String roleName, String[] userList, boolean shared) throws UserStoreException {
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
Composite composite = new Composite();
composite.addComponent(roleName, stringSerializer);
composite.addComponent(tenantIdString, stringSerializer);
mutator.addInsertion(composite, CFConstants.UM_ROLES,
HFactory.createColumn(CFConstants.UM_ROLE_NAME, roleName, stringSerializer, stringSerializer));
mutator.addInsertion(composite, CFConstants.UM_ROLES,
HFactory.createColumn(CFConstants.UM_TENANT_ID, tenantIdString, stringSerializer, stringSerializer));
if (userList != null && userList.length > 0) {
addRoleToUsersList(userList, roleName, mutator);
}
mutator.execute();
}
示例4: addUserToRoleList
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
* Maps the users to a role list. Adds the (username, tenantId) -> roleList
* and (role, tenantId) -> userName
*
* @param userName The username of the user the roles need to be added to.
* @param roleList The list of roles that needs to be mapped against the user.
*/
private void addUserToRoleList(String userName, String[] roleList) {
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
if (roleList != null) {
for (String role : roleList) {
Composite key = new Composite();
key.addComponent(userName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
mutator.addInsertion(key, CFConstants.UM_USER_ROLE, HFactory.createColumn(role, role));
Composite keyRole = new Composite();
keyRole.addComponent(role, stringSerializer);
keyRole.addComponent(tenantIdString, stringSerializer);
mutator.addInsertion(keyRole, CFConstants.UM_ROLE_USER_INDEX, HFactory.createColumn(userName, userName));
}
mutator.execute();
}
}
示例5: doBatchPut
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doBatchPut(PairList<byte[], byte[]> keysValues)
throws StorageException {
try {
Mutator<byte[]> mutator = template.createMutator();
for (int i = 0; i < keysValues.size(); ++i) {
HColumn<String, byte[]> column = HFactory.createColumn(
CassandraStorageSystem.COLUMN_NAME,
keysValues.getSecond(i));
mutator.addInsertion(keysValues.getFirst(i),
CassandraStorageSystem.COLUMN_FAMILY_NAME, column);
if ((i + 1) % MAX_BATCH_ROWS == 0) {
mutator.execute();
}
}
mutator.execute();
} catch (HectorException e) {
handleHectorException(e);
}
}
示例6: doBatchRemove
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doBatchRemove(List<byte[]> keys) throws StorageException {
try {
Mutator<byte[]> mutator = template.createMutator();
int index = 0;
for (byte[] key : keys) {
mutator.addDeletion(key,
CassandraStorageSystem.COLUMN_FAMILY_NAME);
index += 1;
if (index % MAX_BATCH_ROWS == 0) {
mutator.execute();
}
}
mutator.execute();
} catch (HectorException e) {
handleHectorException(e);
}
}
示例7: updateColumnNameBasedSecondaryIndices
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
private void updateColumnNameBasedSecondaryIndices(K key, List<String> secondaryIndexByColumnNameChanges, Map<String, Integer> ttls) {
final Mutator<String> secondaryIndexMutator = HFactory.createMutator(keysp, StringSerializer.get());
String secondaryIndexCF = secondaryIndexedColumnFamilyTemplate.getColumnFamily();
boolean ttlsDefined = MapUtils.isNotEmpty(ttls);
for (String secondaryIndexByColumnName : secondaryIndexByColumnNameChanges) {
int ttl = -1;
if (ttlsDefined && ttls.get(secondaryIndexByColumnName) != null) {
ttl = ttls.get(secondaryIndexByColumnName);
}
HColumn<K, K> hColumn;
if (ttl > 0) {
hColumn = HFactory.createColumn(key, key, keysp.createClock(), ttl, keySerializer, keySerializer);
} else {
hColumn = HFactory.createColumn(key, key, keysp.createClock(), keySerializer, keySerializer);
}
secondaryIndexMutator.addInsertion(getSecondaryIndexKey(secondaryIndexByColumnName, ""), secondaryIndexCF, hColumn);
}
MutationResult execute = secondaryIndexMutator.execute();
log.debug(secondaryIndexByColumnNameChanges.size() + " secondary Indexes got updated for the key " + key.toString() +
". Exec Time = " + execute.getExecutionTimeMicro() + ", Host used = " + execute.getHostUsed());
}
示例8: deleteColumns
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
@Override
public void deleteColumns(K rowKey, N... columnNames) {
if (columnNames.length == 0) {
return;
}
Mutator<K> mutator = createMutator();
if (columnNames.length == 1) {
mutator.delete(rowKey, getColumnFamily(), columnNames[0], getColumnNameSerializer());
} else {
for (N columnName : columnNames) {
mutator.addDeletion(rowKey, getColumnFamily(), columnName, getColumnNameSerializer());
}
mutator.execute();
}
// we used to translate hector exceptions into spring exceptions here, but spring dependency was removed
}
示例9: writeClientPointer
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
* Write the updated client pointer
*
* @param lastReturnedId This is a null safe parameter. If it's null, this won't be written since it means we didn't
* read any messages
*/
protected void writeClientPointer( UUID queueId, UUID consumerId, UUID lastReturnedId ) {
// nothing to do
if ( lastReturnedId == null ) {
return;
}
// we want to set the timestamp to the value from the time uuid. If this is
// not the max time uuid to ever be written
// for this consumer, we want this to be discarded to avoid internode race
// conditions with clock drift.
long colTimestamp = UUIDUtils.getTimestampInMicros( lastReturnedId );
Mutator<UUID> mutator = CountingMutator.createFlushingMutator( ko, ue );
if ( logger.isDebugEnabled() ) {
logger.debug( "Writing last client id pointer of '{}' for queue '{}' and consumer '{}' with timestamp '{}",
lastReturnedId, queueId, consumerId, colTimestamp
);
}
mutator.addInsertion( consumerId, CONSUMERS.getColumnFamily(),
createColumn( queueId, lastReturnedId, colTimestamp, ue, ue ) );
mutator.execute();
}
示例10: insertSingleColumnData
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
private void insertSingleColumnData() {
Mutator<String> mutator = HFactory.createMutator(keyspace, stringSerializer);
mutator.addInsertion("jsmith0", COLUMN_FAMILY_NAME_1, HFactory.createStringColumn("first", "John"))
.addInsertion("jsmith0", COLUMN_FAMILY_NAME_1, HFactory.createStringColumn("last", "Smith"))
.addInsertion("jsmith0", COLUMN_FAMILY_NAME_1, HFactory.createStringColumn("middle", "Q"));
mutator.execute();
mutator.insert("jsmith", COLUMN_FAMILY_NAME_1, HFactory.createStringColumn("first", "John"));
ColumnQuery<String, String, String> columnQuery = HFactory.createStringColumnQuery(keyspace);
columnQuery.setColumnFamily(COLUMN_FAMILY_NAME_1).setKey("jsmith").setName("first");
QueryResult<HColumn<String, String>> result = columnQuery.execute();
System.out.println("Read HColumn from cassandra: " + result.get());
System.out.println("Verify on CLI with: get DynamicKeyspace1.Keyspace1['jsmith'] ");
}
示例11: recordMailingList
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
protected void recordMailingList( String projectVersionMetadataKey, List<MailingList> mailingLists )
{
if ( mailingLists == null || mailingLists.isEmpty() )
{
return;
}
Mutator<String> mailingMutator = this.mailingListTemplate.createMutator();
for ( MailingList mailingList : mailingLists )
{
// we don't care about the key as the real used one with the projectVersionMetadata
String keyMailingList = UUID.randomUUID().toString();
String cfMailingList = cassandraArchivaManager.getMailingListFamilyName();
addInsertion( mailingMutator, keyMailingList, cfMailingList, "projectVersionMetadataModel.key",
projectVersionMetadataKey );
addInsertion( mailingMutator, keyMailingList, cfMailingList, NAME.toString(), mailingList.getName() );
addInsertion( mailingMutator, keyMailingList, cfMailingList, "mainArchiveUrl",
mailingList.getMainArchiveUrl() );
addInsertion( mailingMutator, keyMailingList, cfMailingList, "postAddress", mailingList.getPostAddress() );
addInsertion( mailingMutator, keyMailingList, cfMailingList, "subscribeAddress",
mailingList.getSubscribeAddress() );
addInsertion( mailingMutator, keyMailingList, cfMailingList, "unsubscribeAddress",
mailingList.getUnsubscribeAddress() );
int idx = 0;
for ( String otherArchive : mailingList.getOtherArchives() )
{
addInsertion( mailingMutator, keyMailingList, cfMailingList, "otherArchive." + idx, otherArchive );
idx++;
}
}
mailingMutator.execute();
}
示例12: setAll
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
@Override
public void setAll(final Map<K, V> pairs) {
final Mutator<K> mutator = createMutator(_keyspace, _serializer_k);
for (final K key : pairs.keySet()) {
mutator.addInsertion(key, _cf_name, createColumn(COLUMN_NAME, pairs.get(key), BYTE_SERIALIZER, _serializer_v));
}
try {
mutator.execute();
} catch (final Exception exception) {
_log.error(MessageCatalog._00057_ADD_FAILURE, exception);
}
}
示例13: doDeleteUser
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
* Deletes a user by userName.
*/
@Override
public void doDeleteUser(String userName) throws UserStoreException {
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
String[] roles = doGetExternalRoleListOfUser(userName, "");
for (String role : roles) {
Composite key = new Composite();
key.addComponent(role, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
ColumnFamilyTemplate<Composite, String> userCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
keyspace, CFConstants.UM_ROLE_USER_INDEX, CompositeSerializer.get(), StringSerializer.get());
try {
userCFTemplate.deleteColumn(key, userName);
} catch (HectorException e) {
log.error("Error during deletion ", e);
}
}
Composite userKey = new Composite();
userKey.addComponent(userName, stringSerializer);
userKey.addComponent(tenantIdString, stringSerializer);
mutator.addDeletion(userKey, CFConstants.UM_USER_ROLE, null, CompositeSerializer.get());
mutator.addDeletion(userKey, CFConstants.UM_USER, null, CompositeSerializer.get());
mutator.execute();
if (log.isDebugEnabled()) {
log.debug("Deleted user " + userName + " successfully");
}
}
示例14: doUpdateCredentialByAdmin
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
@Override
public void doUpdateCredentialByAdmin(String userName, Object newCredential) throws UserStoreException {
if (!checkUserPasswordValid(newCredential)) {
throw new UserStoreException(
"Credential not valid. Credential must be a non null string with following format, "
+ realmConfig.getUserStoreProperty(UserCoreConstants.RealmConfig.PROPERTY_JAVA_REG_EX));
}
String saltValue = null;
if (TRUE.equalsIgnoreCase(realmConfig.getUserStoreProperties().get(JDBCRealmConstants.STORE_SALTED_PASSWORDS))) {
saltValue = Util.getSaltValue();
}
String password = Util.preparePassword((String) newCredential, saltValue);
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
Composite key = new Composite();
key.addComponent(userName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
mutator.addInsertion(key, CFConstants.UM_USER,
HFactory.createColumn(CFConstants.UM_SECRET, password, stringSerializer, stringSerializer));
mutator.addInsertion(key, CFConstants.UM_USER,
HFactory.createColumn(CFConstants.UM_SALT_VALUE, saltValue, stringSerializer, stringSerializer));
try {
mutator.execute();
if (log.isDebugEnabled()) {
log.debug("Changed password for user " + userName + "successfully");
}
} catch (HectorException e) {
throw new UserStoreException("Change Password failed.", e);
}
}
示例15: updateSecondaryIndexColumnFamily
import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
* This will update the secondary index column family properly, also deleting the previous values if needed.
*
* @param key : key from the original column family. This will be the column name of the secondary
* index column family.
* @param columnName : name of the column to be indexed.
* @param columnValue : value of the column to be indexed. This can be null if we are indexing based on the
* column names only.
* @param timestamp : timestamp for the new entry in the secondary index.
* @param ttl : time to live for the new entry.
* @param oldColumnValue : old column related to this update so that we can retrieve the old value of the column
* to
* delete the previous secondary index.
*/
private void updateSecondaryIndexColumnFamily(K key, String columnName, String columnValue, long timestamp, int ttl,
String oldColumnValue) {
final Mutator<String> secondaryIndexMutator = HFactory.createMutator(keysp, StringSerializer.get());
String secondaryIndexCF = secondaryIndexedColumnFamilyTemplate.getColumnFamily();
// enqueue a deletion to the secondary index to remove the previous value of this column.
if (!StringUtils.isBlank(oldColumnValue) && !"null".equalsIgnoreCase(oldColumnValue)) {
secondaryIndexMutator.addDeletion(getSecondaryIndexKey(columnName, oldColumnValue), secondaryIndexCF, key,
keySerializer);
}
// add the new value to the secondary index CF. Make sure to handle the TTLs properly.
if (ttl > 0) {
secondaryIndexMutator.addInsertion(getSecondaryIndexKey(columnName, columnValue), secondaryIndexCF,
HFactory.createColumn(key, key,
timestamp > 0 ? timestamp : keysp.createClock(),
ttl, keySerializer, keySerializer));
} else {
secondaryIndexMutator.addInsertion(getSecondaryIndexKey(columnName, columnValue), secondaryIndexCF,
HFactory.createColumn(key, key,
timestamp > 0 ? timestamp : keysp.createClock(),
keySerializer, keySerializer));
}
// execute everything (the deletion and the insertion) together
MutationResult execute = secondaryIndexMutator.execute();
log.debug("Secondary Index column " + columnName + " got updated for the key " + key.toString() +
". Exec Time = " +
execute.getExecutionTimeMicro() + ", Host used = " + execute.getHostUsed());
}