use of com.microsoft.azure.management.resources.implementation.ProviderInner in project photon-model by vmware.
the class AzureInstanceService method registerSubscription.
private void registerSubscription(AzureInstanceContext ctx, String namespace) {
ResourceManagementClientImpl client = getResourceManagementClientImpl(ctx);
client.providers().registerAsync(namespace, new AzureAsyncCallback<ProviderInner>() {
@Override
public void onError(Throwable e) {
handleError(ctx, e);
}
@Override
public void onSuccess(ProviderInner result) {
String registrationState = result.registrationState();
if (!PROVIDER_REGISTRED_STATE.equalsIgnoreCase(registrationState)) {
logInfo(() -> String.format("%s namespace registration in %s state", namespace, registrationState));
long retryExpiration = Utils.getNowMicrosUtc() + DEFAULT_EXPIRATION_INTERVAL_MICROS;
getSubscriptionState(ctx, namespace, retryExpiration);
return;
}
logFine(() -> String.format("Successfully registered namespace [%s]", result.namespace()));
handleAllocation(ctx);
}
});
}
use of com.microsoft.azure.management.resources.implementation.ProviderInner in project photon-model by vmware.
the class AzureInstanceService method getSubscriptionState.
private void getSubscriptionState(AzureInstanceContext ctx, String namespace, long retryExpiration) {
if (Utils.getNowMicrosUtc() > retryExpiration) {
String msg = String.format("Subscription for %s namespace did not reach %s state", namespace, PROVIDER_REGISTRED_STATE);
handleError(ctx, new RuntimeException(msg));
return;
}
ResourceManagementClientImpl client = getResourceManagementClientImpl(ctx);
getHost().schedule(() -> client.providers().getAsync(namespace, new AzureAsyncCallback<ProviderInner>() {
@Override
public void onError(Throwable e) {
handleError(ctx, e);
}
@Override
public void onSuccess(ProviderInner result) {
String registrationState = result.registrationState();
if (!PROVIDER_REGISTRED_STATE.equalsIgnoreCase(registrationState)) {
logInfo(() -> String.format("%s namespace registration in %s state", namespace, registrationState));
getSubscriptionState(ctx, namespace, retryExpiration);
return;
}
logFine(() -> String.format("Successfully registered namespace [%s]", result.namespace()));
handleAllocation(ctx);
}
}), RETRY_INTERVAL_SECONDS, TimeUnit.SECONDS);
}
Aggregations