Search in sources :

Example 6 with StoreStats

use of org.elasticsearch.index.store.StoreStats in project graylog2-server by Graylog2.

the class SizeBasedRotationStrategyTest method testRotate.

@Test
public void testRotate() 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(indexSet.getNewestIndex()).thenReturn("name");
    when(indexSet.getConfig()).thenReturn(indexSetConfig);
    when(indexSetConfig.rotationStrategy()).thenReturn(SizeBasedRotationStrategyConfig.create(100L));
    final SizeBasedRotationStrategy strategy = new SizeBasedRotationStrategy(indices, nodeId, auditEventSender);
    strategy.rotate(indexSet);
    verify(indexSet, times(1)).cycle();
    reset(indexSet);
}
Also used : IndexStatistics(org.graylog2.indexer.indices.IndexStatistics) CommonStats(org.elasticsearch.action.admin.indices.stats.CommonStats) StoreStats(org.elasticsearch.index.store.StoreStats) Test(org.junit.Test)

Example 7 with StoreStats

use of org.elasticsearch.index.store.StoreStats in project elasticsearch by elastic.

the class DiskUsageTests method testFillShardsWithShadowIndices.

public void testFillShardsWithShadowIndices() {
    final Index index = new Index("non-shadow", "0xcafe0000");
    ShardRouting s0 = ShardRouting.newUnassigned(new ShardId(index, 0), false, PeerRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo"));
    s0 = ShardRoutingHelper.initialize(s0, "node1");
    s0 = ShardRoutingHelper.moveToStarted(s0);
    Path i0Path = createTempDir().resolve("indices").resolve(index.getUUID()).resolve("0");
    CommonStats commonStats0 = new CommonStats();
    commonStats0.store = new StoreStats(100);
    final Index index2 = new Index("shadow", "0xcafe0001");
    ShardRouting s1 = ShardRouting.newUnassigned(new ShardId(index2, 0), false, PeerRecoverySource.INSTANCE, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "foo"));
    s1 = ShardRoutingHelper.initialize(s1, "node2");
    s1 = ShardRoutingHelper.moveToStarted(s1);
    Path i1Path = createTempDir().resolve("indices").resolve(index2.getUUID()).resolve("0");
    CommonStats commonStats1 = new CommonStats();
    commonStats1.store = new StoreStats(1000);
    ShardStats[] stats = new ShardStats[] { new ShardStats(s0, new ShardPath(false, i0Path, i0Path, s0.shardId()), commonStats0, null, null), new ShardStats(s1, new ShardPath(false, i1Path, i1Path, s1.shardId()), commonStats1, null, null) };
    ImmutableOpenMap.Builder<String, Long> shardSizes = ImmutableOpenMap.builder();
    ImmutableOpenMap.Builder<ShardRouting, String> routingToPath = ImmutableOpenMap.builder();
    ClusterState state = ClusterState.builder(new ClusterName("blarg")).version(0).metaData(MetaData.builder().put(IndexMetaData.builder("non-shadow").settings(Settings.builder().put(IndexMetaData.SETTING_INDEX_UUID, "0xcafe0000").put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)).numberOfShards(1).numberOfReplicas(0)).put(IndexMetaData.builder("shadow").settings(Settings.builder().put(IndexMetaData.SETTING_INDEX_UUID, "0xcafe0001").put(IndexMetaData.SETTING_SHADOW_REPLICAS, true).put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)).numberOfShards(1).numberOfReplicas(0))).build();
    logger.info("--> calling buildShardLevelInfo with state: {}", state);
    InternalClusterInfoService.buildShardLevelInfo(logger, stats, shardSizes, routingToPath, state);
    assertEquals(2, shardSizes.size());
    assertTrue(shardSizes.containsKey(ClusterInfo.shardIdentifierFromRouting(s0)));
    assertTrue(shardSizes.containsKey(ClusterInfo.shardIdentifierFromRouting(s1)));
    assertEquals(100L, shardSizes.get(ClusterInfo.shardIdentifierFromRouting(s0)).longValue());
    assertEquals(0L, shardSizes.get(ClusterInfo.shardIdentifierFromRouting(s1)).longValue());
}
Also used : Path(java.nio.file.Path) ShardPath(org.elasticsearch.index.shard.ShardPath) ShardStats(org.elasticsearch.action.admin.indices.stats.ShardStats) StoreStats(org.elasticsearch.index.store.StoreStats) UnassignedInfo(org.elasticsearch.cluster.routing.UnassignedInfo) Index(org.elasticsearch.index.Index) ImmutableOpenMap(org.elasticsearch.common.collect.ImmutableOpenMap) ShardId(org.elasticsearch.index.shard.ShardId) CommonStats(org.elasticsearch.action.admin.indices.stats.CommonStats) ShardPath(org.elasticsearch.index.shard.ShardPath) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting)

Aggregations

StoreStats (org.elasticsearch.index.store.StoreStats)7 CommonStats (org.elasticsearch.action.admin.indices.stats.CommonStats)5 Path (java.nio.file.Path)4 ShardRouting (org.elasticsearch.cluster.routing.ShardRouting)4 UnassignedInfo (org.elasticsearch.cluster.routing.UnassignedInfo)4 Index (org.elasticsearch.index.Index)4 ShardStats (org.elasticsearch.action.admin.indices.stats.ShardStats)3 ShardId (org.elasticsearch.index.shard.ShardId)3 ShardPath (org.elasticsearch.index.shard.ShardPath)3 ImmutableOpenMap (org.elasticsearch.common.collect.ImmutableOpenMap)2 QueryCacheStats (org.elasticsearch.index.cache.query.QueryCacheStats)2 RequestCacheStats (org.elasticsearch.index.cache.request.RequestCacheStats)2 SegmentsStats (org.elasticsearch.index.engine.SegmentsStats)2 FieldDataStats (org.elasticsearch.index.fielddata.FieldDataStats)2 FlushStats (org.elasticsearch.index.flush.FlushStats)2 GetStats (org.elasticsearch.index.get.GetStats)2 MergeStats (org.elasticsearch.index.merge.MergeStats)2 RefreshStats (org.elasticsearch.index.refresh.RefreshStats)2 SearchStats (org.elasticsearch.index.search.stats.SearchStats)2 DocsStats (org.elasticsearch.index.shard.DocsStats)2