Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generic way to support scriptable operations #438

Merged
merged 7 commits into from
Aug 18, 2017

Conversation

llali
Copy link
Member

@llali llali commented Aug 17, 2017

  • Any operation that's using SMO and is managed by task manager can now implement SmoScriptableTaskOperation so that the operation either execute, generate script or both

  • Any scriptable request can implement IScriptableRequestParams to that it gets TaskExecutionMode from client. If using the task manager, the execution mode will be passed to the sql task to either execute or generate script

  • Changed restore to use the new classes so that it support scripting

-TODO: I didn't refactor backup to use the new classes, I can do that next if the new contract sign off by reviewers

@llali llali changed the title implemented a generic way to support scriptable operations generic way to support scriptable operations Aug 17, 2017
public SqlTask()
{
}

Copy link
Contributor

@AbbiePetcht AbbiePetcht Aug 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create SQLtask with no params? If so, please write comment #Resolved

@coveralls
Copy link

Coverage Status

Coverage decreased (-20.1%) to 46.228% when pulling 86ba71d on feature/restoreGenerateScript into 3915688 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 66.435% when pulling 751764c on feature/restoreGenerateScript into 3915688 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 66.404% when pulling 751764c on feature/restoreGenerateScript into 3915688 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-12.7%) to 53.624% when pulling 24baa6b on feature/restoreGenerateScript into 3915688 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 66.439% when pulling 24baa6b on feature/restoreGenerateScript into 3915688 on master.

{
get
{
return string.Empty;
Copy link
Member

@kburtram kburtram Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point of this property? #WontFix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the error message to IBackupOperation so that the task manager get the error of the operation but didn't integrate the new changes with backup


In reply to: 134057582 [](ancestors = 134057582)

{
get
{
return TargetDatabaseName;
Copy link
Member

@kburtram kburtram Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have a property that gets & sets another property? Should we remove this property or the other one? #WontFix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the DatabaseName to the request base class assuming all requests will have a database name field. TargetDatabase is the same as DatabaseName if restore so that's why I'm implementing it this way


In reply to: 134058351 [](ancestors = 134058351)

if(mode == TaskExecutionMode.Script || mode == TaskExecutionMode.ExecuteAndScript)
{
this.ScriptContent = GetScriptContent();
if(SqlTask != null)
Copy link
Member

@kburtram kburtram Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing space between 'f' and '(' per coding guidelines. #Resolved

Copy link
Contributor

@kevcunnane kevcunnane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things I'd like to see improved but overall :shipit: assuming you take a run at fixing these.

@@ -1,6 +1,6 @@
[![Travis CI](https://travis-ci.org/Microsoft/sqltoolsservice.svg?branch=dev)](https://travis-ci.org/Microsoft/sqltoolsservice)
[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/Microsoft/sqltoolsservice?svg=true&retina=true&branch=dev)](https://ci.appveyor.com/project/kburtram/sqltoolsservice)
[![Coverage Status](https://coveralls.io/repos/github/Microsoft/sqltoolsservice/badge.svg?branch=dev)](https://coveralls.io/github/Microsoft/sqltoolsservice?branch=dev)
[![Coverage Status](https://coveralls.io/repos/github/Microsoft/sqltoolsservice/badge.svg?branch=dev)](https://coveralls.io/github/Microsoft/sqltoolsservice?branch=master)
Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch :) #WontFix

@@ -163,6 +163,16 @@ public string ScriptContent
}
}

public string ErrorMessage
Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: please add doc comments to public properties #Resolved

metadata.Name = SR.RestoreTaskName;
metadata.IsCancelable = true;
metadata.Data = restoreDataObject;
TaskMetadata metadata = TaskMetadata.Create(restoreParams, SR.RestoreTaskName, restoreDataObject, ConnectionServiceInstance);
Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens to IsCancelable? Is the default True and you just override or don't? #Pending

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it from here and if the cancel function is defined I assume it's cancelable


In reply to: 134042668 [](ancestors = 134042668)

{
if (SqlTask != null)
restorePlan.PercentComplete += (object sender, PercentCompleteEventArgs e) =>
Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. So do we have this hooked up to the front end so you can see latest status in the task viewlet? #WontFix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not yet, the task manager needs to show the messages


In reply to: 134043131 [](ancestors = 134043131)

{
foreach (Restore restore in RestorePlan.RestoreOperations)
{
restore.Abort();
Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So after everything is canceled, when do we send the overall task canceled message / exception? #WontFix

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CancelTaskAsync does that after calling this method


In reply to: 134043367 [](ancestors = 134043367)


namespace Microsoft.SqlTools.ServiceLayer.TaskServices
{
public class SqlTaskOpration
Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add doc comments #WontFix

@@ -3,6 +3,8 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System;
Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? #Resolved

/// <summary>
/// The function to run
/// </summary>
public Func<SqlTask, Task<TaskResult>> TaskToRun
Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Call this RunTask as you'll use it like taskResult = taskOperation.RunTask(task) #WontFix

/// <summary>
/// The function to cancel the operation
/// </summary>
public Func<SqlTask, Task<TaskResult>> TaskToCancel
Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Call this CancelTask as you'll use it like taskResult = taskOperation.CancelTask(task) #WontFix

{
ITaskOperation taskOperation = sqlTask.TaskMetadata.TaskOperation as ITaskOperation;
TaskResult taskResult = null;

Copy link
Contributor

@kevcunnane kevcunnane Aug 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: remove unnecessary whitespace #Resolved

@@ -3,6 +3,8 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//

using System;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this?


// create restore task and perform
SqlTask sqlTask = SqlTaskManagerInstance.CreateAndRun(metadata, this.restoreDatabaseService.RestoreTaskAsync, restoreDatabaseService.CancelTaskAsync);
SqlTask sqlTask = SqlTaskManagerInstance.CreateAndRun<SqlTask>(metadata);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are we setting restore's CancelTask in SqlTask?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.09%) to 66.43% when pulling 21b3793 on feature/restoreGenerateScript into 3915688 on master.

@llali llali merged commit 39dedd8 into master Aug 18, 2017
@llali llali deleted the feature/restoreGenerateScript branch August 21, 2017 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants