Compare commits

...

4 Commits

Author SHA1 Message Date
Srinath Narayanan
9e8793d1b1 Moved constants 2020-11-11 11:31:07 -08:00
Srinath Narayanan
f41de718a0 fixed formatting error. 2020-11-11 08:58:43 -08:00
Srinath Narayanan
5820afc25a changed error message 2020-11-11 08:52:07 -08:00
Srinath Narayanan
6d94f18f9a Added loadOfffer with retry 2020-11-11 08:46:28 -08:00
3 changed files with 24 additions and 3 deletions

View File

@@ -162,6 +162,7 @@ export interface Collection extends CollectionBase {
loadStoredProcedures(): Promise<any>;
loadTriggers(): Promise<any>;
loadOffer(): Promise<void>;
loadAutopilotOfferWithRetry(): Promise<DataModels.Offer>;
createStoredProcedureNode(data: StoredProcedureDefinition & Resource): StoredProcedure;
createUserDefinedFunctionNode(data: UserDefinedFunctionDefinition & Resource): UserDefinedFunction;

View File

@@ -532,11 +532,12 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
}
const updatedOffer: DataModels.Offer = await updateOffer(updateOfferParams);
this.collection.offer(updatedOffer);
this.setState({ isScaleSaveable: false, isScaleDiscardable: false });
if (this.state.isAutoPilotSelected) {
const autoPilotOffer = await this.collection.loadAutopilotOfferWithRetry();
this.setState({
autoPilotThroughput: updatedOffer.content.offerAutopilotSettings.maxThroughput,
autoPilotThroughputBaseline: updatedOffer.content.offerAutopilotSettings.maxThroughput
autoPilotThroughput: autoPilotOffer.content.offerAutopilotSettings.maxThroughput,
autoPilotThroughputBaseline: autoPilotOffer.content.offerAutopilotSettings.maxThroughput
});
} else {
this.setState({
@@ -544,6 +545,8 @@ export class SettingsComponent extends React.Component<SettingsComponentProps, S
throughputBaseline: updatedOffer.content.offerThroughput
});
}
this.setState({ isScaleSaveable: false, isScaleDiscardable: false });
}
}
this.container.isRefreshingExplorer(false);

View File

@@ -41,8 +41,11 @@ import { userContext } from "../../UserContext";
import TabsBase from "../Tabs/TabsBase";
import { fetchPortalNotifications } from "../../Common/PortalNotifications";
import { getErrorMessage, getErrorStack } from "../../Common/ErrorHandlingUtils";
import promiseRetry from "p-retry";
export default class Collection implements ViewModels.Collection {
private static readonly LoadOfferMaxRetries = 5;
private static readonly LoadOfferRetryAfterMilliSeconds = 5000;
public nodeKind: string;
public container: Explorer;
public self: string;
@@ -1331,6 +1334,20 @@ export default class Collection implements ViewModels.Collection {
return this.container.findDatabaseWithId(this.databaseId);
}
public async loadAutopilotOfferWithRetry(): Promise<DataModels.Offer> {
let retryCount = 0;
while (retryCount < Collection.LoadOfferMaxRetries) {
if (this.offer().content.offerAutopilotSettings) {
return this.offer();
} else {
await new Promise(resolve => setTimeout(resolve, Collection.LoadOfferRetryAfterMilliSeconds));
await this.loadOffer();
}
retryCount++;
}
throw new Error("Max retries for loading offer are completed. Offer does not have an Autopilot settings field.");
}
public async loadOffer(): Promise<void> {
if (!this.container.isServerlessEnabled() && !this.offer()) {
this.container.isRefreshingExplorer(true);