/** * Adds the specified linked item to the list of items referenced in this Activity. This method does NOT check for * duplicates. * * @param item * linked item referenced in Activity * @throws NullPointerException * if item is {@code null} * @see #containsId(String) */ public void add(Trackable item) { if (item == null) { throw new NullPointerException("trackable item must be non-null"); } String tid = item.getTrackingId(); if (tid != null) { idset.add(tid); } Set<String> cid = item.getCorrelator(); if (cid != null) { idset.addAll(cid); } if (item instanceof Snapshot) { addSnapshot((Snapshot) item); } item.setTTL(getTTL()); item.setParentId(this); }
/** * {@inheritDoc} */ @Override public String toString() { OpType sType = getType(); ActivityStatus Status = getStatus(); UsecTimestamp sTime = getStartTime(); UsecTimestamp eTime = getEndTime(); StringBuilder str = new StringBuilder(); str.append(getClass().getSimpleName()).append("{") .append("Name:").append(getName()).append(",") .append("ParentId:").append(parentId != null? parentId: "root").append(",") .append("TrackId:").append(getTrackingId()).append(",") .append("Status:").append(Status == null ? "null" : Status.toString()).append(",") .append("Type:").append(sType == null ? "null" : sType.toString()).append(",") .append("PID:").append(getPID()).append(",") .append("TID:").append(getTID()).append(",") .append("ElapsedUsec:").append(getElapsedTimeUsec()).append(",") .append("WallUsec:").append(getWallTimeUsec()).append(",") .append("FQName:").append(getSource().getFQName()).append(",") .append("IdCount=").append(getIdCount()).append(",") .append("SnapCount=").append(getSnapshotCount()).append(",") .append("StartTime:[").append(sTime.toString()).append("],") .append("EndTime:[").append(eTime.toString()).append("]}"); return str.toString(); }
PropertySnapshot cpu = new PropertySnapshot(DEFAULT_SNAPSHOT_CATEGORY, SNAPSHOT_CPU, activity.getSeverity()); double load = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); if (load >= 0) { activity.add(cpu); 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(), activity.add(thread); PropertySnapshot mem = new PropertySnapshot(DEFAULT_SNAPSHOT_CATEGORY, SNAPSHOT_MEMORY, activity.getSeverity()); long usedMem = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); double memPct = (double) ((double) usedMem / (double) Runtime.getRuntime().totalMemory()); mem.add(new Property(DEFAULT_PROPERTY_USED_BYTES, usedMem, ValueTypes.VALUE_TYPE_SIZE_BYTE)); mem.add(new Property(DEFAULT_PROPERTY_USAGE, memPct, ValueTypes.VALUE_TYPE_PERCENT)); activity.add(mem); PropertySnapshot gcSnap = new PropertySnapshot(SNAPSHOT_CATEGORY_GC, gc.getName(), activity.getSeverity()); gcSnap.add(new Property(DEFAULT_PROPERTY_COUNT, gc.getCollectionCount(), ValueTypes.VALUE_TYPE_COUNTER)); gcSnap.add(new Property(DEFAULT_PROPERTY_TIME, gc.getCollectionTime(), ValueTypes.VALUE_TYPE_AGE_MSEC)); gcSnap.add(new Property(DEFAULT_PROPERTY_VALID, gc.isValid())); activity.add(gcSnap); activity.getSeverity()); if (cpuTimingSupported) { long cpuUsed = getUsedCpuTimeNanos(ctx);