Package com.tailf.ncs

Class NcsMain

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

public class NcsMain extends Object implements Runnable, 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

      @Deprecated public String getNcsHost()
      Deprecated.
      Use the getAddress() method instead
      Get the hostname or ip for the Ncs Server
      Returns:
      String hostname or ip for Ncs server
    • getNcsPort

      @Deprecated public int getNcsPort()
      Deprecated.
      Use the getAddress() method instead
      Get the port number for the Ncs Server
      Returns:
      int Ncs server port
    • getAddress

      public SocketAddress getAddress()
      Get the address for the Ncs Server
      Returns:
      String the address for the Ncs server
    • 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
    • getResourceManager

      public ResourceManager getResourceManager()
      Get the ResourceManager.
      Returns:
      ResourceManager the resource manager for this NCS instance
    • run

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

      @Deprecated public static boolean isTailFClassloader()
      Deprecated.
      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 classloader is active
    • isUsingTailFClassloader

      public boolean isUsingTailFClassloader()
      Checks if this instance 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

      @Deprecated public static boolean isStarted()
      Deprecated.
      Check if Ncs main thread is started
      Returns:
      true if the Ncs main thread is running
    • isRunning

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

      public static NcsMain getInstance()
      Get the instance associated with the current thread
      Returns:
      the instance associated with the current thread or null if no instance has been started
    • getLocalInstance

      public static Optional<NcsMain> getLocalInstance()
      Get the instance associated with the current thread
      Returns:
      an optional containng the instance associated with the current thread or empty of no instance has been started
    • getInstance

      @Deprecated public static NcsMain getInstance(String host, int port)
      Deprecated.
      Get the singleton instance of the NcsMain class
      Parameters:
      host - the NCS host to connect to
      port - the NCS port to connect to
      Returns:
      NcsMain instance
    • getInstance

      public static NcsMain getInstance(SocketAddress address)
      Get an instance that should connect to the given address. If an instance already exists for the given address it is returned.
      Returns:
      an instance that is connected or will connect to the given address
    • abortNcsJavaVM

      @Deprecated public static void abortNcsJavaVM(Object obj)
      Deprecated.
      Use shutdown() instead.
      Abort Ncs Java VM
      Parameters:
      obj -
    • abortNcsJavaVM

      @Deprecated public static void abortNcsJavaVM(Object obj, int code)
      Deprecated.
      Use shutdown() instead.
      Abort Ncs Java VM
      Parameters:
      obj -
      code -
    • abortNcsJavaVM

      @Deprecated public static void abortNcsJavaVM(Object obj, int code, String message)
      Deprecated.
      Use shutdown() instead.
      Abort Ncs Java VM
      Parameters:
      obj -
      code -
      message -
    • reportPackageException

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

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

      @Deprecated public static Throwable reportPackageException(String packageName, Throwable e)
    • handlePackageException

      public Throwable handlePackageException(Object instance, Throwable e)
    • handlePackageException

      public Throwable handlePackageException(ClassLoader cl, Throwable e)
    • handlePackageException

      public Throwable handlePackageException(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()
      shutdown Ncs java vm main thread
    • restartPackage

      public void restartPackage(String packageName)
    • restartPackageNow

      public void restartPackageNow(String packageName)
    • uncaughtException

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