use of io.fabric8.maven.docker.util.Timestamp 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.maven.docker.util.Timestamp in project fabric8 by jboss-fuse.
the class RhqMetricsStorage method store.
@Override
public void store(String type, long timestamp, QueryResult queryResult) {
assertValid();
if (metricsService == null) {
throw new IllegalStateException("No metricsService available!");
}
Map<String, Result<?>> results = queryResult.getResults();
if (results != null) {
Set<RawNumericMetric> data = new HashSet<>();
Set<Map.Entry<String, Result<?>>> entries = results.entrySet();
for (Map.Entry<String, Result<?>> entry : entries) {
String key = entry.getKey();
Result<?> result = entry.getValue();
if (result instanceof MBeanOpersResult) {
MBeanOpersResult opersResult = (MBeanOpersResult) result;
List<MBeanOperResult> operResults = opersResult.getResults();
if (operResults != null) {
for (MBeanOperResult operResult : operResults) {
Object value = operResult.getValue();
Double doubleValue = toDouble(value);
if (doubleValue != null) {
String id = Metrics.metricId(type, opersResult.getRequest());
data.add(new RawNumericMetric(id, doubleValue, timestamp));
}
}
}
} else if (result instanceof MBeanAttrsResult) {
MBeanAttrsResult attrsResult = (MBeanAttrsResult) result;
List<MBeanAttrResult> attrResults = attrsResult.getResults();
if (attrResults != null) {
for (MBeanAttrResult attrResult : attrResults) {
Map<String, Object> attrs = attrResult.getAttrs();
if (attrs != null) {
Set<Map.Entry<String, Object>> attrEntries = attrs.entrySet();
for (Map.Entry<String, Object> attrEntry : attrEntries) {
String attributeName = attrEntry.getKey();
Object value = attrEntry.getValue();
Double doubleValue = toDouble(value);
if (doubleValue != null) {
String id = Metrics.metricId(type, attrsResult.getRequest(), attributeName);
data.add(new RawNumericMetric(id, doubleValue, timestamp));
}
}
}
}
}
}
}
if (!data.isEmpty()) {
metricsService.addData(data);
if (LOG.isDebugEnabled()) {
LOG.debug("added " + data.size() + " metrics");
}
}
}
}
use of io.fabric8.maven.docker.util.Timestamp in project fabric8 by jboss-fuse.
the class Log4jLogQuery method filterLogResults.
protected LogResults filterLogResults(Predicate<LogEvent> predicate, int maxCount) {
int matched = 0;
long from = Long.MAX_VALUE;
long to = Long.MIN_VALUE;
List<LogEvent> list = new ArrayList<LogEvent>();
Iterable<LoggingEvent> elements = getEvents().getElements();
for (LoggingEvent element : elements) {
LogEvent logEvent = toLogEvent(element);
long timestamp = element.getTimeStamp();
if (timestamp > to) {
to = timestamp;
}
if (timestamp < from) {
from = timestamp;
}
if (logEvent != null) {
if (predicate == null || predicate.matches(logEvent)) {
list.add(logEvent);
matched += 1;
if (maxCount > 0 && matched >= maxCount) {
break;
}
}
}
}
LogResults results = new LogResults();
results.setEvents(list);
if (from < Long.MAX_VALUE) {
results.setFromTimestamp(from);
}
if (to > Long.MIN_VALUE) {
results.setToTimestamp(to);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Requested " + maxCount + " logging items. returning " + results.getEvents().size() + " event(s) from a possible " + getEvents().size());
}
return results;
}
use of io.fabric8.maven.docker.util.Timestamp in project docker-maven-plugin by fabric8io.
the class LogMatchCallbackTest method matchingSingleLineSucceeds.
@Test(expected = LogCallback.DoneException.class)
public void matchingSingleLineSucceeds() throws Exception {
final String patternString = "The start has finished right now";
final LogMatchCallback logMatchCallback = new LogMatchCallback(logger, callback, patternString);
new Expectations() {
{
callback.matched();
times = 1;
}
};
logMatchCallback.log(1, new Timestamp(), patternString);
}
use of io.fabric8.maven.docker.util.Timestamp in project docker-maven-plugin by fabric8io.
the class LogMatchCallbackTest method matchingMultipleLinesSucceeds.
@Test(expected = LogCallback.DoneException.class)
public void matchingMultipleLinesSucceeds() throws Exception {
final String patterString = "(?s)ready to accept connections.*\\n.*ready to accept connections";
final LogMatchCallback logMatchCallback = new LogMatchCallback(logger, callback, patterString);
new Expectations() {
{
callback.matched();
times = 1;
}
};
logMatchCallback.log(1, new Timestamp(), "LOG: database system is ready to accept connections");
logMatchCallback.log(1, new Timestamp(), "LOG: autovacuum launcher started");
logMatchCallback.log(1, new Timestamp(), "LOG: database system is shut down");
logMatchCallback.log(1, new Timestamp(), "LOG: database system is ready to accept connections");
}
Aggregations