Package com.dianping.cat.report.page.model.matrix

Source Code of com.dianping.cat.report.page.model.matrix.CompositeMatrixService

package com.dianping.cat.report.page.model.matrix;

import java.util.List;

import com.dianping.cat.consumer.matrix.MatrixAnalyzer;
import com.dianping.cat.consumer.matrix.MatrixReportMerger;
import com.dianping.cat.consumer.matrix.model.entity.MatrixReport;
import com.dianping.cat.report.page.model.spi.internal.BaseCompositeModelService;
import com.dianping.cat.report.page.model.spi.internal.BaseRemoteModelService;
import com.dianping.cat.service.ModelRequest;
import com.dianping.cat.service.ModelResponse;

public class CompositeMatrixService extends BaseCompositeModelService<MatrixReport> {
  public CompositeMatrixService() {
    super(MatrixAnalyzer.ID);
  }

  @Override
  protected BaseRemoteModelService<MatrixReport> createRemoteService() {
    return new RemoteMatrixService();
  }

  @Override
  protected MatrixReport merge(ModelRequest request, List<ModelResponse<MatrixReport>> responses) {
    if (responses.size() == 0) {
      return null;
    }
    MatrixReportMerger merger = new MatrixReportMerger(new MatrixReport(request.getDomain()));
    for (ModelResponse<MatrixReport> response : responses) {
      MatrixReport model = response.getModel();
      if (model != null) {
        model.accept(merger);
      }
    }

    return merger.getMatrixReport();
  }
}
TOP

Related Classes of com.dianping.cat.report.page.model.matrix.CompositeMatrixService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.