Tabnine Logo
ManagerParseStop
Code IndexAdd Tabnine to your IDE (free)

How to use
ManagerParseStop
in
com.actiontech.dble.route.parser

Best Java code snippets using com.actiontech.dble.route.parser.ManagerParseStop (Showing top 4 results out of 315)

origin: actiontech/dble

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");
  }
}
origin: actiontech/dble

public static int parse(String stmt, int offset) {
  int i = offset;
  for (; i < stmt.length(); i++) {
    switch (stmt.charAt(i)) {
      case ' ':
        continue;
      case '/':
      case '#':
        i = ParseUtil.comment(stmt, i);
        continue;
      case '@':
        return stop2Check(stmt, i);
      default:
        return OTHER;
    }
  }
  return OTHER;
}
origin: actiontech/dble

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() * 1000L;
    Map<String, PhysicalDBPool> dns = DbleServer.getInstance().getConfig().getDataHosts();
    for (String key : keys.getKey()) {
      PhysicalDBPool dn = dns.get(key);
      if (dn != null) {
        dn.getSource().setHeartbeatRecoveryTime(TimeUtil.currentTimeMillis() + time);
        ++count;
        StringBuilder s = new StringBuilder();
        s.append(dn.getHostName()).append(" stop heartbeat '");
        LOGGER.info(s.append(FormatUtil.formatTime(time, 3)).append("' by manager.").toString());
      }
    }
  }
  OkPacket packet = new OkPacket();
  packet.setPacketId(1);
  packet.setAffectedRows(count);
  packet.setServerStatus(2);
  packet.write(c);
}
origin: actiontech/dble

@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));
}
com.actiontech.dble.route.parserManagerParseStop

Most used methods

  • parse
  • getPair
  • stop2Check

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • JComboBox (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now