private BootstrapStepResult executeStep(BootstrapStep step, Predicate<BootstrapStep> shouldSkip) throws InterruptedException { try { step.validate(); } catch (IllegalArgumentException e) { LOG.warn("Bootstrap step {} failed because it is malformed: {}", step.getLabel(), e.getMessage()); return new BootstrapStepResult(step.getLabel(), BootstrapStepResult.Status.FAILED, e.getMessage()); } if (shouldSkip.test(step)) { return new BootstrapStepResult(step.getLabel(), BootstrapStepResult.Status.SKIPPED, null); } BootstrapStepExecutor bootstrapStepExecutor = bootstrapStepExecutors.get(step.getType()); if (bootstrapStepExecutor == null) { // should not be possible, as deserialization of the file into a BootStrapConfig should have failed return new BootstrapStepResult(step.getLabel(), BootstrapStepResult.Status.FAILED, String.format("Unknown bootstrap step type '%s' for '%s'.", step.getType(), step.getLabel())); } return bootstrapStepExecutor.execute(step.getLabel(), step.getArguments()); }
private BootstrapStepResult executeStep(BootstrapStep step, Predicate<BootstrapStep> shouldSkip) throws InterruptedException { try { step.validate(); } catch (IllegalArgumentException e) { LOG.warn("Bootstrap step {} failed because it is malformed: {}", step.getLabel(), e.getMessage()); return new BootstrapStepResult(step.getLabel(), BootstrapStepResult.Status.FAILED, e.getMessage()); } if (shouldSkip.test(step)) { return new BootstrapStepResult(step.getLabel(), BootstrapStepResult.Status.SKIPPED, null); } BootstrapStepExecutor bootstrapStepExecutor = bootstrapStepExecutors.get(step.getType()); if (bootstrapStepExecutor == null) { // should not be possible, as deserialization of the file into a BootStrapConfig should have failed return new BootstrapStepResult(step.getLabel(), BootstrapStepResult.Status.FAILED, String.format("Unknown bootstrap step type '%s' for '%s'.", step.getType(), step.getLabel())); } return bootstrapStepExecutor.execute(step.getLabel(), step.getArguments()); }
@BeforeClass public static void setupClass() { Map<BootstrapStep.Type, BootstrapStepExecutor> executors = new HashMap<>(); executors.put(STEP1.getType(), EXECUTOR1); executors.put(STEP2.getType(), EXECUTOR2); executors.put(STEP3.getType(), EXECUTOR3); List<BootstrapStep> steps = new ArrayList<>(3); steps.add(STEP1); steps.add(STEP2); steps.add(STEP3); bootstrapConfig = new BootstrapConfig(steps); BootstrapConfigProvider bootstrapConfigProvider = new InMemoryBootstrapConfigProvider(bootstrapConfig); bootstrapStore = AppFabricTestHelper.getInjector().getInstance(BootstrapStore.class); bootstrapService = new BootstrapService(bootstrapConfigProvider, bootstrapStore, executors); bootstrapService.reload(); }