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

How to use
StatDetails
in
com.github.endoscope.storage

Best Java code snippets using com.github.endoscope.storage.StatDetails (Showing top 12 results out of 315)

origin: com.github.endoscope/endoscope-storage-jdbc

protected StatDetails createDetails(String detailsId, List<GroupEntity> groups, List<StatEntity> stats) {
  StatDetails result = new StatDetails(detailsId, null);
  result.setInfo(storageInfo(null));
  groups.forEach( group -> {
    List<StatEntity> groupStats = stats.stream()
        .filter( s -> group.getId().equals(s.getGroupId()) )
        .collect(toList());
    restoreGroupStats(group, groupStats);
    Stat details = group.getMap().get(detailsId);
    result.add(details);
  });
  if( result.getMerged() == null ){
    result.setMerged(Stat.emptyStat());
  }
  return result;
}
origin: com.github.endoscope/endoscope-storage-gzip

@Override
public StatDetails loadDetails(String detailsId, List<String> statsIds){
  StatDetails result = new StatDetails(detailsId, null);
  processStats(statsIds, stats -> {
    Stat stat = getDetailsOrEmpty(detailsId, stats);
    result.add(stat);
  });
  return result;
}
origin: com.github.endoscope/endoscope-core

@Transient
public void add(Stat details){
  if( details == null ){
    return;
  }
  if( getMerged() == null ){
    setMerged(details.deepCopy(true));
  } else {
    getMerged().merge(details, true);
  }
}
origin: com.github.endoscope/core

  @Transient
  public void add(Stat details, Date startDate, Date endDate){
    if( details == null ){
      return;
    }
    if( getMerged() == null ){
      setMerged(details.deepCopy(true));
    } else {
      getMerged().merge(details, true);
    }
    getHistogram().add( new StatHistory(details, startDate, endDate) );
  }
}
origin: com.github.endoscope/endoscope-ui-plugin

private StatDetails detailsForRange(String id, TimeRange range) {
  StatDetails result;
  if( canSearch(range) ){
    result = getStorage().loadDetails(id, range.getFromDate(), range.getToDate(), range.getInstance(), range.getType());
    if( inMemoryInRange(range) ){
      StatDetails current = detailsInMemory(id);
      if( current != null ){
        //we don't want to merge not set stats as it would reset min value to 0
        result.getMerged().merge(current.getMerged(), true);
      }
      result.setInfo("Added in-memory data. Original info: " + result.getInfo());
    }
  } else {
    result = detailsInMemory(id);
    result.setInfo("in-memory data only. Original info: " + result.getInfo());
  }
  return (result != null) ? result : new StatDetails(id, Stat.emptyStat());
}
origin: com.github.endoscope/endoscope-storage-test

@Test
public void should_load_details_by_stats_ids() throws IOException{
  //given
  Stats stats1 = stats(
      dt(year+"-01-01 08:00:00"),
      dt(year+"-01-01 08:15:00"),
      stat(100, 200)//hits = 2, avg = 150
  );
  Stats stats2 = stats(
      dt(year+"-01-01 08:15:00"),
      dt(year+"-01-01 08:30:00"),
      stat(1000)//hits = 1, avg = 1000
  );
  String id1 = storage.save(stats1, null, null);
  String id2 = storage.save(stats2, null, null);
  //when
  StatDetails details = storage.loadDetails(STAT_NAME, asList(id1, id2));
  //then
  Stat expected = stats1.getMap().get(STAT_NAME).deepCopy();
  expected.merge(stats2.getMap().get(STAT_NAME));
  assertEquals(STAT_NAME, details.getId() );
  assertEquals( expected, details.getMerged());
}
origin: com.github.endoscope/endoscope-storage-test

@Test
public void should_load_details_with_children() throws IOException{
  //given
  Stat rootStat = stat(100);
  Stat stat1 = stat(10);
  rootStat.ensureChildrenMap();
  rootStat.getChildren().put("1", stat1);
  Stat stat2 = stat(1);
  stat1.ensureChildrenMap();
  stat1.getChildren().put("11", stat2);
  Stats stats = stats(dt(year+"-01-01 08:05:00"), dt(year+"-01-01 08:15:00"), rootStat);
  storage.save(stats, "i1", "t1");
  //when
  StatDetails details = storage.loadDetails(STAT_NAME, dt(year+"-01-01 08:00:00"), dt(year+"-01-01 08:30:00"), null, null);
  //then
  assertEquals( 100L, details.getMerged().getAvg());
  assertEquals( 10L, details.getMerged().getChild("1").getAvg());
  assertEquals( 1L, details.getMerged().getChild("1").getChild("11").getAvg());
}
origin: com.github.endoscope/endoscope-ui-plugin

private StatDetails detailsInMemory(String id) {
  return Endoscope.processStats(stats -> {
    Stat s = stats.getMap().get(id);
    if( s == null ){//might happen when stats get saved and/or reset in the mean time
      return null;
    }
    s = s.deepCopy();
    StatDetails result = new StatDetails(id, s);
    return result;
  });
}
origin: com.github.endoscope/endoscope-storage-test

@Test
public void should_load_details_by_date_range() throws IOException{
  //given
  Stats stats1 = stats(
      dt(year+"-01-01 08:00:00"),
      dt(year+"-01-01 08:15:00"),
      stat(100, 200)//hits = 2, avg = 150
  );
  Stats stats2 = stats(
      dt(year+"-01-01 08:15:00"),
      dt(year+"-01-01 08:30:00"),
      stat(1000) //hits =1 avg = 1000
  );
  Stats stats3 = stats(
      dt(year+"-01-01 08:30:00"),
      dt(year+"-01-01 08:45:00"),
      stat(1000, 1000, 1000)// hits = 3, avg = 1000
  );
  storage.save(stats1, null, null);
  storage.save(stats2, null, null);
  storage.save(stats3, null, null);
  //when
  StatDetails details = storage.loadDetails(STAT_NAME, dt(year+"-01-01 08:20:00"), dt(year+"-01-01 08:25:00"), null, null);
  //then
  assertEquals(STAT_NAME, details.getId() );
  assertEquals( 1, details.getMerged().getHits());
}
origin: com.github.endoscope/endoscope-storage-test

@Test
public void should_load_details_by_instance_and_type() throws IOException{
  //given
  Stats stats1 = stats(dt(year+"-01-01 08:05:00"), dt(year+"-01-01 08:15:00"), stat(2));
  Stats stats10 = stats(dt(year+"-01-01 08:05:00"), dt(year+"-01-01 08:15:00"), stat(10));
  Stats stats100 = stats(dt(year+"-01-01 08:05:00"), dt(year+"-01-01 08:15:00"), stat(100));
  //save the same but with different instance and type
  storage.save(stats1, "i1", null);
  storage.save(stats10, "i1", "t1");
  storage.save(stats100, "i2", "t1");
  //when
  StatDetails detailsI  = storage.loadDetails(STAT_NAME, dt(year+"-01-01 08:00:00"), dt(year+"-01-01 08:30:00"), "i1", null);
  StatDetails detailsT  = storage.loadDetails(STAT_NAME, dt(year+"-01-01 08:00:00"), dt(year+"-01-01 08:30:00"), null, "t1");
  StatDetails detailsIT = storage.loadDetails(STAT_NAME, dt(year+"-01-01 08:00:00"), dt(year+"-01-01 08:30:00"), "i1", "t1");
  //then
  assertEquals( 6, detailsI.getMerged().getAvg());
  assertEquals( 55, detailsT.getMerged().getAvg());
  assertEquals( 10, detailsIT.getMerged().getAvg());
}
origin: com.github.endoscope/storage-jdbc

@Override
public StatDetails stat(String rootName, Date from, Date to, String appGroup, String appType) {
  StatDetails result = new StatDetails(rootName, null);
  List<GroupEntity> groups = findGroupsInRange(from, to, appGroup, appType);
  loadTree(groups, rootName, from, to, appGroup, appType);
  groups.forEach(g -> {
    Stat details = g.getMap().get(rootName);
    result.add(details, g.getStartDate(),g.getEndDate());
  });
  if( result.getMerged() == null ){
    result.setMerged(Stat.emptyStat());
  }
  return result;
}
origin: com.github.endoscope/storage-gzip

@Override
public StatDetails stat(String id, Date from, Date to, String appGroup, String appType) {
  log.debug("Searching for stat {} from {} to {}", id, getDateFormat().format(from), getDateFormat().format(to));
  StatDetails result = new StatDetails(id, null);
  listParts().stream()
      .peek( fileInfo -> log.debug("Checking {}", fileInfo.getName()))
      .filter(fileInfo -> fileInfo.inRange(from, to))
      .peek( fileInfo -> log.debug("Matches: {}", fileInfo.getName()))
      .forEach( fileInfo -> {
        Stats stats = load(fileInfo.getName());
        Stat details = stats.getMap().get(id);
        result.add(details, stats.getStartDate(), stats.getEndDate());
      });
  if( result.getMerged() == null ){
    result.setMerged(Stat.emptyStat());
  }
  return result;
}
com.github.endoscope.storageStatDetails

Most used methods

  • getMerged
  • <init>
  • setMerged
  • add
  • setInfo
    Implementation specific information.
  • getHistogram
  • getId
  • getInfo
    Implementation specific information.

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • getExternalFilesDir (Context)
  • getSystemService (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • Best IntelliJ plugins
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