Search in sources :

Example 1 with IndexUpgradeStatus

use of org.elasticsearch.action.admin.indices.upgrade.get.IndexUpgradeStatus in project elasticsearch by elastic.

the class OldIndexUtils method assertNotUpgraded.

public static void assertNotUpgraded(Client client, String... index) throws Exception {
    for (IndexUpgradeStatus status : getUpgradeStatus(client, index)) {
        assertTrue("index " + status.getIndex() + " should not be zero sized", status.getTotalBytes() != 0);
        // TODO: it would be better for this to be strictly greater, but sometimes an extra flush
        // mysteriously happens after the second round of docs are indexed
        assertTrue("index " + status.getIndex() + " should have recovered some segments from transaction log", status.getTotalBytes() >= status.getToUpgradeBytes());
        assertTrue("index " + status.getIndex() + " should need upgrading", status.getToUpgradeBytes() != 0);
    }
}
Also used : IndexUpgradeStatus(org.elasticsearch.action.admin.indices.upgrade.get.IndexUpgradeStatus)

Example 2 with IndexUpgradeStatus

use of org.elasticsearch.action.admin.indices.upgrade.get.IndexUpgradeStatus in project elasticsearch by elastic.

the class OldIndexUtils method isUpgraded.

public static boolean isUpgraded(Client client, String index) throws Exception {
    Logger logger = Loggers.getLogger(OldIndexUtils.class);
    int toUpgrade = 0;
    for (IndexUpgradeStatus status : getUpgradeStatus(client, index)) {
        logger.info("Index: {}, total: {}, toUpgrade: {}", status.getIndex(), status.getTotalBytes(), status.getToUpgradeBytes());
        toUpgrade += status.getToUpgradeBytes();
    }
    return toUpgrade == 0;
}
Also used : IndexUpgradeStatus(org.elasticsearch.action.admin.indices.upgrade.get.IndexUpgradeStatus) Logger(org.apache.logging.log4j.Logger)

Example 3 with IndexUpgradeStatus

use of org.elasticsearch.action.admin.indices.upgrade.get.IndexUpgradeStatus in project elasticsearch by elastic.

the class OldIndexUtils method assertUpgraded.

public static void assertUpgraded(Client client, String... index) throws Exception {
    for (IndexUpgradeStatus status : getUpgradeStatus(client, index)) {
        assertTrue("index " + status.getIndex() + " should not be zero sized", status.getTotalBytes() != 0);
        assertEquals("index " + status.getIndex() + " should be upgraded", 0, status.getToUpgradeBytes());
    }
    // double check using the segments api that all segments are actually upgraded
    IndicesSegmentResponse segsRsp;
    if (index == null) {
        segsRsp = client.admin().indices().prepareSegments().execute().actionGet();
    } else {
        segsRsp = client.admin().indices().prepareSegments(index).execute().actionGet();
    }
    for (IndexSegments indexSegments : segsRsp.getIndices().values()) {
        for (IndexShardSegments shard : indexSegments) {
            for (ShardSegments segs : shard.getShards()) {
                for (Segment seg : segs.getSegments()) {
                    assertEquals("Index " + indexSegments.getIndex() + " has unupgraded segment " + seg.toString(), Version.CURRENT.luceneVersion.major, seg.version.major);
                    assertEquals("Index " + indexSegments.getIndex() + " has unupgraded segment " + seg.toString(), Version.CURRENT.luceneVersion.minor, seg.version.minor);
                }
            }
        }
    }
}
Also used : ShardSegments(org.elasticsearch.action.admin.indices.segments.ShardSegments) IndexShardSegments(org.elasticsearch.action.admin.indices.segments.IndexShardSegments) IndexUpgradeStatus(org.elasticsearch.action.admin.indices.upgrade.get.IndexUpgradeStatus) IndicesSegmentResponse(org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse) IndexShardSegments(org.elasticsearch.action.admin.indices.segments.IndexShardSegments) IndexSegments(org.elasticsearch.action.admin.indices.segments.IndexSegments) Segment(org.elasticsearch.index.engine.Segment)

Aggregations

IndexUpgradeStatus (org.elasticsearch.action.admin.indices.upgrade.get.IndexUpgradeStatus)3 Logger (org.apache.logging.log4j.Logger)1 IndexSegments (org.elasticsearch.action.admin.indices.segments.IndexSegments)1 IndexShardSegments (org.elasticsearch.action.admin.indices.segments.IndexShardSegments)1 IndicesSegmentResponse (org.elasticsearch.action.admin.indices.segments.IndicesSegmentResponse)1 ShardSegments (org.elasticsearch.action.admin.indices.segments.ShardSegments)1 Segment (org.elasticsearch.index.engine.Segment)1