8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: LinkTrapGenerator.java,v 1.1 2009/06/19 02:23:15 bigfatrat Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Portions Copyrighted 2011 ForgeRock AS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The LinkTrapGenerator class is used by the agent to trigger the
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * emission of SNMP v1 or v3 traps at a specific rate and according
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * to a specific entry from the "IfTable".
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster implements LinkTrapGeneratorMBean, MBeanRegistration {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // MBean properties.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static Debug debug = Debug.getInstance("amMonitoring");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructors.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("LinkTrapGenerator() returned\n");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public LinkTrapGenerator(int ifIndex, int nbTraps) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("LinkTrapGenerator(int ifIndex) called");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("LinkTrapGenerator(int ifIndex) returned\n");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * MBean registration interface implementation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ObjectName preRegister(MBeanServer server, ObjectName name)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("LinkTrapGenerator.preRegister() called");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Create an object name if it was not given.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Extract the value of ifIndex from the object name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster ifIndex = Integer.valueOf(name.getKeyProperty("ifIndex")).intValue();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.warning("Use default ifIndex = " + ifIndex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debug.message("LinkTrapGenerator.preRegister() " +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "returned\n");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void postRegister (Boolean registrationDone) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Stop the thread.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Wait until the thread die.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // If nbTraps = -1, the link trap generator will trigger traps
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // continuously.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster // Otherwise, the link trap generator will trigger traps nbTraps
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster while ((nbTraps == -1) || (remainingTraps > 0)) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster //IfEntryImpl ifEntryImpl = InterfacesImpl.find(ifIndex);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster //if (ifEntryImpl == null) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster //java.lang.System.err.println(
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster //"ERROR: LinkTrapGenerator.triggerTrap(): " +
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster //"ifIndex " + ifIndex + " not found");
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster //ifEntryImpl.switchifOperStatus();