Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加 SQL 条件的分析,用于 列值/访问次数 的实时统计 #690

Merged
merged 3 commits into from
Dec 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 77 additions & 69 deletions src/main/java/org/opencloudb/handler/ReloadHandler.java
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");
}
}

}
Loading