Create the Mesos TaskManager parameters.

@param flinkConfig the TM configuration.
193255
public static MesosTaskManagerParameters create(Configuration flinkConfig) {

		List<ConstraintEvaluator> constraints = parseConstraints(flinkConfig.getString(MESOS_CONSTRAINTS_HARD_HOSTATTR));
		// parse the common parameters
		ContaineredTaskManagerParameters containeredParameters = ContaineredTaskManagerParameters.create(
			flinkConfig,
			flinkConfig.getInteger(MESOS_RM_TASKS_MEMORY_MB),
			flinkConfig.getInteger(MESOS_RM_TASKS_SLOTS));

		double cpus = flinkConfig.getDouble(MESOS_RM_TASKS_CPUS);
		if (cpus <= 0.0) {
			cpus = Math.max(containeredParameters.numSlots(), 1.0);
		}

		int gpus = flinkConfig.getInteger(MESOS_RM_TASKS_GPUS);

		if (gpus < 0) {
			throw new IllegalConfigurationException(MESOS_RM_TASKS_GPUS.key() +
				" cannot be negative");
		}

		int disk = flinkConfig.getInteger(MESOS_RM_TASKS_DISK_MB);

		// parse the containerization parameters
		String imageName = flinkConfig.getString(MESOS_RM_CONTAINER_IMAGE_NAME);

		ContainerType containerType;
		String containerTypeString = flinkConfig.getString(MESOS_RM_CONTAINER_TYPE);
		switch (containerTypeString) {
			case MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_MESOS:
				containerType = ContainerType.MESOS;
				break;
			case MESOS_RESOURCEMANAGER_TASKS_CONTAINER_TYPE_DOCKER:
				containerType = ContainerType.DOCKER;
				if (imageName == null || imageName.length() == 0) {
					throw new IllegalConfigurationException(MESOS_RM_CONTAINER_IMAGE_NAME.key() +
						" must be specified for docker container type");
				}
				break;
			default:
				throw new IllegalConfigurationException("invalid container type: " + containerTypeString);
		}

		Option<String> containerVolOpt = Option.<String>apply(flinkConfig.getString(MESOS_RM_CONTAINER_VOLUMES));

		Option<String> dockerParamsOpt = Option.<String>apply(flinkConfig.getString(MESOS_RM_CONTAINER_DOCKER_PARAMETERS));

		Option<String> uriParamsOpt = Option.<String>apply(flinkConfig.getString(MESOS_TM_URIS));

		boolean dockerForcePullImage = flinkConfig.getBoolean(MESOS_RM_CONTAINER_DOCKER_FORCE_PULL_IMAGE);

		List<Protos.Volume> containerVolumes = buildVolumes(containerVolOpt);

		List<Protos.Parameter> dockerParameters = buildDockerParameters(dockerParamsOpt);

		List<String> uris = buildUris(uriParamsOpt);

		//obtain Task Manager Host Name from the configuration
		Option<String> taskManagerHostname = Option.apply(flinkConfig.getString(MESOS_TM_HOSTNAME));

		//obtain command-line from the configuration
		String tmCommand = flinkConfig.getString(MESOS_TM_CMD);
		Option<String> tmBootstrapCommand = Option.apply(flinkConfig.getString(MESOS_TM_BOOTSTRAP_CMD));

		return new MesosTaskManagerParameters(
			cpus,
			gpus,
			disk,
			containerType,
			Option.apply(imageName),
			containeredParameters,
			containerVolumes,
			dockerParameters,
			dockerForcePullImage,
			constraints,
			tmCommand,
			tmBootstrapCommand,
			taskManagerHostname,
			uris);
	}
81408
public synchronized void submitTask(final ActiveContext context) {
    final TaskEntity task = taskQueue.poll();
    final Integer taskId = task.getId();
    final String command = task.getCommand();

    final Configuration taskConf = TaskConfiguration.CONF
        .set(TaskConfiguration.TASK, ShellTask.class)
        .set(TaskConfiguration.IDENTIFIER, taskId.toString())
        .build();
    final Configuration commandConf = Tang.Factory.getTang().newConfigurationBuilder()
        .bindNamedParameter(Command.class, command)
        .build();

    final Configuration merged = Configurations.merge(taskConf, commandConf);
    context.submitTask(merged);
    runningTasks.add(task);
  }
128639
public static InfluxConfig createInfluxConfig(MetricsConfig conf) {
        log.info("Configuring stats with direct InfluxDB at {}", conf.getInfluxDBUri());
        return new InfluxConfig() {
            @Override
            public Duration step() {
                return Duration.ofSeconds(conf.getOutputFrequencySeconds().getSeconds());
            }

            @Override
            public String prefix() {
                return conf.getMetricsPrefix();
            }

            @Override
            public String uri() {
                return conf.getInfluxDBUri();
            }

            @Override
            public String db() {
                return conf.getInfluxDBName();
            }

            @Override
            public String userName() {
                return conf.getInfluxDBUserName();
            }

            @Override
            public String password() {
                return conf.getInfluxDBPassword();
            }

            @Override
            public String retentionPolicy() {
                return conf.getInfluxDBRetention();
            }

            @Override
            public String get(String k) {
                return null;  // accept the rest of the defaults, see https://micrometer.io/docs/registry/influx.
            }
        };
    }
170654
private void initSystemRoutingStrategies(Cluster cluster) {
        HashMap<String, RoutingStrategy> routingStrategyMap = createRoutingStrategyMap(cluster,
                                                                                       makeStoreDefinitionMap(getSystemStoreDefList()));
        this.metadataCache.put(SYSTEM_ROUTING_STRATEGY_KEY,
                               new Versioned<Object>(routingStrategyMap));
    }
556903
public void registerTaskManager(final TaskExecutorConnection taskExecutorConnection, SlotReport initialSlotReport) {
		checkInit();

		LOG.debug("Registering TaskManager {} under {} at the SlotManager.", taskExecutorConnection.getResourceID(), taskExecutorConnection.getInstanceID());

		// we identify task managers by their instance id
		if (taskManagerRegistrations.containsKey(taskExecutorConnection.getInstanceID())) {
			reportSlotStatus(taskExecutorConnection.getInstanceID(), initialSlotReport);
		} else {
			// first register the TaskManager
			ArrayList<SlotID> reportedSlots = new ArrayList<>();

			for (SlotStatus slotStatus : initialSlotReport) {
				reportedSlots.add(slotStatus.getSlotID());
			}

			TaskManagerRegistration taskManagerRegistration = new TaskManagerRegistration(
				taskExecutorConnection,
				reportedSlots);

			taskManagerRegistrations.put(taskExecutorConnection.getInstanceID(), taskManagerRegistration);

			// next register the new slots
			for (SlotStatus slotStatus : initialSlotReport) {
				registerSlot(
					slotStatus.getSlotID(),
					slotStatus.getAllocationID(),
					slotStatus.getJobID(),
					slotStatus.getResourceProfile(),
					taskExecutorConnection);
			}
		}

	}
1008986
void prepare(Map stormConf, TopologyContext context, OutputCollector collector,
                 KeyValueState<TaskStream, WindowState> windowState) {
        init(stormConf, context, collector, windowState);
        super.prepare(stormConf, context, collector);
    }
1318829
public static void link(EventLinker.Configuration config) {
		
		long millis = System.currentTimeMillis();

		if(ProfileService.getInstance(config.getContext()).isActive(config.getContext(), Profile.EVENT)) {
		
			EventLinkers[] allLinkers = EventLinkers.values();
			
			for (EventLinkers eventLinker : allLinkers) {
				
				eventLinker.link(config);
			}
		}
		
		millis = System.currentTimeMillis() - millis;
		
		Log.i("INSTRUMENTATION:IckleEventProfile#link()", 
			  EventUtils.class.getSimpleName() + ": " + millis + "ms");
	}
454841
public <T extends ThreadPoolTaskScheduler> T configure(T taskScheduler) {
		PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull();
		map.from(this.poolSize).to(taskScheduler::setPoolSize);
		map.from(this.awaitTermination)
				.to(taskScheduler::setWaitForTasksToCompleteOnShutdown);
		map.from(this.awaitTerminationPeriod).asInt(Duration::getSeconds)
				.to(taskScheduler::setAwaitTerminationSeconds);
		map.from(this.threadNamePrefix).to(taskScheduler::setThreadNamePrefix);
		if (!CollectionUtils.isEmpty(this.customizers)) {
			this.customizers.forEach((customizer) -> customizer.customize(taskScheduler));
		}
		return taskScheduler;
	}
353136
public static CallbacksManager init(Bundle bundle, Object... callbackHandlers) {
    if (bundle == null) {
      return new CallbacksManager();
    }

    CallbacksManager callbacksManager = new CallbacksManager();
    ArrayList<TaskHandler> taskProxies = bundle.getParcelableArrayList(TASK_PROXY_LIST);
    if (taskProxies != null) {
      callbacksManager.proxyTasks.addAll(taskProxies);
    }

    if (callbackHandlers != null) {
      for (TaskHandler proxyTask : new ArrayList<TaskHandler>(callbacksManager.proxyTasks)) {
        proxyTask.clearCallbacks();
        proxyTask.appendCallbacks(callbackHandlers);
      }
    }
    return callbacksManager;
  }
699789
public void submitTask(final String evaluatorConfiguration, final String taskConfiguration) {
    final Configuration contextConfiguration = ContextConfiguration.CONF
        .set(ContextConfiguration.IDENTIFIER, "RootContext_" + this.getId())
        .build();
    final String contextConfigurationString = this.configurationSerializer.toString(contextConfiguration);
    this.launchWithConfigurationString(
        evaluatorConfiguration, contextConfigurationString,  Optional.<String>empty(), Optional.of(taskConfiguration));
  }
919782
public static void registerMappingsFromConfig(Registry registry, Config cfg) {
    registry.register(new JmxMeter(registry, JmxConfig.from(cfg)));
  }
701103
function(config) {
  INIT(config)
  this.__init__()

  this.log = LOG
  this.jobs = JOBS

  MEM = new MemChecker(this, CONF.memChecker)

  this._ = {
     www: WWW
    ,redis: JOBS._rawQueue.client
  }
}
644179
@Override
    public void setConfig(LWMConfig meConfig) {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "setConfig", new Object[] { meConfig });

        _highMessageThreshold = ((JsMessagingEngine) meConfig).getMEThreshold();

        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "setConfig");
    }
315982
def from_user_config(cls):
        
        global _USER_CONFIG_TASKMANAGER
        if _USER_CONFIG_TASKMANAGER is not None:
            return _USER_CONFIG_TASKMANAGER

        # Try in the current directory then in user configuration directory.
        path = os.path.join(os.getcwd(), cls.YAML_FILE)
        if not os.path.exists(path):
            path = os.path.join(cls.USER_CONFIG_DIR, cls.YAML_FILE)

        if not os.path.exists(path):
            raise RuntimeError(colored(
		"\nCannot locate %s neither in current directory nor in %s\n"
                "!!! PLEASE READ THIS: !!!\n"
                "To use AbiPy to run jobs this file must be present\n"
                "It provides a description of the cluster/computer you are running on\n"
                "Examples are provided in abipy/data/managers." % (cls.YAML_FILE, path), color="red"))

        _USER_CONFIG_TASKMANAGER = cls.from_file(path)
        return _USER_CONFIG_TASKMANAGER
1292478
public OperationFuture<LoadBalancerPool> create(LoadBalancerPoolConfig config) {
        LoadBalancer loadBalancer = config.getLoadBalancer();
        LoadBalancerMetadata loadBalancerMetadata = loadBalancerService.findByRef(loadBalancer);

        LoadBalancerPoolMetadata metadata = loadBalancerPoolClient.create(
            loadBalancerMetadata.getDataCenterId(),
            loadBalancerMetadata.getId(),
            new LoadBalancerPoolRequest()
                .port(config.getPort())
                .method(config.getMethod())
                .persistence(config.getPersistence())
        );

        LoadBalancerPool pool = LoadBalancerPool.refById(metadata.getId(), loadBalancer);

        return new OperationFuture<>(
            pool,
            addLoadBalancerNodes(config, pool)
        );
    }
531113
public Protos.TaskInfo constructMesosTaskInfo(Config heronConfig, Config heronRuntime) {
    //String taskIdStr, BaseContainer task, Offer offer
    String taskIdStr = this.taskId;

    Protos.TaskID mesosTaskID = Protos.TaskID.newBuilder().setValue(taskIdStr).build();
    Protos.TaskInfo.Builder taskInfo = Protos.TaskInfo.newBuilder()
        .setName(baseContainer.name)
        .setTaskId(mesosTaskID);
    Protos.Environment.Builder environment = Protos.Environment.newBuilder();

    // If the job defines custom environment variables, add them to the builder
    // Don't add them if they already exist to prevent overwriting the defaults
    Set<String> builtinEnvNames = new HashSet<>();
    for (Protos.Environment.Variable variable : environment.getVariablesList()) {
      builtinEnvNames.add(variable.getName());
    }

    for (BaseContainer.EnvironmentVariable ev : baseContainer.environmentVariables) {
      environment.addVariables(
          Protos.Environment.Variable.newBuilder().setName(ev.name).setValue(ev.value));
    }

    taskInfo
        .addResources(scalarResource(TaskResources.CPUS_RESOURCE_NAME, baseContainer.cpu))
        .addResources(scalarResource(TaskResources.MEM_RESOURCE_NAME, baseContainer.memInMB))
        .addResources(scalarResource(TaskResources.DISK_RESOURCE_NAME, baseContainer.diskInMB))
        .addResources(rangeResource(TaskResources.PORT_RESOURCE_NAME,
            this.freePorts.get(0), this.freePorts.get(this.freePorts.size() - 1))).
        setSlaveId(this.offer.getSlaveId());

    int containerIndex = TaskUtils.getContainerIndexForTaskId(taskIdStr);
    String commandStr = executorCommand(heronConfig, heronRuntime, containerIndex);

    Protos.CommandInfo.Builder command = Protos.CommandInfo.newBuilder();

    List<Protos.CommandInfo.URI> uriProtos = new ArrayList<>();
    for (String uri : baseContainer.dependencies) {
      uriProtos.add(Protos.CommandInfo.URI.newBuilder()
          .setValue(uri)
          .setExtract(true)
          .build());
    }

    command.setValue(commandStr)
        .setShell(baseContainer.shell)
        .setEnvironment(environment)
        .addAllUris(uriProtos);

    if (!baseContainer.runAsUser.isEmpty()) {
      command.setUser(baseContainer.runAsUser);
    }
    taskInfo.setCommand(command);

    return taskInfo.build();
  }
868495
private void initializeContextManager(Map<String, Object> configProps) throws WIMException {

        iContextManager = new ContextManager();

        /*
         * Set SSL configuration
         */
        iContextManager.setSSLAlias((String) configProps.get("sslRef"));
        iContextManager.setSSLEnabled((Boolean) configProps.get(CONFIG_PROP_SSL_ENABLED));

        /*
         * Set the primary server.
         */
        iContextManager.setPrimaryServer((String) configProps.get(CONFIG_PROP_HOST), (Integer) configProps.get(CONFIG_PROP_PORT));

        /*
         * Set fail-over servers and fail-over behavior.
         */
        for (Map<String, Object> serverConfig : Nester.nest(FAILOVER_SERVERS, configProps)) {
            List<Map<String, Object>> servers = Nester.nest(SERVER2, serverConfig);
            for (Map<String, Object> server : servers) {
                iContextManager.addFailoverServer((String) server.get(CONFIG_PROP_HOST), (Integer) server.get(CONFIG_PROP_PORT));
            }
        }
        iContextManager.setWriteToSecondary(Boolean.getBoolean((String) configProps.get(CONFIG_PROP_ALLOW_WRITE_TO_SECONDARY_SERVERS)));
        iContextManager.setReturnToPrimary((Boolean) configProps.get(CONFIG_PROP_RETURN_TO_PRIMARY_SERVER));
        iContextManager.setQueryInterval((Integer) configProps.get(CONFIG_PROP_PRIMARY_SERVER_QUERY_TIME_INTERVAL) * 60);

        /*
         * Set the simple authentication credentials.
         */
        iContextManager.setSimpleCredentials((String) configProps.get(CONFIG_PROP_BIND_DN), (SerializableProtectedString) configProps.get(CONFIG_PROP_BIND_PASSWORD));

        /*
         * Set the connection timeout.
         */
        iContextManager.setConnectTimeout((Long) configProps.get(CONFIG_PROP_CONNECT_TIMEOUT));

        /*
         * Set the connection timeout.
         */
        iContextManager.setReadTimeout((Long) configProps.get(CONFIG_PROP_READ_TIMEOUT));

        /*
         * Determine referral handling behavior. Initially the attribute was spelled missing an 'r' so
         * for backwards compatibility, support customers who might still be using it. The "referal"
         * attribute has no default so unless it is set we won't use it.
         */
        String referal = (String) configProps.get(CONFIG_PROP_REFERAL);
        String referral = (String) configProps.get(CONFIG_PROP_REFERRAL);
        referral = referal != null ? referal : referral;
        iContextManager.setReferral(referral.toLowerCase());

        /*
         * Set binary attribute names.
         */
        iContextManager.setBinaryAttributeNames(getBinaryAttributes());

        /*
         * Configure the context pool.
         */
        boolean enableContextPool = true;

        List<Map<String, Object>> poolConfigs = Nester.nest(CONFIG_CONTEXT_POOL, configProps);

        Map<String, Object> poolConfig = null;
        if (!poolConfigs.isEmpty()) {
            poolConfig = poolConfigs.get(0);
        }

        /*
         * Enable the context pool if the context pool is enabled and the
         * stand-alone LDAP property reuseConnection has not been set to false.
         */
        boolean reuseConn = (Boolean) configProps.get(CONFIG_REUSE_CONNECTION);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Set reuseConnection as [" + reuseConn + "]");
        }
        if (poolConfig != null) {
            enableContextPool = (Boolean) poolConfig.get(CONFIG_PROP_ENABLED);
        }
        if (!reuseConn) {
            enableContextPool = false;
        }

        Integer initPoolSize = null;
        Integer maxPoolSize = null;
        Integer prefPoolSize = null;
        Long poolTimeOut = null;
        Long poolWaitTime = null;

        if (enableContextPool) {
            if (poolConfig != null) {
                if (poolConfig.get(CONFIG_PROP_INIT_POOL_SIZE) != null) {
                    initPoolSize = (Integer) poolConfig.get(CONFIG_PROP_INIT_POOL_SIZE);
                }
                if (poolConfig.get(CONFIG_PROP_MAX_POOL_SIZE) != null) {
                    maxPoolSize = (Integer) poolConfig.get(CONFIG_PROP_MAX_POOL_SIZE);
                }
                if (poolConfig.get(CONFIG_PROP_PREF_POOL_SIZE) != null) {
                    prefPoolSize = (Integer) poolConfig.get(CONFIG_PROP_PREF_POOL_SIZE);
                }

                if (poolConfig.get(CONFIG_PROP_POOL_TIME_OUT) != null) {
                    poolTimeOut = (Long) poolConfig.get(CONFIG_PROP_POOL_TIME_OUT);

                    /**
                     * The metatype is set to long for this property and all
                     * values will be passed as milliseconds.
                     * A value of 0 means no timeout, leave at 0
                     * Between 0 and 1000ms, round up to 1s
                     * Otherwise round to nearest second
                     */
                    if (poolTimeOut > 0 && poolTimeOut <= 1000) {
                        poolTimeOut = 1l; // override to 1 second
                    } else {
                        poolTimeOut = roundToSeconds(poolTimeOut);
                    }
                }
                if (poolConfig.get(CONFIG_PROP_POOL_WAIT_TIME) != null) {
                    poolWaitTime = (Long) poolConfig.get((CONFIG_PROP_POOL_WAIT_TIME));
                }
            }
        }

        /*
         * Set the configuration on the ContextManager.
         */
        iContextManager.setContextPool(enableContextPool, initPoolSize, prefPoolSize, maxPoolSize, poolTimeOut, poolWaitTime);

        /*
         * Initialize the ContextManager.
         *
         * Only need to check for missing password as the configuration for LDAP would catch a missing
         * primary server. The password is optional and only required when the bind DN is configured.
         */
        InitializeResult result = iContextManager.initialize();
        if (result == InitializeResult.MISSING_PASSWORD) {
            String msg = Tr.formatMessage(tc, WIMMessageKey.MISSING_INI_PROPERTY, WIMMessageHelper.generateMsgParms(CONFIG_PROP_BIND_PASSWORD));
            throw new MissingInitPropertyException(WIMMessageKey.MISSING_INI_PROPERTY, msg);
        }
    }