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
Modifier and TypeFieldDescriptionstatic final String
This field represents a system property controlling which classloader the Ncs java vm should use. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
abortNcsJavaVM
(Object obj) Abort Ncs Java VMstatic void
abortNcsJavaVM
(Object obj, int code) Abort Ncs Java VMstatic void
abortNcsJavaVM
(Object obj, int code, String message) Abort Ncs Java VMcom.tailf.ncs.ctrl.ApplicationMuxManager
Get the ApplicationMuxManager.com.tailf.ncs.ctrl.DpMuxManager
Get the DpMuxManager.static NcsMain
Get the singleton instance of the NcsMain classstatic NcsMain
getInstance
(String host, int port) Get the singleton instance of the NcsMain classGet the hostname or ip for the Ncs Serverint
Get the port number for the Ncs Servercom.tailf.ncs.ctrl.NedMuxManager
Get the NedMuxManager.Get the Ncs AlarmSinkCentral instanceGet the Ncs AlarmSourceCentral instancevoid
instantiatePackageComponent
(com.tailf.ncs.ctrl.NcsPDData pdData) Instantiates and registers components for a Ncs Packageboolean
static boolean
Checks if this Ncs java main is instantiated in legacy mode.static boolean
Check if Ncs main thread is startedstatic boolean
Checks 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 jarsvoid
JMX interface - hot redeploy all packagesvoid
redeployPackage
(com.tailf.ncs.ctrl.NcsPDData pdData) Hot redeploy of all components for a packagestatic Throwable
static Throwable
reportPackageException
(Object instance, Throwable e) static Throwable
reportPackageException
(String packageName, Throwable e) void
restartPackage
(String packageName) void
restartPackageNow
(String packageName) void
run()
This method is the Ncs java vm main thread startvoid
shutdown()
JMX interface - shutdown Ncs java vm main threadstatic void
submitPackageAlarm
(ClassLoader cl, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) static void
submitPackageAlarm
(Object instance, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) static void
submitPackageAlarm
(String packageName, ConfIdentityRef alarmType, PerceivedSeverity severity, boolean cleared, String alarmText) void
uncaughtException
(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:
shutdown
in interfaceNcsMainMBean
-
redeployAll
public void redeployAll()JMX interface - hot redeploy all packages- Specified by:
redeployAll
in interfaceNcsMainMBean
-
restartPackage
-
restartPackageNow
-
uncaughtException
- Specified by:
uncaughtException
in interfaceThread.UncaughtExceptionHandler
-