Repository: aries-containers Updated Branches: refs/heads/master a1ebd6fa3 -> e99817a18
Rename example slightly. Project: http://git-wip-us.apache.org/repos/asf/aries-containers/repo Commit: http://git-wip-us.apache.org/repos/asf/aries-containers/commit/e99817a1 Tree: http://git-wip-us.apache.org/repos/asf/aries-containers/tree/e99817a1 Diff: http://git-wip-us.apache.org/repos/asf/aries-containers/diff/e99817a1 Branch: refs/heads/master Commit: e99817a18d3e1445580ec232da78a9b7ca6c3b01 Parents: a1ebd6f Author: David Bosschaert <[email protected]> Authored: Mon May 29 12:37:50 2017 +0100 Committer: David Bosschaert <[email protected]> Committed: Mon May 29 12:37:50 2017 +0100 ---------------------------------------------------------------------- .../container-example-javaapp/pom.xml | 64 ------------------- .../aries/containers/examples/javaapp/Main.java | 67 -------------------- .../containers-example-javaapp/pom.xml | 64 +++++++++++++++++++ .../aries/containers/examples/javaapp/Main.java | 67 ++++++++++++++++++++ 4 files changed, 131 insertions(+), 131 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/aries-containers/blob/e99817a1/containers-examples/container-example-javaapp/pom.xml ---------------------------------------------------------------------- diff --git a/containers-examples/container-example-javaapp/pom.xml b/containers-examples/container-example-javaapp/pom.xml deleted file mode 100644 index ec41f87..0000000 --- a/containers-examples/container-example-javaapp/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.aries.containers</groupId> - <artifactId>org.apache.aries.containers.parent</artifactId> - <version>0.0.1-SNAPSHOT</version> - <relativePath>../containers-parent</relativePath> - </parent> - - <artifactId>org.apache.aries.containers.examples.javaapp</artifactId> - <packaging>jar</packaging> - <name>A simple example java application running the Apache Web server as a service</name> - - <dependencies> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>org.apache.aries.containers.api</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>org.apache.aries.containers.docker.local</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>org.apache.aries.containers.marathon</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - - <dependency> - <groupId>com.mesosphere</groupId> - <artifactId>marathon-client</artifactId> - <version>0.5.0</version> - </dependency> - </dependencies> -</project> - http://git-wip-us.apache.org/repos/asf/aries-containers/blob/e99817a1/containers-examples/container-example-javaapp/src/main/java/org/apache/aries/containers/examples/javaapp/Main.java ---------------------------------------------------------------------- diff --git a/containers-examples/container-example-javaapp/src/main/java/org/apache/aries/containers/examples/javaapp/Main.java b/containers-examples/container-example-javaapp/src/main/java/org/apache/aries/containers/examples/javaapp/Main.java deleted file mode 100644 index 0f06a30..0000000 --- a/containers-examples/container-example-javaapp/src/main/java/org/apache/aries/containers/examples/javaapp/Main.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.aries.containers.examples.javaapp; - -import java.util.Scanner; - -import org.apache.aries.containers.Service; -import org.apache.aries.containers.ServiceConfig; -import org.apache.aries.containers.ServiceManager; -import org.apache.aries.containers.docker.local.impl.LocalDockerServiceManager; - - -public class Main { - public static void main(String [] args) { - try { - ServiceConfig sc = ServiceConfig.builder("mytesthttpd", "httpd"). - cpu(0.2).memory(32).port(80).build(); - - ServiceManager sm = new LocalDockerServiceManager(); - - // If you want to run with Marathon, use the following line - // ServiceManager cf = new MarathonServiceManager("http://192.168.99.100:8080/"); - - System.out.println("Currently known services: " + sm.listServices()); - - Service svc = sm.getService(sc); - - int desiredCount; - try (Scanner scanner = new Scanner(System.in)) { - do { - System.out.println("Containers: (" + svc.getActualInstanceCount() + ")"); - svc.listContainers().stream().map(s -> " " + s).forEach(System.out::println); - - System.out.print("\nEnter desired container count (-1 = refresh, 0 = destroy): "); - desiredCount = scanner.nextInt(); - if (desiredCount > 0) { - svc.setInstanceCount(desiredCount); - } else if (desiredCount == -1) { - svc.refresh(); - } - } while (desiredCount != 0); - } - - svc.destroy(); - System.out.println("Service Destroyed"); - - } catch (Exception e) { - e.printStackTrace(); - } - } -} http://git-wip-us.apache.org/repos/asf/aries-containers/blob/e99817a1/containers-examples/containers-example-javaapp/pom.xml ---------------------------------------------------------------------- diff --git a/containers-examples/containers-example-javaapp/pom.xml b/containers-examples/containers-example-javaapp/pom.xml new file mode 100644 index 0000000..ec41f87 --- /dev/null +++ b/containers-examples/containers-example-javaapp/pom.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.aries.containers</groupId> + <artifactId>org.apache.aries.containers.parent</artifactId> + <version>0.0.1-SNAPSHOT</version> + <relativePath>../containers-parent</relativePath> + </parent> + + <artifactId>org.apache.aries.containers.examples.javaapp</artifactId> + <packaging>jar</packaging> + <name>A simple example java application running the Apache Web server as a service</name> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>org.apache.aries.containers.api</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>org.apache.aries.containers.docker.local</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>org.apache.aries.containers.marathon</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>com.mesosphere</groupId> + <artifactId>marathon-client</artifactId> + <version>0.5.0</version> + </dependency> + </dependencies> +</project> + http://git-wip-us.apache.org/repos/asf/aries-containers/blob/e99817a1/containers-examples/containers-example-javaapp/src/main/java/org/apache/aries/containers/examples/javaapp/Main.java ---------------------------------------------------------------------- diff --git a/containers-examples/containers-example-javaapp/src/main/java/org/apache/aries/containers/examples/javaapp/Main.java b/containers-examples/containers-example-javaapp/src/main/java/org/apache/aries/containers/examples/javaapp/Main.java new file mode 100644 index 0000000..0f06a30 --- /dev/null +++ b/containers-examples/containers-example-javaapp/src/main/java/org/apache/aries/containers/examples/javaapp/Main.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.aries.containers.examples.javaapp; + +import java.util.Scanner; + +import org.apache.aries.containers.Service; +import org.apache.aries.containers.ServiceConfig; +import org.apache.aries.containers.ServiceManager; +import org.apache.aries.containers.docker.local.impl.LocalDockerServiceManager; + + +public class Main { + public static void main(String [] args) { + try { + ServiceConfig sc = ServiceConfig.builder("mytesthttpd", "httpd"). + cpu(0.2).memory(32).port(80).build(); + + ServiceManager sm = new LocalDockerServiceManager(); + + // If you want to run with Marathon, use the following line + // ServiceManager cf = new MarathonServiceManager("http://192.168.99.100:8080/"); + + System.out.println("Currently known services: " + sm.listServices()); + + Service svc = sm.getService(sc); + + int desiredCount; + try (Scanner scanner = new Scanner(System.in)) { + do { + System.out.println("Containers: (" + svc.getActualInstanceCount() + ")"); + svc.listContainers().stream().map(s -> " " + s).forEach(System.out::println); + + System.out.print("\nEnter desired container count (-1 = refresh, 0 = destroy): "); + desiredCount = scanner.nextInt(); + if (desiredCount > 0) { + svc.setInstanceCount(desiredCount); + } else if (desiredCount == -1) { + svc.refresh(); + } + } while (desiredCount != 0); + } + + svc.destroy(); + System.out.println("Service Destroyed"); + + } catch (Exception e) { + e.printStackTrace(); + } + } +}
