use of com.ctrip.framework.dal.cluster.client.exception.ClusterRuntimeException in project dal by ctripcorp.
the class ModShardStrategy method calcAllTableShards.
@Override
protected Set<String> calcAllTableShards(String tableName) {
Integer mod = getTableShardMod(tableName);
if (mod == null)
throw new ClusterRuntimeException(String.format("table shard mod undefined for table '%s'", tableName));
Set<String> allShards = new HashSet<>();
for (int i = 0; i < mod; i++) allShards.add(String.valueOf(i));
return allShards;
}
use of com.ctrip.framework.dal.cluster.client.exception.ClusterRuntimeException in project dal by ctripcorp.
the class ShardStrategyElement method start.
@Override
public void start() {
for (TablesElement tablesElement : tablesElements) {
tablesElement.merge(this);
tablesElement.start();
for (String tableName : tablesElement.getTableNames()) {
PropertyAccessor properties = tablesElement.getTableProperties(tableName);
if (tableProperties.put(tableName, properties) != null)
throw new ClusterRuntimeException("duplicate table names defined under ShardStrategyElement");
}
}
}
Aggregations