Skip to content

Commit

Permalink
Merge pull request #1 from MyCATApache/1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfeng40 committed Dec 28, 2015
2 parents 80e56c5 + 25de78e commit 7e742ea
Show file tree
Hide file tree
Showing 13 changed files with 2,965 additions and 2,512 deletions.
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

0 comments on commit 7e742ea

Please sign in to comment.