Esempio n. 1
0
 protected CommandContextBase(Command command, BuilderContext builderContext)
 {
     CurrentCommand = command;
     BuildParameters = builderContext.Parameters;
     ResultEntry = new CommandResultEntry();
     MetadataProvider = builderContext.MetadataProvider;
 }
 protected override async Task<ResultStatus> ScheduleAndExecuteCommandInternal(Command command)
 {
     var resultStatus = await Step.SpawnCommand(command, executeContext);
     return resultStatus;
 }
Esempio n. 3
0
 public CommandBuildStep(Command command)
 {
     Command = command;
 }
Esempio n. 4
0
        internal async Task<ResultStatus> SpawnCommand(Command command, IExecuteContext executeContext)
        {
            var spawnedStep = new CommandBuildStep(command);
            SpawnedStepsList.Add(spawnedStep);

            executeContext.ScheduleBuildStep(spawnedStep);
            var resultStatus = (await spawnedStep.ExecutedAsync()).Status;

            return resultStatus;
        }
Esempio n. 5
0
        internal OutputObject AddOutputObject(IExecuteContext executeContext, ObjectUrl outputObjectUrl, ObjectId outputObjectId, Command command)
        {
            OutputObject outputObject;

            if (!outputObjects.TryGetValue(outputObjectUrl, out outputObject))
            {
                // New item?
                outputObject = new OutputObject(outputObjectUrl, outputObjectId);
                outputObjects.Add(outputObjectUrl, outputObject);
            }
            else
            {
                // ObjectId should be similar (if no Wait happened), otherwise two tasks spawned with same parameters did output different results
                if (outputObject.ObjectId != outputObjectId && outputObject.Counter == mergeCounter)
                {
                    var error = string.Format("Commands {0} and {1} are both writing {2} at the same time", command, outputObject.Command, outputObjectUrl);
                    executeContext.Logger.Error(error);
                    throw new InvalidOperationException(error);
                }

                // Update new ObjectId
                outputObject.ObjectId = outputObjectId;
            }

            // Update Counter so that we know if a wait happened since this output object has been merged.
            outputObject.Counter = mergeCounter;
            outputObject.Command = command;

            return outputObject;
        }
Esempio n. 6
0
 /// <summary>
 /// Adds the output object. Will try to detect input/output conflicts, and output with different <see cref="ObjectId" /> conflicts.
 /// </summary>
 /// <param name="executeContext">The execute context.</param>
 /// <param name="outputObjectUrl">The output object URL.</param>
 /// <param name="outputObjectId">The output object id.</param>
 /// <param name="command">The command that produced the output object.</param>
 /// <exception cref="System.InvalidOperationException">Two CommandBuildStep with same inputs did output different results.</exception>
 private void CheckOutputObject(IExecuteContext executeContext, ObjectUrl outputObjectUrl, ObjectId outputObjectId, Command command)
 {
     InputObject inputObject;
     if (inputObjects.TryGetValue(outputObjectUrl, out inputObject)
         && inputObject.Command != command
         && inputObject.Counter == mergeCounter)
     {
         var error = string.Format("Command {0} is writing {1} while command {2} is reading it", command, outputObjectUrl, inputObject.Command);
         executeContext.Logger.Error(error);
         throw new InvalidOperationException(error);
     }
 }
Esempio n. 7
0
        private void AddInputObject(IExecuteContext executeContext, ObjectUrl inputObjectUrl, Command command)
        {
            OutputObject outputObject;
            if (outputObjects.TryGetValue(inputObjectUrl, out outputObject)
                && mergeCounter > outputObject.Counter)
            {
                // Object was outputed by ourself, so reading it as input should be ignored.
                return;
            }

            inputObjects[inputObjectUrl] = new InputObject { Command = command, Counter = mergeCounter };
        }
Esempio n. 8
0
 public void RegisterSpawnedCommandWithoutScheduling(Command command)
 {
     ResultEntry.SpawnedCommands.Add(command);
 }
Esempio n. 9
0
 public Task<ResultStatus> ScheduleAndExecuteCommand(Command command)
 {
     ResultEntry.SpawnedCommands.Add(command);
     return ScheduleAndExecuteCommandInternal(command);
 }
Esempio n. 10
0
 protected abstract Task<ResultStatus> ScheduleAndExecuteCommandInternal(Command command);
Esempio n. 11
0
 protected override Task<ResultStatus> ScheduleAndExecuteCommandInternal(Command command)
 {
     // Send serialized command
     return processBuilderRemote.SpawnCommand(command);
 }
Esempio n. 12
0
 public RemoteCommandContext(IProcessBuilderRemote processBuilderRemote, Command command, BuilderContext builderContext, LoggerResult logger)
     : base(command, builderContext)
 {
     this.processBuilderRemote = processBuilderRemote;
     this.logger = logger;
 }
 public async Task<ResultStatus> SpawnCommand(Command command)
 {
     Task<ResultStatus> task = commandContext.ScheduleAndExecuteCommand(command);
     commandContext.Step.AwaitSpawnedCommand(task);
     return await task;
 }
 public ProcessBuilderRemote(LocalCommandContext commandContext, Command remoteCommand, BuildParameterCollection buildParameters)
 {
     this.commandContext = commandContext;
     this.remoteCommand = remoteCommand;
     this.buildParameters = buildParameters;
 }