mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-21 01:41:31 +00:00
Initial pass at removing old spark code (#80)
Co-authored-by: Steve Faulkner <stfaul@microsoft.com>
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
<div data-bind="visible: visible, event: { keydown: onPaneKeyDown }">
|
||||
<div class="contextual-pane-out" data-bind="click: cancel, clickBubble: false"></div>
|
||||
<div class="contextual-pane" id="managesparkclusterpane">
|
||||
<!-- Setup spark form -- Start -->
|
||||
<div class="contextual-pane-in">
|
||||
<div class="paneContentContainer">
|
||||
<form class="paneContentContainer" data-bind="submit: submit">
|
||||
<!-- Setup spark header - Start -->
|
||||
<div class="firstdivbg headerline">
|
||||
<span data-bind="text: title"></span>
|
||||
<div
|
||||
class="closeImg"
|
||||
role="button"
|
||||
aria-label="Close pane"
|
||||
tabindex="0"
|
||||
data-bind="click: cancel, event: { keypress: onCloseKeyPress }"
|
||||
>
|
||||
<img src="../../../images/close-black.svg" title="Close" alt="Close" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- Setup spark header - End -->
|
||||
|
||||
<div class="paneMainContent"><div data-bind="react: clusterSettingsComponentAdapter"></div></div>
|
||||
<div class="paneFooter">
|
||||
<div class="leftpanel-okbut"><input type="submit" value="Save" class="btncreatecoll1" /></div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Setup spark form - Start -->
|
||||
<!-- Loader - Start -->
|
||||
<div class="dataExplorerLoaderContainer dataExplorerPaneLoaderContainer" data-bind="visible: isExecuting">
|
||||
<img class="dataExplorerLoader" alt="loading indicator image" src="/LoadingIndicator_3Squares.gif" />
|
||||
</div>
|
||||
<!-- Loader - End -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,153 +0,0 @@
|
||||
import * as ko from "knockout";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { Areas } from "../../Common/Constants";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { ClusterSettingsComponentAdapter } from "../Controls/Spark/ClusterSettingsComponentAdapter";
|
||||
import { ClusterSettingsComponentProps } from "../Controls/Spark/ClusterSettingsComponent";
|
||||
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
||||
import { Spark } from "../../Common/Constants";
|
||||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
|
||||
const MAX_NUM_WORKERS = 10;
|
||||
|
||||
export class ManageSparkClusterPane extends ContextualPaneBase {
|
||||
public readonly maxWorkerCount = Spark.MaxWorkerCount;
|
||||
public workerCount: ko.Observable<number>;
|
||||
public clusterSettingsComponentAdapter: ClusterSettingsComponentAdapter;
|
||||
|
||||
private _settingsComponentAdapterProps: ko.Observable<ClusterSettingsComponentProps>;
|
||||
private _defaultCluster: ko.Observable<DataModels.SparkCluster>;
|
||||
|
||||
constructor(options: ViewModels.PaneOptions) {
|
||||
super(options);
|
||||
this.title("Manage spark cluster");
|
||||
this.workerCount = ko.observable<number>();
|
||||
this._defaultCluster = ko.observable<DataModels.SparkCluster>({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
type: undefined,
|
||||
properties: {
|
||||
kind: undefined,
|
||||
creationTime: undefined,
|
||||
driverSize: undefined,
|
||||
status: undefined,
|
||||
workerInstanceCount: undefined,
|
||||
workerSize: undefined
|
||||
}
|
||||
});
|
||||
this._settingsComponentAdapterProps = ko.observable<ClusterSettingsComponentProps>({
|
||||
cluster: this._defaultCluster(),
|
||||
onClusterSettingsChanged: this.onClusterSettingsChange
|
||||
});
|
||||
this._defaultCluster.subscribe(cluster => {
|
||||
this._settingsComponentAdapterProps().cluster = cluster;
|
||||
this._settingsComponentAdapterProps.valueHasMutated(); // trigger component re-render
|
||||
});
|
||||
this.clusterSettingsComponentAdapter = new ClusterSettingsComponentAdapter();
|
||||
this.clusterSettingsComponentAdapter.parameters = this._settingsComponentAdapterProps;
|
||||
this.resetData();
|
||||
}
|
||||
|
||||
public async submit() {
|
||||
if (!this.workerCount() || this.workerCount() > MAX_NUM_WORKERS) {
|
||||
this.formErrors("Invalid worker count specified");
|
||||
this.formErrorsDetails(`The number of workers should be between 0 and ${MAX_NUM_WORKERS}`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this._defaultCluster()) {
|
||||
this.formErrors("No default cluster found");
|
||||
this.formErrorsDetails("No default cluster found to be associated with this account");
|
||||
return;
|
||||
}
|
||||
|
||||
const startKey = TelemetryProcessor.traceStart(Action.UpdateSparkCluster, {
|
||||
databaseAccountName: this.container && this.container.databaseAccount().name,
|
||||
defaultExperience: this.container && this.container.defaultExperience(),
|
||||
dataExplorerArea: Areas.ContextualPane,
|
||||
paneTitle: this.title()
|
||||
});
|
||||
const workerCount = this.workerCount();
|
||||
const id = NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.InProgress,
|
||||
`Updating default cluster worker count to ${workerCount} nodes`
|
||||
);
|
||||
this.isExecuting(true);
|
||||
try {
|
||||
const databaseAccount = this.container && this.container.databaseAccount();
|
||||
const cluster = this._defaultCluster();
|
||||
cluster.properties.workerInstanceCount = workerCount;
|
||||
const updatedCluster =
|
||||
this.container &&
|
||||
(await this.container.sparkClusterManager.updateClusterAsync(
|
||||
databaseAccount && databaseAccount.id,
|
||||
cluster.name,
|
||||
cluster
|
||||
));
|
||||
this._defaultCluster(updatedCluster);
|
||||
NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.Info,
|
||||
`Successfully updated default cluster worker count to ${workerCount} nodes`
|
||||
);
|
||||
TelemetryProcessor.traceSuccess(
|
||||
Action.UpdateSparkCluster,
|
||||
{
|
||||
databaseAccountName: this.container && this.container.databaseAccount().name,
|
||||
defaultExperience: this.container && this.container.defaultExperience(),
|
||||
dataExplorerArea: Areas.ContextualPane,
|
||||
paneTitle: this.title()
|
||||
},
|
||||
startKey
|
||||
);
|
||||
} catch (error) {
|
||||
NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.Error,
|
||||
`Failed to update default cluster worker count to ${workerCount} nodes: ${JSON.stringify(error)}`
|
||||
);
|
||||
TelemetryProcessor.traceFailure(
|
||||
Action.UpdateSparkCluster,
|
||||
{
|
||||
databaseAccountName: this.container && this.container.databaseAccount().name,
|
||||
defaultExperience: this.container && this.container.defaultExperience(),
|
||||
dataExplorerArea: Areas.ContextualPane,
|
||||
paneTitle: this.title(),
|
||||
error: JSON.stringify(error)
|
||||
},
|
||||
startKey
|
||||
);
|
||||
} finally {
|
||||
this.isExecuting(false);
|
||||
NotificationConsoleUtils.clearInProgressMessageWithId(id);
|
||||
}
|
||||
}
|
||||
|
||||
public onClusterSettingsChange = (cluster: DataModels.SparkCluster) => {
|
||||
this._defaultCluster(cluster);
|
||||
this.workerCount(
|
||||
(cluster &&
|
||||
cluster.properties &&
|
||||
cluster.properties.workerInstanceCount !== undefined &&
|
||||
cluster.properties.workerInstanceCount) ||
|
||||
0
|
||||
);
|
||||
};
|
||||
|
||||
public async open() {
|
||||
const defaultCluster = await this.container.sparkClusterManager.getClusterAsync(
|
||||
this.container.databaseAccount().id,
|
||||
"default"
|
||||
);
|
||||
this._defaultCluster(defaultCluster);
|
||||
this.workerCount(
|
||||
(defaultCluster &&
|
||||
defaultCluster.properties &&
|
||||
defaultCluster.properties.workerInstanceCount !== undefined &&
|
||||
defaultCluster.properties.workerInstanceCount) ||
|
||||
0
|
||||
);
|
||||
super.open();
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,6 @@ import BrowseQueriesPaneTemplate from "./BrowseQueriesPane.html";
|
||||
import UploadFilePaneTemplate from "./UploadFilePane.html";
|
||||
import StringInputPaneTemplate from "./StringInputPane.html";
|
||||
import SetupNotebooksPaneTemplate from "./SetupNotebooksPane.html";
|
||||
import SetupSparkClusterPaneTemplate from "./SetupSparkClusterPane.html";
|
||||
import ManageSparkClusterPaneTemplate from "./ManageSparkClusterPane.html";
|
||||
import LibraryManagePaneTemplate from "./LibraryManagePane.html";
|
||||
import ClusterLibraryPaneTemplate from "./ClusterLibraryPane.html";
|
||||
import GitHubReposPaneTemplate from "./GitHubReposPane.html";
|
||||
@@ -220,24 +218,6 @@ export class SetupNotebooksPaneComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export class SetupSparkClusterPaneComponent {
|
||||
constructor() {
|
||||
return {
|
||||
viewModel: PaneComponent,
|
||||
template: SetupSparkClusterPaneTemplate
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class ManageSparkClusterPaneComponent {
|
||||
constructor() {
|
||||
return {
|
||||
viewModel: PaneComponent,
|
||||
template: ManageSparkClusterPaneTemplate
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class LibraryManagePaneComponent {
|
||||
constructor() {
|
||||
return {
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
<div data-bind="visible: visible, event: { keydown: onPaneKeyDown }">
|
||||
<div class="contextual-pane-out" data-bind="click: cancel, clickBubble: false"></div>
|
||||
<div class="contextual-pane" id="setupsparkclusterpane">
|
||||
<!-- Setup spark form -- Start -->
|
||||
<div class="contextual-pane-in">
|
||||
<form class="paneContentContainer" data-bind="submit: submit">
|
||||
<div class="paneContentContainer">
|
||||
<!-- Setup spark header - Start -->
|
||||
<div class="firstdivbg headerline">
|
||||
<span data-bind="text: title"></span>
|
||||
<div
|
||||
class="closeImg"
|
||||
role="button"
|
||||
aria-label="Close pane"
|
||||
tabindex="0"
|
||||
data-bind="click: cancel, event: { keypress: onCloseKeyPress }"
|
||||
>
|
||||
<img src="../../../images/close-black.svg" title="Close" alt="Close" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- Setup spark header - End -->
|
||||
|
||||
<div class="paneMainContent">
|
||||
<div class="pkPadding">
|
||||
<div data-bind="text: setupSparkClusterText"></div>
|
||||
<div class="seconddivpadding">
|
||||
<div>Worker Count</div>
|
||||
<input
|
||||
class="sparkWorkerCountInput"
|
||||
type="number"
|
||||
min="1"
|
||||
aria-label="worker count input"
|
||||
required
|
||||
data-bind="textInput: workerCount, attr: { max: maxWorkerNodes }"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="paneFooter">
|
||||
<div class="leftpanel-okbut"><input type="submit" value="Complete Setup" class="btncreatecoll1" /></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- Setup spark form - Start -->
|
||||
<!-- Loader - Start -->
|
||||
<div class="dataExplorerLoaderContainer dataExplorerPaneLoaderContainer" data-bind="visible: isExecuting">
|
||||
<img class="dataExplorerLoader" alt="loading indicator image" src="/LoadingIndicator_3Squares.gif" />
|
||||
</div>
|
||||
<!-- Loader - End -->
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,99 +0,0 @@
|
||||
import * as ko from "knockout";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import { Action } from "../../Shared/Telemetry/TelemetryConstants";
|
||||
import { Areas } from "../../Common/Constants";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { ContextualPaneBase } from "./ContextualPaneBase";
|
||||
import { NotificationConsoleUtils } from "../../Utils/NotificationConsoleUtils";
|
||||
import { Spark } from "../../Common/Constants";
|
||||
import TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
|
||||
|
||||
export class SetupSparkClusterPane extends ContextualPaneBase {
|
||||
public setupSparkClusterText: string =
|
||||
"Looks like you have not yet created a default spark cluster for this account. To proceed and start using notebooks with spark, we'll need to create a default spark cluster for this account.";
|
||||
public readonly maxWorkerNodes: number = Spark.MaxWorkerCount;
|
||||
public workerCount: ko.Observable<number>;
|
||||
|
||||
constructor(options: ViewModels.PaneOptions) {
|
||||
super(options);
|
||||
this.title("Enable spark");
|
||||
this.workerCount = ko.observable<number>(1);
|
||||
this.resetData();
|
||||
}
|
||||
|
||||
public async submit() {
|
||||
await this.setupSparkCluster();
|
||||
}
|
||||
|
||||
public async setupSparkCluster(): Promise<void> {
|
||||
if (!this.container) {
|
||||
return;
|
||||
}
|
||||
|
||||
const startKey: number = TelemetryProcessor.traceStart(Action.CreateSparkCluster, {
|
||||
databaseAccountName: this.container && this.container.databaseAccount().name,
|
||||
defaultExperience: this.container && this.container.defaultExperience(),
|
||||
dataExplorerArea: Areas.ContextualPane,
|
||||
paneTitle: this.title()
|
||||
});
|
||||
const id = NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.InProgress,
|
||||
"Creating a new default spark cluster"
|
||||
);
|
||||
try {
|
||||
this.isExecuting(true);
|
||||
await this.container.sparkClusterManager.createClusterAsync(
|
||||
this.container.databaseAccount() && this.container.databaseAccount().id,
|
||||
{
|
||||
name: "default",
|
||||
properties: {
|
||||
kind: "Spark",
|
||||
workerInstanceCount: this.workerCount(),
|
||||
driverSize: "Cosmos.Spark.D4s",
|
||||
workerSize: "Cosmos.Spark.D4s",
|
||||
creationTime: undefined,
|
||||
status: undefined
|
||||
}
|
||||
}
|
||||
);
|
||||
this.container.isAccountReady.valueHasMutated(); // refresh internal state
|
||||
this.close();
|
||||
TelemetryProcessor.traceSuccess(
|
||||
Action.CreateSparkCluster,
|
||||
{
|
||||
databaseAccountName: this.container && this.container.databaseAccount().name,
|
||||
defaultExperience: this.container && this.container.defaultExperience(),
|
||||
dataExplorerArea: Areas.ContextualPane,
|
||||
paneTitle: this.title()
|
||||
},
|
||||
startKey
|
||||
);
|
||||
NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.Info,
|
||||
"Successfully created a default spark cluster for the account"
|
||||
);
|
||||
} catch (error) {
|
||||
const errorMessage = typeof error == "string" ? error : JSON.stringify(error);
|
||||
TelemetryProcessor.traceFailure(
|
||||
Action.CreateSparkCluster,
|
||||
{
|
||||
databaseAccountName: this.container && this.container.databaseAccount().name,
|
||||
defaultExperience: this.container && this.container.defaultExperience(),
|
||||
dataExplorerArea: Areas.ContextualPane,
|
||||
paneTitle: this.title(),
|
||||
error: errorMessage
|
||||
},
|
||||
startKey
|
||||
);
|
||||
this.formErrors("Failed to setup a default spark cluster");
|
||||
this.formErrorsDetails(`Failed to setup a default spark cluster: ${errorMessage}`);
|
||||
NotificationConsoleUtils.logConsoleMessage(
|
||||
ConsoleDataType.Error,
|
||||
`Failed to create a default spark cluster: ${errorMessage}`
|
||||
);
|
||||
} finally {
|
||||
this.isExecuting(false);
|
||||
NotificationConsoleUtils.clearInProgressMessageWithId(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user