Search in sources :

Example 1 with PersisterCache

use of com.mesosphere.sdk.storage.PersisterCache in project dcos-commons by mesosphere.

the class StateQueries method refreshCache.

/**
 * Refreshes the state store cache to reflect current data on ZK. Should only be needed if ZK was edited behind the
 * scheduler's back, or if there's a bug in the cache handling.
 */
public static Response refreshCache(StateStore stateStore) {
    PersisterCache cache = getPersisterCache(stateStore);
    if (cache == null) {
        LOGGER.warn("State store is not cached: Refresh is not applicable");
        return Response.status(Response.Status.CONFLICT).build();
    }
    try {
        LOGGER.info("Refreshing state store cache...");
        LOGGER.info("Before:\n- tasks: {}\n- properties: {}", stateStore.fetchTaskNames(), stateStore.fetchPropertyKeys());
        cache.refresh();
        LOGGER.info("After:\n- tasks: {}\n- properties: {}", stateStore.fetchTaskNames(), stateStore.fetchPropertyKeys());
        return ResponseUtils.jsonOkResponse(getCommandResult("refresh"));
    } catch (PersisterException ex) {
        LOGGER.error("Failed to refresh state cache", ex);
        return Response.serverError().build();
    }
}
Also used : PersisterCache(com.mesosphere.sdk.storage.PersisterCache) PersisterException(com.mesosphere.sdk.storage.PersisterException)

Aggregations

PersisterCache (com.mesosphere.sdk.storage.PersisterCache)1 PersisterException (com.mesosphere.sdk.storage.PersisterException)1