use of org.jboss.arquillian.container.spi.client.container.LifecycleException in project Payara by payara.
the class PayaraServerControl method executeAdminCommand.
private void executeAdminCommand(String description, String command, List<String> args, ProcessOutputConsumer consumer) throws LifecycleException {
final List<String> cmd = buildCommand(command, args);
if (config.isOutputToConsole()) {
System.out.println(description + " using command: " + cmd.toString());
}
int result;
try (CloseableProcess process = new CloseableProcess(new ProcessBuilder(cmd).redirectErrorStream(true).start());
ConsoleReader consoleReader = new ConsoleReader(process, consumer)) {
new Thread(consoleReader).start();
result = process.waitFor();
} catch (IOException | InterruptedException e) {
logger.log(SEVERE, description + (e instanceof IOException ? " failed." : " interrupted."), e);
throw new LifecycleException("Unable to execute " + cmd.toString(), e);
}
if (result != 0) {
throw new LifecycleException("Unable to execute " + cmd.toString());
}
}
use of org.jboss.arquillian.container.spi.client.container.LifecycleException in project fabric8 by jboss-fuse.
the class Fabric8Container method start.
@Override
public void start() throws LifecycleException {
// lets kill any containers that are running before we start
FabricAssertions.killJavaAndDockerProcesses();
fabricControllerManager = createFabricControllerManager();
Fabric8ContainerConfiguration config = configuration.get();
config.configure(fabricControllerManager);
try {
FabricController fabricController = FabricAssertions.assertFabricCreate(fabricControllerManager);
controller.set(fabricController);
} catch (Exception e) {
throw new LifecycleException("Failed to create fabric: " + e, e);
}
System.out.println("Created a controller " + controller.get());
}
use of org.jboss.arquillian.container.spi.client.container.LifecycleException in project wildfly-swarm by wildfly-swarm.
the class DaemonDeployableContainerBase method start.
@Override
public void start() throws LifecycleException {
// Open up remote resources
try {
final long startTime = System.currentTimeMillis();
final int secondsToWait = this.timeout;
// 10 seconds from now
final long acceptableTime = startTime + 1000 * secondsToWait;
Socket socket = null;
while (true) {
try {
// TODO Security Action
socket = new Socket(remoteAddress.getHostString(), remoteAddress.getPort());
if (log.isLoggable(Level.FINEST)) {
log.finest("Got connection to " + remoteAddress.toString());
}
break;
} catch (final ConnectException ce) {
if (log.isLoggable(Level.FINEST)) {
log.finest("No connection yet available to remote process");
}
final long currentTime = System.currentTimeMillis();
// Time expired?
if (currentTime > acceptableTime) {
throw new LifecycleException("Could not connect to the server at " + remoteAddress.getHostString() + ":" + remoteAddress.getPort() + " in the allotted " + secondsToWait + "s", ce);
}
// Sleep and try again
try {
Thread.sleep(200);
} catch (final InterruptedException e) {
Thread.interrupted();
throw new RuntimeException("No one should be interrupting us while we're waiting to connect", e);
}
}
}
assert socket != null : "Socket should have been connected";
this.socket = socket;
final OutputStream socketOutstream = socket.getOutputStream();
this.socketOutstream = socketOutstream;
final PrintWriter writer = new PrintWriter(new OutputStreamWriter(socketOutstream, WireProtocol.CHARSET), true);
this.writer = writer;
final InputStream socketInstream = socket.getInputStream();
this.socketInstream = socketInstream;
final BufferedReader reader = new BufferedReader(new InputStreamReader(socketInstream));
this.reader = reader;
final StringBuilder builder = new StringBuilder();
builder.append(WireProtocol.COMMAND_CHECK_DEPLOYMENT);
builder.append(WireProtocol.COMMAND_EOF_DELIMITER);
final String checkCommand = builder.toString();
// Request
writer.write(checkCommand);
writer.flush();
Throwable error = null;
try {
final ObjectInputStream response = new ObjectInputStream(socketInstream);
error = (Throwable) response.readObject();
} catch (Throwable e) {
e.printStackTrace();
}
if (error != null) {
throw new LifecycleException(error.getMessage(), error);
}
} catch (final IOException ioe) {
this.closeRemoteResources();
throw new LifecycleException("Could not open connection to remote process", ioe);
}
}
use of org.jboss.arquillian.container.spi.client.container.LifecycleException in project tomee by apache.
the class TomEEWebappContainer method downloadTomcat.
protected void downloadTomcat(final File catalinaDirectory, final String tomcatVersion, final String defaultTempDir) throws LifecycleException {
String source = null;
try {
int v = Integer.parseInt(tomcatVersion.substring(0, tomcatVersion.indexOf('.')));
source = "http://archive.apache.org/dist/tomcat/tomcat-" + v + "/v" + v + "/bin/apache-tomcat-" + tomcatVersion + ".zip";
} catch (final Exception e) {
// no-op
}
if (source == null) {
throw new LifecycleException("Unable to find URL for Tomcat " + tomcatVersion);
}
final File zipFile = Setup.downloadFile("org.apache.tomcat:tomcat:" + tomcatVersion + ":zip", source, defaultTempDir);
Zips.unzip(zipFile, catalinaDirectory);
}
use of org.jboss.arquillian.container.spi.client.container.LifecycleException in project Payara by payara.
the class PayaraContainer method stop.
@Override
public void stop() throws LifecycleException {
try {
unbindCommandRunner();
glassfish.stop();
} catch (Exception e) {
throw new LifecycleException("Could not stop GlassFish Embedded", e);
}
}
Aggregations