Search in sources :

Example 6 with RedisScanResult

use of com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult in project azure-tools-for-java by Microsoft.

the class RedisExplorerPresenter method onKeyList.

/**
 * Called when Scan button is clicked.
 *
 * @param sid
 *            subscription id of Redis Cache
 * @param id
 *            resource id of Redis Cache
 * @param db
 *            index of Redis Cache database
 * @param cursor
 *            scan cursor for Redis Cache
 * @param pattern
 *            scan match pattern for Redis Cache
 */
public void onKeyList(int db, String cursor, String pattern) {
    Operation operation = TelemetryManager.createOperation(TelemetryConstants.REDIS, TelemetryConstants.REDIS_SCAN);
    operation.start();
    Observable.fromCallable(() -> {
        return RedisExplorerMvpModel.getInstance().scanKeys(sid, id, db, cursor, pattern);
    }).subscribeOn(getSchedulerProvider().io()).subscribe(result -> {
        DefaultLoader.getIdeHelper().invokeLater(() -> {
            if (isViewDetached()) {
                return;
            }
            getMvpView().showScanResult(new RedisScanResult(result));
            operation.complete();
        });
    }, e -> {
        EventUtil.logError(operation, ErrorType.userError, new Exception(e), null, null);
        operation.complete();
        errorHandler(CANNOT_GET_REDIS_INFO, (Exception) e);
    });
}
Also used : Operation(com.microsoft.azuretools.telemetrywrapper.Operation) RedisScanResult(com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult)

Aggregations

RedisScanResult (com.microsoft.azuretools.core.mvp.ui.rediscache.RedisScanResult)6 Test (org.junit.Test)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 Operation (com.microsoft.azuretools.telemetrywrapper.Operation)2