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


Java HectorException类代码示例

本文整理汇总了Java中me.prettyprint.hector.api.exceptions.HectorException的典型用法代码示例。如果您正苦于以下问题:Java HectorException类的具体用法?Java HectorException怎么用?Java HectorException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: doBatchGet

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected List<byte[]> doBatchGet(List<byte[]> keys)
		throws StorageException {
	try {
		List<byte[]> result = new ArrayList<byte[]>();
		for (int i = 0; i < keys.size(); i += MAX_BATCH_ROWS) {
			List<byte[]> subKeyList = keys.subList(i,
					Math.min(i + MAX_BATCH_ROWS, keys.size()));
			result.addAll(batchGetSubList(subKeyList));
		}
		return result;
	} catch (HectorException e) {
		handleHectorException(e);
		return null;
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:18,代码来源:CassandraStore.java

示例2: doBatchPut

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的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

示例3: doBatchRemove

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的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);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:20,代码来源:CassandraStore.java

示例4: doScan

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doScan(byte[] beginKey, byte[] endKey,
		IKeyValueCallback callback, boolean includeValue)
		throws StorageException {
	try {
		RangeSlicesQuery<byte[], String, byte[]> query = prepareRangeQuery(
				beginKey, endKey, includeValue);
		byte[] lastKey = null;
		while (true) {
			if (lastKey != null) {
				query.setKeys(lastKey, endKey);
			}

			OrderedRows<byte[], String, byte[]> rows = query.execute()
					.get();
			lastKey = reportScanData(rows, callback, endKey, includeValue);

			if (rows.getCount() < MAX_SCAN_ROWS) {
				break;
			}
		}
	} catch (HectorException e) {
		handleHectorException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:27,代码来源:CassandraStore.java

示例5: readAllColumns

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
public CassandraResultSet<K, String> readAllColumns(K key) throws HectorException {
	try {
		if (maxColumnCount > 0) {
			return readColumnSlice(key, null, null, false, maxColumnCount);
		} else {
			ColumnFamilyResult<K, String> queriedColumns = getColumnFamily().queryColumns(key);
			if (isClientAdapterDebugMessagesEnabled) {
				log.info("Row retrieved from Cassandra. Exec Time (micro-sec) = " +
						queriedColumns.getExecutionTimeMicro() +
						", Host used = " + queriedColumns.getHostUsed() + ", Key = " + key);
			}
			return new HectorResultSet<K, String>(queriedColumns);
		}

	} catch (HectorException e) {
		log.debug("HecubaClientManager error while reading key " + key.toString());
		if (log.isDebugEnabled()) {
			log.debug("Caught Exception", e);

			// lets see whether we have any issues with the downed nodes.
			logDownedHosts();
		}
		throw e;
	}
}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:26,代码来源:HectorBasedHecubaClientManager.java

示例6: readColumns

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
public CassandraResultSet<K, String> readColumns(K key, List<String> columns) throws HectorException {
	ColumnFamilyResult<K, String> queriedColumns;
	try {
		queriedColumns = getColumnFamily().queryColumns(key, columns);
		if (isClientAdapterDebugMessagesEnabled) {
			log.info(columns.size() + " columns retrieved from Cassandra. Exec Time = " +
					queriedColumns.getExecutionTimeMicro() + ", Host used = " +
					queriedColumns.getHostUsed());
		}
		return new HectorResultSet<K, String>(queriedColumns);
	} catch (HectorException e) {
		log.error("HecubaClientManager error while retrieving " + columns.size() + " columns for key " +
				key.toString());
		if (log.isDebugEnabled()) {
			log.debug("Caught Exception", e);
		}
		throw e;
	}
}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:20,代码来源:HectorBasedHecubaClientManager.java

示例7: doDeleteUser

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的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");
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:33,代码来源:CassandraUserStoreManager.java

示例8: doUpdateCredentialByAdmin

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的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

示例9: CassandraStorageSystem

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
/** Constructor. */
public CassandraStorageSystem(int port) throws StorageException {
	try {
		Cluster cluster = createCluster(port);
		if (cluster.describeKeyspace(KEYSPACE_NAME) == null) {
			createKeyspace(cluster);
		}
		keyspace = HFactory.createKeyspace(KEYSPACE_NAME, cluster);
		template = new ThriftColumnFamilyTemplate<byte[], String>(keyspace,
				COLUMN_FAMILY_NAME, BytesArraySerializer.get(),
				StringSerializer.get());
	} catch (HectorException e) {
		throw new StorageException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:16,代码来源:CassandraStorageSystem.java

示例10: doGet

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected byte[] doGet(byte[] key) throws StorageException {
	try {
		ColumnFamilyResult<byte[], String> res = template.queryColumns(key);
		return res.getByteArray(CassandraStorageSystem.COLUMN_NAME);
	} catch (HectorException e) {
		handleHectorException(e);
		return null;
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:12,代码来源:CassandraStore.java

示例11: handleHectorException

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
/** Handles a {@link HectorException} . */
private void handleHectorException(HectorException e)
		throws StorageException {
	if (e instanceof HTimedOutException) {
		throw new TimeoutException(e);
	} else if (e.getMessage().startsWith("All host pools marked down")) {
		throw new TimeoutException(e);
	}
	throw new StorageException(e);
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:11,代码来源:CassandraStore.java

示例12: doPut

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doPut(byte[] key, byte[] value) throws StorageException {
	try {
		ColumnFamilyUpdater<byte[], String> updater = template
				.createUpdater(key);
		updater.setByteArray(CassandraStorageSystem.COLUMN_NAME, value);
		template.update(updater);
	} catch (HectorException e) {
		handleHectorException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:13,代码来源:CassandraStore.java

示例13: doRemove

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void doRemove(byte[] key) throws StorageException {
	try {
		template.deleteRow(key);
	} catch (HectorException e) {
		handleHectorException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:10,代码来源:CassandraStore.java

示例14: retrieveKeysFromSecondaryIndex

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
private List<K> retrieveKeysFromSecondaryIndex(String columnName, String columnValue) {
	String secondaryIndexKey = getSecondaryIndexKey(columnName, columnValue);
	CassandraResultSet<String, K> columns;
	try {
		if (maxSiColumnCount > 0) {
			columns = readSiColumnSlice(secondaryIndexKey, false, maxSiColumnCount);
		} else {
			columns = new HectorResultSet<String, K>(secondaryIndexedColumnFamilyTemplate.queryColumns(
					secondaryIndexKey));
		}

		if (isClientAdapterDebugMessagesEnabled) {
			log.debug("Secondary Index Row for " + secondaryIndexKey + " retrieved from Cassandra. Exec Time = " +
					columns.getExecutionLatency() + ", Host used = " + columns.getHost());
		}

		if (columns != null && CollectionUtils.isNotEmpty(columns.getColumnNames())) {
			return new ArrayList<>(columns.getColumnNames());
		}
	} catch (HectorException e) {
		log.debug("HecubaClientManager error while retrieving secondary index " + getSecondaryIndexKey(columnName,
				columnValue));
		if (log.isDebugEnabled()) {
			log.debug("Caught Exception", e);

			// lets see whether we have any issues with the downed nodes.
			logDownedHosts();
		}
		throw e;
	}
	return null;
}
 
开发者ID:WizeCommerce,项目名称:hecuba,代码行数:33,代码来源:HectorBasedHecubaClientManager.java

示例15: getIsCassandraAlive

import me.prettyprint.hector.api.exceptions.HectorException; //导入依赖的package包/类
/**
 * Wraps "describe_thrift_version API call as this hits a static string in Cassandra. This is the most lightweight
 * way to assure that Hector is alive and talking to the cluster.
 *
 * @return true if we have a lit connection to the cluster.
 */
public boolean getIsCassandraAlive() {
    boolean isAlive = false;
    try {
        isAlive = cluster.describeThriftVersion() != null;
    }
    catch ( HectorException he ) {
        logger.error( "Could not communicate with Cassandra cluster", he );
    }
    return isAlive;
}
 
开发者ID:apache,项目名称:usergrid,代码行数:17,代码来源:UsergridSystemMonitor.java


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