protected override void Execute(CodeActivityContext activityContext)
        {
            QueryPartitionBase querypartition = QueryPartition.Get(activityContext);

            using (Context context = querypartition.Query.CreateContext(this, activityContext, ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                querypartition.InitializeQueryObject(context);
                querypartition.FindRemoteTableReferences();
            }
        }
        protected override void Execute(CodeActivityContext activityContext)
        {
            QueryPartitionBase queryPartition = QueryPartition.Get(activityContext);

            switch (queryPartition.Query.ExecutionMode)
            {
            case ExecutionMode.SingleServer:
                queryPartition.InitializeQueryObject(null, null, true);
                break;

            case ExecutionMode.Graywulf:
                using (var context = ContextManager.Instance.CreateContext(this, activityContext, ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
                {
                    var scheduler = activityContext.GetExtension <IScheduler>();

                    //queryPartition.DatabaseVersionName = queryPartition.Query.SourceDatabaseVersionName; TODO: delete
                    queryPartition.InitializeQueryObject(context, scheduler, false);

                    var dss = queryPartition.FindRequiredDatasets();

                    // Check if there are any Graywulf datasets referenced in the query
                    var assignmydb = (dss.Values.FirstOrDefault(ds => !ds.IsSpecificInstanceRequired) == null);

                    // *** TODO: replace this whole thing to use JOIN graphs
                    // If no graywulf datasets are used, use the server containing myDB,
                    // otherwise ask the scheduler for an appropriate server
                    if (dss.Count == 0 || assignmydb)
                    {
                        // use MyDB's server
                        var ef         = new EntityFactory(context);
                        var federation = queryPartition.FederationReference.Value;
                        var user       = ef.LoadEntity <User>(context.UserGuid);
                        var di         = federation.MyDBDatabaseVersion.GetUserDatabaseInstance(user);

                        queryPartition.AssignedServerInstance = di.ServerInstance;
                    }
                    else
                    {
                        // Assign new server instance
                        var si = new ServerInstance(context);
                        si.Guid = scheduler.GetNextServerInstance(
                            dss.Values.Where(x => !x.IsSpecificInstanceRequired).Select(x => x.DatabaseDefinition.Guid).ToArray(),
                            queryPartition.Query.SourceDatabaseVersionName,
                            null);
                        si.Load();

                        queryPartition.AssignedServerInstance = si;
                    }

                    queryPartition.InitializeQueryObject(context, scheduler, true);
                    EntityGuid.Set(activityContext, queryPartition.AssignedServerInstance.Guid);
                }
                break;
            }
        }
        protected override void Execute(CodeActivityContext activityContext)
        {
            QueryPartitionBase queryPartition = QueryPartition.Get(activityContext);
            QueryBase          query          = queryPartition.Query;

            using (Context context = queryPartition.CreateContext(this, activityContext, ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                query.InitializeQueryObject(context);
                queryPartition.PrepareDestinationTable(context, activityContext.GetExtension <IScheduler>());
            }
        }
Example #4
0
        protected override void Execute(CodeActivityContext activityContext)
        {
            QueryPartitionBase querypartition = QueryPartition.Get(activityContext);

            using (Context context = querypartition.Query.CreateContext(this, activityContext, ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                querypartition.InitializeQueryObject(context);
            }

            querypartition.DropTemporaryTables();
            querypartition.DropTemporaryViews();
        }
Example #5
0
        private void CopyMembers(QueryPartitionBase old)
        {
            this.id = old.id;

            this.query = old.query;

            this.partitioningKeyFrom = old.partitioningKeyFrom;
            this.partitioningKeyTo   = old.partitioningKeyTo;

            this.tableSourceReferences = new Dictionary <string, TableReference>(old.tableSourceReferences, SchemaManager.Comparer);
            this.remoteTableReferences = new Dictionary <string, TableReference>(old.remoteTableReferences, SchemaManager.Comparer);
        }
Example #6
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext activityContext, AsyncCallback callback, object state)
        {
            QueryPartitionBase querypartition = QueryPartition.Get(activityContext);

            using (var context = querypartition.Query.CreateContext(this, activityContext, ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                querypartition.PrepareCopyResultset(context);
            }

            Guid   workflowInstanceGuid = activityContext.WorkflowInstanceId;
            string activityInstanceId   = activityContext.ActivityInstanceId;

            return(EnqueueAsync(_ => OnAsyncExecute(workflowInstanceGuid, activityInstanceId, querypartition), callback, state));
        }
Example #7
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext activityContext, AsyncCallback callback, object state)
        {
            QueryPartitionBase querypartition = (QueryPartitionBase)QueryPartition.Get(activityContext);

            TableReference   remotetable = null;
            SourceTableQuery source;

            using (Context context = querypartition.Query.CreateContext(this, activityContext, ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                remotetable = querypartition.RemoteTableReferences[RemoteTable.Get(activityContext)];
                source      = querypartition.PrepareCopyRemoteTable(remotetable);
            }

            Guid   workflowInstanceGuid = activityContext.WorkflowInstanceId;
            string activityInstanceId   = activityContext.ActivityInstanceId;

            return(EnqueueAsync(_ => OnAsyncExecute(workflowInstanceGuid, activityInstanceId, querypartition, remotetable, source), callback, state));
        }
Example #8
0
        private void CopyMembers(QueryPartitionBase old)
        {
            this.id = old.id;

            this.query = old.query;

            this.partitioningKeyFrom = old.partitioningKeyFrom;
            this.partitioningKeyTo = old.partitioningKeyTo;

            this.tableSourceReferences = new Dictionary<string, TableReference>(old.tableSourceReferences, SchemaManager.Comparer);
            this.remoteTableReferences = new Dictionary<string, TableReference>(old.remoteTableReferences, SchemaManager.Comparer);
        }
Example #9
0
 public QueryPartitionBase(QueryPartitionBase old)
     : base(old)
 {
     CopyMembers(old);
 }
Example #10
0
 protected void AppendPartition(QueryPartitionBase partition)
 {
     partitions.Add(partition);
 }
Example #11
0
 public QueryPartitionBase(QueryPartitionBase old)
     : base(old)
 {
     CopyMembers(old);
 }
Example #12
0
 private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, QueryPartitionBase querypartition, TableReference remotetable, SourceQueryParameters source)
 {
     RegisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition);
     querypartition.CopyRemoteTable(remotetable, source);
     UnregisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition);
 }
Example #13
0
 protected void AppendPartition(QueryPartitionBase partition)
 {
     partition.ID = partitions.Count;
     partitions.Add(partition);
 }
Example #14
0
 private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, QueryPartitionBase querypartition)
 {
     RegisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition);
     querypartition.CopyResultset();
     UnregisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition);
 }
Example #15
0
 private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, QueryPartitionBase querypartition)
 {
     RegisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition);
     querypartition.CopyResultset();
     UnregisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition);
 }
Example #16
0
 private void OnAsyncExecute(Guid workflowInstanceGuid, string activityInstanceId, QueryPartitionBase querypartition, TableReference remotetable, SourceTableQuery source)
 {
     RegisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition);
     querypartition.CopyRemoteTable(remotetable, source);
     UnregisterCancelable(workflowInstanceGuid, activityInstanceId, querypartition);
 }