use of io.fabric8.maven.docker.util.Timestamp in project fabric8 by jboss-fuse.
the class FabricGitSummaryAction method printVersions.
private void printVersions(String title, List<GitVersion> versions) {
System.out.println(title);
TablePrinter table = new TablePrinter();
table.columns("version", "SHA1", "timestamp", "message");
for (GitVersion version : versions) {
table.row(version.getVersion(), version.getSha1(), version.getTimestamp(), version.getMessage());
}
table.print();
}
use of io.fabric8.maven.docker.util.Timestamp in project fabric8 by jboss-fuse.
the class FabricManagerTest method fromJson.
@Test
public void fromJson() throws IOException {
JMXResult res = om().readValue("{\"correlationId\":\"id\",\"code\":0,\"message\":\"OK\",\"response\":{\"@class\":\"io.fabric8.api.commands.GitVersions\",\"versions\":[{\"version\":\"1.0\",\"sha1\":\"SHA1\",\"timestamp\":null,\"message\":null},{\"version\":\"1.0\",\"sha1\":\"SHA1\",\"timestamp\":null,\"message\":null},{\"version\":\"1.0\",\"sha1\":\"SHA1\",\"timestamp\":null,\"message\":null}]}}", JMXResult.class);
assertNotNull(res);
assertThat(res.getMessage(), equalTo("OK"));
assertThat(((GitVersions) res.getResponse()).getVersions().get(2).getSha1(), equalTo("SHA1"));
assertThat(((GitVersions) res.getResponse()).getVersions().size(), equalTo(3));
}
use of io.fabric8.maven.docker.util.Timestamp in project fabric8 by jboss-fuse.
the class MetricsTest method testDefault.
@Test
public void testDefault() throws Exception {
Query query = new Query("test", new HashSet<Request>(Arrays.asList(new MBeanAttrs("memory", "java.lang:type=Memory", Arrays.asList("HeapMemoryUsage", "NonHeapMemoryUsage")), new MBeanOpers("deadlocks", "java.lang:type=Threading", "dumpAllThreads", Arrays.<Object>asList(true, true), Arrays.<String>asList(boolean.class.getName(), boolean.class.getName())))), null, null, null, 0, 0);
System.gc();
QueryResult qrs = JmxUtils.execute(new Server("local"), query, ManagementFactory.getPlatformMBeanServer());
String output = new Renderer().render(qrs);
Map map = new ObjectMapper().readValue(output, Map.class);
assertEquals("local", map.get("host"));
assertNotNull(map.get("@timestamp"));
}
use of io.fabric8.maven.docker.util.Timestamp in project fabric8 by jboss-fuse.
the class LogQuery method getLogEventList.
public LogResults getLogEventList(int count, Predicate<PaxLoggingEvent> predicate) {
LogResults answer = new LogResults();
answer.setHost(getHostName());
long from = Long.MAX_VALUE;
long to = Long.MIN_VALUE;
if (appender != null) {
LruList events = appender.getEvents();
if (events != null) {
Iterable<PaxLoggingEvent> iterable = events.getElements();
if (iterable != null) {
int matched = 0;
for (PaxLoggingEvent event : iterable) {
if (event != null) {
long timestamp = event.getTimeStamp();
if (timestamp > to) {
to = timestamp;
}
if (timestamp < from) {
from = timestamp;
}
if (predicate == null || predicate.matches(event)) {
answer.addEvent(Logs.newInstance(event));
matched += 1;
if (count > 0 && matched >= count) {
break;
}
}
}
}
}
}
} else {
LOG.warn("No VmLogAppender available!");
}
answer.setFromTimestamp(from);
answer.setToTimestamp(to);
return answer;
}
use of io.fabric8.maven.docker.util.Timestamp in project fabric8 by jboss-fuse.
the class InfluxDBMetricsStorage method store.
@Override
public void store(String type, long timestamp, QueryResult queryResult) {
assertValid();
if (influxDB == null) {
throw new IllegalStateException("No influxDB available!");
}
List<Serie> series = new LinkedList<>();
Map<String, Result<?>> results = queryResult.getResults();
if (results != null) {
Map<String, Object> data = new HashMap<>();
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.put(id, doubleValue);
}
}
}
} 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.put(id, doubleValue);
}
}
}
}
}
}
if (!data.isEmpty()) {
data.put("time", timestamp);
series.add(new Serie.Builder("insight").columns(data.keySet().toArray(new String[data.size()])).values(data.values().toArray(new Object[data.size()])).build());
}
}
if (!series.isEmpty()) {
influxDB.get().write("fabric", TimeUnit.MILLISECONDS, series.toArray(new Serie[series.size()]));
if (LOG.isDebugEnabled()) {
LOG.debug("added " + series.size() + " metrics");
}
}
}
}
Aggregations