Ejemplo n.º 1
0
 public CommonStats getTotal() {
   if (total != null) {
     return total;
   }
   CommonStats stats = new CommonStats();
   for (ShardStats shard : shards) {
     stats.add(shard.getStats());
   }
   total = stats;
   return stats;
 }
Ejemplo n.º 2
0
 public CommonStats getPrimary() {
   if (primary != null) {
     return primary;
   }
   CommonStats stats = new CommonStats();
   for (ShardStats shard : shards) {
     if (shard.getShardRouting().primary()) {
       stats.add(shard.getStats());
     }
   }
   primary = stats;
   return stats;
 }
  @Test
  public void testDontRotate() throws Exception {
    final CommonStats commonStats = new CommonStats();
    commonStats.store = new StoreStats(1000, 0);
    final IndexStatistics stats =
        IndexStatistics.create(
            "name", commonStats, commonStats, Collections.<ShardRouting>emptyList());

    when(indices.getIndexStats("name")).thenReturn(stats);
    when(deflector.getNewestTargetName()).thenReturn("name");
    when(clusterConfigService.get(SizeBasedRotationStrategyConfig.class))
        .thenReturn(SizeBasedRotationStrategyConfig.create(100000L));

    final SizeBasedRotationStrategy strategy =
        new SizeBasedRotationStrategy(
            indices, deflector, clusterConfigService, nodeId, auditEventSender);

    strategy.rotate();
    verify(deflector, never()).cycle();
    reset(deflector);
  }
Ejemplo n.º 4
0
 public void add(CommonStats stats) {
   if (docs == null) {
     if (stats.docs() != null) {
       docs = new DocsStats();
       docs.add(stats.docs());
     }
   } else {
     docs.add(stats.docs());
   }
   if (store == null) {
     if (stats.store() != null) {
       store = new StoreStats();
       store.add(stats.store());
     }
   } else {
     store.add(stats.store());
   }
   if (indexing == null) {
     if (stats.indexing() != null) {
       indexing = new IndexingStats();
       indexing.add(stats.indexing());
     }
   } else {
     indexing.add(stats.indexing());
   }
   if (get == null) {
     if (stats.get() != null) {
       get = new GetStats();
       get.add(stats.get());
     }
   } else {
     get.add(stats.get());
   }
   if (search == null) {
     if (stats.search() != null) {
       search = new SearchStats();
       search.add(stats.search());
     }
   } else {
     search.add(stats.search());
   }
   if (merge == null) {
     if (stats.merge() != null) {
       merge = new MergeStats();
       merge.add(stats.merge());
     }
   } else {
     merge.add(stats.merge());
   }
   if (refresh == null) {
     if (stats.refresh() != null) {
       refresh = new RefreshStats();
       refresh.add(stats.refresh());
     }
   } else {
     refresh.add(stats.refresh());
   }
   if (flush == null) {
     if (stats.flush() != null) {
       flush = new FlushStats();
       flush.add(stats.flush());
     }
   } else {
     flush.add(stats.flush());
   }
   if (warmer == null) {
     if (stats.warmer() != null) {
       warmer = new WarmerStats();
       warmer.add(stats.warmer());
     }
   } else {
     warmer.add(stats.warmer());
   }
 }
Ejemplo n.º 5
0
 public static CommonStats readCommonStats(StreamInput in) throws IOException {
   CommonStats stats = new CommonStats();
   stats.readFrom(in);
   return stats;
 }
Ejemplo n.º 6
0
 private static boolean isSet(Flag flag, CommonStats response) {
   switch (flag) {
     case Docs:
       return response.getDocs() != null;
     case FieldData:
       return response.getFieldData() != null;
     case FilterCache:
       return response.getFilterCache() != null;
     case Flush:
       return response.getFlush() != null;
     case Get:
       return response.getGet() != null;
     case IdCache:
       return response.getIdCache() != null;
     case Indexing:
       return response.getIndexing() != null;
     case Merge:
       return response.getMerge() != null;
     case Refresh:
       return response.getRefresh() != null;
     case Search:
       return response.getSearch() != null;
     case Store:
       return response.getStore() != null;
     case Warmer:
       return response.getWarmer() != null;
     case Percolate:
       return response.getPercolate() != null;
     case Completion:
       return response.getCompletion() != null;
     default:
       assert false : "new flag? " + flag;
       return false;
   }
 }