Java Code Examples for org.elasticsearch.common.unit.TimeValue#timeValueHours()

The following examples show how to use org.elasticsearch.common.unit.TimeValue#timeValueHours() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CachedFeatureStoreTests.java    From elasticsearch-learning-to-rank with Apache License 2.0 6 votes vote down vote up
public void testWontBlowUp() throws IOException {
    Caches caches = new Caches(TimeValue.timeValueHours(1), TimeValue.timeValueHours(1), new ByteSizeValue(100000));
    CachedFeatureStore store = new CachedFeatureStore(memStore, caches);
    long curWeight = store.modelWeight();
    long maxWeight = caches.getMaxWeight();
    long maxIter = 1000;
    while (true) {
        CompiledLtrModel model = LtrTestUtils.buildRandomModel();
        memStore.add(model);
        if (curWeight + model.ramBytesUsed() > maxWeight) {
            store.loadModel(model.name());
            assertTrue(store.modelWeight() < maxWeight);
            break;
        }
        assertTrue(maxIter-- > 0);
        memStore.clear();
        curWeight = store.modelWeight();
    }
}
 
Example 2
Source File: CachedFeatureStoreTests.java    From elasticsearch-learning-to-rank with Apache License 2.0 6 votes vote down vote up
@BadApple(bugUrl = "https://github.com/o19s/elasticsearch-learning-to-rank/issues/75")
public void testExpirationOnWrite() throws IOException, InterruptedException {
    Caches caches = new Caches(TimeValue.timeValueMillis(100), TimeValue.timeValueHours(1), new ByteSizeValue(1000000));
    CachedFeatureStore store = new CachedFeatureStore(memStore, caches);
    CompiledLtrModel model = LtrTestUtils.buildRandomModel();
    memStore.add(model);
    store.loadModel(model.name());
    assertNotNull(store.getCachedModel(model.name()));
    assertFalse(caches.getCachedStoreNames().isEmpty());
    assertEquals(1, caches.getPerStoreStats(memStore.getStoreName()).totalCount());
    Thread.sleep(500);
    caches.modelCache().refresh();
    assertNull(store.getCachedModel(model.name()));
    assertTrue(caches.getCachedStoreNames().isEmpty());
    assertEquals(0, caches.getPerStoreStats(memStore.getStoreName()).modelRam());
    assertEquals(0, caches.getPerStoreStats(memStore.getStoreName()).totalCount());
}
 
Example 3
Source File: CachedFeatureStoreTests.java    From elasticsearch-learning-to-rank with Apache License 2.0 6 votes vote down vote up
@BadApple(bugUrl = "https://github.com/o19s/elasticsearch-learning-to-rank/issues/75")
public void testExpirationOnGet() throws IOException, InterruptedException {
    Caches caches = new Caches(TimeValue.timeValueHours(1), TimeValue.timeValueMillis(100), new ByteSizeValue(1000000));
    CachedFeatureStore store = new CachedFeatureStore(memStore, caches);
    CompiledLtrModel model = LtrTestUtils.buildRandomModel();
    memStore.add(model);
    store.loadModel(model.name()); // fill cache
    store.loadModel(model.name()); // access cache
    assertNotNull(store.getCachedModel(model.name()));
    Thread.sleep(500);
    caches.modelCache().refresh();
    assertNull(store.getCachedModel(model.name()));
    assertNull(store.getCachedModel(model.name()));
    assertTrue(caches.getCachedStoreNames().isEmpty());
    assertEquals(0, caches.getPerStoreStats(memStore.getStoreName()).modelRam());
    assertEquals(0, caches.getPerStoreStats(memStore.getStoreName()).totalCount());
}
 
Example 4
Source File: ClusterHealthResponse.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/** needed for plugins BWC */
public ClusterHealthResponse(String clusterName, String[] concreteIndices, ClusterState clusterState) {
    this(clusterName, concreteIndices, clusterState, -1, -1, -1, TimeValue.timeValueHours(0));
}