@Override public Options addAll(OptionsByType options) { for (Option option : options.asArray()) { add(option); } return this; }
@Override public OptionsByType addAll(OptionsByType options) { for (Option option : options.asArray()) { add(option); } return this; }
/** * Iterate over the registered {@link RemoteEventListener}s together with the registration {@link Option}s. * * @param consumer the {@link BiConsumer} */ public void forEach(BiConsumer<RemoteEventListener, Option[]> consumer) { eventListeners.forEach( (streamName, remoteEventListenerMap) -> { remoteEventListenerMap.forEach( (remoteEventListener, optionsByType) -> { consumer.accept(remoteEventListener, optionsByType.asArray()); }); }); }
@Override protected void after() { // close the assembly assembly.close(closingOptionsByType.asArray()); super.after(); }
/** * Iterate over the registered {@link RemoteEventListener}s together with the registration {@link Option}s. * * @param consumer the {@link BiConsumer} */ public void forEach(BiConsumer<RemoteEventListener, Option[]> consumer) { eventListeners.forEach( (streamName, remoteEventListenerMap) -> { remoteEventListenerMap.forEach( (remoteEventListener, optionsByType) -> { consumer.accept(remoteEventListener, optionsByType.asArray()); }); }); }
@Override protected void after() { // close the assembly assembly.close(closingOptionsByType.asArray()); super.after(); }
/** * Launches a new {@link Application} based on the specified program executable / command * and provided {@link Option}s. * * @param executable the name of the executable / command to launch the application on the {@link Platform} * @param options the {@link Option}s for the {@link Application} * * @return an {@link Application} representing the launched application */ default Application launch(String executable, Option... options) { // add the program as a launch option OptionsByType optionsByType = OptionsByType.of(options).add(Executable.named(executable)); // launch as an Application.class return launch(Application.class, optionsByType.asArray()); }
Repetitively.assertThat(message, deferred, matcher, optionsByType.asArray());
@Override protected boolean performRemoteCopy(String source, String destination, Platform platform, OptionsByType deploymentOptions) { if (platform instanceof RemotePlatform) { JSchRemoteTerminal terminal = new JSchRemoteTerminal((RemotePlatform) platform); OptionsByType optionsByType = OptionsByType.of(platform.getOptions()); optionsByType.addAll(deploymentOptions.asArray()); terminal.moveFile(source, destination, optionsByType); return false; } else { throw new IllegalArgumentException("The platform argument must be an instance of a RemotePlatform"); } }
@Override protected boolean performRemoteCopy(String source, String destination, Platform platform, OptionsByType deploymentOptions) throws IOException { if (platform instanceof RemotePlatform) { WindowsRemoteTerminal terminal = new WindowsRemoteTerminal((RemotePlatform) platform); OptionsByType optionsByType = OptionsByType.of(platform.getOptions()); optionsByType.addAll(deploymentOptions.asArray()); terminal.moveFile(source, destination, optionsByType); return false; } else { throw new IllegalArgumentException("The platform argument must be an instance of a RemotePlatform"); } } }
@Override public <A extends Application> A launch(MetaClass<A> metaClass, Option... options) { // establish the initial launch options based on those defined by the platform OptionsByType launchOptions = OptionsByType.of(getOptions().asArray()); // include the options specified when this method was called launchOptions.addAll(options); // obtain the application launcher for the class of application ApplicationLauncher<A> launcher = getApplicationLauncher(metaClass, launchOptions); if (launcher == null) { throw new IllegalArgumentException("Can't determine ApplicationLauncher for " + metaClass + " using " + launchOptions); } else { // now launch the application return launcher.launch(this, metaClass, launchOptions); } }
@Override public <A extends Application> A launch(MetaClass<A> metaClass, Option... options) { // establish the initial launch options based on those defined by the platform OptionsByType launchOptions = OptionsByType.of(getOptions().asArray()); // include the options specified when this method was called launchOptions.addAll(options); // obtain the application launcher for the class of application ApplicationLauncher<A> launcher = getApplicationLauncher(metaClass, launchOptions); if (launcher == null) { throw new IllegalArgumentException("Can't determine ApplicationLauncher for " + metaClass + " using " + launchOptions); } else { // now launch the application return launcher.launch(this, metaClass, launchOptions); } }
/** * Launches a new {@link Application} based on the specified program executable / command * and provided {@link Option}s. * * @param executable the name of the executable / command to launch the application on the {@link Platform} * @param options the {@link Option}s for the {@link Application} * * @return an {@link Application} representing the launched application */ default Application launch(String executable, Option... options) { // add the program as a launch option OptionsByType optionsByType = OptionsByType.of(options).add(Executable.named(executable)); // launch as an Application.class return launch(Application.class, optionsByType.asArray()); }
@Override protected void before() throws Throwable { // establish the launch definitions for the assembly builder for (Triple<Integer, Class<? extends A>, OptionsByType> launchDefinition : launchDefinitions) { // create the options for the application, based on the common options OptionsByType optionsByType = OptionsByType.of(commonOptionsByType).addAll(launchDefinition.getZ()); // include in the assembly builder assemblyBuilder.include(launchDefinition.getX(), launchDefinition.getY(), optionsByType.asArray()); } // build the assembly assembly = assemblyBuilder.build(infrastructure == null ? Infrastructure.local() : infrastructure, creationOptionsByType.asArray()); super.before(); }
@Override protected void before() throws Throwable { // establish the launch definitions for the assembly builder for (Triple<Integer, Class<? extends A>, OptionsByType> launchDefinition : launchDefinitions) { // create the options for the application, based on the common options OptionsByType optionsByType = OptionsByType.of(commonOptionsByType).addAll(launchDefinition.getZ()); // include in the assembly builder assemblyBuilder.include(launchDefinition.getX(), launchDefinition.getY(), optionsByType.asArray()); } // build the assembly assembly = assemblyBuilder.build(infrastructure == null ? Infrastructure.local() : infrastructure, creationOptionsByType.asArray()); super.before(); }
/** * Start the HTTP server that will be used to serve the artifacts * to be deployed. * * @param executor the {@link Executor} to pass to the {@link HttpServer} * @param artifacts a {@link Map} of {@link DeploymentArtifact}s to deploy * keyed by the URL path for each artifact * * @return the {@link HttpServer} */ protected HttpServer createServer(ExecutorService executor, Map<String, DeploymentArtifact> artifacts) { try { LocalPlatform platform = LocalPlatform.get(); InetAddress address = NetworkHelper.getFeasibleLocalHost(); int port = platform.getAvailablePorts().next(); HttpServer server = HttpServer.create(new InetSocketAddress(address, port), 0); server.createContext("/", new ArtifactsHandler(artifacts, optionsByType.asArray())); server.setExecutor(executor); server.start(); return server; } catch (IOException e) { throw new RuntimeException("Unable to create HTTP server", e); } }
@Override public G build(Infrastructure infrastructure, Option... options) { // establish the assembly starting with a copy of the common options G assembly = createAssembly(OptionsByType.of(optionsByType)); // use the characteristics to expand the assembly on the infrastructure for (Characteristics characteristic : characteristics) { int instanceCount = characteristic.getCount(); Class<? extends A> applicationClass = characteristic.getApplicationClass(); OptionsByType launchOptions = OptionsByType.of(characteristic.getOptions()).addAll(options); // expand the assembly based on the desired characteristics assembly.expand(instanceCount, infrastructure, applicationClass, launchOptions.asArray()); } return assembly; }
@Override public G build(Infrastructure infrastructure, Option... options) { // establish the assembly starting with a copy of the common options G assembly = createAssembly(OptionsByType.of(optionsByType)); // use the characteristics to expand the assembly on the infrastructure for (Characteristics characteristic : characteristics) { int instanceCount = characteristic.getCount(); Class<? extends A> applicationClass = characteristic.getApplicationClass(); OptionsByType launchOptions = OptionsByType.of(characteristic.getOptions()).addAll(options); // expand the assembly based on the desired characteristics assembly.expand(instanceCount, infrastructure, applicationClass, launchOptions.asArray()); } return assembly; }