public class DpNotifStream extends Thread
A stream always has a "live feed", which is the sequence of new notifications, sent in real time as they are generated. Subscribers may also request "replay" of older, logged notifications if the stream supports this, perhaps transition to the live feed when the end of the log is reached. There may be one or more replays active simultaneously with the live feed. ConfD/NCS forwards replay requests from subscribers to the application via callbacks if the stream supports replay.
Each notification has an associated time stamp, the "event time". This is the time when the event that generated the notification occurred, rather than the time the notification is logged or sent, in case these times differ. The application must pass the event time to ConfD/NCS when sending a notification, and it is also needed when replaying logged events.
This class implements the Notification streams. The purpose of this class to provide a mechanism for sending notifications.
Example: Consider the following yang model of a notification:
module mynotif { namespace "http://tail-f.com/test/mynotif/1.0"; prefix myn; import ietf-yang-types { prefix yang; } notification my_notif { leaf arg1 { type string; } leaf arg2 { type int64; } } }For a netconf notification stream to be valid it must be defined in the ConfD/NCS config file. For NCS this example needs the following definitions in the config (there are small differences in the tagnames for ConfD)
<notifications> <event-streams> <stream> <name>mystream</name> <description>my test stream</description> <replay-support>false</replay-support> </stream> </event-streams> </notifications>If we want to sent a NETCONF notification based on the above model we can do the following:
// create new control socket Socket ctrlSocket = new Socket("127.0.0.1", Conf.PORT); // This is the main Data Provider instance. "dp" Dp dp = new Dp("hosts_daemon", ctrlSocket); mynotif myn = new mynotif(); // create Dp Notification stream (you may create many) DpNotifStream stream = dp.createNotifStream("mystream"); // send a notification ConfXMLParam[] vals = new ConfXMLParam[] { new ConfXMLParamStart(myn.hash(), mynotif.myn_my_notif), new ConfXMLParamValue(myn.hash(), mynotif.myn_arg1, new ConfBuf("Hello")), new ConfXMLParamValue(myn.hash(), mynotif.myn_arg2, new ConfInt64(32)), new ConfXMLParamStop(myn.hash(), mynotif.myn_my_notif) }; stream.send(ConfDatetime.getConfDatetime(), vals);
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Modifier and Type | Method and Description |
---|---|
void |
flush()
Notifications are sent asynchronously, i.e.
|
Dp |
getDp()
The Data Provider main class.
|
int |
getFD()
file descriptor
|
int |
getQRef()
last qref
|
DpNotifReplayCallback |
getReplayCb()
The replay callback
|
Socket |
getSocket()
The worker socket which is connected to ConfD/NCS.
|
String |
getStreamName() |
int |
getSubId()
last subid.
|
void |
send(ConfDatetime time,
ConfXMLParam params)
Send a notification on this notification stream to ConfD/NCS.
|
void |
send(ConfDatetime time,
ConfXMLParam[] params)
Send a notification on this notification stream to ConfD/NCS.
|
void |
setFD(int fd)
file descriptor
|
void |
setQRef(int qref)
last qref
|
void |
setSocket(Socket socket) |
void |
setSubId(int subid)
last subid.
|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public void flush() throws IOException, ConfException
IOException
ConfException
public Dp getDp()
public int getFD()
public int getQRef()
public DpNotifReplayCallback getReplayCb()
public Socket getSocket()
public String getStreamName()
public int getSubId()
public void send(ConfDatetime time, ConfXMLParam params) throws IOException, ConfException
time
- ConfDatetime time to begin replayparams
- ConfXMLParam structure of dataIOException
ConfException
public void send(ConfDatetime time, ConfXMLParam[] params) throws IOException, ConfException
time
- ConfDatetime time to begin replayparams
- ConfXMLParam structure of dataIOException
ConfException
public void setFD(int fd)
public void setQRef(int qref)
public void setSocket(Socket socket)
public void setSubId(int subid)