sun.management.counter.perf.PerfInstrumentation Java Examples

The following examples show how to use sun.management.counter.perf.PerfInstrumentation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectorAddressLink.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #2
Source File: ConnectorAddressLink.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #3
Source File: ConnectorAddressLink.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #4
Source File: ConnectorAddressLink.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #5
Source File: ConnectorAddressLink.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #6
Source File: ConnectorAddressLink.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #7
Source File: ConnectorAddressLink.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #8
Source File: ConnectorAddressLink.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #9
Source File: ConnectorAddressLink.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #10
Source File: ConnectorAddressLink.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #11
Source File: ConnectorAddressLink.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #12
Source File: ConnectorAddressLink.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #13
Source File: ConnectorAddressLink.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #14
Source File: ConnectorAddressLink.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #15
Source File: ConnectorAddressLink.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #16
Source File: ConnectorAddressLink.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #17
Source File: ConnectorAddressLink.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #18
Source File: ConnectorAddressLink.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #19
Source File: ConnectorAddressLink.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #20
Source File: ConnectorAddressLink.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #21
Source File: ConnectorAddressLink.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #22
Source File: ConnectorAddressLink.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #23
Source File: ConnectorAddressLink.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #24
Source File: ConnectorAddressLink.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #25
Source File: ConnectorAddressLink.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the remote connector address and associated
 * configuration properties from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return a map containing the remote connector's properties, or an empty
 * map if the target VM has not exported the remote connector's properties.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static Map<String, String> importRemoteFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters = new PerfInstrumentation(bb).getAllCounters();
    Map<String, String> properties = new HashMap<>();
    for (Counter c : counters) {
        String name =  c.getName();
        if (name.startsWith(REMOTE_CONNECTOR_COUNTER_PREFIX) &&
                !name.equals(CONNECTOR_ADDRESS_COUNTER)) {
            properties.put(name, c.getValue().toString());
        }
    }
    return properties;
}
 
Example #26
Source File: ConnectorAddressLink.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Imports the connector address from the instrument buffer
 * of the specified Java virtual machine.
 *
 * @param vmid an identifier that uniquely identifies a local Java virtual
 * machine, or <code>0</code> to indicate the current Java virtual machine.
 *
 * @return the value of the connector address, or <code>null</code> if the
 * target VM has not exported a connector address.
 *
 * @throws IOException An I/O error occurred while trying to acquire the
 * instrumentation buffer.
 */
public static String importFrom(int vmid) throws IOException {
    Perf perf = Perf.getPerf();
    ByteBuffer bb;
    try {
        bb = perf.attach(vmid, "r");
    } catch (IllegalArgumentException iae) {
        throw new IOException(iae.getMessage());
    }
    List<Counter> counters =
            new PerfInstrumentation(bb).findByPattern(CONNECTOR_ADDRESS_COUNTER);
    Iterator<Counter> i = counters.iterator();
    if (i.hasNext()) {
        Counter c = i.next();
        return (String) c.getValue();
    } else {
        return null;
    }
}
 
Example #27
Source File: PerfData.java    From bistoury with GNU General Public License v3.0 5 votes vote down vote up
private PerfData(int pid) throws IOException, InvocationTargetException, IllegalAccessException {
    ByteBuffer bb = (ByteBuffer) ATTACH_METHOD.invoke(PERF_INSTANCE, pid, "r");
    instr = new PerfInstrumentation(bb);
    counters = buildAllCounters();

    long hz = (Long) counters.get("sun.os.hrt.frequency").getValue();
    nanosPerTick = ((double) TimeUnit.SECONDS.toNanos(1)) / hz;
}
 
Example #28
Source File: PerfCounterCommand.java    From arthas with Apache License 2.0 5 votes vote down vote up
private static List<Counter> getPerfCounters() {

        /**
         * <pre>
         * Perf p = Perf.getPerf();
         * ByteBuffer buffer = p.attach(pid, "r");
         * </pre>
         */
        try {
            if (perfObject == null) {
                // jdk8
                String perfClassName = "sun.misc.Perf";
                // jdk 11
                if (!JavaVersionUtils.isLessThanJava9()) {
                    perfClassName = "jdk.internal.perf.Perf";
                }

                Class<?> perfClass = ClassLoader.getSystemClassLoader().loadClass(perfClassName);
                Method getPerfMethod = perfClass.getDeclaredMethod("getPerf");
                perfObject = getPerfMethod.invoke(null);
            }

            if (attachMethod == null) {
                attachMethod = perfObject.getClass().getDeclaredMethod("attach",
                        new Class<?>[] { int.class, String.class });
            }

            ByteBuffer buffer = (ByteBuffer) attachMethod.invoke(perfObject,
                    new Object[] { (int) PidUtils.currentLongPid(), "r" });

            PerfInstrumentation perfInstrumentation = new PerfInstrumentation(buffer);
            return perfInstrumentation.getAllCounters();
        } catch (Throwable e) {
            logger.error("get perf counter error", e);
        }
        return Collections.emptyList();
    }
 
Example #29
Source File: PerfData.java    From vjtools with Apache License 2.0 5 votes vote down vote up
public PerfIntr(int pid) throws IllegalArgumentException, IOException {
	ByteBuffer bb = Perf.getPerf().attach(pid, "r");
	instr = new PerfInstrumentation(bb);
	long hz = ((sun.management.counter.LongCounter) instr
			.findByPattern("sun.os.hrt.frequency").get(0)).longValue();
	tick = ((double) TimeUnit.SECONDS.toNanos(1)) / hz;
}
 
Example #30
Source File: PerfCounters.java    From java-svc with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Map<String, Counter> setUpCounters() {
	Map<String, Counter> counters = new HashMap<>();
	Perf p = Perf.getPerf();
	try {
		ByteBuffer buffer = p.attach(0, "r");
		PerfInstrumentation perfInstrumentation = new PerfInstrumentation(buffer);
		for (Counter counter : perfInstrumentation.getAllCounters()) {
			counters.put(counter.getName(), counter);
		}
	} catch (IllegalArgumentException | IOException e) {
		System.err.println("Failed to access performance counters. No counters will be available!");
		e.printStackTrace();
	}
	return counters;
}