Class KstatUtil.KstatChain

  • All Implemented Interfaces:
    java.lang.AutoCloseable
    Enclosing class:
    KstatUtil

    public static final class KstatUtil.KstatChain
    extends java.lang.Object
    implements java.lang.AutoCloseable
    A copy of the Kstat chain, encapsulating a kstat_ctl_t object. Only one thread may actively use this object at any time.

    The chain is created once calling LibKstat.kstat_open() and then this object is instantiated using the KstatUtil.openChain() method. Instantiating this object updates the chain using LibKstat.kstat_chain_update(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl). The control object should be closed with close(), which releases the lock and allows another instance to be instantiated.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl localCtlRef  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private KstatChain​(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl ctl)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Release the lock on the chain.
      com.sun.jna.platform.unix.solaris.LibKstat.Kstat lookup​(java.lang.String module, int instance, java.lang.String name)
      Convenience method for LibKstat.kstat_lookup(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, java.lang.String, int, java.lang.String).
      java.util.List<com.sun.jna.platform.unix.solaris.LibKstat.Kstat> lookupAll​(java.lang.String module, int instance, java.lang.String name)
      Convenience method for LibKstat.kstat_lookup(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, java.lang.String, int, java.lang.String).
      boolean read​(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp)
      Convenience method for LibKstat.kstat_read(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, com.sun.jna.platform.unix.solaris.LibKstat.Kstat, com.sun.jna.Pointer) which gets data from the kernel for the kstat pointed to by ksp.
      int update()
      Convenience method for LibKstat.kstat_chain_update(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • localCtlRef

        private final com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl localCtlRef
    • Constructor Detail

      • KstatChain

        private KstatChain​(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl ctl)
    • Method Detail

      • read

        public boolean read​(com.sun.jna.platform.unix.solaris.LibKstat.Kstat ksp)
        Convenience method for LibKstat.kstat_read(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, com.sun.jna.platform.unix.solaris.LibKstat.Kstat, com.sun.jna.Pointer) which gets data from the kernel for the kstat pointed to by ksp. ksp.ks_data is automatically allocated (or reallocated) to be large enough to hold all of the data. ksp.ks_ndata is set to the number of data fields, ksp.ks_data_size is set to the total size of the data, and ksp.ks_snaptime is set to the high-resolution time at which the data snapshot was taken.
        Parameters:
        ksp - The kstat from which to retrieve data
        Returns:
        true if successful; false otherwise
      • lookup

        public com.sun.jna.platform.unix.solaris.LibKstat.Kstat lookup​(java.lang.String module,
                                                                       int instance,
                                                                       java.lang.String name)
        Convenience method for LibKstat.kstat_lookup(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, java.lang.String, int, java.lang.String). Traverses the kstat chain, searching for a kstat with the same module, instance, and name fields; this triplet uniquely identifies a kstat. If module is null, instance is -1, or name is null, then those fields will be ignored in the search.
        Parameters:
        module - The module, or null to ignore
        instance - The instance, or -1 to ignore
        name - The name, or null to ignore
        Returns:
        The first match of the requested Kstat structure if found, or null
      • lookupAll

        public java.util.List<com.sun.jna.platform.unix.solaris.LibKstat.Kstat> lookupAll​(java.lang.String module,
                                                                                          int instance,
                                                                                          java.lang.String name)
        Convenience method for LibKstat.kstat_lookup(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl, java.lang.String, int, java.lang.String). Traverses the kstat chain, searching for all kstats with the same module, instance, and name fields; this triplet uniquely identifies a kstat. If module is null, instance is -1, or name is null, then those fields will be ignored in the search.
        Parameters:
        module - The module, or null to ignore
        instance - The instance, or -1 to ignore
        name - The name, or null to ignore
        Returns:
        All matches of the requested Kstat structure if found, or an empty list otherwise
      • update

        public int update()
        Convenience method for LibKstat.kstat_chain_update(com.sun.jna.platform.unix.solaris.LibKstat.KstatCtl). Brings this kstat header chain in sync with that of the kernel.

        This function compares the kernel's current kstat chain ID(KCID), which is incremented every time the kstat chain changes, to this object's KCID.

        Returns:
        the new KCID if the kstat chain has changed, 0 if it hasn't, or -1 on failure.
      • close

        public void close()
        Release the lock on the chain.
        Specified by:
        close in interface java.lang.AutoCloseable