/// <summary>
        /// Enlists a dependency property value into this storyboard instance.
        /// </summary>
        /// <param name="dpValue">The dependency property value to enlist.</param>
        /// <param name="animation">The animation to apply to the dependency property.</param>
        internal void Enlist(IDependencyPropertyValue dpValue, AnimationBase animation)
        {
            Contract.Require(dpValue, "dpValue");

            var enlistment = new Enlistment(dpValue, animation);
            enlistedDependencyProperties.Add(enlistment);
        }
 private void ConfigureEnlistment()
 {
     Enlistment enlistment = new Enlistment {
         ProtocolProviderContext = this
     };
     base.enlistment = enlistment;
 }
        private void ConfigureEnlistment(WsatRegistrationHeader header)
        {
            Enlistment enlistment = new Enlistment();
            string contextId = header.ContextId;
            if (contextId == null)
            {
                contextId = CoordinationContext.CreateNativeIdentifier(header.TransactionId);
            }
            enlistment.LocalTransactionId = header.TransactionId;
            enlistment.RemoteTransactionId = contextId;
            Notifications twoPhaseCommit = Notifications.TwoPhaseCommit;
            switch (this.protocol)
            {
                case Microsoft.Transactions.Wsat.Messaging.ControlProtocol.Volatile2PC:
                    twoPhaseCommit |= Notifications.Volatile | Notifications.Phase0;
                    break;

                case Microsoft.Transactions.Wsat.Messaging.ControlProtocol.Durable2PC:
                    break;

                default:
                    Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Invalid protocol");
                    break;
            }
            enlistment.NotificationMask = twoPhaseCommit;
            enlistment.ProtocolProviderContext = this;
            base.enlistment = enlistment;
        }
 public ParticipantEnlistment(ProtocolState state, Enlistment coordinatorEnlistment, TransactionContextManager contextManager) : base(state)
 {
     this.protocol = Microsoft.Transactions.Wsat.Messaging.ControlProtocol.Volatile2PC;
     base.ourContextManager = contextManager;
     base.enlistment = new Enlistment();
     base.enlistment.LocalTransactionId = coordinatorEnlistment.LocalTransactionId;
     base.enlistment.RemoteTransactionId = coordinatorEnlistment.RemoteTransactionId;
     base.enlistment.NotificationMask = Notifications.Volatile | Notifications.TwoPhaseCommit;
     base.enlistment.ProtocolProviderContext = this;
     base.stateMachine = new SubordinateStateMachine(this);
     base.stateMachine.ChangeState(state.States.SubordinateInitializing);
 }
 private void ConfigureEnlistment(CoordinationContext context)
 {
     Enlistment enlistment = new Enlistment();
     string identifier = context.Identifier;
     if (identifier == null)
     {
         Microsoft.Transactions.Bridge.DiagnosticUtility.FailFast("Need transactionId to create enlistment");
     }
     enlistment.RemoteTransactionId = identifier;
     enlistment.LocalTransactionId = Ports.GetGuidFromTransactionId(identifier);
     enlistment.ProtocolProviderContext = this;
     base.enlistment = enlistment;
 }
 public void Forget(Enlistment enlistment, ProtocolProviderCallback callback, object obj)
 {
     ParticipantEnlistment protocolProviderContext = enlistment.ProtocolProviderContext as ParticipantEnlistment;
     if (protocolProviderContext != null)
     {
         protocolProviderContext.StateMachine.Enqueue(new TmParticipantForgetEvent(protocolProviderContext, callback, obj));
     }
     else
     {
         CoordinatorEnlistment coordinator = (CoordinatorEnlistment) enlistment.ProtocolProviderContext;
         coordinator.StateMachine.Enqueue(new TmCoordinatorForgetEvent(coordinator, callback, obj));
     }
 }
 public ParticipantEnlistment(ProtocolState state, Enlistment enlistment, Guid enlistmentId, EndpointAddress service) : base(state, enlistmentId)
 {
     base.enlistment = enlistment;
     base.enlistment.ProtocolProviderContext = this;
     this.protocol = Microsoft.Transactions.Wsat.Messaging.ControlProtocol.Durable2PC;
     base.stateMachine = new DurableStateMachine(this);
     this.participantProxy = state.TryCreateTwoPhaseCommitParticipantProxy(service);
     if (this.participantProxy == null)
     {
         if (RecoveredParticipantInvalidMetadataRecord.ShouldTrace)
         {
             RecoveredParticipantInvalidMetadataRecord.Trace(base.enlistmentId, enlistment.RemoteTransactionId, service, base.state.ProtocolVersion);
         }
         base.stateMachine.ChangeState(state.States.DurableFailedRecovery);
     }
     else
     {
         base.stateMachine.ChangeState(state.States.DurableRecovering);
     }
     base.AddToLookupTable();
 }
 public CoordinatorEnlistment(ProtocolState state, Enlistment enlistment, Guid enlistmentId, EndpointAddress service) : base(state, enlistmentId)
 {
     base.enlistment = enlistment;
     base.enlistment.ProtocolProviderContext = this;
     this.recoveredCoordinatorService = service;
     base.stateMachine = new CoordinatorStateMachine(this);
     base.coordinatorProxy = state.TryCreateTwoPhaseCommitCoordinatorProxy(service);
     if (base.coordinatorProxy == null)
     {
         if (RecoveredCoordinatorInvalidMetadataRecord.ShouldTrace)
         {
             RecoveredCoordinatorInvalidMetadataRecord.Trace(base.enlistmentId, enlistment.RemoteTransactionId, service, base.state.ProtocolVersion);
         }
         base.stateMachine.ChangeState(state.States.CoordinatorFailedRecovery);
     }
     else
     {
         base.stateMachine.ChangeState(state.States.CoordinatorRecovering);
     }
     base.AddToLookupTable();
 }
 public static void SubordinateRegisterResponse(Enlistment enlistment, Status status, object obj)
 {
     InternalEnlistSubordinateTransactionEvent source = (InternalEnlistSubordinateTransactionEvent) obj;
     ParticipantEnlistment protocolProviderContext = (ParticipantEnlistment) enlistment.ProtocolProviderContext;
     protocolProviderContext.StateMachine.Enqueue(new TmSubordinateRegisterResponseEvent(protocolProviderContext, status, source));
 }
Beispiel #10
0
        public static bool TryLoadPathWhitelist(ITracer tracer, string pathWhitelistInput, string pathWhitelistFile, Enlistment enlistment, List <string> pathWhitelistOutput)
        {
            Func <string, string> makePathAbsolute = path => Path.Combine(enlistment.EnlistmentRoot, path.Replace('/', '\\').TrimStart('\\'));

            pathWhitelistOutput.AddRange(pathWhitelistInput.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(makePathAbsolute));

            if (!string.IsNullOrWhiteSpace(pathWhitelistFile))
            {
                if (File.Exists(pathWhitelistFile))
                {
                    IEnumerable <string> allLines = File.ReadAllLines(pathWhitelistFile)
                                                    .Select(line => line.Trim())
                                                    .Where(line => !string.IsNullOrEmpty(line))
                                                    .Where(line => !line.StartsWith(GVFSConstants.GitCommentSignString))
                                                    .Select(makePathAbsolute);

                    pathWhitelistOutput.AddRange(allLines);
                }
                else
                {
                    tracer.RelatedError("Could not find '{0}' for folder filtering.", pathWhitelistFile);
                    Console.WriteLine("Could not find '{0}' for folder filtering.", pathWhitelistFile);
                    return(false);
                }
            }

            pathWhitelistOutput.RemoveAll(string.IsNullOrWhiteSpace);
            return(true);
        }
 public static void RegisterResponse(Enlistment enlistment, Status status, object obj)
 {
     MsgRegisterEvent source = (MsgRegisterEvent) obj;
     ParticipantEnlistment protocolProviderContext = (ParticipantEnlistment) enlistment.ProtocolProviderContext;
     protocolProviderContext.StateMachine.Enqueue(new TmRegisterResponseEvent(protocolProviderContext, status, source));
 }
Beispiel #12
0
        public void Execute()
        {
            // CmdParser doesn't strip quotes, and Path.Combine will throw
            this.GitBinPath = this.GitBinPath.Replace("\"", string.Empty);
            if (!GitProcess.GitExists(this.GitBinPath))
            {
                Console.WriteLine(
                    "Could not find git.exe {0}",
                    !string.IsNullOrWhiteSpace(this.GitBinPath) ? "at " + this.GitBinPath : "on %PATH%");
                return;
            }

            if (this.Commit != null && this.Branch != null)
            {
                Console.WriteLine("Cannot specify both a commit sha and a branch name to checkout.");
                return;
            }

            this.CacheServerUrl = Enlistment.StripObjectsEndpointSuffix(this.CacheServerUrl);

            this.SearchThreadCount   = this.SearchThreadCount > 0 ? this.SearchThreadCount : Environment.ProcessorCount;
            this.DownloadThreadCount = this.DownloadThreadCount > 0 ? this.DownloadThreadCount : Environment.ProcessorCount;
            this.IndexThreadCount    = this.IndexThreadCount > 0 ? this.IndexThreadCount : Environment.ProcessorCount;
            this.CheckoutThreadCount = this.CheckoutThreadCount > 0 ? this.CheckoutThreadCount : Environment.ProcessorCount;

            this.GitBinPath = !string.IsNullOrWhiteSpace(this.GitBinPath) ? this.GitBinPath : GitProcess.GetInstalledGitBinPath();

            Enlistment enlistment = (Enlistment)GVFSEnlistment.CreateFromCurrentDirectory(this.CacheServerUrl, this.GitBinPath)
                                    ?? GitEnlistment.CreateFromCurrentDirectory(this.CacheServerUrl, this.GitBinPath);

            if (enlistment == null)
            {
                Console.WriteLine("Must be run within a .git repo or GVFS enlistment");
                return;
            }

            string commitish = this.Commit ?? this.Branch ?? DefaultBranch;

            EventLevel maxVerbosity = this.Silent ? EventLevel.LogAlways : EventLevel.Informational;

            using (JsonEtwTracer tracer = new JsonEtwTracer("Microsoft.Git.FastFetch", "FastFetch"))
            {
                tracer.AddConsoleEventListener(maxVerbosity, Keywords.Any);
                tracer.WriteStartEvent(
                    enlistment.EnlistmentRoot,
                    enlistment.RepoUrl,
                    enlistment.CacheServerUrl,
                    new EventMetadata
                {
                    { "TargetCommitish", commitish },
                });

                FetchHelper fetchHelper = this.GetFetchHelper(tracer, enlistment);

                fetchHelper.MaxRetries = this.MaxRetries;

                if (!FetchHelper.TryLoadPathWhitelist(this.PathWhitelist, this.PathWhitelistFile, tracer, fetchHelper.PathWhitelist))
                {
                    Environment.ExitCode = 1;
                    return;
                }

                try
                {
                    bool isBranch = this.Commit == null;
                    fetchHelper.FastFetch(commitish, isBranch);
                    if (fetchHelper.HasFailures)
                    {
                        Environment.ExitCode = 1;
                    }
                }
                catch (AggregateException e)
                {
                    Environment.ExitCode = 1;
                    foreach (Exception ex in e.Flatten().InnerExceptions)
                    {
                        tracer.RelatedError(ex.ToString());
                    }
                }
                catch (Exception e)
                {
                    Environment.ExitCode = 1;
                    tracer.RelatedError(e.ToString());
                }

                EventMetadata stopMetadata = new EventMetadata();
                stopMetadata.Add("Success", Environment.ExitCode == 0);
                tracer.Stop(stopMetadata);
            }

            if (Debugger.IsAttached)
            {
                Console.ReadKey();
            }
        }
 public PrefetchGitObjects(ITracer tracer, Enlistment enlistment, GitObjectsHttpRequestor objectRequestor, PhysicalFileSystem fileSystem = null) : base(tracer, enlistment, objectRequestor, fileSystem)
 {
 }
Beispiel #14
0
 public void InDoubt(Enlistment enlistment)
 {
     Assert.Equal(_expectedOutcome, EnlistmentOutcome.InDoubt);
     enlistment.Done();
 }
 public void Rollback(Enlistment enlistment)
 {
     Trace("MyEnlistment.Rollback");
     _aborted = true;
     enlistment.Done();
     _outcomeReceived.Set();
 }
Beispiel #16
0
        public void Rollback(Enlistment enlistment)
        {
            receivedMessage.SafeAbandon();

            enlistment.Done();
        }
Beispiel #17
0
 public void Commit(Enlistment enlistment)
 {
     enlistment.Done();
 }
 /// <summary>
 /// Used to notify an enlisted resource manager that the transaction is in doubt.
 /// </summary>
 /// <remarks>
 /// A transaction is in doubt if it has not received votes from all enlisted resource managers
 /// as to the state of the transaciton.
 /// </remarks>
 /// <param name="enlistment">The enlistment class used to communicate with the resource manager.</param>
 public void InDoubt(Enlistment enlistment)
 {
     Rollback(enlistment);
 }
Beispiel #19
0
        public void Commit(Enlistment enlistment)
        {
            receivedMessage.SafeComplete();

            enlistment.Done();
        }
 /// <summary>
 /// Used to notify an enlisted resource manager that the transaction is being committed.
 /// </summary>
 /// <param name="enlistment">The enlistment class used to communicate with the resource manager.</param>
 public void Commit(Enlistment enlistment)
 {
     Commit();
     m_dicEnlistments.Remove(CurrentTransaction.TransactionInformation.LocalIdentifier);
     enlistment.Done();
 }
Beispiel #21
0
 public static Result SparseCheckoutInit(Enlistment enlistment)
 {
     return(new GitProcess(enlistment).InvokeGitInWorkingDirectoryRoot("sparse-checkout init --cone", fetchMissingObjects: true));
 }
 public void Rollback(Enlistment enlistment)
 {
     // Restore previous state
     _memberValue    = _oldMemberValue;
     _oldMemberValue = 0;
 }
Beispiel #23
0
 public void Rollback(Enlistment enlistment)
 {
     Assert.Equal(_expectedOutcome, EnlistmentOutcome.Aborted);
     if (_outcomeReceived != null)
     {
         _outcomeReceived.Set();
     }
     enlistment.Done();
 }
Beispiel #24
0
 public void Rollback(Enlistment enlistment)
 {
     Rollback();
 }
Beispiel #25
0
 public void Commit(Enlistment enlistment)
 {
     Assert.Equal(_expectedOutcome, EnlistmentOutcome.Committed);
     enlistment.Done();
 }
 public void InDoubt(Enlistment enlistment)
 {
     throw new NotSupportedException("In Doubt transactions are not supported");
 }
 public void Commit(Enlistment enlistment)
 {
     Trace("MyEnlistment.Commit");
     _committed = true;
     enlistment.Done();
     _outcomeReceived.Set();
 }
Beispiel #28
0
 public void Commit(Enlistment enlistment)
 {
     //TODO: Ostateczna akcja mająca zatwierdzić zmiany. Powinna wykoanać się zawsze bez błędu.
     CommitAction();
     enlistment.Done();
 }
 public void InDoubt(Enlistment enlistment)
 {
     throw new NotImplementedException();
 }
Beispiel #30
0
 public void Rollback(Enlistment enlistment)
 {
     RollbackAction();
     enlistment.Done();
 }
 public void InDoubt(Enlistment enlistment)
 {
 }
Beispiel #32
0
 public void InDoubt(Enlistment enlistment)
 {
     InDoubtAction();
     enlistment.Done();
 }
Beispiel #33
0
 public void Commit(Enlistment enlistment)
 {
     _Forget();
     enlistment.Done();
 }
Beispiel #34
0
 public ConfigHttpRequestor(ITracer tracer, Enlistment enlistment, RetryConfig retryConfig)
     : base(tracer, retryConfig, enlistment.Authentication)
 {
     this.repoUrl = enlistment.RepoUrl;
 }
 public static void PrePrepareResponse(Enlistment enlistment, Status status, object obj)
 {
     VolatileCoordinatorEnlistment coordinator = (VolatileCoordinatorEnlistment) obj;
     coordinator.StateMachine.Enqueue(new TmPrePrepareResponseEvent(coordinator, status));
 }
 private void ValidateIsNone(Enlistment enlistment, CacheServerInfo cacheServer)
 {
     cacheServer.Url.ShouldEqual(enlistment.RepoUrl);
     cacheServer.Name.ShouldEqual(CacheServerInfo.ReservedNames.None);
 }
 public static void RollbackResponse(Enlistment enlistment, Status status, object obj)
 {
     TransactionEnlistment enlistment2 = (TransactionEnlistment) obj;
     enlistment2.StateMachine.Enqueue(new TmRollbackResponseEvent(enlistment2, status));
 }
 public void Commit(Enlistment enlistment)
 {
     throw new NotImplementedException();
 }
 public static void CommitResponse(Enlistment enlistment, Status status, object obj)
 {
     CoordinatorEnlistment coordinator = (CoordinatorEnlistment) obj;
     coordinator.StateMachine.Enqueue(new TmCommitResponseEvent(coordinator, status));
 }
 public void InDoubt(Enlistment enlistment)
 {
     throw new NotImplementedException();
 }
Beispiel #41
0
 public void InDoubt(Enlistment enlistment)
 {
     Assert.Equal(_expectedOutcome, EnlistmentOutcome.InDoubt);
     if (_outcomeReceived != null)
     {
         _outcomeReceived.Set();
     }
     enlistment.Done();
 }
 public void Rollback(Enlistment enlistment)
 {
     throw new NotImplementedException();
 }
Beispiel #43
0
 public void Rollback(Enlistment enlistment)
 {
     Assert.Equal(_expectedOutcome, EnlistmentOutcome.Aborted);
     enlistment.Done();
 }
 public void InDoubt(Enlistment enlistment)
 {
     database.Rollback(txId);
     enlistment.Done();
 }
 /// <summary>
 /// Responds to the Rollback notification.
 /// </summary>
 /// <param name="enlistment">An Enlistment that facilitates communication between the enlisted transaction participant and the transaction manager during the final phase of the transaction.</param>
 public override void Rollback(Enlistment enlistment)
 {
     if (enlistment != null)
     {
         // Indicate that the transaction participant has completed its work.
         enlistment.Done();
     }
 }
 public abstract void CreateTransaction(Enlistment enlistment, EnlistmentOptions enlistmentOptions, TransactionManagerCallback callback, object state);
 public void InDoubt(Enlistment enlistment)
 {
     Trace("MyEnlistment.InDoubt");
     _indoubt = true;
     enlistment.Done();
     _outcomeReceived.Set();
 }
Beispiel #48
0
        public void Rollback(Enlistment enlistment)
        {
            resource.NumRollback++;
            if (resource.FailRollback)
            {
                if (resource.FailWithException)
                    throw (resource.ThrowThisException ?? new NotSupportedException());
                else
                    return;
            }

            resource.Rollback();
        }
 public void Commit(Enlistment enlistment)
 {
     throw new NotImplementedException();
 }
 public void Commit(Enlistment enlistment)
 {
     database.Commit(txId);
     enlistment.Done();
 }
 public void Rollback(Enlistment enlistment)
 {
     throw new NotImplementedException();
 }
Beispiel #52
0
 public static Result Init(Enlistment enlistment)
 {
     return(new GitProcess(enlistment).InvokeGitOutsideEnlistment("init \"" + enlistment.WorkingDirectoryRoot + "\""));
 }
Beispiel #53
0
 public void InDoubt(Enlistment enlistment)
 {
     // not going to happen when enlisted durably
     throw new NotImplementedException();
 }
 public void Commit(Enlistment enlistment)
 {
     // Clear out oldMemberValue
     _oldMemberValue = 0;
 }
 public abstract void CreateSubordinateEnlistment(Enlistment enlistment, TransactionManagerCallback callback, object state);
            public void Rollback(Enlistment enlistment)
            {
                _transactionContext.Dispose();

                enlistment.Done();
            }
Beispiel #57
0
        public void Commit(Enlistment enlistment)
        {
            resource.NumCommit++;
            if (resource.FailCommit)
            {
                if (resource.FailWithException)
                    throw (resource.ThrowThisException ?? new NotSupportedException());
                else
                    return;
            }

            resource.Commit();
            enlistment.Done();
        }
 public void InDoubt(Enlistment enlistment)
 {
     enlistment.Done();
 }
Beispiel #59
0
 public void InDoubt(Enlistment enlistment)
 {
     resource.NumInDoubt++;
     throw new Exception("IntResourceManager.InDoubt is not implemented.");
 }
Beispiel #60
0
 public GitProcess(Enlistment enlistment)
     : this(enlistment.GitBinPath, enlistment.WorkingDirectoryRoot, enlistment.GVFSHooksRoot)
 {
 }