/// <summary> /// do create connections /// </summary> /// <param name="url"> target url </param> /// <param name="pool"> connection pool </param> /// <param name="taskName"> task name </param> /// <param name="syncCreateNumWhenNotWarmup"> you can specify this param to ensure at least desired number of connections available in sync way </param> /// <exception cref="RemotingException"> </exception> private void doCreate(Url url, ConnectionPool pool, string taskName, int syncCreateNumWhenNotWarmup) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int actualNum = pool.size(); int actualNum = pool.size(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int expectNum = url.getConnNum(); int expectNum = url.ConnNum; if (actualNum >= expectNum) { return; } if (logger.IsEnabled(LogLevel.Debug)) { logger.LogDebug("actual num {}, expect num {}, task name {}", actualNum, expectNum, taskName); } if (url.ConnWarmup) { for (int i = actualNum; i < expectNum; ++i) { Connection connection = create(url); pool.add(connection); } } else { if (syncCreateNumWhenNotWarmup < 0 || syncCreateNumWhenNotWarmup > url.ConnNum) { throw new ArgumentException("sync create number when not warmup should be [0," + url.ConnNum + "]"); } // create connection in sync way if (syncCreateNumWhenNotWarmup > 0) { for (int i = 0; i < syncCreateNumWhenNotWarmup; ++i) { Connection connection = create(url); pool.add(connection); } if (syncCreateNumWhenNotWarmup >= url.ConnNum) { return; } } pool.markAsyncCreationStart(); // mark the start of async try { asyncCreateConnectionExecutor.execute(new TempRunnable(this, pool, url, taskName)); } catch (RejectedExecutionException) { pool.markAsyncCreationDone(); // mark the end of async when reject throw; } } // end of NOT warm up }
public override void executeJobs(IList <string> jobIds, ProcessEngineImpl processEngine) { try { threadPoolExecutor.execute(getExecuteJobsRunnable(jobIds, processEngine)); } catch (RejectedExecutionException) { logRejectedExecution(processEngine, jobIds.Count); rejectedJobsHandler.jobsRejected(jobIds, processEngine, this); } }
protected internal virtual bool executeShortRunning(ThreadStart runnable) { try { threadPoolExecutor.execute(runnable); return(true); } catch (RejectedExecutionException e) { LOG.debugRejectedExecutionException(e); return(false); } }