< prev index next >

core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/jdk/JdkAttributes.java

Print this page




  32  */
  33 package org.openjdk.jmc.flightrecorder.jdk;
  34 
  35 import static org.openjdk.jmc.common.item.Attribute.attr;
  36 import static org.openjdk.jmc.common.unit.UnitLookup.ADDRESS;
  37 import static org.openjdk.jmc.common.unit.UnitLookup.CLASS;
  38 import static org.openjdk.jmc.common.unit.UnitLookup.CLASS_LOADER;
  39 import static org.openjdk.jmc.common.unit.UnitLookup.FLAG;
  40 import static org.openjdk.jmc.common.unit.UnitLookup.LABELED_IDENTIFIER;
  41 import static org.openjdk.jmc.common.unit.UnitLookup.MEMORY;
  42 import static org.openjdk.jmc.common.unit.UnitLookup.METHOD;
  43 import static org.openjdk.jmc.common.unit.UnitLookup.NUMBER;
  44 import static org.openjdk.jmc.common.unit.UnitLookup.OLD_OBJECT;
  45 import static org.openjdk.jmc.common.unit.UnitLookup.PERCENTAGE;
  46 import static org.openjdk.jmc.common.unit.UnitLookup.PLAIN_TEXT;
  47 import static org.openjdk.jmc.common.unit.UnitLookup.THREAD;
  48 import static org.openjdk.jmc.common.unit.UnitLookup.TIMESPAN;
  49 import static org.openjdk.jmc.common.unit.UnitLookup.TIMESTAMP;
  50 import static org.openjdk.jmc.common.unit.UnitLookup.UNKNOWN;
  51 

  52 import java.util.List;
  53 
  54 import org.openjdk.jmc.common.IDisplayable;
  55 import org.openjdk.jmc.common.IMCClassLoader;
  56 import org.openjdk.jmc.common.IMCFrame;
  57 import org.openjdk.jmc.common.IMCMethod;
  58 import org.openjdk.jmc.common.IMCModule;
  59 import org.openjdk.jmc.common.IMCOldObject;
  60 import org.openjdk.jmc.common.IMCOldObjectGcRoot;
  61 import org.openjdk.jmc.common.IMCPackage;
  62 import org.openjdk.jmc.common.IMCStackTrace;
  63 import org.openjdk.jmc.common.IMCThread;
  64 import org.openjdk.jmc.common.IMCThreadGroup;
  65 import org.openjdk.jmc.common.IMCType;
  66 import org.openjdk.jmc.common.item.Attribute;
  67 import org.openjdk.jmc.common.item.IAttribute;
  68 import org.openjdk.jmc.common.item.IMemberAccessor;
  69 import org.openjdk.jmc.common.item.IType;
  70 import org.openjdk.jmc.common.unit.ContentType;
  71 import org.openjdk.jmc.common.unit.IQuantity;
  72 import org.openjdk.jmc.common.unit.UnitLookup;
  73 import org.openjdk.jmc.common.util.FormatToolkit;
  74 import org.openjdk.jmc.common.util.LabeledIdentifier;
  75 import org.openjdk.jmc.common.util.MCClassLoader;

  76 import org.openjdk.jmc.flightrecorder.JfrAttributes;
  77 import org.openjdk.jmc.flightrecorder.jdk.messages.internal.Messages;
  78 
  79 /**
  80  * Various attributes based on JDK flight recorder data.
  81  */
  82 public final class JdkAttributes {
  83 
  84         public static final IAttribute<String> EVENT_THREAD_NAME = Attribute
  85                         .canonicalize(new Attribute<String>("(thread).name", Messages.getString(Messages.ATTR_EVENT_THREAD_NAME), //$NON-NLS-1$
  86                                         Messages.getString(Messages.ATTR_EVENT_THREAD_NAME_DESC), PLAIN_TEXT) {
  87                                 @Override
  88                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
  89                                         final IMemberAccessor<IMCThread, U> accessor = JfrAttributes.EVENT_THREAD.getAccessor(type);
  90                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
  91                                                 @Override
  92                                                 public String getMember(U i) {
  93                                                         IMCThread thread = accessor.getMember(i);
  94                                                         return thread == null ? null : thread.getThreadName();
  95                                                 }


 453         public static final IAttribute<String> IO_PATH = attr("path", Messages.getString(Messages.ATTR_IO_PATH), //$NON-NLS-1$
 454                         Messages.getString(Messages.ATTR_IO_PATH_DESC), PLAIN_TEXT);
 455         public static final IAttribute<IQuantity> IO_FILE_BYTES_READ = attr("bytesRead", //$NON-NLS-1$
 456                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_READ),
 457                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_READ_DESC), MEMORY);
 458         public static final IAttribute<Boolean> IO_FILE_READ_EOF = attr("endOfFile", //$NON-NLS-1$
 459                         Messages.getString(Messages.ATTR_IO_FILE_READ_EOF), Messages.getString(Messages.ATTR_IO_FILE_READ_EOF_DESC),
 460                         FLAG);
 461         public static final IAttribute<IQuantity> IO_FILE_BYTES_WRITTEN = attr("bytesWritten", //$NON-NLS-1$
 462                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_WRITTEN),
 463                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_WRITTEN_DESC), MEMORY);
 464         public static final IAttribute<IQuantity> IO_SOCKET_BYTES_READ = attr("bytesRead", //$NON-NLS-1$
 465                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_READ),
 466                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_READ_DESC), MEMORY);
 467         public static final IAttribute<Boolean> IO_SOCKET_READ_EOS = attr("endOfStream", //$NON-NLS-1$
 468                         Messages.getString(Messages.ATTR_IO_SOCKET_READ_EOS),
 469                         Messages.getString(Messages.ATTR_IO_SOCKET_READ_EOS_DESC), FLAG);
 470         public static final IAttribute<IQuantity> IO_SOCKET_BYTES_WRITTEN = attr("bytesWritten", //$NON-NLS-1$
 471                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_WRITTEN),
 472                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_WRITTEN_DESC), MEMORY);

















 473         public static final IAttribute<String> IO_ADDRESS = attr("address", Messages.getString(Messages.ATTR_IO_ADDRESS), //$NON-NLS-1$
 474                         PLAIN_TEXT);
 475         public static final IAttribute<String> IO_HOST = attr("host", Messages.getString(Messages.ATTR_IO_HOST), //$NON-NLS-1$
 476                         Messages.getString(Messages.ATTR_IO_HOST_DESC), PLAIN_TEXT);
 477         public static final IAttribute<IQuantity> IO_PORT = attr("port", Messages.getString(Messages.ATTR_IO_PORT), NUMBER); //$NON-NLS-1$
 478         public static final IAttribute<Object> IO_PORT_ON_ADDRESS = Attribute.canonicalize(new Attribute<Object>(
 479                         "portOnAddress", Messages.getString(Messages.ATTR_IO_PORT_ON_ADDRESS), null, UNKNOWN) { //$NON-NLS-1$
 480                 @Override
 481                 public <U> IMemberAccessor<Object, U> customAccessor(IType<U> type) {
 482                         class PortOnAddress implements IDisplayable {
 483 
 484                                 final String address;
 485                                 final IQuantity port;
 486 
 487                                 PortOnAddress(String address, IQuantity port) {
 488                                         this.address = address;
 489                                         this.port = port;
 490                                 }
 491 
 492                                 @Override




  32  */
  33 package org.openjdk.jmc.flightrecorder.jdk;
  34 
  35 import static org.openjdk.jmc.common.item.Attribute.attr;
  36 import static org.openjdk.jmc.common.unit.UnitLookup.ADDRESS;
  37 import static org.openjdk.jmc.common.unit.UnitLookup.CLASS;
  38 import static org.openjdk.jmc.common.unit.UnitLookup.CLASS_LOADER;
  39 import static org.openjdk.jmc.common.unit.UnitLookup.FLAG;
  40 import static org.openjdk.jmc.common.unit.UnitLookup.LABELED_IDENTIFIER;
  41 import static org.openjdk.jmc.common.unit.UnitLookup.MEMORY;
  42 import static org.openjdk.jmc.common.unit.UnitLookup.METHOD;
  43 import static org.openjdk.jmc.common.unit.UnitLookup.NUMBER;
  44 import static org.openjdk.jmc.common.unit.UnitLookup.OLD_OBJECT;
  45 import static org.openjdk.jmc.common.unit.UnitLookup.PERCENTAGE;
  46 import static org.openjdk.jmc.common.unit.UnitLookup.PLAIN_TEXT;
  47 import static org.openjdk.jmc.common.unit.UnitLookup.THREAD;
  48 import static org.openjdk.jmc.common.unit.UnitLookup.TIMESPAN;
  49 import static org.openjdk.jmc.common.unit.UnitLookup.TIMESTAMP;
  50 import static org.openjdk.jmc.common.unit.UnitLookup.UNKNOWN;
  51 
  52 import java.util.ArrayList;
  53 import java.util.List;
  54 
  55 import org.openjdk.jmc.common.IDisplayable;
  56 import org.openjdk.jmc.common.IMCClassLoader;
  57 import org.openjdk.jmc.common.IMCFrame;
  58 import org.openjdk.jmc.common.IMCMethod;
  59 import org.openjdk.jmc.common.IMCModule;
  60 import org.openjdk.jmc.common.IMCOldObject;
  61 import org.openjdk.jmc.common.IMCOldObjectGcRoot;
  62 import org.openjdk.jmc.common.IMCPackage;
  63 import org.openjdk.jmc.common.IMCStackTrace;
  64 import org.openjdk.jmc.common.IMCThread;
  65 import org.openjdk.jmc.common.IMCThreadGroup;
  66 import org.openjdk.jmc.common.IMCType;
  67 import org.openjdk.jmc.common.item.Attribute;
  68 import org.openjdk.jmc.common.item.IAttribute;
  69 import org.openjdk.jmc.common.item.IMemberAccessor;
  70 import org.openjdk.jmc.common.item.IType;
  71 import org.openjdk.jmc.common.unit.ContentType;
  72 import org.openjdk.jmc.common.unit.IQuantity;
  73 import org.openjdk.jmc.common.unit.UnitLookup;
  74 import org.openjdk.jmc.common.util.FormatToolkit;
  75 import org.openjdk.jmc.common.util.LabeledIdentifier;
  76 import org.openjdk.jmc.common.util.MCClassLoader;
  77 import org.openjdk.jmc.common.util.MemberAccessorToolkit;
  78 import org.openjdk.jmc.flightrecorder.JfrAttributes;
  79 import org.openjdk.jmc.flightrecorder.jdk.messages.internal.Messages;
  80 
  81 /**
  82  * Various attributes based on JDK flight recorder data.
  83  */
  84 public final class JdkAttributes {
  85 
  86         public static final IAttribute<String> EVENT_THREAD_NAME = Attribute
  87                         .canonicalize(new Attribute<String>("(thread).name", Messages.getString(Messages.ATTR_EVENT_THREAD_NAME), //$NON-NLS-1$
  88                                         Messages.getString(Messages.ATTR_EVENT_THREAD_NAME_DESC), PLAIN_TEXT) {
  89                                 @Override
  90                                 public <U> IMemberAccessor<String, U> customAccessor(IType<U> type) {
  91                                         final IMemberAccessor<IMCThread, U> accessor = JfrAttributes.EVENT_THREAD.getAccessor(type);
  92                                         return accessor == null ? null : new IMemberAccessor<String, U>() {
  93                                                 @Override
  94                                                 public String getMember(U i) {
  95                                                         IMCThread thread = accessor.getMember(i);
  96                                                         return thread == null ? null : thread.getThreadName();
  97                                                 }


 455         public static final IAttribute<String> IO_PATH = attr("path", Messages.getString(Messages.ATTR_IO_PATH), //$NON-NLS-1$
 456                         Messages.getString(Messages.ATTR_IO_PATH_DESC), PLAIN_TEXT);
 457         public static final IAttribute<IQuantity> IO_FILE_BYTES_READ = attr("bytesRead", //$NON-NLS-1$
 458                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_READ),
 459                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_READ_DESC), MEMORY);
 460         public static final IAttribute<Boolean> IO_FILE_READ_EOF = attr("endOfFile", //$NON-NLS-1$
 461                         Messages.getString(Messages.ATTR_IO_FILE_READ_EOF), Messages.getString(Messages.ATTR_IO_FILE_READ_EOF_DESC),
 462                         FLAG);
 463         public static final IAttribute<IQuantity> IO_FILE_BYTES_WRITTEN = attr("bytesWritten", //$NON-NLS-1$
 464                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_WRITTEN),
 465                         Messages.getString(Messages.ATTR_IO_FILE_BYTES_WRITTEN_DESC), MEMORY);
 466         public static final IAttribute<IQuantity> IO_SOCKET_BYTES_READ = attr("bytesRead", //$NON-NLS-1$
 467                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_READ),
 468                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_READ_DESC), MEMORY);
 469         public static final IAttribute<Boolean> IO_SOCKET_READ_EOS = attr("endOfStream", //$NON-NLS-1$
 470                         Messages.getString(Messages.ATTR_IO_SOCKET_READ_EOS),
 471                         Messages.getString(Messages.ATTR_IO_SOCKET_READ_EOS_DESC), FLAG);
 472         public static final IAttribute<IQuantity> IO_SOCKET_BYTES_WRITTEN = attr("bytesWritten", //$NON-NLS-1$
 473                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_WRITTEN),
 474                         Messages.getString(Messages.ATTR_IO_SOCKET_BYTES_WRITTEN_DESC), MEMORY);
 475         public static final IAttribute<IQuantity> IO_SIZE = Attribute.canonicalize(new Attribute<IQuantity>("size",  //#NON-NLS-1$
 476                         "Size", null, MEMORY) {
 477                 @Override
 478                 public <U> IMemberAccessor<IQuantity, U> customAccessor(IType<U> type){
 479                         List<IMemberAccessor<IQuantity, U>> accessorList = new ArrayList<>();
 480                         accessorList.add(type.getAccessor(JdkAttributes.IO_SOCKET_BYTES_READ.getKey()));
 481                         accessorList.add(type.getAccessor(JdkAttributes.IO_SOCKET_BYTES_WRITTEN.getKey()));
 482                         accessorList.add(type.getAccessor(JdkAttributes.IO_FILE_BYTES_READ.getKey()));
 483                         accessorList.add(type.getAccessor(JdkAttributes.IO_FILE_BYTES_WRITTEN.getKey()));
 484                         for (IMemberAccessor<IQuantity, U> accessor : accessorList) {
 485                                 if(accessor != null) {
 486                                         return accessor;
 487                                 }
 488                         }
 489                         return MemberAccessorToolkit.constant(UnitLookup.BYTE.quantity(0));
 490                 }
 491         });
 492         public static final IAttribute<String> IO_ADDRESS = attr("address", Messages.getString(Messages.ATTR_IO_ADDRESS), //$NON-NLS-1$
 493                         PLAIN_TEXT);
 494         public static final IAttribute<String> IO_HOST = attr("host", Messages.getString(Messages.ATTR_IO_HOST), //$NON-NLS-1$
 495                         Messages.getString(Messages.ATTR_IO_HOST_DESC), PLAIN_TEXT);
 496         public static final IAttribute<IQuantity> IO_PORT = attr("port", Messages.getString(Messages.ATTR_IO_PORT), NUMBER); //$NON-NLS-1$
 497         public static final IAttribute<Object> IO_PORT_ON_ADDRESS = Attribute.canonicalize(new Attribute<Object>(
 498                         "portOnAddress", Messages.getString(Messages.ATTR_IO_PORT_ON_ADDRESS), null, UNKNOWN) { //$NON-NLS-1$
 499                 @Override
 500                 public <U> IMemberAccessor<Object, U> customAccessor(IType<U> type) {
 501                         class PortOnAddress implements IDisplayable {
 502 
 503                                 final String address;
 504                                 final IQuantity port;
 505 
 506                                 PortOnAddress(String address, IQuantity port) {
 507                                         this.address = address;
 508                                         this.port = port;
 509                                 }
 510 
 511                                 @Override


< prev index next >