findbugs:change for style:SF_SWITCH_NO_DEFAULT

This commit is contained in:
yanhuqing666
2017-08-14 16:02:00 +08:00
parent 7ccc851d7a
commit e627611f14
12 changed files with 88 additions and 61 deletions

View File

@@ -26,10 +26,20 @@
<Match>
<Class name="io.mycat.sqlengine.mpp.UnsafeRowGrouper"/>
</Match>
<Match>
<Class name="io.mycat.sqlengine.mpp.RowDataPacketGrouper"/>
</Match>
<!-- need refactor -->
<Match>
<Package name="io.mycat.util.dataMigrator"/>
</Match>
<Match>
<Package name="io.mycat.util.dataMigrator.dataIOImpl"/>
</Match>
<!--MALICIOUS_CODE 68,STYLE 50+ -->
<Match>
<Bug category="MALICIOUS_CODE,STYLE,CORRECTNESS"/>
<Bug category="MALICIOUS_CODE,CORRECTNESS"/>
</Match>
@@ -40,11 +50,29 @@
<Bug pattern="DM_DEFAULT_ENCODING"/>
</Match>
<!-- STYLE start -->
<!-- switch without default:TODO-->
<Match>
<!-- need refactor -->
<Match>
<Bug category="STYLE"/>
<Bug pattern="SF_SWITCH_NO_DEFAULT"/>
<Class name="io.mycat.server.parser.ServerParseSelect"/>
</Match>
<!-- need refactor -->
<Match>
<Bug category="STYLE"/>
<Bug pattern="SF_SWITCH_NO_DEFAULT"/>
<Class name="io.mycat.server.response.CharacterSet"/>
</Match>
<!-- use enum? -->
<Match>
<Bug category="STYLE"/>
<Bug pattern="SF_SWITCH_NO_DEFAULT"/>
<Class name="io.mycat.backend.heartbeat.MySQLHeartbeat"/>
</Match>
<Match>
<Bug category="STYLE"/>
<Bug pattern="SF_SWITCH_NO_DEFAULT"/>
<Class name="io.mycat.server.response.SessionIsolation"/>
</Match>
<!-- always throw new exception-->
<Match>
@@ -123,4 +151,4 @@
</Match>
<!-- BAD_PRACTICE end-->
</FindBugsFilter>
</FindBugsFilter>

View File

@@ -173,6 +173,9 @@ public class MySQLDataSource extends PhysicalDatasource {
r323.write(out);
out.flush();
break;
default:
isConnected = false;
break;
}
} catch (IOException e) {

View File

@@ -32,7 +32,7 @@ public abstract class Versions {
public static final byte PROTOCOL_VERSION = 10;
/**服务器版本**/
public static byte[] SERVER_VERSION = "5.6.29-mycat-2.17.08.0-dev-20170813134310".getBytes();
public static byte[] SERVER_VERSION = "5.6.29-mycat-2.17.08.0-dev-20170814145517".getBytes();
public static byte[] VERSION_COMMENT = "MyCat Server (OpenCloundDB)".getBytes();
public static final String ANNOTATION_NAME = "mycat:";
public static final String ROOT_PREFIX = "mycat";

View File

@@ -545,25 +545,21 @@ public class XMLSchemaLoader implements SchemaLoader {
private void checkRuleSuitTable(TableConfig tableConf) {
AbstractPartitionAlgorithm function = tableConf.getRule().getRuleAlgorithm();
int suitValue = function.suitableFor(tableConf);
switch(suitValue) {
case -1:
// 少节点,给提示并抛异常
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");
case 0:
// table datanode size == rule function partition size
break;
case 1:
// 有些节点是多余的,给出warn log
LOGGER.warn("table conf : table [ {} ] rule function [ {} ] partition size : {} < table datanode size : {} , this cause some datanode to be redundant",
new String[]{
tableConf.getName(),
tableConf.getRule().getFunctionName(),
String.valueOf(tableConf.getRule().getRuleAlgorithm().getPartitionNum()),
String.valueOf(tableConf.getDataNodes().size())
});
break;
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) {// 有些节点是多余的,给出warn log
LOGGER.warn("table conf : table [ {} ] rule function [ {} ] partition size : {} < table datanode size : {} , this cause some datanode to be redundant",
new String[]{
tableConf.getName(),
tableConf.getRule().getFunctionName(),
String.valueOf(tableConf.getRule().getRuleAlgorithm().getPartitionNum()),
String.valueOf(tableConf.getDataNodes().size())
});
} else {
// table datanode size == rule function partition size
}
}

View File

@@ -241,6 +241,8 @@ public class BinaryRowDataPacket extends MySQLPacket {
LOGGER.error("error",e);
}
break;
default:
throw new IllegalArgumentException("Field type is not supported");
}
}

View File

@@ -491,6 +491,8 @@ public class MySQLItemVisitor extends MySqlASTVisitorAdapter {
case "STDDEV":
item = new ItemSumStd(args, 0, false, null);
break;
default:
throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "not supported "+funcName);
}
}
@Override

View File

@@ -63,39 +63,26 @@ public class QueryConditionAnalyzer implements QueryResultListener {
@Override
public void onQueryResult(QueryResult queryResult) {
// this.lock.lock();
// try {
int sqlType = queryResult.getSqlType();
String sql = queryResult.getSql();
switch(sqlType) {
case ServerParse.SELECT:
List<Object> values = sqlParser.parseConditionValues(sql, this.tableName, this.columnName);
if ( values != null ) {
if ( this.map.size() < MAX_QUERY_MAP_SIZE ) {
for(Object value : values) {
AtomicLong count = this.map.get(value);
if (count == null) {
count = new AtomicLong(1L);
} else {
count.getAndIncrement();
}
this.map.put(value, count);
}
} else {
LOGGER.debug(" this map is too large size ");
}
}
}
// } finally {
// this.lock.unlock();
// }
int sqlType = queryResult.getSqlType();
String sql = queryResult.getSql();
if (sqlType == ServerParse.SELECT) {
List<Object> values = sqlParser.parseConditionValues(sql, this.tableName, this.columnName);
if (values != null) {
if (this.map.size() < MAX_QUERY_MAP_SIZE) {
for (Object value : values) {
AtomicLong count = this.map.get(value);
if (count == null) {
count = new AtomicLong(1L);
} else {
count.getAndIncrement();
}
this.map.put(value, count);
}
} else {
LOGGER.debug(" this map is too large size ");
}
}
}
}
public boolean setCf(String cf) {

View File

@@ -63,6 +63,8 @@ public class TableStat implements Comparable<TableStat> {
case ServerParse.REPLACE:
this.wCount.incrementAndGet();
break;
default:
break;
}
// 记录 关联表执行情况

View File

@@ -72,6 +72,9 @@ public class TableStatAnalyzer implements QueryResultListener {
tableStat.update(sqlType, sql, queryResult.getStartTime(), queryResult.getEndTime(), relaTables);
}
break;
default:
break;
}
}

View File

@@ -93,6 +93,8 @@ public class UserSqlRWStat {
case ServerParse.REPLACE:
this.wCount.incrementAndGet();
break;
default:
break;
}
//SQL执行所在的耗时区间

View File

@@ -48,6 +48,8 @@ public class UserStatAnalyzer implements QueryResultListener {
}
userStat.update(sqlType, sql, sqlRows, netInBytes, netOutBytes, startTime, endTime,resultSetSize);
break;
default:
break;
}
}

View File

@@ -1,5 +1,5 @@
BuildTime 2017-08-13 05:43:07
GitVersion 58bab7dd231195db3548308f0f16392c78a8ffaa
BuildTime 2017-08-14 06:55:11
GitVersion 704c94064af101666290c82ca7652f8cc682f0d1
MavenVersion 2.17.08.0-dev
GitUrl https://github.com/MyCATApache/Mycat-Server.git
MyCatSite http://www.mycat.org.cn