use of io.fabric8.arquillian.kubernetes.event.Start in project docker-maven-plugin by fabric8io.
the class LogMatchCallbackTest method matchingLinesNonConformantToThePatternFails.
@Test
public void matchingLinesNonConformantToThePatternFails() throws Exception {
final String patterString = "The start has started right now";
final LogMatchCallback logMatchCallback = new LogMatchCallback(logger, callback, patterString);
new Expectations() {
{
callback.matched();
times = 0;
}
};
logMatchCallback.log(1, new Timestamp(), "LOG: database system is ready to accept connections");
}
use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.
the class AbstractChildContainerCreateAction method preCreateContainer.
/**
* Pre validates input before creating the container(s)
*
* @param name the name of the container to create
* @throws IllegalArgumentException is thrown if input is invalid
*/
protected void preCreateContainer(String name) throws IllegalArgumentException {
FabricValidations.validateContainerName(name);
if (clusterService.getEnsembleContainers().isEmpty()) {
return;
}
if (FabricCommand.doesContainerExist(fabricService, name)) {
throw new IllegalArgumentException("A container with name " + name + " already exists.");
}
// get the profiles for the given version
Version ver = version != null ? profileService.getRequiredVersion(version) : fabricService.getRequiredDefaultVersion();
List<Profile> profiles = ver.getProfiles();
// validate profiles exists before creating a new container
Set<String> names = getProfileNames();
for (String profile : names) {
Profile prof = getProfile(profiles, profile, ver);
if (prof == null) {
throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " does not exist.");
}
if (prof.isAbstract()) {
throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " is abstract and can not be associated to containers.");
}
}
if (fabricService.getZookeeperUrl() == null) {
throw new IllegalArgumentException("should start a zookeeper ensemble first.");
}
}
use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.
the class AbstractContainerCreateAction method preCreateContainer.
/**
* Pre validates input before creating the container(s)
*
* @param name the name of the container to create
* @throws IllegalArgumentException is thrown if input is invalid
*/
protected void preCreateContainer(String name) throws IllegalArgumentException {
FabricValidations.validateContainerName(name);
if (!isEnsembleServer) {
if (clusterService.getEnsembleContainers().isEmpty()) {
if (!isEnsembleServer) {
throw new IllegalStateException("The use of the --ensemble-server option is mandatory when creating an initial container");
}
return;
}
if (FabricCommand.doesContainerExist(fabricService, name)) {
throw new IllegalArgumentException("A container with name " + name + " already exists.");
}
// get the profiles for the given version
Version ver = version != null ? profileService.getRequiredVersion(version) : fabricService.getRequiredDefaultVersion();
List<Profile> profiles = ver.getProfiles();
// validate profiles exists before creating a new container
Set<String> names = getProfileNames();
for (String profile : names) {
Profile prof = getProfile(profiles, profile, ver);
if (prof == null) {
throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " does not exist.");
}
if (prof.isAbstract()) {
throw new IllegalArgumentException("Profile " + profile + " with version " + ver.getId() + " is abstract and can not be associated to containers.");
}
}
}
if (!isEnsembleServer && fabricService.getZookeeperUrl() == null) {
throw new IllegalArgumentException("Either start a zookeeper ensemble or use --ensemble-server.");
}
}
use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.
the class ContainerEditJvmOptionsAction method doExecute.
protected Object doExecute() throws Exception {
validateContainerName(container);
if (!FabricCommand.doesContainerExist(fabricService, container)) {
System.out.println("Container " + container + " does not exists!");
return null;
}
Container containerInstance = FabricCommand.getContainerIfExists(fabricService, container);
String type = containerInstance.getType();
if (!"karaf".equals(type)) {
System.out.println("Sorry, currently only \"karaf\" type container are supported");
return null;
}
// read current jvm values
FabricManager fabricManager = new FabricManager(fabricService);
if (full) {
String jmxUrl = null;
JMXConnector connector = null;
MBeanServerConnection remote = null;
HashMap<String, String[]> authenticationData = null;
jmxUrl = containerInstance.getJmxUrl();
authenticationData = prepareAuthenticationData();
try {
connector = connectOrRetry(authenticationData, jmxUrl);
} catch (Exception e) {
username = null;
password = null;
System.out.println("Operation Failed. Check logs.");
log.error("Unable to connect to JMX Server", e);
return null;
}
ObjectName objName = new ObjectName(JAVA_LANG_OBJECT_NAME);
try {
remote = connector.getMBeanServerConnection();
String[] arguments = (String[]) remote.getAttribute(objName, "InputArguments");
String output = Arrays.toString(arguments);
output = output.replaceAll(",", "");
output = output.substring(1, output.length() - 1);
System.out.println(output);
} catch (Exception e) {
System.out.println("Operation Failed. Check logs.");
log.error("Unable to fetch child jvm opts", e);
}
try {
connector.close();
} catch (IOException e) {
log.error("Errors closing remote MBean connection", e);
}
} else {
try {
String output = fabricManager.getJvmOpts(container);
if ("Inapplicable".equals(output)) {
String message = container + " jvmOpts cannot be handled within Fabric. You have to set required values directly in startup scripts.";
System.out.println(message);
log.error(message);
return null;
}
if (jvmOptions == null) {
System.out.println(output);
} else {
fabricManager.setJvmOpts(container, jvmOptions);
System.out.println("Operation succeeded. New JVM flags will be loaded at the next start of " + container + " container");
log.info("Updated JVM flags for container {}", container);
}
} catch (Exception e) {
System.out.println("Operation Failed. Check logs.");
log.error("Unable to set ssh jvm opts", e);
}
}
return null;
}
use of io.fabric8.arquillian.kubernetes.event.Start in project fabric8 by jboss-fuse.
the class MavenDownloadProxyServlet method start.
@Override
public synchronized void start() throws IOException {
// Create a thread pool with the given maxmimum number of threads
// All threads will time out after 60 seconds
int nbThreads = threadMaximumPoolSize > 0 ? threadMaximumPoolSize : 8;
executorService = new ThreadPoolExecutor(0, nbThreads, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory("MavenDownloadProxyServlet"));
if (this.timeout <= 0) {
// default
this.timeout = 5000;
}
LOGGER.info("Starting maven download servlet. Using async timeout value: " + this.timeout + "ms");
super.start();
}
Aggregations