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


Java Mutator.addInsertion方法代码示例

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


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

示例1: 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();
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:23,代码来源:CassandraUserStoreManager.java

示例2: 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();
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:CassandraUserStoreManager.java

示例3: addRoleToUsersList

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
/**
 * Maps the role to a user list. Adds the (username, tenantId) -> roleList
 * and (role, tenantId) -> userName
 *
 * @param userNames The username list of the user the role need to be added to.
 * @param roleName  The role that needs to be mapped against the user list.
 * @param mutator   Passes the mutator and returns it with the insert statements.
 */
private Mutator<Composite> addRoleToUsersList(String[] userNames, String roleName, Mutator<Composite> mutator) {
    if (userNames != null) {
        for (String userName : userNames) {

            Composite key = new Composite();
            key.addComponent(userName, stringSerializer);
            key.addComponent(tenantIdString, stringSerializer);

            mutator.addInsertion(key, CFConstants.UM_USER_ROLE, HFactory.createColumn(roleName, roleName));

            Composite keyRole = new Composite();
            keyRole.addComponent(roleName, stringSerializer);
            keyRole.addComponent(tenantIdString, stringSerializer);

            mutator.addInsertion(keyRole, CFConstants.UM_ROLE_USER_INDEX, HFactory.createColumn(userName, userName));

        }

    }
    return mutator;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:30,代码来源:CassandraUserStoreManager.java

示例4: 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);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:23,代码来源:CassandraStore.java

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

	}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:26,代码来源:HectorBasedHecubaClientManager.java

示例6: prepareMutatorForSecondaryIndexUpdate

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
private void prepareMutatorForSecondaryIndexUpdate(K key, Map<String, Object> allColumnsToBeChanged,
		Mutator<String> secondaryIndexMutator, String secondaryIndexCF,
		String columnName, String oldValue, Map<String, Integer> ttls) {
	if (!StringUtils.isBlank(oldValue) && !"null".equalsIgnoreCase(oldValue)) {
		// delete those indexes first
		secondaryIndexMutator.addDeletion(getSecondaryIndexKey(columnName, oldValue), secondaryIndexCF, key,
				keySerializer);
	}

	int ttl = -1;
	if (ttls != null && ttls.get(columnName) != null) {
		ttl = ttls.get(columnName);
	}

	// add the new ones
	if (ttl > 0) {
		secondaryIndexMutator.addInsertion(getSecondaryIndexKey(columnName, allColumnsToBeChanged.get(columnName)
				.toString()), secondaryIndexCF, HFactory.createColumn(key, key, keysp.createClock(), ttl, keySerializer, keySerializer));
	} else {
		secondaryIndexMutator.addInsertion(getSecondaryIndexKey(columnName, allColumnsToBeChanged.get(columnName)
				.toString()), secondaryIndexCF, HFactory.createColumn(key, key, keysp.createClock(), keySerializer, keySerializer));
	}
}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:24,代码来源:HectorBasedHecubaClientManager.java

示例7: addToMutation

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public void addToMutation( Mutator<ByteBuffer> batch, UUID queueId, long shard_ts, long timestamp ) {

        if ( propertyEntryList != null ) {
            for ( Entry<String, List<Entry<String, Object>>> property : propertyEntryList.entrySet() ) {

                for ( Map.Entry<String, Object> indexEntry : property.getValue() ) {

                    if ( validIndexableValue( indexEntry.getValue() ) ) {

                        batch.addInsertion( bytebuffer( key( queueId, shard_ts, indexEntry.getKey() ) ),
                                PROPERTY_INDEX.getColumnFamily(), createColumn(
                                new DynamicComposite( indexValueCode( indexEntry.getValue() ), indexEntry.getValue(),
                                        message.getUuid() ), ByteBuffer.allocate( 0 ), timestamp, dce, be ) );

                        batch.addInsertion( bytebuffer( key( queueId, DICTIONARY_MESSAGE_INDEXES ) ),
                                QUEUE_DICTIONARIES.getColumnFamily(),
                                createColumn( indexEntry.getKey(), ByteBuffer.allocate( 0 ), timestamp, se, be ) );
                    }
                }

                batch.addInsertion( bytebuffer( key( queueId, DICTIONARY_MESSAGE_INDEXES ) ),
                        QUEUE_DICTIONARIES.getColumnFamily(),
                        createColumn( property.getKey(), ByteBuffer.allocate( 0 ), timestamp, se, be ) );
            }
        }
    }
 
开发者ID:apache,项目名称:usergrid,代码行数:27,代码来源:MessageIndexUpdate.java

示例8: addMessageToMutator

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public static Mutator<ByteBuffer> addMessageToMutator( Mutator<ByteBuffer> m, Message message, long timestamp ) {

        Map<ByteBuffer, ByteBuffer> columns = serializeMessage( message );

        if ( columns == null ) {
            return m;
        }

        for ( Map.Entry<ByteBuffer, ByteBuffer> column_entry : columns.entrySet() ) {
            if ( ( column_entry.getValue() != null ) && column_entry.getValue().hasRemaining() ) {
                HColumn<ByteBuffer, ByteBuffer> column =
                        createColumn( column_entry.getKey(), column_entry.getValue(), timestamp, be, be );
                m.addInsertion( bytebuffer( message.getUuid() ), QueuesCF.MESSAGE_PROPERTIES.toString(), column );
            }
            else {
                m.addDeletion( bytebuffer( message.getUuid() ), QueuesCF.MESSAGE_PROPERTIES.toString(),
                        column_entry.getKey(), be, timestamp );
            }
        }

        return m;
    }
 
开发者ID:apache,项目名称:usergrid,代码行数:23,代码来源:CassandraMQUtils.java

示例9: addQueueToMutator

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public static Mutator<ByteBuffer> addQueueToMutator( Mutator<ByteBuffer> m, Queue queue, long timestamp ) {

        Map<ByteBuffer, ByteBuffer> columns = serializeQueue( queue );

        if ( columns == null ) {
            return m;
        }

        for ( Map.Entry<ByteBuffer, ByteBuffer> column_entry : columns.entrySet() ) {
            if ( ( column_entry.getValue() != null ) && column_entry.getValue().hasRemaining() ) {
                HColumn<ByteBuffer, ByteBuffer> column =
                        createColumn( column_entry.getKey(), column_entry.getValue(), timestamp, be, be );
                m.addInsertion( bytebuffer( queue.getUuid() ), QueuesCF.QUEUE_PROPERTIES.toString(), column );
            }
            else {
                m.addDeletion( bytebuffer( queue.getUuid() ), QueuesCF.QUEUE_PROPERTIES.toString(),
                        column_entry.getKey(), be, timestamp );
            }
        }

        return m;
    }
 
开发者ID:apache,项目名称:usergrid,代码行数:23,代码来源:CassandraMQUtils.java

示例10: 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();
}
 
开发者ID:apache,项目名称:usergrid,代码行数:32,代码来源:AbstractSearch.java

示例11: batchIncrementQueueCounter

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public Mutator<ByteBuffer> batchIncrementQueueCounter( Mutator<ByteBuffer> m, UUID queueId, String name, long value,
                                                       long timestamp, UUID applicationId ) {
    if ( logger.isTraceEnabled() ) {
        logger.trace( "BIQC: Incrementing property {} of queue {} by value {}",
                name, queueId, value );
    }
    m.addInsertion( bytebuffer( key( queueId, DICTIONARY_COUNTERS ).toString() ),
            QueuesCF.QUEUE_DICTIONARIES.toString(),
            createColumn( name, ByteBuffer.allocate( 0 ), timestamp, se, be ) );
    if ( "o".equals( counterType ) || "p".equals( counterType ) ) {
        HCounterColumn<String> c = createCounterColumn( name, value );
        ByteBuffer keybytes = bytebuffer( queueId );
        m.addCounter( keybytes, QueuesCF.COUNTERS.toString(), c );
    }
    if ( "n".equals( counterType ) || "p".equals( counterType ) ) {
        PrefixedSerializer ps = new PrefixedSerializer( applicationId, ue, ue );
        batcher.add( new Count( QueuesCF.COUNTERS.toString(), ps.toByteBuffer( queueId ), name, value ) );
    }
    return m;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:21,代码来源:CounterUtils.java

示例12: addInsertToMutator

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public static void addInsertToMutator( Mutator<ByteBuffer> m, Object columnFamily, Object key, Object columnName,
                                       Object columnValue, long timestamp ) {

    logBatchOperation( "Insert", columnFamily, key, columnName, columnValue, timestamp );

    if ( columnName instanceof List<?> ) {
        columnName = DynamicComposite.toByteBuffer( ( List<?> ) columnName );
    }
    if ( columnValue instanceof List<?> ) {
        columnValue = DynamicComposite.toByteBuffer( ( List<?> ) columnValue );
    }

    HColumn<ByteBuffer, ByteBuffer> column =
            createColumn( bytebuffer( columnName ), bytebuffer( columnValue ), timestamp, be, be );
    m.addInsertion( bytebuffer( key ), columnFamily.toString(), column );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:17,代码来源:CassandraPersistenceUtils.java

示例13: addInsertion

import me.prettyprint.hector.api.mutation.Mutator; //导入方法依赖的package包/类
public static void addInsertion( Mutator<String> mutator, String key, String columnFamily, String columnName,
                                 String value )
{
    if ( value != null )
    {
        mutator.addInsertion( key, columnFamily, column( columnName, value ) );
    }
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:9,代码来源:CassandraUtils.java

示例14: 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);
	}
}
 
开发者ID:cumulusrdf,项目名称:cumulusrdf,代码行数:15,代码来源:Cassandra12xMapDAO.java

示例15: 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);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:32,代码来源:CassandraUserStoreManager.java


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