public static void waitSearchIndexIncPhrase()

in java/core/src/main/java/com/aliyun/openservices/tablestore/agent/util/TablestoreHelper.java [961:982]


    public static void waitSearchIndexIncPhrase(SyncClient client, String tableName, String indexName) {
        long maxWaitTime = 300 * 1000_0000_000L;// 300s
        long startTime = System.nanoTime();
        while (System.nanoTime() - startTime < maxWaitTime) {
            DescribeSearchIndexRequest request = new DescribeSearchIndexRequest();
            request.setTableName(tableName);
            request.setIndexName(indexName);
            DescribeSearchIndexResponse searchResponse = client.describeSearchIndex(request);
            SyncStat syncStat = searchResponse.getSyncStat();
            if (syncStat.getSyncPhase().equals(SyncStat.SyncPhase.INCR)
                && Math.abs(syncStat.getCurrentSyncTimestamp() / 1000 / 1000 - System.currentTimeMillis()) <= 10_000) {
                log.info("search index inc phrase ready, use: {}s", (System.nanoTime() - startTime) / 1000_000_000L);
                return;
            }
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
        throw Exceptions.runtime("search index not ready");
    }