use of io.fabric8.maven.docker.util.Logger in project fabric8 by jboss-fuse.
the class SubsystemResolver method resolve.
public Map<Resource, List<Wire>> resolve(MetadataBuilder builder, Set<String> overrides, String featureResolutionRange, final org.osgi.service.repository.Repository globalRepository) throws Exception {
if (root == null) {
return Collections.emptyMap();
}
// Download bundles
root.downloadBundles(manager, builder, overrides, featureResolutionRange);
// Populate digraph and resolve
digraph = new StandardRegionDigraph(null, null);
populateDigraph(digraph, root);
Resolver resolver = new ResolverImpl(new Slf4jResolverLog(LOGGER));
Downloader downloader = manager.createDownloader();
wiring = resolver.resolve(new SubsystemResolveContext(root, digraph, globalRepository, downloader));
downloader.await();
// Remove wiring to the fake environment resource
if (environmentResource != null) {
for (List<Wire> wires : wiring.values()) {
for (Iterator<Wire> iterator = wires.iterator(); iterator.hasNext(); ) {
Wire wire = iterator.next();
if (wire.getProvider() == environmentResource) {
iterator.remove();
}
}
}
}
// Fragments are always wired to their host only, so create fake wiring to
// the subsystem the host is wired to
associateFragments();
return wiring;
}
use of io.fabric8.maven.docker.util.Logger in project fabric8 by jboss-fuse.
the class Log4jLogQuery method toLogEvent.
protected LogEvent toLogEvent(LoggingEvent element) {
LogEvent answer = new LogEvent();
answer.setClassName(element.getFQNOfLoggerClass());
// TODO
// answer.setContainerName(element.get);
ThrowableInformation throwableInformation = element.getThrowableInformation();
if (throwableInformation != null) {
ThrowableFormatter renderer = new ThrowableFormatter();
String[] stack = renderer.doRender(throwableInformation.getThrowable());
if (stack == null) {
stack = element.getThrowableStrRep();
}
answer.setException(stack);
}
LocationInfo locationInformation = element.getLocationInformation();
if (locationInformation != null) {
answer.setFileName(locationInformation.getFileName());
answer.setClassName(locationInformation.getClassName());
answer.setMethodName(locationInformation.getMethodName());
answer.setLineNumber(locationInformation.getLineNumber());
}
Level level = element.getLevel();
if (level != null) {
answer.setLevel(level.toString());
}
// TODO
answer.setLogger(element.getLoggerName());
Category logger = element.getLogger();
Object message = element.getMessage();
if (message != null) {
// TODO marshal differently?
answer.setMessage(message.toString());
}
answer.setProperties(element.getProperties());
// TODO
answer.setSeq(element.getTimeStamp());
answer.setTimestamp(new Date(element.getTimeStamp()));
answer.setThread(element.getThreadName());
answer.setHost(getHostName());
return answer;
}
use of io.fabric8.maven.docker.util.Logger in project fabric8 by jboss-fuse.
the class ExceptionMavenCoordsTest method testQueryOfLogMessages.
@Test
public void testQueryOfLogMessages() throws Exception {
Logger testLog = LoggerFactory.getLogger("io.fabric8.insight.log.log4j.TestLogger");
// now lets force an exception with a stack trace from camel...
try {
CamelContextHelper.getMandatoryEndpoint(null, null);
} catch (Throwable e) {
testLog.error("Expected exception for testing: " + e, e);
}
// now lets find the error
LogResults results = logQuery.allLogResults();
List<LogEvent> logEvents = Log4jTest.assertNotEmpty(results);
LogEvent log = logEvents.get(0);
assertNotNull("Should have a log event", log);
List<String> list = Arrays.asList(log.getException());
assertTrue("Should have more than 1 items in the stack trace but got: " + list, list.size() > 1);
String first = list.get(1);
LOG.info("First line: " + first);
String expects = "[org.apache.camel:camel-core:";
assertTrue("Should have camel coordinate '" + expects + "' but got " + first, first.indexOf(expects) > 0);
for (String line : list) {
LOG.info(line);
}
}
use of io.fabric8.maven.docker.util.Logger in project fabric8-maven-plugin by fabric8io.
the class ApplyMojo method applyEntities.
protected void applyEntities(Controller controller, KubernetesClient kubernetes, String namespace, String fileName, Set<HasMetadata> entities) throws Exception {
// Apply all items
for (HasMetadata entity : entities) {
if (entity instanceof Pod) {
Pod pod = (Pod) entity;
controller.applyPod(pod, fileName);
} else if (entity instanceof Service) {
Service service = (Service) entity;
controller.applyService(service, fileName);
} else if (entity instanceof ReplicationController) {
ReplicationController replicationController = (ReplicationController) entity;
controller.applyReplicationController(replicationController, fileName);
} else if (entity != null) {
controller.apply(entity, fileName);
}
}
String command = clusterAccess.isOpenShiftImageStream(log) ? "oc" : "kubectl";
log.info("[[B]]HINT:[[B]] Use the command `%s get pods -w` to watch your pods start up", command);
Logger serviceLogger = createExternalProcessLogger("[[G]][SVC][[G]] ");
long serviceUrlWaitTimeSeconds = this.serviceUrlWaitTimeSeconds;
for (HasMetadata entity : entities) {
if (entity instanceof Service) {
Service service = (Service) entity;
String name = getName(service);
Resource<Service, DoneableService> serviceResource = kubernetes.services().inNamespace(namespace).withName(name);
String url = null;
// lets wait a little while until there is a service URL in case the exposecontroller is running slow
for (int i = 0; i < serviceUrlWaitTimeSeconds; i++) {
if (i > 0) {
Thread.sleep(1000);
}
Service s = serviceResource.get();
if (s != null) {
url = getExternalServiceURL(s);
if (Strings.isNotBlank(url)) {
break;
}
}
if (!isExposeService(service)) {
break;
}
}
// lets not wait for other services
serviceUrlWaitTimeSeconds = 1;
if (Strings.isNotBlank(url) && url.startsWith("http")) {
serviceLogger.info("" + name + ": " + url);
}
}
}
}
use of io.fabric8.maven.docker.util.Logger in project fabric8-maven-plugin by fabric8io.
the class JavaExecGeneratorMainClassDeterminationTest method testMainClassDeterminationFromConfig.
/**
* The main class is determined via config in a non-fat-jar deployment
* @throws MojoExecutionException
*/
@Test
public void testMainClassDeterminationFromConfig() throws MojoExecutionException {
new MockBuild();
new MockProcessorConfig("the.main.ClassName");
new MockMavenProject();
final GeneratorContext generatorContext = new GeneratorContext.Builder().project(new MavenProject()).config(new ProcessorConfig()).strategy(OpenShiftBuildStrategy.docker).logger(log).build();
JavaExecGenerator generator = new JavaExecGenerator(generatorContext);
final List<ImageConfiguration> images = new ArrayList<ImageConfiguration>();
List<ImageConfiguration> customized = generator.customize(images, false);
assertEquals("1 images returned", (long) 1, (long) customized.size());
ImageConfiguration imageConfig = customized.get(0);
assertEquals("Image name", "TheImageName", imageConfig.getName());
assertEquals("Main Class set as environment variable", "the.main.ClassName", imageConfig.getBuildConfiguration().getEnv().get(JavaExecGenerator.JAVA_MAIN_CLASS_ENV_VAR));
}
Aggregations