Configurations

Overview

javadoc

  • ParallecGlobalConfig: this is the global system config. You can replace the values here before executing them. Different from those settings defined in ParallelTaskConfig, settings here are effective to all executions, and cannot be overwritten for a particular task.
  • ParallelTaskConfig: Configuration as a member of every ParallecTask. You may overwrite it by setConfig() when build the task. The initial values are set from the defaults.

We recommand you to read the source code (straighforward) to check what you may be able to change.

Async HTTP Client

"HttpClientStore" (singleton) stores a pair of default embedded fast/slow AsyncHttpClient, and another pair of customized fast/slow AsyncHttpClient. By default the pair of customized ones are just refereces (same as) the embedded ones.

When you submit a ParallelTask, if you do not set a specific AsyncHttpClient for this session, the default one is the Embedded fast.

You may set your customized client:

  • Just for one task or a session: when submit the task, setAsyncHttpClient() with your own context/parameters
  • Want to change for all the sessions, you can still do the above way every time you submit the task. Or you could call the following to set the default to be your own customized client to avoid setting it everytime.
 HttpClientStore.getInstance().setCustomClientFast(yourClient);
 HttpClientStore.getInstance().setHttpClientTypeCurrentDefault(HttpClientType.CUSTOM_FAST);

Timeout

  • Connection / Request Timeout, as these are parameters from the Async HTTP Client, you will need to either change them in the global config or replace it in
  • timeoutInManagerSec and actorMaxOperationTimeoutSec respectively, controls if the AHC or SSH/TCP/Ping client does not timeout, the actor level timeout in manager (for parallel task) and in the worker.
Example of setting the AHC timeout, also the actor timeout

Set the global config before the new ParallelClient(). This example also changes some other config parameters.

ParallecGlobalConfig.ningFastClientConnectionTimeoutMillis = 5000;
ParallecGlobalConfig.ningFastClientRequestTimeoutMillis = 15000;

ParallelTaskConfig config = new ParallelTaskConfig();
    config.setActorMaxOperationTimeoutSec(20);
    config.setAutoSaveLogToLocal(true);
    config.setSaveResponseToTask(true);

ParallelClient pc = new ParallelClient();
...
pc.prepareHttpPost("/api")
    .setConfig(config)
    ...

Long Running Jobs

Do you have your long job completed without all the target responses returned? It could be the whole task has been prematurely cancelled due to the timeout.

By Default the whole parallel task timeouts at 10 minutes. If you have a long polling jobs that could run longer than that, please adjust it accordingly.

public ParallelTaskConfig genParallelTaskConfig() {
    ParallelTaskConfig config = new ParallelTaskConfig();
    config.setTimeoutInManagerSec(900);
    config.setTimeoutAskManagerSec(910);
    return config;
}

Reduce Verbose Logs

Reduce response logs

If you find the logs are chatty, please check the global config, there are parameters related to how to reduce the interval. Current logic is always log first the first K% and the last K% percent, for those in the middle, will log based on the interval. You may overwrite these before submit a ParallelTask.

Also, you may change the log level as a whole.

    /** The log response interval. */
    public static int logResponseInterval = 1;

    /** The log all response after percent. */
    public static double logAllResponseAfterPercent = 95.0;

    /** The log all response before percent. */
    public static double logAllResponseBeforePercent = 5.0;

    /** The log all response before init count. */
    public static int logAllResponseBeforeInitCount = 2;

    /** The log all response if total less than. */
    public static int logAllResponseIfTotalLessThan = 11;

Customize Parallec Logging

Parallec uses slf4j + logback for logging. And it is output is controlled by logback.xml in src/main/resources. Note that since version 0.9.2 the logback.xml is not part of the released jar file and therefore a default setting will apply.

To customize logging in parallec, please simply put your own logback.xml to src/main/resources in your app. Feel free to use this as a reference. You may remove <appender-ref ref="STDOUT" /> to remove most parallec logs to the console.

  <root level="INFO">          
    <appender-ref ref="STDOUT" />
    <appender-ref ref="FILE" />
  </root>