Package com.tailf.ncs
Class NcsMain
Object
com.tailf.ncs.NcsMain
- All Implemented Interfaces:
 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThis field represents a system property controlling which classloader the Ncs java vm should use. - 
Method Summary
Modifier and TypeMethodDescriptionstatic voidabortNcsJavaVM(Object obj) Deprecated.static voidabortNcsJavaVM(Object obj, int code) Deprecated.Useshutdown()instead.static voidabortNcsJavaVM(Object obj, int code, String message) Deprecated.Useshutdown()instead.Get the address for the NCS Server.com.tailf.ncs.ctrl.ApplicationMuxManagerGet the ApplicationMuxManager instance.com.tailf.ncs.ctrl.DpMuxManagerGet the DpMuxManager instance.static NcsMainGets the NcsMain instance associated with the current thread.static NcsMaingetInstance(String host, int port) Deprecated.UsegetInstance(SocketAddress)instead.static NcsMaingetInstance(SocketAddress address) Get an instance that should connect to the given address.Gets the NcsMain instance associated with the current thread.Deprecated.Use thegetAddress()method insteadintDeprecated.Use thegetAddress()method insteadcom.tailf.ncs.ctrl.NedMuxManagerGet the NedMuxManager instance.Get the ResourceManager instance.Get the NCS AlarmSinkCentral instance.Get the NCS AlarmSourceCentral instance.Handles exceptions from package components by class loader context.handlePackageException(Object instance, Throwable e) Handles exceptions from package components.handlePackageException(String packageName, Throwable e) Handles exceptions from a specific package by name.voidinstantiatePackageComponent(com.tailf.ncs.ctrl.NcsPDData pdData) Instantiates and registers components for an NCS package.booleanChecks if packages are being added to the system.booleanChecks if the NCS main thread is running.static booleanDeprecated.UseisRunning()insteadbooleanChecks if this instance was started with the Tail-f Jar classloader, as opposed to running with the standard java system classloader.voidredeployPackage(com.tailf.ncs.ctrl.NcsPDData pdData) Hot redeploy of all components for a package.static ThrowableDeprecated.UsehandlePackageException(ClassLoader, Throwable)instead.static ThrowablereportPackageException(Object instance, Throwable e) Deprecated.UsehandlePackageException(Object, Throwable)instead.static ThrowablereportPackageException(String packageName, Throwable e) Deprecated.UsehandlePackageException(String, Throwable)instead.voidrestartPackage(String packageName) Schedules a package for restart.voidrestartPackageNow(String packageName) Immediately restarts a packagevoidrun()This method is the Ncs java vm main thread startvoidshutdown()shutdown Ncs java vm main threadstatic voidsubmitPackageAlarm(ClassLoader cl, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) Submits an alarm for a package using its class loader context.static voidsubmitPackageAlarm(Object instance, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) Submits an alarm for a package component instance.static voidsubmitPackageAlarm(String packageName, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) Submits an alarm for a specific package by name.voiduncaughtException(Thread t, Throwable e) Handles uncaught exceptions from any thread by initiating system shutdown. 
- 
Field Details
- 
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.Use thegetAddress()method insteadGet the hostname or IP address for the NCS Server.- Returns:
 - hostname or IP address for NCS server
 
 - 
getNcsPort
Deprecated.Use thegetAddress()method insteadGet the port number for the NCS Server.- Returns:
 - NCS server port
 
 - 
getAddress
Get the address for the NCS Server.- Returns:
 - socket address for the NCS server
 
 - 
getSinkCentral
Get the NCS AlarmSinkCentral instance.- Returns:
 - AlarmSinkCentral instance
 
 - 
getSourceCentral
Get the NCS AlarmSourceCentral instance.- Returns:
 - AlarmSourceCentral instance
 
 - 
getDPMuxManager
public com.tailf.ncs.ctrl.DpMuxManager getDPMuxManager()Get the DpMuxManager instance. This manager controls the DP instances and all registered callback components from all packages.- Returns:
 - DpMuxManager instance
 
 - 
getNedMuxManager
public com.tailf.ncs.ctrl.NedMuxManager getNedMuxManager()Get the NedMuxManager instance. This manager controls the NedMux and all registered NED components from all packages.- Returns:
 - NedMuxManager instance
 
 - 
getApplicationMuxManager
public com.tailf.ncs.ctrl.ApplicationMuxManager getApplicationMuxManager()Get the ApplicationMuxManager instance. This manager controls all application component threads from all packages.- Returns:
 - ApplicationMuxManager instance
 
 - 
getResourceManager
Get the ResourceManager instance.- Returns:
 - resource manager for this NCS instance
 
 - 
run
public void run()This method is the Ncs java vm main thread start - 
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 classloader is active
 
 - 
isAddingPkgs
public boolean isAddingPkgs()Checks if packages are being added to the system.- Returns:
 - true if packages are currently being added
 
 - 
instantiatePackageComponent
Instantiates and registers components for an NCS package.- Parameters:
 pdData- package deployment data containing components to instantiate- Throws:
 Exception- if component instantiation fails
 - 
redeployPackage
Hot redeploy of all components for a package.- Parameters:
 pdData- package deployment data for the package to redeploy- Throws:
 Exception- if redeployment fails
 - 
isStarted
Deprecated.UseisRunning()insteadChecks if the NCS main thread has been started.- Returns:
 - true if the NCS main thread is running
 
 - 
isRunning
public boolean isRunning()Checks if the NCS main thread is running.- Returns:
 - true if the NCS main thread is running
 
 - 
getInstance
Gets the NcsMain instance associated with the current thread.- Returns:
 - instance associated with the current thread, or null if no instance has been started
 
 - 
getLocalInstance
Gets the NcsMain instance associated with the current thread.- Returns:
 - an optional containing the instance associated with the current thread, or empty of no instance has been started
 
 - 
getInstance
Deprecated.UsegetInstance(SocketAddress)instead.Gets the singleton instance of the NcsMain class.- Parameters:
 host- the NCS host to connect toport- the NCS port to connect to- Returns:
 - NcsMain instance
 
 - 
getInstance
Get an instance that should connect to the given address. If an instance already exists for the given address it is returned.- Parameters:
 address- socket address to connect to- Returns:
 - an instance that is connected or will connect to the given address
 
 - 
abortNcsJavaVM
Deprecated.Useshutdown()instead.Aborts the NCS Java VM.- Parameters:
 obj- the object context (unused)
 - 
abortNcsJavaVM
Deprecated.Useshutdown()instead.Aborts the NCS Java VM with exit code.- Parameters:
 obj- the object context (unused)code- the exit code (unused)
 - 
abortNcsJavaVM
Deprecated.Useshutdown()instead.Abort Ncs Java VM- Parameters:
 obj- the object context (unused)code- the exit code (unused)message- the error message (unused)
 - 
reportPackageException
Deprecated.UsehandlePackageException(Object, Throwable)instead.Reports package exceptions and initiates restart handling.- Parameters:
 instance- the component instance that threw the exceptione- the exception to report- Returns:
 - the processed exception
 
 - 
reportPackageException
Deprecated.UsehandlePackageException(ClassLoader, Throwable)instead.Reports package exceptions using class loader context.- Parameters:
 cl- the class loader of the failing packagee- the exception to report- Returns:
 - the processed exception
 
 - 
reportPackageException
Deprecated.UsehandlePackageException(String, Throwable)instead.Reports package exceptions by package name.- Parameters:
 packageName- the name of the failing packagee- the exception to report- Returns:
 - the processed exception
 
 - 
handlePackageException
Handles exceptions from package components.- Parameters:
 instance- the object instance that threw the exceptione- the exception to handle- Returns:
 - the exception to be thrown
 
 - 
handlePackageException
Handles exceptions from package components by class loader context.- Parameters:
 cl- the class loader associated with the failing packagee- the exception to handle- Returns:
 - the exception to be thrown
 
 - 
handlePackageException
Handles exceptions from a specific package by name.- Parameters:
 packageName- the name of the package that generated the exceptione- the exception to handle- Returns:
 - the exception to be thrown
 
 - 
submitPackageAlarm
public static void submitPackageAlarm(Object instance, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) Submits an alarm for a package component instance.- Parameters:
 instance- the component instance generating the alarmalarmType- the type of alarm to submitseverity- the perceived severity of the alarmcleared- whether the alarm is clearedalarmText- descriptive text for the alarm
 - 
submitPackageAlarm
public static void submitPackageAlarm(ClassLoader cl, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) Submits an alarm for a package using its class loader context.- Parameters:
 cl- the class loader of the package generating the alarmalarmType- the type of alarm to submitseverity- the perceived severity of the alarmcleared- whether the alarm is clearedalarmText- descriptive text for the alarm
 - 
submitPackageAlarm
public static void submitPackageAlarm(String packageName, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) Submits an alarm for a specific package by name.- Parameters:
 packageName- the name of the package generating the alarmalarmType- the type of alarm to submitseverity- the perceived severity of the alarmcleared- whether the alarm is clearedalarmText- descriptive text for the alarm
 - 
shutdown
public void shutdown()shutdown Ncs java vm main thread - 
restartPackage
Schedules a package for restart.- Parameters:
 packageName- the name of the package to restart
 - 
restartPackageNow
Immediately restarts a package- Parameters:
 packageName- the name of the package to restart
 - 
uncaughtException
Handles uncaught exceptions from any thread by initiating system shutdown.- Specified by:
 uncaughtExceptionin interfaceThread.UncaughtExceptionHandler- Parameters:
 t- the thread that threw the uncaught exceptione- the uncaught exception
 
 - 
 
shutdown()instead.