Package com.sun.jdmk.tasks

Examples of com.sun.jdmk.tasks.DaemonTaskServer$Daemon


            // of trap loss.
            // We set the priority of the DaemonTaskServer to
            // Thread.NORM_PRIORITY so that emptying the socket takes
            // precedence over trap processing.
            //
            final DaemonTaskServer taskServer = new DaemonTaskServer();
            taskServer.start(Thread.NORM_PRIORITY);

            // Create a listener and dispatcher for SNMP traps
            // (SnmpEventReportDispatcher).
            // SnmpEventReportDispatcher is run as a thread and listens
            // for traps in UDP port = agent port + 1.
            // Add TrapListenerImpl as SnmpTrapListener.
            // TrapListenerImpl will receive a callback when a valid trap
            // PDU is received.
            //
            final SnmpEventReportDispatcher trapAgent =
                    new SnmpEventReportDispatcher((this.getTrapSnmpPort()),
                    null, taskServer, null);
            SNMPTrapListenerImpl trapListener = new SNMPTrapListenerImpl();
            trapAgent.addTrapListener(trapListener);
            final Thread trapThread = new Thread(trapAgent);
            trapThread.setPriority(Thread.MAX_PRIORITY);
            trapThread.start();
           
            // One Trap
            this.setDown();
           
            int trapNumbers = trapListener.getNumberV1Traps();
           
            // Should received 1 traps
            assertEquals(trapNumbers, 1);
           
            trapAgent.close();
            taskServer.terminate();

            return;

        } catch (Exception e) {
            fail("SyncManager::main: " +
View Full Code Here

TOP

Related Classes of com.sun.jdmk.tasks.DaemonTaskServer$Daemon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.