/** * Human readable description of the container * * @return The {@link #description} variable along with the state of this {@link #container} */ @Override public String toString() { return description + "_<" + container.getState() + ">"; }
public LocalConfiguration getConfiguration() { return container.getConfiguration(); }
/** * The container's port for the specified port type */ public String getPort(String portType) { LocalConfiguration config = getConfiguration(); config.applyPortOffset(); if (!container.getState().isStarted()) throw new IllegalStateException( "Container is not started, thus a port has not yet been assigned to the container."); return config.getPropertyValue(portType); }
ConfigurationType.STANDALONE, this.containerConfigHome.getAbsolutePath()); configuration.setProperty(GeneralPropertySet.LOGGING, loggingLevel); configuration.setProperty(GeneralPropertySet.JVMARGS, "-Djava.security.egd=file:/dev/./urandom"); .createContainer(install.getInstallId(), ContainerType.INSTALLED, configuration); container.setHome(install.getHome()); container.setOutput(logDir.getAbsolutePath() + "/container.log");
if (container.getState().isStarted()) throw new IllegalArgumentException("Container " + description + " failed to start because it is currently " + container.getState()); int containerRmiPort = portSupplier.getAsInt(); int tomcatAjpPort = portSupplier.getAsInt(); config.setProperty(ServletPropertySet.PORT, Integer.toString(servletPort)); config.setProperty(GeneralPropertySet.RMI_PORT, Integer.toString(containerRmiPort)); config.setProperty(TomcatPropertySet.AJP_PORT, Integer.toString(tomcatAjpPort)); config.setProperty(GeneralPropertySet.PORT_OFFSET, "0"); int jvmJmxPort = portSupplier.getAsInt(); String jvmArgs = "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=" + jvmJmxPort; " --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED"; config.setProperty(GeneralPropertySet.START_JVMARGS, jvmArgs); container.setConfiguration(config); container.start(); } catch (Exception e) { throw new RuntimeException(
/** * {@inheritDoc} */ @Override public void undeployWebApp(Deployable deployable) { throw new ContainerException("Not supported"); } }
/** * {@inheritDoc} */ @Override protected Configuration getConfiguration() { return this.container.getConfiguration(); }
/** * set the container's logging level */ public void setLoggingLevel(String loggingLevel) { this.loggingLevel = loggingLevel; LocalConfiguration config = getConfiguration(); config.setProperty(GeneralPropertySet.LOGGING, loggingLevel); container.setConfiguration(config); }
/** * {@inheritDoc} */ @Override protected Configuration getConfiguration() { return this.container.getConfiguration(); } }
/** * {@inheritDoc} */ @Override protected void executeLocalContainerAction() { this.localContainer.restart(); } }
/** * Executes the local container action. */ protected void executeLocalContainerAction() { this.localContainer.start(); }
/** * Get all active containers */ private ArrayList<ServerContainer> getActiveContainers() { return getContainersWithState(State.STARTED.toString()); }
/** * @return the Cargo file utility class */ protected FileHandler getFileHandler() { return container.getFileHandler(); } }
/** * {@inheritDoc} */ @Override public void undeploy(Deployable deployable) { throw new ContainerException("Not supported"); }
public State getState() { return container.getState(); }
/** * Get the indexes of all active containers */ private ArrayList<Integer> getActiveContainerIndexes() { return getContainerIndexesWithState(State.STARTED.toString()); }
/** * Get all inactive containers */ private ArrayList<ServerContainer> getInactiveContainers() { ArrayList<ServerContainer> inactiveContainers = getContainersWithState(State.STOPPED.toString()); inactiveContainers.addAll(getContainersWithState(State.UNKNOWN.toString())); return inactiveContainers; } }
/** * Get the positions of the containers with the given container state * * @param state A string representing the Cargo state a container is in. The possible states can * be found in as static variables in the {@link State} class. */ public ArrayList<Integer> getContainerIndexesWithState(String state) { if (!(state.equals(State.STARTED.toString()) || state.equals(State.STOPPED.toString()) || state.equals(State.STARTING.toString()) || state.equals(State.STOPPING.toString()) || state.equals(State.UNKNOWN.toString()))) { throw new IllegalArgumentException( "State must be one of the 5 specified cargo state strings (stopped, started, starting, stopping, or unknown). State given was: " + state); } ArrayList<Integer> indexes = new ArrayList<>(); for (int i = 0; i < numContainers(); i++) { if (getContainer(i).getState().toString().equals(state)) indexes.add(i); } return indexes; }