本文整理汇总了Java中com.alibaba.cobar.manager.parser.ManagerParseStop类的典型用法代码示例。如果您正苦于以下问题:Java ManagerParseStop类的具体用法?Java ManagerParseStop怎么用?Java ManagerParseStop使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ManagerParseStop类属于com.alibaba.cobar.manager.parser包,在下文中一共展示了ManagerParseStop类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.alibaba.cobar.manager.parser.ManagerParseStop; //导入依赖的package包/类
public static void execute(String stmt, ManagerConnection c) {
int count = 0;
Pair<String[], Integer> keys = ManagerParseStop.getPair(stmt);
if (keys.getKey() != null && keys.getValue() != null) {
long time = keys.getValue().intValue() * 1000L;
Map<String, MySQLDataNode> dns = CobarServer.getInstance().getConfig().getDataNodes();
for (String key : keys.getKey()) {
MySQLDataNode dn = dns.get(key);
if (dn != null) {
dn.setHeartbeatRecoveryTime(TimeUtil.currentTimeMillis() + time);
++count;
StringBuilder s = new StringBuilder();
s.append(dn.getName()).append(" stop heartbeat '");
logger.warn(s.append(FormatUtil.formatTime(time, 3)).append("' by manager."));
}
}
}
OkPacket packet = new OkPacket();
packet.packetId = 1;
packet.affectedRows = count;
packet.serverStatus = 2;
packet.write(c);
}
示例2: handle
import com.alibaba.cobar.manager.parser.ManagerParseStop; //导入依赖的package包/类
public static void handle(String stmt, ManagerConnection c, int offset) {
switch (ManagerParseStop.parse(stmt, offset)) {
case ManagerParseStop.HEARTBEAT:
StopHeartbeat.execute(stmt, c);
break;
default:
c.writeErrMessage(ErrorCode.ER_YES, "Unsupported statement");
}
}
示例3: testStopHeartBeat
import com.alibaba.cobar.manager.parser.ManagerParseStop; //导入依赖的package包/类
@Test
public void testStopHeartBeat() {
Assert.assertEquals(ManagerParseStop.HEARTBEAT, ManagerParseStop.parse("stop @@heartbeat ds:1000", 4));
Assert.assertEquals(ManagerParseStop.HEARTBEAT, ManagerParseStop.parse(" STOP @@HEARTBEAT ds:1000", 5));
Assert.assertEquals(ManagerParseStop.HEARTBEAT, ManagerParseStop.parse(" STOP @@heartbeat ds:1000", 5));
}