ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/java/JavaHost.java
(Generate patch)

Comparing projects/cms/source/host/java/JavaHost.java (file contents):
Revision 1.3 by ab11, Thu Nov 30 04:08:25 2000 UTC vs.
Revision 1.5 by ab11, Fri Dec 8 15:44:56 2000 UTC

# Line 20 | Line 20 | class JavaHost {
20      
21      /**
22       * Constructor for the class. Takes in the hostname and port number
23 <     * of the Configuration Manager.
23 >     * of the Filter Manager.
24       *
25       */
26      public JavaHost( String serverName, int port ){
27 <        // create a connection to the configurator
28 <        System.out.println("Creating connection with Configurtator");
27 >        // create a connection to the filter manager
28 >        System.out.println("Creating connection with Filter Manager");
29          Config config = new Config(serverName, port);
30          // the config class knows what values it wants to get from
31 <        // the configurator
31 >        // the configuration system
32          
33 <        // create a SystemMonitor object and pass the confifurator
33 >        // create a SystemMonitor object and pass the config
34          // as a param so it knows what to do!
35          System.out.println("Creating System Monitor");
36          SystemMonitor sysMon = new SystemMonitor(config);
37          
38 +        try {
39 +                udpcheckInterval = Long.parseLong(config.getProperty("UDPUpdateTime")) * 1000;
40 +                System.out.println("Configured UDPUpdateTime");
41 +        }
42 +        catch ( NumberFormatException e ){
43 +                System.out.println("The value for UDPUpdateTime is invalid, using a default");
44 +                // 1 mins
45 +                udpcheckInterval = 1000 * 60;  // 1 minute
46 +        }
47 +        
48 +        try {
49 +                tcpcheckInterval = Long.parseLong(config.getProperty("TCPUpdateTime")) * 1000;
50 +                System.out.println("Configured TCPUpdateTime");
51 +        }
52 +        catch ( NumberFormatException e ){
53 +                System.out.println("The value for UDPUpdateTime is invalid, using a default");
54 +                // 10 mins
55 +                tcpcheckInterval = 10000 * 60;  // 5 minutes
56 +        }
57 +        
58 +        // the current time..
59 +        long currentTime = System.currentTimeMillis();
60 +        long nextUDP = currentTime + udpcheckInterval;
61 +        long nextTCP = currentTime + tcpcheckInterval;
62 +        
63          while ( true ){
64 +            currentTime = System.currentTimeMillis();
65              // keep going for ever and ever ;)
66 <            // send a udp packet to the filter declared in config
67 <            // send it the xml packet created by getInfo()
68 <            System.out.println("Sending UDP Packet");
69 <            LowLevelNet.sendUDPPacket(config, sysMon.getInfo());  
70 <            config.sendHeartBeat();
71 <            if ( config.reloadConfig() ){
72 <                System.out.println("Resarting System");
73 <                break;  
66 >            
67 >            if ( nextTCP < nextUDP ){
68 >                try {
69 >                        long sleeptime = nextTCP - currentTime;
70 >                        if ( sleeptime > 0 ){
71 >                                Thread.sleep(sleeptime);
72 >                        }
73 >                        nextTCP += tcpcheckInterval;
74 >                        // send a heartbeat
75 >                        System.out.println("Sending Heartbeat");
76 >                        config.sendHeartBeat();
77 >                        if ( config.reloadConfig() ){
78 >                            System.out.println("Resarting System");
79 >                            break;      
80 >                        }
81 >                 }
82 >                 catch ( InterruptedException e ){
83 >                        // do nothing
84 >                 }
85              }
86 +            else {
87 +                try {
88 +                    long sleeptime = nextUDP - currentTime;
89 +                        if ( sleeptime > 0 ){
90 +                                Thread.sleep(sleeptime);
91 +                        }
92 +                        nextUDP += udpcheckInterval;
93 +                        // send a heartbeat
94 +                        System.out.println("Sending UDP Packet");
95 +                        LowLevelNet.sendUDPPacket(config, sysMon.getInfo());  
96 +            
97 +                 }
98 +                 catch ( InterruptedException e ){
99 +                        // do nothing
100 +                 }      
101 +            }
102 +            
103 +            
104 +            
105          } // while
106          
107            
# Line 59 | Line 115 | class JavaHost {
115   //---ACCESSOR/MUTATOR METHODS---
116  
117   //---ATTRIBUTES---
118 +
119 +    private long udpcheckInterval;
120 +    private long tcpcheckInterval;
121 +    private final long defaultUpdateTime = 60000;
122 +
123  
124   //---STATIC ATTRIBUTES---
125  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines