public void ExecuteRunnableChokesOnNullArgument()
        {
            var e = Assert.Throws <ArgumentNullException>(
                () => ExecutorService.Execute((IRunnable)null));

            Assert.That(e.ParamName, Is.EqualTo("runnable"));
        }
        public void ExecuteActionChokesOnNullArgument()
        {
            var e = Assert.Throws <ArgumentNullException>(
                () => ExecutorService.Execute((Action)null));

            Assert.That(e.ParamName, Is.EqualTo("action"));
        }
        public virtual void TestConcurrentWrites()
        {
            StartUpCluster(true, 9);
            string MethodName     = GenericTestUtils.GetMethodName();
            int    Seed           = unchecked ((int)(0xFADED));
            int    NumWriters     = 4;
            int    NumWriterPaths = 5;

            Path[][] paths = new Path[][] { new Path[NumWriterPaths], new Path[NumWriterPaths
                                            ], new Path[NumWriterPaths], new Path[NumWriterPaths] };
            for (int i = 0; i < NumWriters; i++)
            {
                paths[i] = new Path[NumWriterPaths];
                for (int j = 0; j < NumWriterPaths; j++)
                {
                    paths[i][j] = new Path("/" + MethodName + ".Writer" + i + ".File." + j + ".dat");
                }
            }
            CountDownLatch  latch      = new CountDownLatch(NumWriters);
            AtomicBoolean   testFailed = new AtomicBoolean(false);
            ExecutorService executor   = Executors.NewFixedThreadPool(ThreadpoolSize);

            for (int i_1 = 0; i_1 < NumWriters; i_1++)
            {
                Runnable writer = new TestLazyPersistFiles.WriterRunnable(this, i_1, paths[i_1],
                                                                          Seed, latch, testFailed);
                executor.Execute(writer);
            }
            Sharpen.Thread.Sleep(3 * LazyWriterIntervalSec * 1000);
            TriggerBlockReport();
            // Stop executor from adding new tasks to finish existing threads in queue
            latch.Await();
            Assert.AssertThat(testFailed.Get(), IS.Is(false));
        }
        public void ExecuteRejectsTaskOnShutdown()
        {
            var runnable = MockRepository.GenerateStub <IRunnable>();

            ExecutorService.Shutdown();

            Assert.Throws <RejectedExecutionException>(() => ExecutorService.Execute(runnable));

            JoinPool(ExecutorService);
            runnable.AssertWasNotCalled(r => r.Run());
        }
        public void IsShutdownReturnsFalseBeforeShutdownTrueAfter()
        {
            //ExecutorService = NewThreadPoolExecutor(1, 1);
            Assert.IsFalse(ExecutorService.IsShutdown);

            ExecutorService.Execute(_mediumInterruptableAction);
            ExecutorService.Shutdown();

            Assert.IsTrue(ExecutorService.IsShutdown);
            InterruptAndJoinPool(ExecutorService);
        }
示例#6
0
        public async Task <IActionResult> Post(Execution execution)
        {
            await _executionRepository.Create(execution);

            await _executorService.SetExecutionPlan(execution.PlanId);

            _executorService.Execution = execution;
            await _executorService.Execute();

            return(NoContent());
        }
 public void ExecuteChokesWhenSaturated()
 {
     Assert.Throws <RejectedExecutionException>(
         () =>
     {
         for (int i = 0; i < 1000; ++i)
         {
             ExecutorService.Execute(_mediumInterruptableAction);
         }
     });
     InterruptAndJoinPool((ExecutorService));
     ThreadManager.JoinAndVerify();
 }
示例#8
0
        /// <summary>Schedule a request for execution.</summary>
        /// <remarks>Schedule a request for execution.</remarks>
        /// <?></?>
        /// <param name="request">request to execute</param>
        /// <param name="context">optional context; use null if not needed.</param>
        /// <param name="responseHandler">handler that will process the response.</param>
        /// <param name="callback">
        /// callback handler that will be called when the request is scheduled,
        /// started, completed, failed, or cancelled.
        /// </param>
        /// <returns>HttpAsyncClientFutureTask for the scheduled request.</returns>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual HttpRequestFutureTask <T> Execute <T>(IHttpUriRequest request, HttpContext
                                                             context, ResponseHandler <T> responseHandler, FutureCallback <T> callback)
        {
            if (closed.Get())
            {
                throw new InvalidOperationException("Close has been called on this httpclient instance."
                                                    );
            }
            metrics.GetScheduledConnections().IncrementAndGet();
            HttpRequestTaskCallable <T> callable = new HttpRequestTaskCallable <T>(httpclient,
                                                                                   request, context, responseHandler, callback, metrics);
            HttpRequestFutureTask <T> httpRequestFutureTask = new HttpRequestFutureTask <T>(request
                                                                                            , callable);

            executorService.Execute(httpRequestFutureTask);
            return(httpRequestFutureTask);
        }
示例#9
0
        private void Form_Load(object sender, EventArgs e)
        {
            Updated = !Storage.GetBoolOr("check-update", true);
            Folder  = Directory.GetCurrentDirectory();
            string programFullPath  = Path.Combine(Folder, "BfLauncher.exe");
            string programFullPath2 = Path.Combine(Folder, "BrickForce.exe");

            Firewall.UnauthorizeProgram("BFLauncher", programFullPath);
            Firewall.UnauthorizeProgram("BrickForce", programFullPath2);
            string text  = "";
            string text2 = "";

            Firewall.AuthorizeProgram("BFLauncher", programFullPath, ref text, ref text2);
            Firewall.AuthorizeProgram("BrickForce", programFullPath2, ref text, ref text2);
            this.timer.Enabled = true;
            executor.Execute(() =>
            {
                GithubUpdater.UpdateBrickForce(this);
            });
        }
示例#10
0
        private static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                ExitBecauseWrongParameters();
            }

            var isRole = Enum.TryParse(args[1], true, out Role role);

            if (!isRole)
            {
                ExitBecauseWrongParameters("The role is not specified.");
            }

            var isAttributeFile = Enum.TryParse(args[2], true, out AttributeFile attributeFile);

            if (!isAttributeFile)
            {
                ExitBecauseWrongParameters("The attribute file is not specified.");
            }
            var isHidden = attributeFile == AttributeFile.Hidden;

            var programName = args[0];

            var executorService = new ExecutorService()
            {
                Name         = programName,
                Arguments    = role.ToString(),
                UseExecutor  = false,
                IsWait       = false,
                IsRemoveFile = false,
                IsHiddenFile = isHidden
            };

            executorService.Execute();
        }
示例#11
0
 public override void Execute(Runnable command)
 {
     e.Execute(command);
 }