/** * Add a property with a given key and value. * * @param key * property key name * @param value * value associated with the key * @return reference to this snapshot */ public PropertySnapshot add(String key, Object value) { this.add(key, value, false); return this; }
@Override public Snapshot newSnapshot(String cat, String name) { PropertySnapshot snapshot = new PropertySnapshot(cat, name); snapshot.setSource(getSource()); return snapshot; }
@Override public String toString() { StringBuilder str = new StringBuilder(512); str.append(this.getClass().getSimpleName()).append("{Category: " + category + ", Name: " + snapName) .append(", TimeStamp: ").append(timeStamp).append(", Count: " + this.size()).append(", List: ["); for (Property item : propSet.values()) { str.append(item); } str.append("]}"); return str.toString(); }
PropertySnapshot cpu = new PropertySnapshot(DEFAULT_SNAPSHOT_CATEGORY, SNAPSHOT_CPU, activity.getSeverity()); double load = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); if (load >= 0) { cpu.add(new Property(DEFAULT_PROPERTY_LOAD_AVG, load, ValueTypes.VALUE_TYPE_GAUGE)); cpu.add(DEFAULT_PROPERTY_COUNT, ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors()); cpu.add(new Property(DEFAULT_PROPERTY_CPU_TIME, ((double) tmbean.getThreadCpuTime(ctx.ownerThread.getThreadId()) / 1000.0d), ValueTypes.VALUE_TYPE_AGE_USEC)); cpu.add(new Property(DEFAULT_PROPERTY_TOTAL_USER_TIME, ((double) tmbean.getThreadUserTime(ctx.ownerThread.getThreadId()) / 1000.0d), ValueTypes.VALUE_TYPE_AGE_USEC)); PropertySnapshot thread = new PropertySnapshot(DEFAULT_SNAPSHOT_CATEGORY, SNAPSHOT_THREAD, activity.getSeverity()); thread.add(new Property(DEFAULT_PROPERTY_COUNT, tmbean.getThreadCount(), ValueTypes.VALUE_TYPE_GAUGE)); thread.add(new Property(DEFAULT_PROPERTY_DAEMON_COUNT, tmbean.getDaemonThreadCount(), ValueTypes.VALUE_TYPE_GAUGE)); thread.add(new Property(DEFAULT_PROPERTY_STARTED_COUNT, tmbean.getTotalStartedThreadCount(), ValueTypes.VALUE_TYPE_COUNTER)); thread.add(new Property(DEFAULT_PROPERTY_PEAK_COUNT, tmbean.getPeakThreadCount(), ValueTypes.VALUE_TYPE_GAUGE)); if (ctx != null) { thread.add(new Property(DEFAULT_PROPERTY_BLOCKED_COUNT, ctx.ownerThread.getBlockedCount(), ValueTypes.VALUE_TYPE_COUNTER)); thread.add(new Property(DEFAULT_PROPERTY_WAITED_COUNT, ctx.ownerThread.getWaitedCount(), ValueTypes.VALUE_TYPE_COUNTER)); thread.add(new Property(DEFAULT_PROPERTY_BLOCKED_TIME, ctx.ownerThread.getBlockedTime() * 1000, ValueTypes.VALUE_TYPE_AGE_USEC));
/** * Extract syslog structured data if available (part of RFC 5424) * * @param sevent * syslog structured message * @param tevent * tracking event */ protected void extractStructuredData(StructuredSyslogServerEvent sevent, TrackingEvent tevent) { StructuredSyslogMessage sm = sevent.getStructuredMessage(); Map<?, ?> map = sm.getStructuredData(); if (map != null && !map.isEmpty()) { PropertySnapshot snap = new PropertySnapshot(SNAPSHOT_CAT_SYSLOG_MAP, sevent.getApplicationName(), tevent.getSeverity()); snap.addAll(map); tevent.getOperation().addSnapshot(snap); } }
curSnapshot = new PropertySnapshot(category, name, severity, simCurrTime); curSnapshot.setTTL(TNT4JSimulator.getTTL()); } catch (Exception e) { if (e instanceof SAXException) {
private Snapshot getSelfSnapshot(Operation op) { Snapshot selfSnapshot = new PropertySnapshot("Self"); if (op.getCorrelator() != null) { Set<String> cids = op.getCorrelator(); if (!cids.isEmpty()) { selfSnapshot.add(JSON_CORR_ID_FIELD, cids); } } if (op.getUser() != null) { selfSnapshot.add(JSON_USER_FIELD, op.getUser()); } if (op.getLocation() != null) { selfSnapshot.add(JSON_LOCATION_FIELD, op.getLocation()); } selfSnapshot.add(JSON_SEVERITY_FIELD, op.getSeverity()); selfSnapshot.add(JSON_PID_FIELD, op.getPID()); selfSnapshot.add(JSON_TID_FIELD, op.getTID()); selfSnapshot.add(JSON_SNAPSHOT_COUNT_FIELD, op.getSnapshotCount()); selfSnapshot.add(JSON_ELAPSED_TIME_USEC_FIELD, op.getElapsedTimeUsec()); return selfSnapshot; }
/** * Extract syslog name/value pairs if available in within the message * * @param event * syslog event message * @param tevent * tracking event * @return map of parsed out event attributes (name=value pairs) */ protected Map<String, Object> extractVariables(SyslogServerEventIF event, TrackingEvent tevent) { Map<String, Object> attr = parseVariables(event.getMessage()); if (attr != null && attr.size() > 0) { extractSpecialKeys(attr, tevent); PropertySnapshot snap = new PropertySnapshot(SNAPSHOT_CAT_SYSLOG_VARS, tevent.getOperation().getResource(), tevent.getSeverity()); snap.addAll(attr); tevent.getOperation().addSnapshot(snap); } return attr; }
/** * Add a property with a given key and value. * * @param key * property key name * @param value * value associated with the key * @param transient_ * flag indicating whether property is transient * @return reference to this snapshot */ public PropertySnapshot add(String key, Object value, boolean transient_) { this.add((Object) key, value, transient_); return this; }
@Override public Snapshot newSnapshot(String cat, String name, OpLevel level) { PropertySnapshot snapshot = new PropertySnapshot(cat, name, level); snapshot.setSource(getSource()); return snapshot; }
private void collectStats(Stats stats, PropertySnapshot snapshot, MBeanAttributeInfo mbAttrInfo, PropertyNameBuilder statName) { String initialStatName = statName.toString(); int initialPropsCount = snapshot.size(); if (snapshot.size() == initialPropsCount) { processEmptyStats(stats, snapshot, statName);
/** * Add a property with a given key and value. * * @param key * property key name * @param value * value associated with the key * @return reference to this snapshot */ @Override public PropertySnapshot add(Object key, Object value) { this.add(key.toString(), value, false); return this; }
@Override public Snapshot addAll(Map<? extends Object, ? extends Object> m) { for (Entry<? extends Object, ? extends Object> entry : m.entrySet()) { this.add(entry.getKey(), entry.getValue()); } return this; }
protected void processEmptyStats(Stats stats, PropertySnapshot snapshot, PropertyNameBuilder propName) { snapshot.add(propName.propString(), stats.toString()); }
/** * Add a property with a given key and value. * * @param key * property key name * @param value * value associated with the key * @param transient_ * flag indicating whether property is transient * @return reference to this snapshot */ @Override public PropertySnapshot add(Object key, Object value, boolean transient_) { this.add(new Property(String.valueOf(key), value, transient_)); return this; }
/** * Add a property with a given key and value. * * @param key * property key name * @param value * value associated with the key * @param valType * value type such as (currency, percent). See {@link ValueTypes}. * @return reference to this snapshot */ @Override public PropertySnapshot add(Object key, Object value, String valType) { this.add(new Property(key.toString(), value, valType)); return this; }
curSnapshot.add(prop); } else if (SIM_XML_EVENT.equals(curElement)) { curEvent.getOperation().addProperty(prop);
@Override protected void processEmptyStats(Stats stats, PropertySnapshot snapshot, PropertyNameBuilder propName) { if (stats instanceof StatsImpl) { StatsImpl wsStatsImpl = (StatsImpl) stats; WSStats wsStats = wsStatsImpl.getWSImpl(); snapshot.add(propName.append("name").propString(), wsStats.getName()); snapshot.add(propName.append("type").propString(), wsStats.getStatsType()); snapshot.add(propName.append("time").propString(), wsStats.getTime()); } else { super.processEmptyStats(stats, snapshot, propName); } } }