Compare commits

...

10 Commits

Author SHA1 Message Date
Srinath Narayanan
8c7f4d1ddf split service changes 2021-09-02 21:31:13 +05:30
Srinath Narayanan
78e5c88e3c Added notebookServerInfo 2021-08-22 12:38:15 -07:00
Bala Lakshmi Narayanasami
c0bd74ce1b Merge branch 'users/srnara/containerPooling' of https://github.com/Azure/cosmos-explorer into users/srnara/containerPooling 2021-08-20 23:42:57 +05:30
Bala Lakshmi Narayanasami
c04ba728ef Initialize Container Request payload change 2021-08-20 23:42:37 +05:30
Srinath Narayanan
127b16cfc8 added postgres button 2021-07-30 00:53:08 -07:00
Srinath Narayanan
0f281c7a64 changed postgres terminal -> shell 2021-07-13 08:38:45 -07:00
Srinath Narayanan
659d5a6677 Added postgreSQL terminal 2021-07-08 03:22:13 -07:00
Srinath Narayanan
5f66f113af Added container unprovisioning 2021-06-30 04:21:42 -07:00
Srinath Narayanan
b1c238f43a Merge branch 'master' into users/srnara/containerPooling 2021-06-25 11:17:20 -07:00
Srinath Narayanan
445d2650a2 initial changes for CP 2021-06-25 11:17:07 -07:00
8 changed files with 76 additions and 28 deletions

View File

@@ -3,7 +3,7 @@ import {
Resource,
StoredProcedureDefinition,
TriggerDefinition,
UserDefinedFunctionDefinition,
UserDefinedFunctionDefinition
} from "@azure/cosmos";
import Explorer from "../Explorer/Explorer";
import { ConsoleData } from "../Explorer/Menus/NotificationConsole/ConsoleData";
@@ -370,6 +370,7 @@ export enum TerminalKind {
Default = 0,
Mongo = 1,
Cassandra = 2,
PostgreSQL = 3
}
export interface DataExplorerInputsFrame {

View File

@@ -6,6 +6,7 @@ import _ from "underscore";
import { AuthType } from "../AuthType";
import { BindingHandlersRegisterer } from "../Bindings/BindingHandlersRegisterer";
import * as Constants from "../Common/Constants";
import { HttpHeaders } from "../Common/Constants";
import { readCollection } from "../Common/dataAccess/readCollection";
import { readDatabases } from "../Common/dataAccess/readDatabases";
import { isPublicInternetAccessAllowed } from "../Common/DatabaseAccountUtility";
@@ -24,12 +25,6 @@ import * as TelemetryProcessor from "../Shared/Telemetry/TelemetryProcessor";
import { userContext } from "../UserContext";
import { getCollectionName, getDatabaseName, getUploadName } from "../Utils/APITypeUtils";
import { update } from "../Utils/arm/generatedClients/cosmos/databaseAccounts";
import {
get as getWorkspace,
listByDatabaseAccount,
listConnectionInfo,
start,
} from "../Utils/arm/generatedClients/cosmosNotebooks/notebookWorkspaces";
import { getAuthorizationHeader } from "../Utils/AuthorizationUtils";
import { stringToBlob } from "../Utils/BlobUtils";
import { isCapabilityEnabled } from "../Utils/CapabilityUtils";
@@ -69,6 +64,8 @@ import StoredProcedure from "./Tree/StoredProcedure";
import { useDatabases } from "./useDatabases";
import { useSelectedNode } from "./useSelectedNode";
BindingHandlersRegisterer.registerBindingHandlers();
// Hold a reference to ComponentRegisterer to prevent transpiler to ignore import
var tmp = ComponentRegisterer;
@@ -458,16 +455,35 @@ export default class Explorer {
this._isInitializingNotebooks = true;
await this.ensureNotebookWorkspaceRunning();
/*
const connectionInfo = await listConnectionInfo(
userContext.subscriptionId,
userContext.resourceGroup,
databaseAccount.name,
"default"
);
*/
const provisionData = {
cosmosEndpoint: userContext.databaseAccount.properties.documentEndpoint,
resourceId: userContext.databaseAccount.id,
dbAccountName: userContext.databaseAccount.name,
aadToken: userContext.authorizationToken,
resourceGroup: userContext.resourceGroup,
subscriptionId: userContext.subscriptionId
}
const response = await window.fetch("http://localhost:443/api/containerpooling/provision", {
method: "POST",
headers: {
[HttpHeaders.contentType]: "application/json",
},
body: JSON.stringify(provisionData)
})
var notebookServerInfo = await response.json();
this.notebookServerInfo({
notebookServerEndpoint: userContext.features.notebookServerUrl || connectionInfo.notebookServerEndpoint,
authToken: userContext.features.notebookServerToken || connectionInfo.authToken,
notebookServerEndpoint: userContext.features.notebookServerUrl || notebookServerInfo.notebookServerUrl,
authToken: userContext.features.notebookServerToken || notebookServerInfo.notebookServerToken,
});
this.notebookServerInfo.valueHasMutated();
this.refreshNotebookList();
@@ -501,6 +517,7 @@ export default class Explorer {
return false;
}
/*
try {
const { value: workspaces } = await listByDatabaseAccount(
userContext.subscriptionId,
@@ -512,6 +529,8 @@ export default class Explorer {
Logger.logError(getErrorMessage(error), "Explorer/_containsDefaultNotebookWorkspace");
return false;
}
*/
return true
}
private async ensureNotebookWorkspaceRunning() {
@@ -519,6 +538,7 @@ export default class Explorer {
return;
}
/*
let clearMessage;
try {
const notebookWorkspace = await getWorkspace(
@@ -541,6 +561,7 @@ export default class Explorer {
} finally {
clearMessage && clearMessage();
}
*/
}
private _resetNotebookWorkspace = async () => {
@@ -1131,6 +1152,10 @@ export default class Explorer {
title = "Cassandra Shell";
break;
case ViewModels.TerminalKind.PostgreSQL:
title = "PostgreSQL Shell";
break;
default:
throw new Error("Terminal kind: ${kind} not supported");
}

View File

@@ -74,18 +74,17 @@ export function createStaticCommandBarButtons(
buttons.push(createOpenTerminalButton(container));
buttons.push(createNotebookWorkspaceResetButton(container));
if (
(userContext.apiType === "Mongo" &&
container.isShellEnabled() &&
selectedNodeState.isDatabaseNodeOrNoneSelected()) ||
userContext.apiType === "Cassandra"
) {
buttons.push(createDivider());
if (userContext.apiType === "Cassandra") {
buttons.push(createOpenCassandraTerminalButton(container));
} else {
buttons.push(createOpenPostgreSQLTerminalButton(container));
if (userContext.apiType === "Mongo" &&
container.isShellEnabled() &&
selectedNodeState.isDatabaseNodeOrNoneSelected()){
buttons.push(createOpenMongoTerminalButton(container));
}
if (userContext.apiType === "Cassandra") {
buttons.push(createOpenCassandraTerminalButton(container));
}
} else {
if (!isRunningOnNationalCloud()) {
@@ -468,6 +467,19 @@ function createOpenTerminalButton(container: Explorer): CommandButtonComponentPr
};
}
function createOpenPostgreSQLTerminalButton(container: Explorer): CommandButtonComponentProps {
const label = "Open PostgreSQL Shell";
return {
iconSrc: HostedTerminalIcon,
iconAlt: label,
onCommandClick: () => container.openNotebookTerminal(ViewModels.TerminalKind.PostgreSQL),
commandButtonLabel: label,
hasPopup: false,
disabled: false,
ariaLabel: label,
};
}
function createOpenMongoTerminalButton(container: Explorer): CommandButtonComponentProps {
const label = "Open Mongo Shell";
const tooltip =

View File

@@ -9,7 +9,7 @@ import {
KernelRef,
RemoteKernelProps,
selectors,
ServerConfig as JupyterServerConfig,
ServerConfig as JupyterServerConfig
} from "@nteract/core";
import { Channels, childOf, createMessage, JupyterMessage, message, ofMessageType } from "@nteract/messaging";
import { RecordOf } from "immutable";
@@ -29,7 +29,7 @@ import {
switchMap,
take,
tap,
timeout,
timeout
} from "rxjs/operators";
import { webSocket } from "rxjs/webSocket";
import * as Constants from "../../../Common/Constants";
@@ -107,7 +107,7 @@ const formWebSocketURL = (serverConfig: NotebookServiceConfig, kernelId: string,
const q = params.toString();
const suffix = q !== "" ? `?${q}` : "";
const url = (serverConfig.endpoint || "") + `api/kernels/${kernelId}/channels${suffix}`;
const url = (serverConfig.endpoint.slice(0, -1) || "") + `api/kernels/${kernelId}/channels${suffix}`;
return url.replace(/^http(s)?/, "ws$1");
};

View File

@@ -6,7 +6,6 @@ import { getErrorMessage } from "../../Common/ErrorHandlingUtils";
import * as Logger from "../../Common/Logger";
import * as DataModels from "../../Contracts/DataModels";
import { userContext } from "../../UserContext";
import { createOrUpdate, destroy } from "../../Utils/arm/generatedClients/cosmosNotebooks/notebookWorkspaces";
import { logConsoleProgress } from "../../Utils/NotificationConsoleUtils";
export class NotebookContainerClient {
@@ -54,7 +53,7 @@ export class NotebookContainerClient {
const { notebookServerEndpoint, authToken } = this.getNotebookServerConfig();
try {
const response = await fetch(`${notebookServerEndpoint}/api/metrics/memory`, {
const response = await fetch(`${notebookServerEndpoint}api/metrics/memory`, {
method: "GET",
headers: {
Authorization: authToken,
@@ -135,6 +134,7 @@ export class NotebookContainerClient {
if (!databaseAccount?.id) {
throw new Error("DataExplorer not initialized");
}
/*
try {
await destroy(userContext.subscriptionId, userContext.resourceGroup, userContext.databaseAccount.name, "default");
await createOrUpdate(
@@ -147,5 +147,6 @@ export class NotebookContainerClient {
Logger.logError(getErrorMessage(error), "NotebookContainerClient/recreateNotebookWorkspaceAsync");
return Promise.reject(error);
}
*/
}
}

View File

@@ -12,7 +12,7 @@ export class NotebookContentClient {
private notebookServerInfo: ko.Observable<DataModels.NotebookWorkspaceConnectionInfo>,
public notebookBasePath: ko.Observable<string>,
private contentProvider: IContentProvider
) {}
) { }
/**
* This updates the item and points all the children's parent to this item
@@ -25,6 +25,9 @@ export class NotebookContentClient {
});
}
private sleep = (milliseconds: number) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
/**
*
* @param parent parent folder
@@ -35,6 +38,7 @@ export class NotebookContentClient {
}
const type = "notebook";
return this.contentProvider
.create<"notebook">(this.getServerConfig(), parent.path, { type })
.toPromise()

View File

@@ -14,7 +14,6 @@ import SaveIcon from "../../../images/save-cosmos.svg";
import { useNotebookSnapshotStore } from "../../hooks/useNotebookSnapshotStore";
import { Action, ActionModifiers, Source } from "../../Shared/Telemetry/TelemetryConstants";
import * as TelemetryProcessor from "../../Shared/Telemetry/TelemetryProcessor";
import * as NotebookConfigurationUtils from "../../Utils/NotebookConfigurationUtils";
import { logConsoleInfo } from "../../Utils/NotificationConsoleUtils";
import { CommandButtonComponentProps } from "../Controls/CommandButton/CommandButtonComponent";
import * as CommandBarComponentButtonFactory from "../Menus/CommandBar/CommandBarComponentButtonFactory";
@@ -361,12 +360,14 @@ export default class NotebookTabV2 extends NotebookTabBase {
private async configureServiceEndpoints(kernelName: string) {
const notebookConnectionInfo = this.container && this.container.notebookServerInfo();
const sparkClusterConnectionInfo = this.container && this.container.sparkClusterConnectionInfo();
/*
await NotebookConfigurationUtils.configureServiceEndpoints(
this.notebookPath(),
notebookConnectionInfo,
kernelName,
sparkClusterConnectionInfo
);
*/
}
private publishToGallery = async () => {

View File

@@ -91,6 +91,10 @@ export default class TerminalTab extends TabsBase {
endpointSuffix = "cassandra";
break;
case ViewModels.TerminalKind.PostgreSQL:
endpointSuffix = "postgreSQL";
break;
default:
throw new Error(`Terminal kind: ${options.kind} not supported`);
}