wuba / oceanus Goto Github PK
View Code? Open in Web Editor NEW58同城数据库中间件
License: Apache License 2.0
58同城数据库中间件
License: Apache License 2.0
是否还在维护?
类: com.bj58.oceanus.core.loadbalance.ha.DataNodeChecker.FirstChecker
/**
* 该线程用于轮询检测全部DataSource状态,初步判断数据源是否可用,如果不可用,交给ConfirmChecker(确认线程)延时处理
*/
private static class FirstChecker implements Runnable{
@Override
public void run() {
logger.debug("dataNodeMap:"+DataNodeChecker.dataNodeMap);
// .......
}
}
输出的是DataNodeChecker.dataNodeMap这个HashMap的地址
类: com.bj58.oceanus.config.parser.ConfigurationLoader
public void load(String path) throws Exception {
// ...
loadConfigFile(new File(path));
// ...
}
void loadConfigFile(File configFile) throws Exception {
// ...
if(configFile==null || !configFile.exists())
throw new Exception("oceanus config file:"+configFile.getName()+" not found !");
// ......
List<Node> includeNodes = ParseUtils.getNodeList(rootNodeList, INCLUDE_TAG);
for(Node includeNode : includeNodes) {
IncludeConfig includeConfig = (IncludeConfig) ParseUtils.getParser(includeNode).parse((Element)includeNode);
loadConfigFile(new File(configFile.getParent() + SEPERATOR + includeConfig.getFile()));
}
}
如果传入的configFile可能为null, 那configFile.getName就有问题了.
环境:
一个MySQL实例,两个schema[ ocuanus、ocuanus2 ],四张表
ocuanus
t_user
ocuanus2
t_user
t_user1
t_user2
表结构与oceanus-test/t_user.sql里面一致
问题1描述:
执行SQL,会出现异常
SELECT AVG(age) FROM t_user u GROUP BY age HAVING age > 20
异常信息:
java.sql.SQLException: Column 'age' not found.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
at com.mysql.jdbc.ResultSetImpl.findColumn(ResultSetImpl.java:1064)
at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.findColumn(DelegatingResultSet.java:331)
at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.findColumn(DelegatingResultSet.java:331)
at com.bj58.oceanus.result.merger.DefaultResultSetMerger$ResultSetColumnFinder.findIndex(DefaultResultSetMerger.java:407)
at com.bj58.oceanus.result.merger.DefaultResultSetMerger.merge(DefaultResultSetMerger.java:121)
at com.bj58.oceanus.exchange.executors.jdbc.SimpleExecutor.doQuery(SimpleExecutor.java:184)
at com.bj58.oceanus.exchange.executors.jdbc.SimpleExecutor.doQuery(SimpleExecutor.java:148)
at com.bj58.oceanus.exchange.executors.jdbc.SimpleExecutor.execute(SimpleExecutor.java:66)
at com.bj58.oceanus.exchange.jdbc.PreparedStatementWrapper.executeQuery(PreparedStatementWrapper.java:102)
at com.bj58.oceanus.demo.UserRwDemo.selectTest(UserRwDemo.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
.....
问题2描述:
执行SQL,会出现异常
SELECT AVG(age), MIN(age), MAX(age), age FROM t_user u
GROUP BY u.age
HAVING u.age > 20
ORDER BY u.age DESC
LIMIT 0, 15
异常信息:
18:10:47.328 [main] ERROR com.bj58.oceanus.result.merger.DefaultResultSetMerger.processHaving(DefaultResultSetMerger.java:254) - script execute error!
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "U" is not defined. (#1) in at line number 1
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:156) ~[na:1.6.0_45]
at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:170) ~[na:1.6.0_45]
at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:216) ~[na:1.6.0_45]
at com.bj58.oceanus.core.script.InterpretedScriptExecutor.execute(InterpretedScriptExecutor.java:47) ~[oceanus-core-0.0.2-SNAPSHOT.jar:na]
at com.bj58.oceanus.result.merger.DefaultResultSetMerger.processHaving(DefaultResultSetMerger.java:250) [oceanus-results-merger-0.0.2-SNAPSHOT.jar:na]
at com.bj58.oceanus.result.merger.DefaultResultSetMerger.merge(DefaultResultSetMerger.java:192) [oceanus-results-merger-0.0.2-SNAPSHOT.jar:na]
at com.bj58.oceanus.exchange.executors.jdbc.SimpleExecutor.doQuery(SimpleExecutor.java:184) [oceanus-exchange-executors-0.0.2-SNAPSHOT.jar:na]
at com.bj58.oceanus.exchange.executors.jdbc.SimpleExecutor.doQuery(SimpleExecutor.java:148) [oceanus-exchange-executors-0.0.2-SNAPSHOT.jar:na]
at com.bj58.oceanus.exchange.executors.jdbc.SimpleExecutor.execute(SimpleExecutor.java:66) [oceanus-exchange-executors-0.0.2-SNAPSHOT.jar:na]
at com.bj58.oceanus.exchange.jdbc.PreparedStatementWrapper.executeQuery(PreparedStatementWrapper.java:102) [oceanus-exchange-jdbc-0.0.2-SNAPSHOT.jar:na]
at com.bj58.oceanus.demo.UserRwDemo.selectTest(UserRwDemo.java:89) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_45]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_45]
.....
类: com.bj58.oceanus.core.loadbalance.ha.DataNodeChecker
/**
* 从状态映射map中查看DataNode是否可用
* @param dataNode
* @return
*/
public static boolean dataNodeAlive(DataNode dataNode){
if(dataNode==null || dataNode.getId()==null)
return true;
if(!dataNodeAliveMap.containsKey(dataNode.getId())){
logger.error("DataNode ["+dataNode.getId()+"] is not in the check list !!");
return true;
}
return dataNodeAliveMap.get(dataNode.getId()).get();
}
前面的两个if特殊情况应该不会发生, 而且为什么返回的是true?
类: com.bj58.oceanus.core.shard.ScriptFunction
@Override
public int execute(int size, Map<String, Object> parameters) {
try {
// ...
context.put("$NODE_SIZE", size);
Double value = scriptExecutor.execute(null,context);
if (value != null) {
return value.intValue();
} else {
throw new ShardException("function error,could not find namenodes index="+value+"!parameters=" + parameters); //
}
} catch (ScriptException e) {
throw new ShardException("script error!parameters=" + parameters, e);
}
}
应该是写错了,上下文没有namenodes的信息,而且这个else分支value是null
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.