Package com.tailf.ncs

Class NcsMain

Object
com.tailf.ncs.NcsMain
All Implemented Interfaces:
NcsMainMBean, Runnable, Thread.UncaughtExceptionHandler

public class NcsMain extends Object implements Runnable, NcsMainMBean, Thread.UncaughtExceptionHandler
Main class for Ncs java vm management and control. This class implements the Runnable interface and should be started in a thread which becomes the Ncs java vm main thread. Normally this thread is instantiated and started by the NcsJVMLauncher which contains a main() method. It is however possible to embed and start the NcsMain thread from any other java program by inserting the following code snippet:
 NcsMain ncs = NcsMain.getInstance(host, port);
 Thread ncsThread = new Thread(ncs);
 ncsThread.start();
 
The Ncs java vm main thread will connect to the Ncs Server and start negotiation of which packages/components that should be instantiated registered and started. No manual registration is necessary.
  • Field Details

    • TAILF_CLASSLOADER

      public static final String TAILF_CLASSLOADER
      This field represents a system property controlling which classloader the Ncs java vm should use. If the system classloader is preferred this property should be set "false". The default is true If the system classloader is used, redeployment is not possible Example: java -cp ... -DTAILF_CLASSLOADER=false com...NcsJVMLauncher
      See Also:
  • Method Details

    • getNcsHost

      public String getNcsHost()
      Get the hostname or ip for the Ncs Server
      Returns:
      String hostname or ip for Ncs server
    • getNcsPort

      public int getNcsPort()
      Get the port number for the Ncs Server
      Returns:
      int Ncs server port
    • getSinkCentral

      public AlarmSinkCentral getSinkCentral()
      Get the Ncs AlarmSinkCentral instance
      Returns:
      AlarmSinkCentral
    • getSourceCentral

      public AlarmSourceCentral getSourceCentral()
      Get the Ncs AlarmSourceCentral instance
      Returns:
      AlarmSourceCentral
    • getDPMuxManager

      public com.tailf.ncs.ctrl.DpMuxManager getDPMuxManager()
      Get the DpMuxManager. This Manager controls the Dp instances and all registered callback components from all packages
      Returns:
      DpMuxManager
    • getNedMuxManager

      public com.tailf.ncs.ctrl.NedMuxManager getNedMuxManager()
      Get the NedMuxManager. This Manager controls the NedMux and all registered Ned components from all packages
      Returns:
      NedMuxManager
    • getApplicationMuxManager

      public com.tailf.ncs.ctrl.ApplicationMuxManager getApplicationMuxManager()
      Get the ApplicationMuxManager. This Manager controls all Application component threads from all packages
      Returns:
      ApplicationMuxManager
    • run

      public void run()
      This method is the Ncs java vm main thread start
      Specified by:
      run in interface Runnable
    • isNcsMainCtrl

      public static boolean isNcsMainCtrl()
      Checks if this Ncs java main is instantiated in legacy mode. This mode is only expected for Ncs implementations which are built for Ncs releases prior to version 2.0
      Returns:
      true if NcsMain was instantiated and started
    • isTailFClassloader

      public static boolean isTailFClassloader()
      Checks if NcsMain was started with the Tail-f Jar classloader, as opposed to running with the standard java system classloader. The default is running with the Tail-f Jar classloader, which is necessary to be able to perform component hot re-deploy.
      Returns:
      true if the Tail-f Jar classloaded is active
    • isAddingPkgs

      public boolean isAddingPkgs()
    • instantiatePackageComponent

      public void instantiatePackageComponent(com.tailf.ncs.ctrl.NcsPDData pdData) throws Exception
      Instantiates and registers components for a Ncs Package
      Parameters:
      pdData -
      Throws:
      Exception
    • redeployPackage

      public void redeployPackage(com.tailf.ncs.ctrl.NcsPDData pdData) throws Exception
      Hot redeploy of all components for a package
      Parameters:
      pdData -
      Throws:
      Exception
    • isStarted

      public static boolean isStarted()
      Check if Ncs main thread is started
      Returns:
      true if the Ncs main thread is running
    • getInstance

      public static NcsMain getInstance()
      Get the singleton instance of the NcsMain class
      Returns:
      NcsMain instance
    • getInstance

      public static NcsMain getInstance(String host, int port)
      Get the singleton instance of the NcsMain class
      Parameters:
      host -
      port -
      Returns:
      NcsMain instance
    • abortNcsJavaVM

      public static void abortNcsJavaVM(Object obj)
      Abort Ncs Java VM
      Parameters:
      obj -
    • abortNcsJavaVM

      public static void abortNcsJavaVM(Object obj, int code)
      Abort Ncs Java VM
      Parameters:
      obj -
      code -
    • abortNcsJavaVM

      public static void abortNcsJavaVM(Object obj, int code, String message)
      Abort Ncs Java VM
      Parameters:
      obj -
      code -
      message -
    • reportPackageException

      public static Throwable reportPackageException(Object instance, Throwable e)
    • reportPackageException

      public static Throwable reportPackageException(ClassLoader cl, Throwable e)
    • reportPackageException

      public static Throwable reportPackageException(String packageName, Throwable e)
    • submitPackageAlarm

      public static void submitPackageAlarm(Object instance, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText)
    • submitPackageAlarm

      public static void submitPackageAlarm(ClassLoader cl, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText)
    • submitPackageAlarm

      public static void submitPackageAlarm(String packageName, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText)
    • shutdown

      public void shutdown()
      JMX interface - shutdown Ncs java vm main thread
      Specified by:
      shutdown in interface NcsMainMBean
    • redeployAll

      public void redeployAll()
      JMX interface - hot redeploy all packages
      Specified by:
      redeployAll in interface NcsMainMBean
    • restartPackage

      public void restartPackage(String packageName)
    • restartPackageNow

      public void restartPackageNow(String packageName)
    • listSharedJars

      public String[] listSharedJars()
      JMX interface - list shared jars
      Specified by:
      listSharedJars in interface NcsMainMBean
    • uncaughtException

      public void uncaughtException(Thread t, Throwable e)
      Specified by:
      uncaughtException in interface Thread.UncaughtExceptionHandler