/** * @param name Custom executor name. * @return Executor configuration. */ private ExecutorConfiguration createExecConfiguration(String name) { ExecutorConfiguration exec = new ExecutorConfiguration(); exec.setName(name); exec.setSize(1); return exec; }
/** * @throws Exception If failed. */ @Test public void testConfigurations() throws Exception { try { checkStartWithInvalidConfiguration(getConfiguration("node0") .setExecutorConfiguration(new ExecutorConfiguration())); checkStartWithInvalidConfiguration(getConfiguration("node0") .setExecutorConfiguration(new ExecutorConfiguration(""))); checkStartWithInvalidConfiguration(getConfiguration("node0") .setExecutorConfiguration(new ExecutorConfiguration("exec").setSize(-1))); checkStartWithInvalidConfiguration(getConfiguration("node0") .setExecutorConfiguration(new ExecutorConfiguration("exec").setSize(0))); } finally { Ignition.stopAll(true); } }
/** * {@inheritDoc} * * This implementation registers adds custom executors to the configuration. */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setExecutorConfiguration(new ExecutorConfiguration(CUSTOM_EXECUTOR_0), new ExecutorConfiguration(CUSTOM_EXECUTOR_1)); return cfg; }
public static void main(String[] args) { IgniteConfiguration icfg = defaultIgniteCfg("custom-thread-pool-grid"); icfg.setExecutorConfiguration(new ExecutorConfiguration("myCustomThreadPool").setSize(16)); try (Ignite ignite = Ignition.start(icfg)) { ignite.compute().run(new OuterTask()); } } }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setMetricsLogFrequency(1000); cfg.setExecutorConfiguration(new ExecutorConfiguration(CUSTOM_EXECUTOR_0), new ExecutorConfiguration(CUSTOM_EXECUTOR_1)); cfg.setGridLogger(strLog); return cfg; }
if (jobs != null) { final ExecutorConfiguration[] executorConfigurations = jobs.stream() .map(job -> new ExecutorConfiguration(job.getId()).setSize(job.getThreads())) .toArray(ExecutorConfiguration[]::new);
clone[i] = new ExecutorConfiguration(execCfgs[i]);
/** * @param cfgs Array of the executors configurations. * @throws IgniteCheckedException If configuration is wrong. */ private static void validateCustomExecutorsConfiguration(ExecutorConfiguration[] cfgs) throws IgniteCheckedException { if (cfgs == null) return; Set<String> names = new HashSet<>(cfgs.length); for (ExecutorConfiguration cfg : cfgs) { if (F.isEmpty(cfg.getName())) throw new IgniteCheckedException("Custom executor name cannot be null or empty."); if (!names.add(cfg.getName())) throw new IgniteCheckedException("Duplicate custom executor name: " + cfg.getName()); if (cfg.getSize() <= 0) throw new IgniteCheckedException("Custom executor size must be positive [name=" + cfg.getName() + ", size=" + cfg.getSize() + ']'); } }
clone[i] = new ExecutorConfiguration(execCfgs[i]);
/** * @param cfgs Array of the executors configurations. * @throws IgniteCheckedException If configuration is wrong. */ private static void validateCustomExecutorsConfiguration(ExecutorConfiguration[] cfgs) throws IgniteCheckedException { if (cfgs == null) return; Set<String> names = new HashSet<>(cfgs.length); for (ExecutorConfiguration cfg : cfgs) { if (F.isEmpty(cfg.getName())) throw new IgniteCheckedException("Custom executor name cannot be null or empty."); if (!names.add(cfg.getName())) throw new IgniteCheckedException("Duplicate custom executor name: " + cfg.getName()); if (cfg.getSize() <= 0) throw new IgniteCheckedException("Custom executor size must be positive [name=" + cfg.getName() + ", size=" + cfg.getSize() + ']'); } }