-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #690 from zhuam/1.5
增加 SQL 条件的分析,用于 列值/访问次数 的实时统计
- Loading branch information
Showing
13 changed files
with
2,965 additions
and
2,512 deletions.
There are no files selected for viewing
146 changes: 77 additions & 69 deletions
146
src/main/java/org/opencloudb/handler/ReloadHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,78 @@ | ||
/* | ||
* Copyright (c) 2013, OpenCloudDB/MyCAT and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software;Designed and Developed mainly by many Chinese | ||
* opensource volunteers. you can redistribute it and/or modify it under the | ||
* terms of the GNU General Public License version 2 only, as published by the | ||
* Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Any questions about this component can be directed to it's project Web address | ||
* https://code.google.com/p/opencloudb/. | ||
* | ||
*/ | ||
package org.opencloudb.handler; | ||
|
||
import org.opencloudb.config.ErrorCode; | ||
import org.opencloudb.manager.ManagerConnection; | ||
import org.opencloudb.parser.ManagerParseReload; | ||
import org.opencloudb.parser.util.ParseUtil; | ||
import org.opencloudb.response.ReloadConfig; | ||
import org.opencloudb.response.ReloadSqlSlowTime; | ||
import org.opencloudb.response.ReloadUser; | ||
import org.opencloudb.response.ReloadUserStat; | ||
|
||
/** | ||
* @author mycat | ||
*/ | ||
public final class ReloadHandler | ||
{ | ||
|
||
public static void handle(String stmt, ManagerConnection c, int offset) | ||
{ | ||
int rs = ManagerParseReload.parse(stmt, offset); | ||
switch (rs) | ||
{ | ||
case ManagerParseReload.CONFIG: | ||
ReloadConfig.execute(c,false); | ||
break; | ||
case ManagerParseReload.CONFIG_ALL: | ||
ReloadConfig.execute(c,true); | ||
break; | ||
case ManagerParseReload.ROUTE: | ||
c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement"); | ||
break; | ||
case ManagerParseReload.USER: | ||
ReloadUser.execute(c); | ||
break; | ||
case ManagerParseReload.USER_STAT: | ||
ReloadUserStat.execute(c); | ||
break; | ||
case ManagerParseReload.SQL_SLOW: | ||
ReloadSqlSlowTime.execute(c,ParseUtil.getSQLId(stmt)); | ||
break; | ||
|
||
default: | ||
c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement"); | ||
} | ||
} | ||
|
||
/* | ||
* Copyright (c) 2013, OpenCloudDB/MyCAT and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software;Designed and Developed mainly by many Chinese | ||
* opensource volunteers. you can redistribute it and/or modify it under the | ||
* terms of the GNU General Public License version 2 only, as published by the | ||
* Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Any questions about this component can be directed to it's project Web address | ||
* https://code.google.com/p/opencloudb/. | ||
* | ||
*/ | ||
package org.opencloudb.handler; | ||
|
||
import org.opencloudb.config.ErrorCode; | ||
import org.opencloudb.manager.ManagerConnection; | ||
import org.opencloudb.parser.ManagerParseReload; | ||
import org.opencloudb.parser.util.ParseUtil; | ||
import org.opencloudb.response.ReloadConfig; | ||
import org.opencloudb.response.ReloadQueryCf; | ||
import org.opencloudb.response.ReloadSqlSlowTime; | ||
import org.opencloudb.response.ReloadUser; | ||
import org.opencloudb.response.ReloadUserStat; | ||
|
||
/** | ||
* @author mycat | ||
*/ | ||
public final class ReloadHandler | ||
{ | ||
|
||
public static void handle(String stmt, ManagerConnection c, int offset) | ||
{ | ||
int rs = ManagerParseReload.parse(stmt, offset); | ||
switch (rs) | ||
{ | ||
case ManagerParseReload.CONFIG: | ||
ReloadConfig.execute(c,false); | ||
break; | ||
case ManagerParseReload.CONFIG_ALL: | ||
ReloadConfig.execute(c,true); | ||
break; | ||
case ManagerParseReload.ROUTE: | ||
c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement"); | ||
break; | ||
case ManagerParseReload.USER: | ||
ReloadUser.execute(c); | ||
break; | ||
case ManagerParseReload.USER_STAT: | ||
ReloadUserStat.execute(c); | ||
break; | ||
case ManagerParseReload.SQL_SLOW: | ||
ReloadSqlSlowTime.execute(c,ParseUtil.getSQLId(stmt)); | ||
break; | ||
case ManagerParseReload.QUERY_CF: | ||
String dhAfter = "NULL"; | ||
int dhOffset = stmt.indexOf('='); | ||
if (dhOffset != -1 && stmt.length() > ++dhOffset) { | ||
dhAfter = stmt.substring(dhOffset).trim(); | ||
} | ||
ReloadQueryCf.execute(c, dhAfter); | ||
break; | ||
default: | ||
c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement"); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.