campus.snmp
Class SnmpLocator

java.lang.Object
  |
  +--campus.snmp.SnmpLocator
All Implemented Interfaces:
java.lang.Runnable, SyslogConstants

public class SnmpLocator
extends java.lang.Object
implements SyslogConstants, java.lang.Runnable

This locator monitors the Syslog messages and polls APs to fill the ip-ap and mac-ap mapping tables. It polls the AP when a new client is associate with an AP which has not been polled for a fixed interval. Otherwise, that AP is put into a waiting list which is processed by a thread periodically. That thread also randomly picks one AP from all seen APs for processing.

Version:
$Id: SnmpLocator.java,v 1.7 2003/09/21 03:13:36 glchen Exp $
Author:
Guanling Chen

Nested Class Summary
(package private)  class SnmpLocator.SnmpTask
          A single snmp polling task.
 
Field Summary
protected  java.util.Set _aplist
           
protected  java.util.Hashtable _apstat
           
protected  java.lang.String _community
           
protected  java.util.Hashtable _ipLocator
           
protected  java.lang.Object _lock
           
protected  java.util.Hashtable _macLocator
           
protected  java.util.Hashtable _polled
           
protected  EDU.oswego.cs.dl.util.concurrent.PooledExecutor _pool
           
protected  java.util.Random _random
           
protected  java.lang.String _script
           
protected  java.util.Set _waiting
           
protected  java.util.Set _working
           
static long POLL_INTERVAL
           
static long WAIT_INTERVAL
           
 
Fields inherited from interface campus.syslog.SyslogConstants
BASE, EVT_ACTION, EVT_APNAME, EVT_CLIENTHOST, EVT_CLIENTMAC, EVT_DAY, EVT_MONTH, EVT_MSGTYPE, EVT_NOTE, EVT_TIME, EVT_TIMESTAMP, EVT_YEAR, IDX_ACTION, IDX_APNAME, IDX_CLIENTHOST, IDX_CLIENTMAC, IDX_DAY, IDX_MONTH, IDX_MSGTYPE, IDX_NOTE, IDX_TIME, IDX_TIMESTAMP, IDX_YEAR, TAG_ASSOCIATED, TAG_AUTHENTICATED, TAG_DEASSOCIATING, TAG_DEASSOCIATION, TAG_DEAUTHENTICATING, TAG_DEAUTHENTICATION, TAG_FATAL, TAG_INACTIVITY, TAG_INFO, TAG_REASSOCIATED, TAG_REPEAT_LAST_MSG, TAG_ROAMED, TAG_SYSLOG, TAG_WARNING
 
Constructor Summary
SnmpLocator(java.lang.String community)
           
SnmpLocator(java.lang.String script, java.lang.String community)
           
 
Method Summary
private  void addPollTask(java.lang.String apname, java.lang.String clientmac, long timestamp)
          generate a polling task and hand over to thread pool.
private  java.lang.String convertMac(java.lang.String mac)
          Convert mac address from snmp format to syslog format.
private  void doPoll(java.lang.String apname, java.lang.String clientmac, long timestamp)
          Actually poll the access point using a script.
private  void doUpdate(long timestamp, java.lang.String msgtype, java.lang.String apname, java.lang.String clienthost, java.lang.String clientmac, java.lang.String action)
          update the locator with a syslog message.
private  java.lang.String formatTime()
          Format current time for logging.
private  java.lang.String formatTime(long timestamp)
           
 java.lang.String getApByIp(java.lang.String ipaddress)
          Return the current AP of the specified IP address.
 java.lang.String getApByMac(java.lang.String mac)
          Return the current AP of the specified MAC.
 ApStat getApStat(java.lang.String apname)
          Return some statistics of the specified AP.
static void main(java.lang.String[] args)
           
private  void record(java.lang.String clientmac, java.lang.String ipaddress, java.lang.String apname)
          Record location mapping in tables.
 void run()
          Periodically poll the APs on the waiting list.
private  boolean toPoll(java.lang.String apname, java.lang.String clientmac)
          Check whether an AP is pollable at this time.
 void update(Event evt)
          Update the locator with a published syslog event.
 void update(java.lang.String msg)
          Update the locator with a parsed syslog message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POLL_INTERVAL

public static final long POLL_INTERVAL
See Also:
Constant Field Values

WAIT_INTERVAL

public static final long WAIT_INTERVAL
See Also:
Constant Field Values

_random

protected java.util.Random _random

_apstat

protected java.util.Hashtable _apstat

_ipLocator

protected java.util.Hashtable _ipLocator

_macLocator

protected java.util.Hashtable _macLocator

_pool

protected EDU.oswego.cs.dl.util.concurrent.PooledExecutor _pool

_aplist

protected java.util.Set _aplist

_working

protected java.util.Set _working

_waiting

protected java.util.Set _waiting

_polled

protected java.util.Hashtable _polled

_lock

protected java.lang.Object _lock

_community

protected java.lang.String _community

_script

protected java.lang.String _script
Constructor Detail

SnmpLocator

public SnmpLocator(java.lang.String community)

SnmpLocator

public SnmpLocator(java.lang.String script,
                   java.lang.String community)
Method Detail

update

public void update(java.lang.String msg)
Update the locator with a parsed syslog message.


update

public void update(Event evt)
Update the locator with a published syslog event.


getApByMac

public java.lang.String getApByMac(java.lang.String mac)
Return the current AP of the specified MAC.


getApByIp

public java.lang.String getApByIp(java.lang.String ipaddress)
Return the current AP of the specified IP address.


getApStat

public ApStat getApStat(java.lang.String apname)
Return some statistics of the specified AP.


doUpdate

private void doUpdate(long timestamp,
                      java.lang.String msgtype,
                      java.lang.String apname,
                      java.lang.String clienthost,
                      java.lang.String clientmac,
                      java.lang.String action)
update the locator with a syslog message.


toPoll

private boolean toPoll(java.lang.String apname,
                       java.lang.String clientmac)
Check whether an AP is pollable at this time.


addPollTask

private void addPollTask(java.lang.String apname,
                         java.lang.String clientmac,
                         long timestamp)
generate a polling task and hand over to thread pool.


doPoll

private void doPoll(java.lang.String apname,
                    java.lang.String clientmac,
                    long timestamp)
             throws java.lang.Exception
Actually poll the access point using a script.

java.lang.Exception

convertMac

private java.lang.String convertMac(java.lang.String mac)
Convert mac address from snmp format to syslog format.


record

private void record(java.lang.String clientmac,
                    java.lang.String ipaddress,
                    java.lang.String apname)
Record location mapping in tables.


formatTime

private java.lang.String formatTime()
Format current time for logging.


formatTime

private java.lang.String formatTime(long timestamp)

run

public void run()
Periodically poll the APs on the waiting list.

Specified by:
run in interface java.lang.Runnable

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
java.lang.Exception