本文整理汇总了Java中me.prettyprint.cassandra.service.template.ColumnFamilyTemplate类的典型用法代码示例。如果您正苦于以下问题:Java ColumnFamilyTemplate类的具体用法?Java ColumnFamilyTemplate怎么用?Java ColumnFamilyTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ColumnFamilyTemplate类属于me.prettyprint.cassandra.service.template包,在下文中一共展示了ColumnFamilyTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteColumn
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
/**
* Deletes a given column value of a row identified by the key.
*
* @param key - key of the row.
* @param columnName - name of the column to be deleted.
*/
public void deleteColumn(K key, String columnName) {
final ColumnFamilyTemplate<K, String> columnFamily1 = getColumnFamily();
final HColumn<String, String> oldValue = readColumn(key, columnName);
// is this insertion involves a change to secondary indexes
if (isSecondaryIndexByColumnNameAndValueEnabled && Collections.binarySearch(columnsToIndexOnColumnNameAndValue,
columnName) >= 0 &&
oldValue != null) {
secondaryIndexedColumnFamilyTemplate.deleteColumn(getSecondaryIndexKey(columnName, oldValue.getValue()),
key);
}
if (isSecondaryIndexesByColumnNamesEnabled && columnName.matches(secondaryIdxByColumnPattern)) {
secondaryIndexedColumnFamilyTemplate.deleteColumn(getSecondaryIndexKey(columnName, ""), key);
}
columnFamily1.deleteColumn(key, columnName);
}
示例2: doDeleteUser
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的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");
}
}
示例3: doAuthenticate
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
/**
* Authenticates a user given the user name and password against the user
* store.
*/
@Override
public boolean doAuthenticate(String userName, Object credential) throws UserStoreException {
String password = (String) credential;
boolean isAuthed = false;
if (!checkUserNameValid(userName)) {
log.error("Invalid Username");
return false;
}
if (!checkUserPasswordValid(credential)) {
log.error("Invalid password");
return false;
}
if (UserCoreUtil.isRegistryAnnonymousUser(userName)) {
log.error("Anonnymous user trying to login");
return false;
}
Composite key = new Composite();
key.addComponent(userName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
ColumnFamilyTemplate<Composite, String> userCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
keyspace, CFConstants.UM_USER, CompositeSerializer.get(), StringSerializer.get());
ColumnFamilyResult<Composite, String> result = userCFTemplate.queryColumns(key);
String saltVallue = result.getString(CFConstants.UM_SALT_VALUE);
String storedPassword = result.getString(CFConstants.UM_SECRET);
if (TRUE.equalsIgnoreCase(realmConfig.getUserStoreProperty(JDBCRealmConstants.STORE_SALTED_PASSWORDS))) {
password = Util.preparePassword(password, saltVallue);
if ((storedPassword != null) && (storedPassword.equals(password))) {
isAuthed = true;
}
}
return isAuthed;
}
示例4: CassandraStore
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
/** Constructor. */
public CassandraStore(String name, Keyspace keyspace,
ColumnFamilyTemplate<byte[], String> template) {
super(name);
this.keyspace = keyspace;
this.template = template;
}
示例5: exists
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
/**
* Determines if a storage with the given path already exists.
*
* @param path Storage path
* @return True, if such storage exists, false otherwise.
*/
@Override
protected boolean exists(String path) throws IOException {
ColumnFamilyTemplate<String, String> template =
new ThriftColumnFamilyTemplate<String, String>(ksp,
COLUMN_FAMILY_NAME,
StringSerializer.get(),
StringSerializer.get());
ColumnFamilyResult<String, String> res = template.queryColumns(path);
return res.hasResults();
}
示例6: update
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
private void update(ColumnFamilyTemplate<String, String> template) {
ColumnFamilyUpdater<String, String> updater = template.createUpdater("a key");
updater.setString("domain", "www.chaosxu.com");
updater.setLong("time", System.currentTimeMillis());
template.update(updater);
}
示例7: doUpdateUserListOfRole
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
/**
* Update the user list mapped to a role.
*/
@Override
public void doUpdateUserListOfRole(String roleName, String[] deletedUsers, String[] newUsers)
throws UserStoreException {
Mutator<Composite> mutator = HFactory.createMutator(keyspace, CompositeSerializer.get());
RoleContext ctx = createRoleContext(roleName);
roleName = ctx.getRoleName();
boolean isShared = ctx.isShared();
if (!isShared) {
//TODO TO BE Implemented
}
if (deletedUsers != null && deletedUsers.length > 0) {
if (isShared) {
//TODO TO BE Implemented
} else {
if (deletedUsers.length > 0) {
Composite key = new Composite();
key.addComponent(roleName, stringSerializer);
key.addComponent(tenantIdString, stringSerializer);
for (String user : deletedUsers) {
Composite userKey = new Composite();
userKey.addComponent(user, stringSerializer);
userKey.addComponent(tenantIdString, stringSerializer);
ColumnFamilyTemplate<Composite, String> userCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
keyspace, CFConstants.UM_USER_ROLE, CompositeSerializer.get(), StringSerializer.get());
ColumnFamilyTemplate<Composite, String> roleCFTemplate = new ThriftColumnFamilyTemplate<Composite, String>(
keyspace, CFConstants.UM_ROLE_USER_INDEX, CompositeSerializer.get(),
StringSerializer.get());
try {
roleCFTemplate.deleteColumn(mutator, key, user);
userCFTemplate.deleteColumn(mutator, userKey, roleName);
} catch (HectorException e) {
log.error(e.getMessage(), e);
throw new UserStoreException("Error during the updating of a user's role list");
}
}
}
}
}
// need to clear user roles cache upon roles update
clearUserRolesCacheByTenant(this.tenantId);
if (newUsers != null && newUsers.length > 0) {
if (isShared) {
//TODO TO BE Implemented
} else {
addRoleToUsersList(newUsers, roleName, mutator);
}
}
mutator.execute();
}
示例8: getColumnFamilyTemplates
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
public List<ColumnFamilyTemplate<K, String>> getColumnFamilyTemplates() {
return columnFamilyTemplates;
}
示例9: getColumnFamily
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
ColumnFamilyTemplate<K, String> getColumnFamily() {
return columnFamilyTemplates.get(0);
}
示例10: test
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
@Test
public void test() {
Cluster cluster = HFactory.getOrCreateCluster("test-cluster","localhost:9160");
KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(KEYSPACE);
if (keyspaceDef == null)
createSchema(cluster, KEYSPACE);
Keyspace ksp = HFactory.createKeyspace(KEYSPACE, cluster);
ColumnFamilyTemplate<String, String> template =
new ThriftColumnFamilyTemplate<String, String>(ksp,
COLUMN_FAMILY_NAME,
StringSerializer.get(),
StringSerializer.get());
update(template);
query(ksp);
//delete(template);
}
示例11: delete
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
private void delete(ColumnFamilyTemplate<String, String> template) {
ColumnFamilyResult<String, String> res = template.queryColumns("a key");
String value = res.getString("domain");
template.deleteColumn("key", "column name");
}
示例12: setColumnFamilyTemplate
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
public void setColumnFamilyTemplate(ColumnFamilyTemplate<Composite, String> columnFamilyTemplate) {
this.columnFamilyTemplate = columnFamilyTemplate;
}
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:4,代码来源:CassandraPersistentActorRepository.java
示例13: PersistentActorUpdateEventProcessor
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
public PersistentActorUpdateEventProcessor(ColumnFamilyTemplate<Composite, String> columnFamilyTemplate) {
this.columnFamilyTemplate = columnFamilyTemplate;
}
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:4,代码来源:PersistentActorUpdateEventProcessor.java
示例14: CassandraActorSystemEventListenerRepository
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
public CassandraActorSystemEventListenerRepository(String clusterName, ColumnFamilyTemplate<Composite, String> columnFamilyTemplate) {
this.clusterName = clusterName;
this.columnFamilyTemplate = columnFamilyTemplate;
}
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:5,代码来源:CassandraActorSystemEventListenerRepository.java
示例15: CassandraScheduledMessageRepository
import me.prettyprint.cassandra.service.template.ColumnFamilyTemplate; //导入依赖的package包/类
public CassandraScheduledMessageRepository(String clusterName, ColumnFamilyTemplate<Composite, Composite> columnFamilyTemplate, ScheduledMessageDeserializer scheduledMessageDeserializer) {
this.clusterName = clusterName;
this.columnFamilyTemplate = columnFamilyTemplate;
this.scheduledMessageDeserializer = scheduledMessageDeserializer;
}
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:6,代码来源:CassandraScheduledMessageRepository.java