Class CacheInstance

java.lang.Object
com.vmware.vim.cf.CacheInstance

public class CacheInstance extends Object
  • Constructor Details

  • Method Details

    • watch

      public void watch(ManagedObject[] mos, String[] props)
      Add the managed objects and their properties to be watched.
      Parameters:
      mos - array of managed objects.
      props - array of properties to watch
    • watch

      public void watch(PropertyFilterSpec pfs)
      Add PropertyFilterSpec for advanced settings
      Parameters:
      pfs - the property filter spec which specifies the managed objects and properties to watch.
    • getCopy

      public Object getCopy(ManagedObject mo, String propName)
      Get a copy of the cached property. You can change the returned object as you like
      Parameters:
      mo - Managed object
      propName - property name
      Returns:
      the data object identified by the propName. NullObject.NULL if the data object is really null
    • getCopy

      public Object getCopy(ManagedObjectReference mor, String propName)
      Get a copy of the cached property. You can change the returned object as you like
      Parameters:
      mor - Managed object reference
      propName - property name
      Returns:
      the data object identified by the propName. NullObject.NULL if the data object is really null
    • get

      public Object get(ManagedObject mo, String propName)
      Get the value of cached property whose name is propName. You should NEVER change the returned data object.
      Parameters:
      mo - Managed object on which the cached property is requested
      propName - Property name, can include "."
      Returns:
      the data object identified by the propName. NullObject.NULL if the data object is really null
    • get

      public Object get(ManagedObjectReference mor, String propName)
      Get the value of cached property whose name is propName. You should NEVER change the returned data object.
      Parameters:
      mor - Managed object reference pointing to the managed object
      propName - Property name
      Returns:
      the data object identified by the propName. NullObject.NULL if the data object is really null
    • start

      public void start()
      Start the caching service. Called after specifying the managed objects and their properties to watch.
    • destroy

      public void destroy()
      Destroy the caching service when no longer needed. Call this before ServiceInstance.disconnect(); otherwise the watcher thread will spin on the dead session until vCenter rejects the next call with NotAuthenticated.

      Cancels any in-flight waitForUpdatesEx on the underlying property collector, destroys the watcher's filters, and joins the watcher thread so this method returns only after the watcher has actually stopped. Safe to call multiple times.

    • getServiceInstance

      public ServiceInstance getServiceInstance()
      Get the corresponding ServiceInstance
      Returns:
      ServiceInstance object
    • isReady

      public boolean isReady()
      Check if the CacheInstance is ready for retrieval
      Returns:
      true if ready; false otherwise
    • awaitReady

      public boolean awaitReady(long timeoutMillis) throws InterruptedException
      Block until the cache has received its first update from the server, or until the timeout elapses. Use this after start() to avoid the race window where get(com.vmware.vim25.mo.ManagedObject, java.lang.String) returns null because the watcher thread has not yet delivered an update.
      Parameters:
      timeoutMillis - maximum time to wait, in milliseconds; non-positive returns immediately
      Returns:
      true if the cache became ready before the timeout; false otherwise
      Throws:
      InterruptedException - if the current thread is interrupted while waiting