Пример #1
0
  public static XLogPack getTranxData(File xlogDir, StyledText header, int serverId) {
    String xlogPath = xlogDir.getAbsolutePath() + "/" + xLogFileName;
    File xlogFile = new File(xlogPath);
    if (!xlogFile.canRead()) {
      return null;
    }
    byte[] xlogb = new byte[(int) xlogFile.length()];

    try {
      FileInputStream xlogInputStream = new FileInputStream(xlogFile);
      xlogInputStream.read(xlogb);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    DataInputX inX = new DataInputX(xlogb);
    XLogPack p = null;
    try {
      p = (XLogPack) inX.readPack();
    } catch (IOException e) {
      e.printStackTrace();
    }

    String date = DateUtil.yyyymmdd(p.endTime);

    if (p != null) {
      ProfileTextFull.buildXLogData(date, header, p, serverId);
    }
    return p;
  }
Пример #2
0
 public Step read(DataInputX in) throws IOException {
   this.hash = (int) in.readDecimal();
   this.count = (int) in.readDecimal();
   this.elapsed = in.readDecimal();
   this.cputime = in.readDecimal();
   return this;
 }
Пример #3
0
 @ServiceHandler(RequestCmd.REMOTE_CONTROL)
 public void remoteControl(DataInputX din, DataOutputX dout, boolean login) throws IOException {
   MapPack param = (MapPack) din.readPack();
   long session = param.getLong("toSession");
   RemoteControl control =
       new RemoteControl( //
           param.getText("command"), //
           System.currentTimeMillis(), //
           param,
           param.getLong("fromSession"));
   boolean result = RemoteControlManager.add(session, control);
   Logger.println(
       "["
           + RequestCmd.REMOTE_CONTROL
           + "]"
           + control.commnad()
           + " from "
           + LoginManager.getUser(control.commander()).ip()
           + " to "
           + LoginManager.getUser(session).ip()
           + " "
           + result);
   MapPack m = new MapPack();
   if (result) {
     m.put("success", new BooleanValue(true));
     dout.writeByte(TcpFlag.HasNEXT);
     dout.writePack(m);
   } else {
     m.put("success", new BooleanValue(false));
     dout.writeByte(TcpFlag.HasNEXT);
     dout.writePack(m);
   }
 }
Пример #4
0
  public synchronized void put(long time, long value) throws IOException {
    byte[] buffer = DataOutputX.toBytes5(value);
    int pos = _offset(time);

    // increase count if new one
    if (DataInputX.toLong5(this.memBuffer, pos) == 0) {
      addCount(1);
    }

    System.arraycopy(buffer, 0, this.memBuffer, pos, _keyLength);
    this.dirty = true;
  }
Пример #5
0
 public Pack read(DataInputX din) throws IOException {
   // this.key = din.readLong();
   this.time = din.readLong();
   this.level = din.readByte();
   this.objType = din.readText();
   this.objHash = din.readInt();
   this.title = din.readText();
   this.message = din.readText();
   this.tags = (MapValue) din.readValue();
   return this;
 }
Пример #6
0
 @ServiceHandler(RequestCmd.CHECK_JOB)
 public void checkJob(DataInputX din, DataOutputX dout, boolean login) throws IOException {
   MapPack param = (MapPack) din.readPack();
   long session = param.getLong("session");
   RemoteControl control = RemoteControlManager.getCommand(session);
   if (control != null) {
     TextPack t = new TextPack();
     t.text = control.commnad();
     dout.writeByte(TcpFlag.HasNEXT);
     dout.writePack(t);
     dout.writeByte(TcpFlag.HasNEXT);
     dout.writePack(control.param());
   }
 }
Пример #7
0
  private void open(String path) throws FileNotFoundException, IOException {
    this.path = path;
    this.file = new File(this.path + ".hfile");
    boolean isNew = this.file.exists() == false || this.file.length() < _memHeadReserved;

    if (isNew) {
      this.memBuffer = new byte[_memHeadReserved + memBufferSize];
      this.memBuffer[0] = (byte) 0xCA;
      this.memBuffer[1] = (byte) 0xFE;
    } else {
      this.memBufferSize = (int) (this.file.length() - _memHeadReserved);
      this.memBuffer = FileUtil.readAll(this.file);
      this.count = DataInputX.toInt(this.memBuffer, _countPos);
    }

    FlushCtr.getInstance().regist(this);
  }
Пример #8
0
 @ServiceHandler(RequestCmd.SERVER_DB_DELETE)
 public void deleteDbFiles(DataInputX din, DataOutputX dout, boolean login) throws IOException {
   String rootPath = DBCtr.getRootPath();
   MapPack param = (MapPack) din.readPack();
   ListValue fileLv = param.getList("file");
   MapPack m = new MapPack();
   if (fileLv != null) {
     for (int i = 0; i < fileLv.size(); i++) {
       String filename = fileLv.getString(i);
       File file = new File(rootPath + filename);
       deleteFiles(file);
     }
     m.put("size", fileLv.size());
   }
   dout.writeByte(TcpFlag.HasNEXT);
   dout.writePack(m);
   dout.flush();
 }
Пример #9
0
 @ServiceHandler(RequestCmd.REMOTE_CONTROL_ALL)
 public void remoteControlAll(DataInputX din, DataOutputX dout, boolean login) throws IOException {
   MapPack param = (MapPack) din.readPack();
   RemoteControl control =
       new RemoteControl( //
           param.getText("command"), //
           System.currentTimeMillis(), //
           param,
           param.getLong("fromSession"));
   LoginUser[] users = LoginManager.getLoginUserList();
   for (int i = 0, len = (users != null ? users.length : 0); i < len; i++) {
     long session = users[i].session();
     RemoteControlManager.add(session, control);
   }
   Logger.println(
       "["
           + RequestCmd.REMOTE_CONTROL_ALL
           + "]"
           + control.commnad()
           + " from "
           + LoginManager.getUser(control.commander()).ip());
 }
Пример #10
0
  public Step read(DataInputX in) throws IOException {
    super.read(in);

    this.txid = in.readDecimal();
    this.hash = (int) in.readDecimal();
    this.elapsed = (int) in.readDecimal();
    this.cputime = (int) in.readDecimal();
    this.error = (int) in.readDecimal();
    this.opt = in.readByte();
    switch (opt) {
      case 1:
        this.address = in.readText();
        break;
      default:
    }
    return this;
  }
Пример #11
0
 public synchronized long get(long time) throws IOException {
   int pos = _offset(time);
   return DataInputX.toLong5(this.memBuffer, pos);
 }