Exemple #1
0
 private Snapshot decodeSnapshot() {
   long execCount = jsonReader.readDecimal(FIELD.count.name()).getUnscaled();
   long firstTime = jsonReader.readDecimal(FIELD.first.name()).getUnscaled();
   long lastTime = jsonReader.readDecimal(FIELD.last.name()).getUnscaled();
   jsonReader.findField(FIELD.exec.name());
   TimeHolder[] timeHolders = decodeTimeHolders();
   return new SnapshotImpl(firstTime, lastTime, execCount, timeHolders);
 }
Exemple #2
0
 private StatDto decodeStatistics(int ind) {
   JsonHelper.Decimal decimal = jsonReader.readDecimal(FIELD.id.name());
   int id = decimal == null ? ind : (int) decimal.getUnscaled();
   int len = jsonReader.stringLength(FIELD.name.name());
   String name = charBuffer.subSequence(0, len).toString();
   Boolean b = jsonReader.readBoolean(FIELD.hist.name());
   boolean histogram = b != null && b;
   return new StatDto(id, name, histogram);
 }
Exemple #3
0
 private ServiceBox<String> createStringBox(ServiceBox.Type type) {
   List<String> list = new ArrayList<String>();
   while (jsonReader.next()) {
     int len = jsonReader.stringLength();
     list.add(charBuffer.subSequence(0, len).toString());
     charBuffer.position(charBuffer.position() + len);
   }
   return new ServiceBox<String>(type, list);
 }
Exemple #4
0
 private int[] decodeHistogram() {
   jsonReader.findField(FIELD.hist.name());
   ArrayList<Integer> list = new ArrayList<Integer>();
   while (jsonReader.next()) {
     list.add((int) jsonReader.readDecimal().getUnscaled());
   }
   int[] hist = new int[list.size()];
   for (int i = 0; i < list.size(); i++) {
     hist[i] = list.get(i);
   }
   return hist;
 }
Exemple #5
0
 private TimeHolder[] decodeTimeHolders() {
   ArrayList<TimeHolder> list = new ArrayList<TimeHolder>();
   while (jsonReader.next()) {
     long min = jsonReader.readDecimal(FIELD.min.name()).getUnscaled();
     long max = jsonReader.readDecimal(FIELD.max.name()).getUnscaled();
     long accum = jsonReader.readDecimal(FIELD.accum.name()).getUnscaled();
     int[] hist = decodeHistogram();
     TimeHolder holder = new TimeHolder(min, max, accum, hist);
     list.add(holder);
   }
   TimeHolder[] holders = list.toArray(new TimeHolder[] {});
   return holders;
 }
Exemple #6
0
 private ServiceBox<StatDto> createStatBox(ServiceBox.Type type) {
   List<StatDto> sts = new ArrayList<StatDto>();
   for (int i = 0; jsonReader.next(); i++) {
     StatDto s = decodeStatistics(i);
     sts.add(s);
   }
   return new ServiceBox<StatDto>(type, sts);
 }
Exemple #7
0
 private ServiceBox<Snapshot> createSnapshotBox(ServiceBox.Type type) {
   List<Snapshot> snapshots = new ArrayList<Snapshot>();
   while (jsonReader.next()) {
     Snapshot sn = decodeSnapshot();
     snapshots.add(sn);
   }
   return new ServiceBox<Snapshot>(type, snapshots);
 }
Exemple #8
0
  public ServiceBox decodeBox(String s) {
    ServiceBox box = null;
    charBuffer.clear();
    charBuffer.put(s);
    charBuffer.flip();
    // String typeString = s.replaceAll("\\\":.*$", "").replaceAll("^.*\\\"", "");
    int typeLength = jsonReader.stringLength(FIELD.type.name());
    if (typeLength < 1) {
      log.err("Data type undefined " + s);
      return null;
    }
    String typeString = charBuffer.subSequence(0, typeLength).toString();

    TYPE type = TYPE.valueOf(typeString);
    int statusCode = 0;
    if (type == TYPE.status) {
      statusCode = (int) jsonReader.readDecimal(FIELD.data.name()).getUnscaled();
    } else {
      jsonReader.findField(FIELD.data.name());
    }
    ServiceBox.Type boxType;
    switch (type) {
      case pList:
      case mList:
      case rList:
        box = createStatBox(ServiceBox.Type.REG);
        break;
      case descData:
        box = createStringBox(ServiceBox.Type.DESC);
        break;
      case status:
        box = createStringBox(statusCode);
        break;
      case statData:
        box = createSnapshotBox(ServiceBox.Type.STAT);
        break;
      case cfgData:
        box = createStringBox(ServiceBox.Type.CFG);
        break;
    }
    return box;
  }