(ErrorCode.class);
27 |
28 | static {
29 | errMsgMapping.put(ErrorCode.TABLE_NUM_LIMIT, "Number of created table beyond the SLA limit");
30 | errMsgMapping.put(ErrorCode.RECORDS_IN_SINGLE_TABLE_LIMIT, "Records beyond the SLA limit in single table");
31 | errMsgMapping.put(ErrorCode.USER_RULE_LIMIT, "Don't have the authority for the operation");
32 | errMsgMapping.put(ErrorCode.UNKNOWN_FATAL_ERROR, "Unknown fatal error!");
33 | }
34 |
35 | public static int getErrorNo(ErrorCode code) {
36 | return errNoMapping.get(code) != null ? errNoMapping.get(code) : 0;
37 | }
38 |
39 | public static String getErrorMsg(ErrorCode code) {
40 | return errMsgMapping.get(code) != null ? errMsgMapping.get(code) : "";
41 | }
42 |
43 | private EnumCode(){
44 |
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/com/meidusa/amoeba/util/HashFunction.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.util;
2 |
3 | public interface HashFunction {
4 |
5 | long hash(Object string);
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/com/meidusa/amoeba/util/Initialisable.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * This program is free software; you can redistribute it and/or modify it under the terms of
4 | * the GNU AFFERO GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 3 of the License,
5 | * or (at your option) any later version.
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 | * See the GNU AFFERO GENERAL PUBLIC LICENSE for more details.
10 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE along with this program;
11 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
12 | *
13 | */
14 | package com.meidusa.amoeba.util;
15 |
16 | import com.meidusa.amoeba.exception.InitialisationException;
17 |
18 | public interface Initialisable {
19 |
20 | public void init() throws InitialisationException;
21 | }
22 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/com/meidusa/amoeba/util/NameableRunner.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is free software; you can redistribute it and/or modify it under the terms of
3 | * the GNU AFFERO GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 3 of the License,
4 | * or (at your option) any later version.
5 | *
6 | * This program is distributed in the hope that it will be useful,
7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 | * See the GNU AFFERO GENERAL PUBLIC LICENSE for more details.
9 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE along with this program;
10 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11 | */
12 | package com.meidusa.amoeba.util;
13 |
14 | public interface NameableRunner extends Runnable {
15 |
16 | public String getRunnerName();
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/com/meidusa/amoeba/util/OptionType.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.util;
2 | public enum OptionType{
3 | String,Long,Int,Double,Boolean
4 | }
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/com/meidusa/amoeba/util/Reporter.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * This program is free software; you can redistribute it and/or modify it under the terms of
4 | * the GNU AFFERO GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 3 of the License,
5 | * or (at your option) any later version.
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 | * See the GNU AFFERO GENERAL PUBLIC LICENSE for more details.
10 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE along with this program;
11 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
12 | *
13 | */
14 | package com.meidusa.amoeba.util;
15 |
16 | import org.apache.log4j.Level;
17 |
18 | /**
19 | * @author Struct chen
20 | */
21 | public interface Reporter {
22 |
23 | /**
24 | * @param buffer 组装report信息的 StringBuilder
25 | * @param now report 任务开始产生report的当时时间,单位ms
26 | * @param sinceLast 上一次report的时间
27 | * @param reset 是否需要重新统计
28 | */
29 | public void appendReport(StringBuilder buffer, long now, long sinceLast, boolean reset, Level level);
30 |
31 | // public void alertStartReport();
32 |
33 | public static interface SubReporter {
34 |
35 | public void appendReport(StringBuilder buffer, long now, long sinceLast, boolean reset, Level level);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/com/meidusa/amoeba/util/RunQueue.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * This program is free software; you can redistribute it and/or modify it under the terms of
4 | * the GNU AFFERO GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 3 of the License,
5 | * or (at your option) any later version.
6 | *
7 | * This program is distributed in the hope that it will be useful,
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9 | * See the GNU AFFERO GENERAL PUBLIC LICENSE for more details.
10 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE along with this program;
11 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
12 | *
13 | */
14 | package com.meidusa.amoeba.util;
15 |
16 | /**
17 | * An interface for a service that queues up execution of Runnables.
18 | */
19 | public interface RunQueue {
20 |
21 | /**
22 | * Post the specified Runnable to be run on the RunQueue.
23 | */
24 | public void postRunnable(Runnable r);
25 |
26 | /**
27 | * @return true if the calling thread is the RunQueue dispatch thread.
28 | */
29 | public boolean isDispatchThread();
30 |
31 | public int size();
32 | }
33 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/com/meidusa/amoeba/util/SqlUtil.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.util;
2 |
3 |
4 | public class SqlUtil {
5 |
6 | public static boolean isUseStatement(String sql){
7 |
8 | if (!StringUtil.isEmpty(sql)) {
9 |
10 | sql = sql.trim();
11 | String[] words = sql.split("\\s+");
12 |
13 | if (!StringUtil.isEmpty(words[0]) && words[0].toLowerCase().equals("use")) {
14 | return true;
15 | }
16 | }
17 |
18 | return false;
19 | }
20 |
21 |
22 | public static String getUseSchema(String sql){
23 |
24 | String schema = null;
25 |
26 | if (isUseStatement(sql)) {
27 | if (!StringUtil.isEmpty(sql)) {
28 | sql = sql.trim();
29 | String[] words = sql.split("\\s+");
30 |
31 | if (words != null && words.length >= 2) {
32 | if (!StringUtil.isEmpty(words[1])) {
33 | schema = words[1].trim();
34 | }
35 | }
36 | }
37 | }
38 |
39 | return schema;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/com/meidusa/amoeba/util/StaticString.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.util;
2 |
3 | public interface StaticString {
4 |
5 | public static final String DATE_FORMAT_SYMBOLS = "DATE_FORMAT_SYMBOLS";
6 | public static final String CALENDAR = "CALENDAR";
7 | public static final String JEP_RUNTIME = "JEP_RUNTIME";
8 | public static final String HANDLER = "_HANDLER_";
9 | }
10 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/com/vispractice/amoeba/base/Activator.java:
--------------------------------------------------------------------------------
1 | package com.vispractice.amoeba.base;
2 |
3 | import org.osgi.framework.BundleActivator;
4 | import org.osgi.framework.BundleContext;
5 |
6 |
7 | public class Activator implements BundleActivator {
8 |
9 | public static BundleContext bundleContext;
10 |
11 | /*
12 | * (non-Javadoc)
13 | *
14 | * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
15 | */
16 | public void start(BundleContext context) throws Exception {
17 | Activator.bundleContext = context;
18 | }
19 |
20 | /*
21 | * (non-Javadoc)
22 | *
23 | * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
24 | */
25 | public void stop(BundleContext context) throws Exception {
26 | Activator.bundleContext = null;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.base/src/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=ERROR,Console,R
2 |
3 | log4j.logger.com.vispractice=DEBUG
4 | log4j.logger.com.meidusa=INFO
5 | log4j.logger.com.meidusa.amoeba.mysql=INFO
6 | log4j.logger.com.meidusa.amoeba.base=INFO
7 |
8 | log4j.appender.Console=org.apache.log4j.ConsoleAppender
9 | log4j.appender.Console.layout=org.apache.log4j.PatternLayout
10 | log4j.appender.Console.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss} [%c:%L]-[%p] %m%n
11 |
12 | log4j.appender.R=org.apache.log4j.RollingFileAppender
13 | log4j.appender.R.File=./log/log4j.log
14 | log4j.appender.R.MaxFileSize=500KB
15 | log4j.appender.R.MaxBackupIndex=10
16 | log4j.appender.R.layout=org.apache.log4j.PatternLayout
17 | log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%t] [%c:%L] [%p] - %m%n
18 |
19 | ### reporter logger ###
20 | #log4j.logger.report=DEBUG,ReportAppender
21 | #log4j.additivity.report=false
22 | #log4j.appender.ReportAppender=org.apache.log4j.DailyRollingFileAppender
23 | #log4j.appender.ReportAppender.File=./log/report.log
24 | #log4j.appender.ReportAppender.layout=org.apache.log4j.PatternLayout
25 | #log4j.appender.ReportAppender.layout.ConversionPattern=%d %-5p %c{2} - %m%n
26 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: File
4 | Bundle-SymbolicName: com.vispractice.amoeba.loader.file
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-Activator: com.vispractice.amoeba.loader.file.Activator
7 | Bundle-Vendor: VISPRACTICE
8 | Bundle-RequiredExecutionEnvironment: JavaSE-1.7
9 | Import-Package: org.osgi.framework;version="1.3.0"
10 | Bundle-ActivationPolicy: lazy
11 | Service-Component: OSGI-INF/AmoebaContextFileLoader.xml,
12 | OSGI-INF/DBServerConfigFileLoader.xml,
13 | OSGI-INF/UserFileLoader.xml,
14 | OSGI-INF/TableRuleFileLoader.xml,
15 | OSGI-INF/RuleFunctionMapFileLoader.xml,
16 | OSGI-INF/SqlFunctionMapFileLoader.xml,
17 | OSGI-INF/IpAccessListFileLoader.xml
18 | Require-Bundle: com.vispractice.amoeba.base;bundle-version="1.0.0",
19 | org.springframework.osgi.log4j.osgi;bundle-version="1.2.15",
20 | com.springsource.org.apache.commons.collections;bundle-version="3.2.1"
21 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/OSGI-INF/AmoebaContextFileLoader.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/OSGI-INF/DBServerConfigFileLoader.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/OSGI-INF/IpAccessListFileLoader.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/OSGI-INF/RuleFunctionMapFileLoader.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/OSGI-INF/SqlFunctionMapFileLoader.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/OSGI-INF/TableRuleFileLoader.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/OSGI-INF/UserFileLoader.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/release/conf/access_list.conf:
--------------------------------------------------------------------------------
1 | #配置IP访问控制
2 | #
3 | # 优先级别从上往下,前面的优先级别高,每条一行
4 |
5 | #192.*.1.236-239:yes
6 | #比如192.34.1.238则可以访问,否则将不能访问。
7 |
8 | #218.85.*.*:no
9 | #127.0.0.1:yes
10 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/release/conf/rule.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 |
11 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/release/conf/ruleFunctionMap.xml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.loader.file/release/conf/ruleFunctionMap.xml
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/release/conf/seq.properties:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.loader.file/release/conf/seq.properties
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/release/conf/users.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/config/loader/RuleFunctionMapFileLoader.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.config.loader;
2 |
3 | import java.util.Map;
4 |
5 | import com.meidusa.amoeba.config.BeanObjectEntityConfig;
6 | import com.meidusa.amoeba.sqljep.function.PostfixCommand;
7 |
8 | public class RuleFunctionMapFileLoader extends FunctionFileLoader implements RuleFunctionMapLoader{
9 |
10 | @Override
11 | public void initBeanObject(BeanObjectEntityConfig config, PostfixCommand bean) {
12 | bean.setName(config.getName());
13 | }
14 |
15 | @Override
16 | public void putToMap(Map map, PostfixCommand value) {
17 | map.put(value.getName(), value);
18 | }
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/config/loader/SqlFunctionMapFileLoader.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.config.loader;
2 |
3 | import java.util.Map;
4 |
5 | import com.meidusa.amoeba.config.BeanObjectEntityConfig;
6 | import com.meidusa.amoeba.parser.function.Function;
7 |
8 | public class SqlFunctionMapFileLoader extends FunctionFileLoader implements SqlFunctionMapLoader{
9 |
10 | @Override
11 | public void initBeanObject(BeanObjectEntityConfig config, Function bean) {
12 | bean.setName(config.getName());
13 | }
14 |
15 | @Override
16 | public void putToMap(Map map, Function value) {
17 | map.put(value.getName(), value);
18 | }
19 |
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xml/amoeba.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xml/dbserver.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xml/function.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xml/objectMap.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xml/rule.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xml/table.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xml/user.dtd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xmltable/Condition.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.xmltable;
2 |
3 | public class Condition {
4 | public static enum TYPE {exist,match,nameMatch};
5 | public String name;
6 | public String value;
7 | public TYPE type;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xmltable/XmlColumn.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.xmltable;
2 |
3 | public class XmlColumn {
4 | private String name;
5 | private int type;
6 | private String value;
7 |
8 | public String getName() {
9 | return name;
10 | }
11 | public void setName(String name) {
12 | this.name = name;
13 | }
14 | public int getType() {
15 | return type;
16 | }
17 | public void setType(int type) {
18 | this.type = type;
19 | }
20 | public String getValue() {
21 | return value;
22 | }
23 | public void setValue(String value) {
24 | this.value = value;
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xmltable/XmlRow.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.xmltable;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | import com.meidusa.amoeba.util.StringUtil;
7 |
8 | public class XmlRow {
9 | private Map columMap = new HashMap();
10 |
11 | public Map getColumMap() {
12 | return columMap;
13 | }
14 |
15 | public void setColumMap(Map columMap) {
16 | this.columMap = columMap;
17 | }
18 |
19 | public void addColumn(String name,XmlColumn column){
20 | columMap.put(name, column);
21 | }
22 |
23 | public boolean isMatch(Condition condition){
24 | if(condition == null) return true;
25 | if(condition.type == Condition.TYPE.exist){
26 | return columMap.get(condition.name) != null;
27 | }else if(condition.type == Condition.TYPE.match){
28 | XmlColumn column = columMap.get(condition.name);
29 | if(column == null) return false;
30 | return StringUtil.equalsIgnoreCase(column.getValue(), condition.value);
31 | }else{
32 | return false;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/meidusa/amoeba/xmltable/XmlTable.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.xmltable;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class XmlTable {
7 | private String name;
8 | private String schema;
9 | private List columns = new ArrayList();
10 | private List rows = new ArrayList();
11 |
12 | public List getColumns() {
13 | return columns;
14 | }
15 | public void setColumns(List columns) {
16 | this.columns = columns;
17 | }
18 | public List getRows() {
19 | return rows;
20 | }
21 | public void setRows(List rows) {
22 | this.rows = rows;
23 | }
24 |
25 | public String getName() {
26 | return name;
27 | }
28 | public void setName(String name) {
29 | this.name = name;
30 | }
31 |
32 | public String getSchema() {
33 | return schema;
34 | }
35 |
36 | public void setSchema(String schema) {
37 | this.schema = schema;
38 | }
39 |
40 | public XmlTable query(Condition condition){
41 | XmlTable table = new XmlTable();
42 | for(String column:columns){
43 | table.columns.add(column);
44 | }
45 | for(XmlRow row : rows){
46 | if(row.isMatch(condition)){
47 | table.rows.add(row);
48 | }
49 | }
50 | return table;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.loader.file/src/com/vispractice/amoeba/loader/file/Activator.java:
--------------------------------------------------------------------------------
1 | package com.vispractice.amoeba.loader.file;
2 |
3 | import org.osgi.framework.BundleActivator;
4 | import org.osgi.framework.BundleContext;
5 |
6 | public class Activator implements BundleActivator {
7 |
8 | private static BundleContext context;
9 |
10 | static BundleContext getContext() {
11 | return context;
12 | }
13 |
14 | /*
15 | * (non-Javadoc)
16 | * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
17 | */
18 | public void start(BundleContext bundleContext) throws Exception {
19 | Activator.context = bundleContext;
20 | }
21 |
22 | /*
23 | * (non-Javadoc)
24 | * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
25 | */
26 | public void stop(BundleContext bundleContext) throws Exception {
27 | Activator.context = null;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: Mysql
4 | Bundle-SymbolicName: com.vispractice.amoeba.mysql
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-Activator: com.vispractice.amoeba.mysql.Activator
7 | Bundle-Vendor: VISPRACTICE
8 | Bundle-RequiredExecutionEnvironment: JavaSE-1.6
9 | Import-Package: org.osgi.framework;version="1.3.0",
10 | org.osgi.service.component;version="1.1.0"
11 | Require-Bundle: com.vispractice.amoeba.base;bundle-version="1.0.0",
12 | com.springsource.org.apache.commons.collections;bundle-version="3.2.1",
13 | com.springsource.org.apache.commons.lang;bundle-version="2.4.0",
14 | org.springframework.osgi.log4j.osgi;bundle-version="1.2.15",
15 | org.apache.servicemix.bundles.commons-pool;bundle-version="1.5.4",
16 | com.vispractice.amoeba.seq.fetcher;bundle-version="1.0.0"
17 | Export-Package: com.meidusa.amoeba.mysql.context,
18 | com.meidusa.amoeba.mysql.handler,
19 | com.meidusa.amoeba.mysql.jdbc,
20 | com.meidusa.amoeba.mysql.net,
21 | com.meidusa.amoeba.mysql.net.packet,
22 | com.meidusa.amoeba.mysql.net.packet.result,
23 | com.meidusa.amoeba.mysql.parser,
24 | com.meidusa.amoeba.mysql.util
25 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/filter/AbstractIOFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2108 amoeba.meidusa.com
3 | *
4 | * This program is free software; you can redistribute it and/or modify it under the terms of
5 | * the GNU AFFERO GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 3 of the License,
6 | * or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 | * See the GNU AFFERO GENERAL PUBLIC LICENSE for more details.
11 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE along with this program;
12 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
13 | */
14 | package com.meidusa.amoeba.mysql.filter;
15 |
16 | import com.meidusa.amoeba.mysql.filter.FilterInvocation.Result;
17 |
18 | /**
19 | *
20 | * @author Struct chen
21 | *
22 | */
23 | public abstract class AbstractIOFilter implements IOFilter {
24 |
25 | private byte[] resultBuffer;
26 | public void startFiltrate(){
27 | }
28 |
29 | protected void setResultBuffer(byte[] resultBuffer) {
30 | this.resultBuffer = resultBuffer;
31 | }
32 |
33 | public void finishFiltrate(){
34 | resultBuffer = null;
35 | }
36 |
37 | public Result doFilter(PacketFilterInvocation invocation) {
38 | return packetFilter(invocation.getByteBuffer());
39 | }
40 |
41 | protected abstract Result packetFilter(byte[] packetBuffer);
42 |
43 | public byte[] getFiltedResult(){
44 | return resultBuffer;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/filter/FilterInvocation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2108 amoeba.meidusa.com
3 | *
4 | * This program is free software; you can redistribute it and/or modify it under the terms of
5 | * the GNU AFFERO GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 3 of the License,
6 | * or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 | * See the GNU AFFERO GENERAL PUBLIC LICENSE for more details.
11 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE along with this program;
12 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
13 | */
14 | package com.meidusa.amoeba.mysql.filter;
15 |
16 | /**
17 | *
18 | * @author Struct chen
19 | *
20 | */
21 | public interface FilterInvocation {
22 | enum Result{RETURN,OK,ERROR,PROCESSED,QUIT}
23 | void invoke();
24 | Result getResultCode();
25 | }
26 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/filter/IOFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2008-2108 amoeba.meidusa.com
3 | *
4 | * This program is free software; you can redistribute it and/or modify it under the terms of
5 | * the GNU AFFERO GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 3 of the License,
6 | * or (at your option) any later version.
7 | *
8 | * This program is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 | * See the GNU AFFERO GENERAL PUBLIC LICENSE for more details.
11 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE along with this program;
12 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
13 | */
14 | package com.meidusa.amoeba.mysql.filter;
15 |
16 | import com.meidusa.amoeba.mysql.filter.FilterInvocation.Result;
17 |
18 | /**
19 | *
20 | * @author Struct chen
21 | *
22 | */
23 | public interface IOFilter {
24 | public void startFiltrate();
25 | public Result doFilter(PacketFilterInvocation invocation);
26 | public byte[] getFiltedResult();
27 | public void finishFiltrate();
28 | }
29 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/handler/CommitStatementHandler.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.handler;
2 |
3 | import org.apache.log4j.Logger;
4 |
5 | import com.meidusa.amoeba.mysql.net.MysqlClientConnection;
6 | import com.meidusa.amoeba.net.poolable.ObjectPool;
7 | import com.meidusa.amoeba.parser.statement.Statement;
8 | import com.meidusa.amoeba.route.Request;
9 |
10 | public class CommitStatementHandler extends StickyForTransactionHandler {
11 | public static Logger logger = Logger.getLogger(CommitStatementHandler.class);
12 |
13 | public CommitStatementHandler(MysqlClientConnection source, byte[] query, Statement statment,
14 | ObjectPool[] pools, Request request, long timeout) {
15 | super(source, query, statment, pools, request, timeout);
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/handler/RollbackStatementHandler.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.handler;
2 |
3 | import org.apache.log4j.Logger;
4 |
5 | import com.meidusa.amoeba.mysql.net.MysqlClientConnection;
6 | import com.meidusa.amoeba.net.poolable.ObjectPool;
7 | import com.meidusa.amoeba.parser.statement.Statement;
8 | import com.meidusa.amoeba.route.Request;
9 |
10 | public class RollbackStatementHandler extends StickyForTransactionHandler{
11 | public static Logger logger = Logger.getLogger(RollbackStatementHandler.class);
12 |
13 | public RollbackStatementHandler(MysqlClientConnection source, byte[] query, Statement statment,
14 | ObjectPool[] pools, Request request, long timeout) {
15 |
16 | super(source, query, statment, pools, request, timeout);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/handler/session/CommandStatus.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.meidusa.amoeba.mysql.handler.session;
5 |
6 | public enum CommandStatus{
7 | ConnectionNotComplete,ConnectionCompleted,AllCompleted
8 | }
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/handler/session/SessionStatus.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.handler.session;
2 |
3 | /**
4 | * 表示服务器返回的数据包所表示当前会话状态
5 | * @author Struct chen
6 | *
7 | */
8 | public class SessionStatus{
9 | public static final int QUERY = 1;
10 | public static final int RESULT_HEAD = 2;
11 | public static final int EOF_FIELDS = 4;
12 | public static final int EOF_ROWS = 8;
13 | public static final int OK = 16;
14 | public static final int ERROR = 32;
15 | public static final int COMPLETED = 64;
16 | }
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/jdbc/IsolationLevels.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.jdbc;
2 |
3 | public class IsolationLevels {
4 | public static final int READ_UNCOMMITTED = 1;
5 | public static final int READ_COMMITTED = 2;
6 |
7 | public static final int REPEATED_READ = 4;
8 |
9 | public static final int SERIALIZABLE = 8;
10 | }
11 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/net/CommandListener.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is free software; you can redistribute it and/or modify it under the terms of
3 | * the GNU AFFERO GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 3 of the License,
4 | * or (at your option) any later version.
5 | *
6 | * This program is distributed in the hope that it will be useful,
7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 | * See the GNU AFFERO GENERAL PUBLIC LICENSE for more details.
9 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE along with this program;
10 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11 | */
12 | package com.meidusa.amoeba.mysql.net;
13 |
14 | public interface CommandListener{
15 | public void startCommand(CommandInfo command);
16 | public void finishedCommand(CommandInfo command);
17 | }
18 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/net/MysqlClientConnectionFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * This program is free software; you can redistribute it and/or modify it under the terms of
3 | * the GNU AFFERO GENERAL PUBLIC LICENSE as published by the Free Software Foundation; either version 3 of the License,
4 | * or (at your option) any later version.
5 | *
6 | * This program is distributed in the hope that it will be useful,
7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8 | * See the GNU AFFERO GENERAL PUBLIC LICENSE for more details.
9 | * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE along with this program;
10 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11 | */
12 | package com.meidusa.amoeba.mysql.net;
13 |
14 | import java.nio.channels.SocketChannel;
15 |
16 | import com.meidusa.amoeba.net.Connection;
17 | import com.meidusa.amoeba.net.FrontendConnectionFactory;
18 |
19 | /**
20 | *
21 | * @author Struct chen
22 | *
23 | */
24 | public class MysqlClientConnectionFactory extends FrontendConnectionFactory {
25 |
26 | @Override
27 | protected Connection newConnectionInstance(SocketChannel channel,
28 | long createStamp) {
29 | return new MysqlClientConnection(channel, createStamp);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/net/packet/ConstantPacketBuffer.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.net.packet;
2 |
3 | import com.meidusa.amoeba.mysql.net.packet.OkPacket;
4 |
5 | public class ConstantPacketBuffer {
6 | public static byte[] STATIC_OK_BUFFER;
7 | static {
8 | OkPacket ok = new OkPacket();
9 | ok.affectedRows = 0;
10 | ok.insertId = 0;
11 | ok.packetId = 1;
12 | ok.serverStatus = 2;
13 | STATIC_OK_BUFFER = ok.toByteBuffer(null).array();
14 | }
15 |
16 | public static final String _READ_UNCOMMITTED = "SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED";
17 |
18 | public static final String _READ_COMMITTED = "SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED";
19 |
20 | public static final String _REPEATED_READ = "SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ";
21 |
22 | public static final String _SERIALIZABLE = "SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE";
23 | }
24 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/net/packet/MysqlPingPacket.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.net.packet;
2 |
3 | /**
4 | *
5 | * @author struct
6 | *
7 | */
8 | public class MysqlPingPacket extends CommandPacket {
9 | public MysqlPingPacket(){
10 | command = COM_PING;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/net/packet/Scramble323Packet.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.net.packet;
2 |
3 | import java.io.UnsupportedEncodingException;
4 |
5 | import com.meidusa.amoeba.mysql.util.Util;
6 | import com.meidusa.amoeba.net.packet.AbstractPacketBuffer;
7 |
8 | /**
9 | *
10 | * By sending this very specific reply server asks us to send scrambled
11 | * password in old format. The reply contains scramble_323.
12 | *
13 | *
14 | * @author Struct
15 | */
16 | public class Scramble323Packet extends AbstractPacket {
17 |
18 | public String password;
19 | public String seed323;
20 |
21 | public void write2Buffer(AbstractPacketBuffer mybuffer) throws UnsupportedEncodingException {
22 | super.write2Buffer(mybuffer);
23 | MysqlPacketBuffer buffer = (MysqlPacketBuffer) mybuffer;
24 | buffer.writeString(Util.newCrypt(password, seed323));
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/net/packet/result/ErrorResultPacket.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.net.packet.result;
2 |
3 | import com.meidusa.amoeba.mysql.net.packet.ErrorPacket;
4 | import com.meidusa.amoeba.net.Connection;
5 |
6 | /**
7 | *
8 | * @author struct
9 | *
10 | */
11 | public class ErrorResultPacket implements ResultPacket{
12 | private boolean isError;
13 | private String errorMessage;
14 | public boolean isError() {
15 | return isError;
16 | }
17 |
18 | private int errorCode;
19 | public void setError(int errorCode,String errorMessage) {
20 | isError = true;
21 | this.errorCode = errorCode;
22 | this.errorMessage = errorMessage;
23 | }
24 |
25 | public void wirteToConnection(Connection conn) {
26 | ErrorPacket packet = new ErrorPacket();
27 | packet.packetId = 1;
28 | packet.errno = errorCode;
29 | packet.serverErrorMessage = errorMessage;
30 | conn.postMessage(packet.toByteBuffer(conn));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/net/packet/result/MysqlSimpleResultPacket.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.net.packet.result;
2 |
3 | import java.util.concurrent.atomic.AtomicLong;
4 |
5 | import com.meidusa.amoeba.mysql.net.packet.OkPacket;
6 | import com.meidusa.amoeba.net.Connection;
7 |
8 | /**
9 | *
10 | * @author struct
11 | *
12 | */
13 | public class MysqlSimpleResultPacket extends ErrorResultPacket {
14 |
15 | private AtomicLong resultCount = new AtomicLong();
16 | public void addResultCount(int count){
17 | resultCount.addAndGet(count);
18 | }
19 |
20 | public void wirteToConnection(Connection conn) {
21 | if(isError()){
22 | super.wirteToConnection(conn);
23 | return;
24 | }
25 | OkPacket packet = new OkPacket();
26 | packet.affectedRows = resultCount.get();
27 | packet.insertId = 0;
28 | packet.serverStatus = 2;
29 | packet.packetId = 1;
30 | conn.postMessage(packet.toByteBuffer(conn));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/net/packet/result/ResultPacket.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.net.packet.result;
2 |
3 | import com.meidusa.amoeba.net.Connection;
4 |
5 | /**
6 | *
7 | * @author struct
8 | *
9 | */
10 | public interface ResultPacket {
11 |
12 | public void setError(int errorCode,String errorMessage);
13 | /**
14 | * 将ResultSet这些包合并以后写到Connection
15 | * head--> fields --> eof -->rows --> eof
16 | * @param conn
17 | */
18 | public abstract void wirteToConnection(Connection conn);
19 |
20 | }
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/parser/MysqlSyntaxConstants.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.mysql.parser;
2 |
3 | public class MysqlSyntaxConstants {
4 | // 数据库虚表的名称
5 | public final static String DUAL_TABLE_NAME = "DUAL";
6 | }
7 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/meidusa/amoeba/mysql/parser/sql/MysqlParserTreeConstants.java:
--------------------------------------------------------------------------------
1 | /* Generated By:JavaCC: Do not edit this line. MysqlParserTreeConstants.java Version 5.0 */
2 | package com.meidusa.amoeba.mysql.parser.sql;
3 |
4 | public interface MysqlParserTreeConstants
5 | {
6 | public int JJTVOID = 0;
7 |
8 |
9 | public String[] jjtNodeName = {
10 | "void",
11 | };
12 | }
13 | /* JavaCC - OriginalChecksum=dfbb97a40f8c7240511d1c243626087a (do not edit this line) */
14 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.mysql/src/com/vispractice/amoeba/mysql/Activator.java:
--------------------------------------------------------------------------------
1 | package com.vispractice.amoeba.mysql;
2 |
3 | import org.osgi.framework.BundleActivator;
4 | import org.osgi.framework.BundleContext;
5 |
6 | public class Activator implements BundleActivator {
7 | public static BundleContext bundleContext = null;
8 |
9 | /*
10 | * (non-Javadoc)
11 | * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
12 | */
13 | public void start(BundleContext context) throws Exception {
14 | Activator.bundleContext = context;
15 | }
16 |
17 | /*
18 | * (non-Javadoc)
19 | * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
20 | */
21 | public void stop(BundleContext context) throws Exception {
22 | Activator.bundleContext = null;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.fetcher/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: Seq
4 | Bundle-SymbolicName: com.vispractice.amoeba.seq.fetcher
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-Activator: com.vispractice.amoeba.seq.fetcher.Activator
7 | Bundle-Vendor: VISPRACTICE
8 | Bundle-RequiredExecutionEnvironment: JavaSE-1.6
9 | Import-Package: org.osgi.framework;version="1.3.0"
10 | Service-Component: OSGI-INF/SeqFetcherComp.xml
11 | Export-Package: com.meidusa.amoeba.seq.fetcher
12 | Require-Bundle: org.springframework.osgi.log4j.osgi;bundle-version="1.2.15"
13 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.fetcher/OSGI-INF/SeqFetcherComp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.fetcher/src/com/meidusa/amoeba/seq/fetcher/SeqConstants.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.seq.fetcher;
2 |
3 | public class SeqConstants {
4 | public final static String NEXTVAL = "NEXTVAL";
5 | public final static String CURRVAL = "CURRVAL";
6 | public final static String BULKVAL = "BULKVAL";
7 | }
8 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.fetcher/src/com/meidusa/amoeba/seq/fetcher/SeqOperationResult.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.seq.fetcher;
2 |
3 | public class SeqOperationResult {
4 | private boolean isSuccessed;
5 | private String errMsg;
6 |
7 | public SeqOperationResult(boolean isSuccessed, String errMsg) {
8 | this.isSuccessed = isSuccessed;
9 | this.errMsg = errMsg;
10 | }
11 |
12 | public boolean isSuccessed() {
13 | return isSuccessed;
14 | }
15 | public void setSuccessed(boolean isSuccessed) {
16 | this.isSuccessed = isSuccessed;
17 | }
18 | public String getErrMsg() {
19 | return errMsg;
20 | }
21 | public void setErrMsg(String errMsg) {
22 | this.errMsg = errMsg;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.fetcher/src/com/meidusa/amoeba/seq/fetcher/SeqProvider.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.seq.fetcher;
2 |
3 | public abstract class SeqProvider {
4 | public abstract SeqOperationResult createSeq(String schema, String seqName, long start, long offset);
5 | public abstract long getSeqCurrVal(String schema, String seqName);
6 | public abstract long getSeqNextVal(String schema, String seqName);
7 | public abstract long batchGetSeqVal(String schema, String seqName, long count);
8 | public abstract SeqOperationResult deleteSeq(String schema, String seqName);
9 |
10 | public void init() throws Exception {
11 |
12 | }
13 |
14 | public void stop() throws Exception {
15 |
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.fetcher/src/com/vispractice/amoeba/seq/fetcher/Activator.java:
--------------------------------------------------------------------------------
1 | package com.vispractice.amoeba.seq.fetcher;
2 |
3 | import org.osgi.framework.BundleActivator;
4 | import org.osgi.framework.BundleContext;
5 |
6 | public class Activator implements BundleActivator {
7 |
8 | public static BundleContext context;
9 |
10 | /*
11 | * (non-Javadoc)
12 | * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
13 | */
14 | public void start(BundleContext bundleContext) throws Exception {
15 | Activator.context = bundleContext;
16 | }
17 |
18 | /*
19 | * (non-Javadoc)
20 | * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
21 | */
22 | public void stop(BundleContext bundleContext) throws Exception {
23 | Activator.context = null;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: Generator
4 | Bundle-SymbolicName: com.vispractice.amoeba.seq.provider
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-Activator: com.vispractice.amoeba.seq.provider.Activator
7 | Bundle-Vendor: VISPRACTICE
8 | Bundle-RequiredExecutionEnvironment: JavaSE-1.6
9 | Import-Package: org.osgi.framework;version="1.3.0"
10 | Service-Component: OSGI-INF/SeqProviderComp.xml
11 | Require-Bundle: com.vispractice.amoeba.base;bundle-version="1.0.0",
12 | com.vispractice.amoeba.seq.fetcher;bundle-version="1.0.0"
13 | Export-Package: com.meidusa.amoeba.seq.provider
14 | Bundle-ClassPath: .,lib/jline-0.9.94.jar,
15 | lib/netty-3.2.2.Final.jar,
16 | lib/zookeeper-3.4.5.jar,
17 | lib/log4j-1.2.15.jar,
18 | lib/slf4j-api-1.6.1.jar,
19 | lib/slf4j-log4j12-1.6.1.jar,
20 | lib/curator-client-1.3.3.jar,
21 | lib/curator-framework-1.3.3.jar,
22 | lib/curator-recipes-1.3.3.jar,
23 | lib/guava-14.0.1.jar
24 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/OSGI-INF/SeqProviderComp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/curator-client-1.3.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/curator-client-1.3.3.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/curator-framework-1.3.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/curator-framework-1.3.3.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/curator-recipes-1.3.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/curator-recipes-1.3.3.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/guava-14.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/guava-14.0.1.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/jline-0.9.94.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/jline-0.9.94.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/log4j-1.2.15.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/log4j-1.2.15.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/netty-3.2.2.Final.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/netty-3.2.2.Final.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/slf4j-api-1.6.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/slf4j-api-1.6.1.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/slf4j-log4j12-1.6.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/slf4j-log4j12-1.6.1.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/lib/zookeeper-3.4.5.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/com.vispractice.amoeba.seq.provider/lib/zookeeper-3.4.5.jar
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/src/com/meidusa/amoeba/seq/provider/utils/Utils.java:
--------------------------------------------------------------------------------
1 | package com.meidusa.amoeba.seq.provider.utils;
2 |
3 | import java.io.FileReader;
4 | import java.io.IOException;
5 | import java.util.Properties;
6 |
7 | import com.meidusa.amoeba.context.ProxyRuntimeContext;
8 | import com.meidusa.amoeba.util.StringUtil;
9 |
10 | public class Utils {
11 |
12 | public final static String SEQ_CONFIG_FILENAME = "seq.properties";
13 |
14 | static public Properties readGlobalSeqConfigProps() throws IOException{
15 | Properties props = new Properties();
16 | String amoebaHomePath = ProxyRuntimeContext.getInstance().getAmoebaHomePath();
17 | String PATH_SEPARATOR = StringUtil.PATH_SEPARATOR;
18 | String seqConfigPath = amoebaHomePath + PATH_SEPARATOR + "conf" + PATH_SEPARATOR + SEQ_CONFIG_FILENAME;
19 | FileReader reader = new FileReader(seqConfigPath);
20 | props.load(reader);
21 | return props;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.seq.provider/src/com/vispractice/amoeba/seq/provider/Activator.java:
--------------------------------------------------------------------------------
1 | package com.vispractice.amoeba.seq.provider;
2 |
3 | import org.osgi.framework.BundleActivator;
4 | import org.osgi.framework.BundleContext;
5 |
6 | public class Activator implements BundleActivator {
7 |
8 | public static BundleContext context;
9 |
10 | /*
11 | * (non-Javadoc)
12 | * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
13 | */
14 | public void start(BundleContext bundleContext) throws Exception {
15 | Activator.context = bundleContext;
16 | }
17 |
18 | /*
19 | * (non-Javadoc)
20 | * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
21 | */
22 | public void stop(BundleContext bundleContext) throws Exception {
23 | Activator.context = null;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.startup/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Bundle-ManifestVersion: 2
3 | Bundle-Name: Startup
4 | Bundle-SymbolicName: com.vispractice.amoeba.startup
5 | Bundle-Version: 1.0.0.qualifier
6 | Bundle-Activator: com.vispractice.amoeba.startup.Activator
7 | Bundle-Vendor: VISPRACTICE
8 | Bundle-RequiredExecutionEnvironment: JavaSE-1.6
9 | Import-Package: org.osgi.framework;version="1.3.0"
10 | Require-Bundle: com.springsource.org.apache.commons.lang;bundle-version="2.4.0",
11 | com.springsource.org.apache.commons.collections;bundle-version="3.2.1",
12 | org.springframework.osgi.log4j.osgi;bundle-version="1.2.15",
13 | org.apache.servicemix.bundles.commons-pool;bundle-version="1.5.4",
14 | com.vispractice.amoeba.base;bundle-version="1.0.0",
15 | com.vispractice.amoeba.mysql;bundle-version="1.0.0"
16 |
--------------------------------------------------------------------------------
/com.vispractice.amoeba.startup/src/com/vispractice/amoeba/startup/Activator.java:
--------------------------------------------------------------------------------
1 | package com.vispractice.amoeba.startup;
2 |
3 |
4 | import org.apache.log4j.Logger;
5 | import org.osgi.framework.BundleActivator;
6 | import org.osgi.framework.BundleContext;
7 |
8 | import com.meidusa.amoeba.exception.AmoebaRuntimeException;
9 | import com.meidusa.amoeba.server.AmoebaProxyServer;
10 |
11 |
12 | public class Activator implements BundleActivator {
13 | private static Logger logger = Logger.getLogger(Activator.class);
14 |
15 | /*
16 | * (non-Javadoc)
17 | * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
18 | */
19 | public void start(final BundleContext context) throws Exception {
20 | String[] args = {"start"};
21 | try {
22 | AmoebaProxyServer.run(args, context);
23 | } catch (Exception e) {
24 | logger.error("start amoeba error", e);
25 | throw new AmoebaRuntimeException(e);
26 | }
27 | }
28 |
29 | /*
30 | * (non-Javadoc)
31 | * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
32 | */
33 | public void stop(BundleContext context) throws Exception {
34 | }
35 |
36 | }
37 |
38 |
39 |
--------------------------------------------------------------------------------
/plugins/com.alibaba.china.jdbc_proxy_1.1.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/com.alibaba.china.jdbc_proxy_1.1.0.jar
--------------------------------------------------------------------------------
/plugins/com.springsource.javassist-3.15.0.GA.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/com.springsource.javassist-3.15.0.GA.jar
--------------------------------------------------------------------------------
/plugins/com.springsource.javax.xml.stream-1.0.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/com.springsource.javax.xml.stream-1.0.1.jar
--------------------------------------------------------------------------------
/plugins/com.springsource.org.apache.commons.collections-3.2.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/com.springsource.org.apache.commons.collections-3.2.1.jar
--------------------------------------------------------------------------------
/plugins/com.springsource.org.apache.commons.lang-2.4.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/com.springsource.org.apache.commons.lang-2.4.0.jar
--------------------------------------------------------------------------------
/plugins/com.springsource.org.dom4j-1.6.1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/com.springsource.org.dom4j-1.6.1.jar
--------------------------------------------------------------------------------
/plugins/com.springsource.org.ognl-2.7.3.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/com.springsource.org.ognl-2.7.3.jar
--------------------------------------------------------------------------------
/plugins/com.springsource.slf4j.api-1.5.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/com.springsource.slf4j.api-1.5.6.jar
--------------------------------------------------------------------------------
/plugins/com.springsource.slf4j.log4j-1.5.6.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/com.springsource.slf4j.log4j-1.5.6.jar
--------------------------------------------------------------------------------
/plugins/log4j.osgi-1.2.15-SNAPSHOT.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/log4j.osgi-1.2.15-SNAPSHOT.jar
--------------------------------------------------------------------------------
/plugins/org.apache.servicemix.bundles.asm-3.3_2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/org.apache.servicemix.bundles.asm-3.3_2.jar
--------------------------------------------------------------------------------
/plugins/org.apache.servicemix.bundles.commons-pool-1.5.4_1.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/org.apache.servicemix.bundles.commons-pool-1.5.4_1.jar
--------------------------------------------------------------------------------
/plugins/org.eclipse.equinox.ds_1.1.1.R35x_v20090806.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/org.eclipse.equinox.ds_1.1.1.R35x_v20090806.jar
--------------------------------------------------------------------------------
/plugins/org.eclipse.equinox.event_1.2.100.v20110502.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/org.eclipse.equinox.event_1.2.100.v20110502.jar
--------------------------------------------------------------------------------
/plugins/org.eclipse.equinox.util_1.0.100.v20090520-1800.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/org.eclipse.equinox.util_1.0.100.v20090520-1800.jar
--------------------------------------------------------------------------------
/plugins/org.eclipse.osgi.services_3.3.0.v20110513.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/org.eclipse.osgi.services_3.3.0.v20110513.jar
--------------------------------------------------------------------------------
/plugins/org.eclipse.osgi.util_3.2.200.v20110110.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/org.eclipse.osgi.util_3.2.200.v20110110.jar
--------------------------------------------------------------------------------
/plugins/org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/plugins/org.eclipse.osgi_3.7.1.R37x_v20110808-1106.jar
--------------------------------------------------------------------------------
/release/amoeba-plus-mysql-1.0-RC1.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/release/amoeba-plus-mysql-1.0-RC1.tar.gz
--------------------------------------------------------------------------------
/release/amoeba-plus-mysql-1.0-RC1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vispractice/Amoeba-Plus-For-MySQL/3579ddd5a569b2ac84a489709c0df1857979346b/release/amoeba-plus-mysql-1.0-RC1.zip
--------------------------------------------------------------------------------