|
| 1 | +import com.mathworks.toolbox.distcomp.mjs.service.ConfigUtil; |
| 2 | +import com.mathworks.toolbox.distcomp.control.PortConfig; |
| 3 | +import com.mathworks.util.PlatformInfo; |
| 4 | +import com.mathworks.toolbox.parallel.pctutil.logging.DistcompFileHandler; |
| 5 | +import com.mathworks.toolbox.parallel.pctutil.logging.DistcompSimpleFormatter; |
| 6 | +import com.mathworks.toolbox.parallel.pctutil.logging.DistcompLevel; |
| 7 | + |
| 8 | +/* Copyright 2018-2024 The MathWorks, Inc. */ |
| 9 | + |
| 10 | +// IMPORTANT!!!: Please note that the system properties referenced here actually get set |
| 11 | +// in start-workergroup.config file, are read by the service constructor on STDIN and then are |
| 12 | +// set using the java.lang.System.setProperty method before the service makes use of the |
| 13 | +// config file. This is because MATLAB does not accept -D arguments. In order to see a |
| 14 | +// property here, you need to add them to the String[] that is passed as the 6th argument |
| 15 | +// to the SharedActivatableServiceDescriptor in start-workergroup.config |
| 16 | + |
| 17 | +com.mathworks.toolbox.distcomp.workergroup { |
| 18 | + private static configDir = "${com.mathworks.toolbox.distcomp.toolboxroot}${/}config${/}"; |
| 19 | + |
| 20 | + persistenceDirectory = "${com.mathworks.toolbox.distcomp.persistenceDir}"; |
| 21 | + logDirectory = "${com.mathworks.toolbox.distcomp.logdir}"; |
| 22 | + serviceName = "${com.mathworks.toolbox.distcomp.servicename}"; |
| 23 | + |
| 24 | + lookupServiceQueryIntervalSecs = 30; |
| 25 | + maxWaitBeforeShutdownSecs = 10; |
| 26 | + |
| 27 | + codebase = ""; |
| 28 | + policy = ConfigUtil.concat(new String[]{configDir,"jsk-all.policy"}); |
| 29 | + minServiceExportPort = PortConfig.getMinDistcompServiceExportPort("${com.mathworks.toolbox.distcomp.base_port}"); |
| 30 | + |
| 31 | + // Each worker needs 2 ports, so need a large port range to accommodate |
| 32 | + // machines running many workers. This range will allow approximately 2000 |
| 33 | + // workers. |
| 34 | + maxNumPorts = 4000; |
| 35 | + |
| 36 | + defaultRmiClientConnectTimeoutSecs = 5; |
| 37 | + |
| 38 | + logLevel = "${com.mathworks.toolbox.distcomp.loglevel}"; |
| 39 | + |
| 40 | + onDemand = "${com.mathworks.toolbox.distcomp.worker.onDemand}"; |
| 41 | + idleKillTimeoutInSeconds = 5L; |
| 42 | + idleLicenseTimeoutInSeconds = 0L; // Immediately return licenses every time |
| 43 | + |
| 44 | + // Messages logged via LOGGER.log() in the Worker JVM will end up in this file. |
| 45 | + serviceLogFilePattern = ConfigUtil.concat(new String[]{ |
| 46 | + "${com.mathworks.toolbox.distcomp.logdir}${/}", |
| 47 | + "workergroup_", |
| 48 | + serviceName, |
| 49 | + ".%u.%g", //unique number and sequence number |
| 50 | + ".log"}); |
| 51 | + serviceHandler = new DistcompFileHandler(serviceLogFilePattern, |
| 52 | + true, |
| 53 | + DistcompLevel.getLevelFromValue(Integer.parseInt(logLevel)), |
| 54 | + 10, |
| 55 | + 100000000, |
| 56 | + new DistcompSimpleFormatter()); |
| 57 | + |
| 58 | + securityLevel = "${com.mathworks.toolbox.distcomp.securityLevel}"; |
| 59 | + securityDir = "${com.mathworks.toolbox.distcomp.securityDir}"; |
| 60 | + |
| 61 | + useSecureCommunication = Boolean.parseBoolean("${com.mathworks.toolbox.distcomp.rmi.useSecureCommunication}"); |
| 62 | + |
| 63 | + requireWebLicensing = Boolean.parseBoolean("${com.mathworks.toolbox.distcomp.requireWebLicensing}"); |
| 64 | + |
| 65 | + requireClientCertificate = Boolean.parseBoolean("${com.mathworks.toolbox.distcomp.rmi.requireClientCertificate}"); |
| 66 | + |
| 67 | + taskEvaluator = "com.mathworks.toolbox.distcomp.mjs.worker.matlab.VersionSwitchingTaskEvaluator"; |
| 68 | + |
| 69 | + matlabroot = "${com.mathworks.toolbox.distcomp.matlabroot}"; |
| 70 | + |
| 71 | + // These properties control how the Worker starts MATLAB. |
| 72 | + matlabExecutable = "${com.mathworks.toolbox.distcomp.matlabexecutable}"; |
| 73 | + |
| 74 | + // Use -noFigureWindows on Windows and -nodisplay everywhere else |
| 75 | + private static nodisplay = ConfigUtil.ifThenElse( |
| 76 | + /*if*/ PlatformInfo.isWindows(), |
| 77 | + /*then*/ "-noFigureWindows", |
| 78 | + /*else*/ "-nodisplay" |
| 79 | + ); |
| 80 | + |
| 81 | + |
| 82 | + // Can add other command line arguments: e.g -timing or -jdb |
| 83 | + // In addition to these arguments, the PID of the Java worker service is automatically |
| 84 | + // added as an argument to the initworker.m script |
| 85 | + matlabArguments = new String[]{"-parallelserver", nodisplay, "-r", "initworker"}; |
| 86 | + // Command line arguments for worker MATLABs from 18b and earlier |
| 87 | + matlabArgumentsDmlWorker = new String[]{"-dmlworker", nodisplay, "-r", "initworker"}; |
| 88 | + // Command line arguments for worker MATLABs launched with MVM from 19b |
| 89 | + matlabArgumentsMvm = new String[]{"-parallelserver", nodisplay}; |
| 90 | + |
| 91 | + // Time to wait between polls on the MVM for whether it is still running |
| 92 | + mvmPollIntervalMillis = 1000L; |
| 93 | + |
| 94 | + // Can be used to instrument the workers for debugging, with e.g. strace or gdb. |
| 95 | + // Will be placed in front of the MATLAB executable on the command line |
| 96 | + workerInstrumentation = new String[]{}; |
| 97 | + |
| 98 | + // Whether to launch each worker with "mpiexec -n 1 -laucher fork" |
| 99 | + // This is required for mpich3, but should be removed for other mpi |
| 100 | + // implementations |
| 101 | + shouldLaunchWithMpiexec = false; |
| 102 | + |
| 103 | + // MATLAB stdout and stderr streams are written to this file. |
| 104 | + matlabOutputMaxTotalSize = 1000000000; // 1GB |
| 105 | + matlabOutputMaxNumFiles = 10; |
| 106 | + |
| 107 | + matlabEnvironment = new String[]{ |
| 108 | + "HOSTNAME", "${com.mathworks.toolbox.distcomp.hostname}", |
| 109 | + "BASE_PORT", "${com.mathworks.toolbox.distcomp.base_port}", |
| 110 | + "USE_SERVER_SPECIFIED_HOSTNAME", "${com.mathworks.toolbox.distcomp.rmi.useServerSpecifiedHostname}", |
| 111 | + "MDCS_PEERSESSION_KEEP_ALIVE_PERIOD", "${com.mathworks.toolbox.distcomp.pmode.keepAlivePeriod}", |
| 112 | + "MDCS_PEERSESSION_KEEP_ALIVE_TIME_UNIT", "${com.mathworks.toolbox.distcomp.pmode.keepAliveTimeUnit}", |
| 113 | + "MDCS_MAX_NUM_PORTS", Integer.toString(maxNumPorts), |
| 114 | + "MDCS_MATLAB_DRIVE_ENABLED_ON_WORKER", "${com.mathworks.toolbox.distcomp.matlabDriveEnabledOnWorker}", |
| 115 | + "MJS_IDLE_LICENSE_TIMEOUT_SECS", Long.toString(idleLicenseTimeoutInSeconds), |
| 116 | + "MW_MATLAB_DRIVE_FOLDER_LOCATION_CFG", "${com.mathworks.toolbox.distcomp.matlabDriveFolderLocationCfg}"}; |
| 117 | + |
| 118 | + // Other useful variables to set for debugging purposes are: |
| 119 | + //"PCTIPC_VERBOSE", "DEBUG4", |
| 120 | + //"PCTIPC_LOGFILE", ConfigUtil.concat("/tmp/pctipc_", serviceName, ".log") |
| 121 | + |
| 122 | + // Set by mjs_def "WORKER_START_TIMEOUT" property |
| 123 | + matlabStartupTimeoutSecs = Long.parseLong("${com.mathworks.toolbox.distcomp.workerstarttimeout}"); |
| 124 | + |
| 125 | + // Maximum time to wait for a clean MATLAB shutdown before the process is hard-killed |
| 126 | + matlabShutdownTimeoutSecs = 60; |
| 127 | + |
| 128 | + windowsDomain = "${com.mathworks.toolbox.distcomp.worker.windowsDomain}"; |
| 129 | + |
| 130 | + // By default do not use an activatable exporter. |
| 131 | + useActivatableExporter = false; |
| 132 | +} |
| 133 | + |
0 commit comments