Search in sources :

Example 1 with RedisCacheProperty

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

the class RedisPropertyViewPresenter method onGetRedisProperty.

/**
 * Called from view when the view needs to show the property.
 *
 * @param sid
 *            Subscription Id
 * @param id
 *            Redis Cache's Id
 */
public void onGetRedisProperty(String sid, String id) {
    if (Utils.isEmptyString(sid)) {
        getMvpView().onError(CANNOT_GET_SUBSCRIPTION_ID);
        return;
    }
    if (Utils.isEmptyString(id)) {
        getMvpView().onError(CANNOT_GET_REDIS_ID);
        return;
    }
    if (!(getMvpView() instanceof RedisPropertyMvpView)) {
        return;
    }
    Observable.fromCallable(() -> {
        return AzureRedisMvpModel.getInstance().getRedisCache(sid, id);
    }).subscribeOn(getSchedulerProvider().io()).subscribe(redis -> {
        DefaultLoader.getIdeHelper().invokeLater(() -> {
            if (isViewDetached()) {
                return;
            }
            if (redis == null) {
                getMvpView().onError(CANNOT_GET_REDIS_PROPERTY);
                return;
            }
            RedisCacheProperty property = new RedisCacheProperty(redis.name(), redis.type(), redis.resourceGroupName(), redis.regionName(), sid, redis.redisVersion(), redis.sslPort(), redis.nonSslPort(), redis.keys().primaryKey(), redis.keys().secondaryKey(), redis.hostName());
            getMvpView().showProperty(property);
        });
    }, e -> {
        errorHandler(CANNOT_GET_REDIS_PROPERTY, (Exception) e);
    });
}
Also used : RedisCacheProperty(com.microsoft.azuretools.core.mvp.ui.rediscache.RedisCacheProperty)

Example 2 with RedisCacheProperty

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

the class RedisCachePropertyView method onReadProperty.

@Override
public void onReadProperty(String sid, String id) {
    AzureRedis az = Azure.az(AzureRedis.class).subscription(sid);
    Mono.fromCallable(() -> az.get(id).entity()).map(redis -> {
        RedisCacheProperty property = new RedisCacheProperty(redis.getName(), redis.getType(), redis.getResourceGroupName(), redis.getRegion().getName(), sid, redis.getRedisVersion(), redis.getSSLPort(), redis.getNonSslPortEnabled(), redis.getPrimaryKey(), redis.getSecondaryKey(), redis.getHostName());
        return property;
    }).subscribeOn(Schedulers.boundedElastic()).subscribe(property -> {
        this.showProperty(property);
    });
}
Also used : AzureRedis(com.microsoft.azure.toolkit.redis.AzureRedis) RedisCacheProperty(com.microsoft.azuretools.core.mvp.ui.rediscache.RedisCacheProperty)

Aggregations

RedisCacheProperty (com.microsoft.azuretools.core.mvp.ui.rediscache.RedisCacheProperty)2 AzureRedis (com.microsoft.azure.toolkit.redis.AzureRedis)1