/** * valid the consistency between table's node size and rule's node size * * @param tableConf * @return -1 if table datanode size < rule function partition size * 0 if table datanode size == rule function partition size * 1 if table datanode size > rule function partition size */ public final int suitableFor(TableConfig tableConf) { int nPartition = getPartitionNum(); if (nPartition > 0) { int dnSize = tableConf.getDataNodes().size(); if (dnSize < nPartition) { return -1; } else if (dnSize > nPartition) { return 1; } } return 0; }
/** * shard table datanode(2) < function count(3) and check failed */ private void checkRuleSuitTable(TableConfig tableConf) { AbstractPartitionAlgorithm function = tableConf.getRule().getRuleAlgorithm(); int suitValue = function.suitableFor(tableConf); if (suitValue < 0) { throw new ConfigException("Illegal table conf : table [ " + tableConf.getName() + " ] rule function [ " + tableConf.getRule().getFunctionName() + " ] partition size : " + tableConf.getRule().getRuleAlgorithm().getPartitionNum() + " > table datanode size : " + tableConf.getDataNodes().size() + ", please make sure table datanode size = function partition size"); } else if (suitValue > 0) { problemReporter.warn("table conf : table [ " + tableConf.getName() + " ] rule function [ " + tableConf.getRule().getFunctionName() + " ] " + "partition size : " + String.valueOf(tableConf.getRule().getRuleAlgorithm().getPartitionNum()) + " < table datanode size : " + String.valueOf(tableConf.getDataNodes().size())); } else { // table data node size == rule function partition size } }