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 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) Abort Ncs Java VMstatic voidabortNcsJavaVM(Object obj, int code) Abort Ncs Java VMstatic voidabortNcsJavaVM(Object obj, int code, String message) Abort Ncs Java VMcom.tailf.ncs.ctrl.ApplicationMuxManagerGet the ApplicationMuxManager.com.tailf.ncs.ctrl.DpMuxManagerGet the DpMuxManager.static NcsMainGet the singleton instance of the NcsMain classstatic NcsMaingetInstance(String host, int port) Get the singleton instance of the NcsMain classGet the hostname or ip for the Ncs ServerintGet the port number for the Ncs Servercom.tailf.ncs.ctrl.NedMuxManagerGet the NedMuxManager.Get the Ncs AlarmSinkCentral instanceGet the Ncs AlarmSourceCentral instancevoidinstantiatePackageComponent(com.tailf.ncs.ctrl.NcsPDData pdData) Instantiates and registers components for a Ncs Packagebooleanstatic booleanChecks if this Ncs java main is instantiated in legacy mode.static booleanCheck if Ncs main thread is startedstatic booleanChecks if NcsMain was started with the Tail-f Jar classloader, as opposed to running with the standard java system classloader.String[]JMX interface - list shared jarsvoidJMX interface - hot redeploy all packagesvoidredeployPackage(com.tailf.ncs.ctrl.NcsPDData pdData) Hot redeploy of all components for a packagestatic Throwablestatic ThrowablereportPackageException(Object instance, Throwable e) static ThrowablereportPackageException(String packageName, Throwable e) voidrestartPackage(String packageName) voidrestartPackageNow(String packageName) voidrun()This method is the Ncs java vm main thread startvoidshutdown()JMX interface - shutdown Ncs java vm main threadstatic voidsubmitPackageAlarm(ClassLoader cl, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) static voidsubmitPackageAlarm(Object instance, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) static voidsubmitPackageAlarm(String packageName, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) voiduncaughtException(Thread t, Throwable e)
-
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
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
Get the Ncs AlarmSinkCentral instance- Returns:
- AlarmSinkCentral
-
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 -
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
Instantiates and registers components for a Ncs Package- Parameters:
pdData-- Throws:
Exception
-
redeployPackage
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
Get the singleton instance of the NcsMain class- Returns:
- NcsMain instance
-
getInstance
Get the singleton instance of the NcsMain class- Parameters:
host-port-- Returns:
- NcsMain instance
-
abortNcsJavaVM
Abort Ncs Java VM- Parameters:
obj-
-
abortNcsJavaVM
Abort Ncs Java VM- Parameters:
obj-code-
-
abortNcsJavaVM
Abort Ncs Java VM- Parameters:
obj-code-message-
-
reportPackageException
-
reportPackageException
-
reportPackageException
-
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:
shutdownin interfaceNcsMainMBean
-
redeployAll
public void redeployAll()JMX interface - hot redeploy all packages- Specified by:
redeployAllin interfaceNcsMainMBean
-
restartPackage
-
restartPackageNow
-
uncaughtException
- Specified by:
uncaughtExceptionin interfaceThread.UncaughtExceptionHandler
-