| 1 | 
 + | 
 /*  | 
 
 
 
 
 
 
 
 
 | 2 | 
 + | 
  * i-scream central monitoring system | 
 
 
 
 
 
 
 
 
 | 3 | 
 + | 
  * Copyright (C) 2000-2002 i-scream | 
 
 
 
 
 
 
 
 
 | 4 | 
 + | 
  *  | 
 
 
 
 
 
 
 
 
 | 5 | 
 + | 
  * This program is free software; you can redistribute it and/or | 
 
 
 
 
 
 
 
 
 | 6 | 
 + | 
  * modify it under the terms of the GNU General Public License | 
 
 
 
 
 
 
 
 
 | 7 | 
 + | 
  * as published by the Free Software Foundation; either version 2 | 
 
 
 
 
 
 
 
 
 | 8 | 
 + | 
  * of the License, or (at your option) any later version. | 
 
 
 
 
 
 
 
 
 | 9 | 
 + | 
  *  | 
 
 
 
 
 
 
 
 
 | 10 | 
 + | 
  * This program is distributed in the hope that it will be useful, | 
 
 
 
 
 
 
 
 
 | 11 | 
 + | 
  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
 
 
 
 
 
 
 
 
 | 12 | 
 + | 
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
 
 
 
 
 
 
 
 
 | 13 | 
 + | 
  * GNU General Public License for more details. | 
 
 
 
 
 
 
 
 
 | 14 | 
 + | 
  *  | 
 
 
 
 
 
 
 
 
 | 15 | 
 + | 
  * You should have received a copy of the GNU General Public License | 
 
 
 
 
 
 
 
 
 | 16 | 
 + | 
  * along with this program; if not, write to the Free Software | 
 
 
 
 
 
 
 
 
 | 17 | 
 + | 
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. | 
 
 
 
 
 
 
 
 
 | 18 | 
 + | 
  */ | 
 
 
 
 
 
 
 
 
 | 19 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 20 | 
   | 
 //---PACKAGE DECLARATION--- | 
 
 
 
 
 
 
 
 
 
 
 
 | 21 | 
 < | 
 package uk.ac.ukc.iscream.filtermanager; | 
 
 
 
 
 
 
 
 
 
 | 21 | 
 > | 
 package uk.org.iscream.cms.server.filtermanager; | 
 
 
 
 
 
 
 
 
 
 
 
 | 22 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 23 | 
   | 
 //---IMPORTS--- | 
 
 
 
 
 
 
 
 
 
 
 
 | 24 | 
 < | 
 import uk.ac.ukc.iscream.core.*; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 25 | 
 < | 
 import uk.ac.ukc.iscream.filter.*; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 26 | 
 < | 
 import uk.ac.ukc.iscream.util.*; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 27 | 
 < | 
 import uk.ac.ukc.iscream.componentmanager.*; | 
 
 
 
 
 
 
 
 
 
 | 24 | 
 > | 
 import uk.org.iscream.cms.server.core.*; | 
 
 
 
 
 
 | 25 | 
 > | 
 import uk.org.iscream.cms.server.filter.*; | 
 
 
 
 
 
 | 26 | 
 > | 
 import uk.org.iscream.cms.server.util.*; | 
 
 
 
 
 
 | 27 | 
 > | 
 import uk.org.iscream.cms.server.componentmanager.*; | 
 
 
 
 
 
 
 
 
 
 
 
 | 28 | 
   | 
 import java.net.*; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 29 | 
   | 
 import java.io.*; | 
 
 
 
 
 
 
 
 
 | 30 | 
 + | 
 import java.util.*; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 31 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 32 | 
   | 
 /** | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 33 | 
   | 
  * Handles setting up a host. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 56 | 
   | 
      * @param socket The socket to which the host is connected | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 57 | 
   | 
      */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 58 | 
   | 
     public HostInit(Socket socket) throws IOException { | 
 
 
 
 
 
 
 
 
 | 59 | 
 + | 
         // set the Thread name | 
 
 
 
 
 
 
 
 
 | 60 | 
 + | 
         setName("filtermanager.HostInit"); | 
 
 
 
 
 
 
 
 
 | 61 | 
 + | 
          | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 62 | 
   | 
         _socket = socket; | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 63 | 
   | 
         // setup reader & writer | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 64 | 
   | 
         _socketIn = new BufferedReader(new InputStreamReader(_socket.getInputStream())); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 73 | 
   | 
      * the host to determine it's setup. | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 74 | 
   | 
      */ | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 75 | 
   | 
     public void run() { | 
 
 
 
 
 
 
 
 
 | 76 | 
 + | 
         // get a hook on the config proxy | 
 
 
 
 
 
 
 
 
 | 77 | 
 + | 
         ConfigurationProxy cp = ConfigurationProxy.getInstance(); | 
 
 
 
 
 
 
 
 
 | 78 | 
 + | 
         // this is our config name | 
 
 
 
 
 
 
 
 
 | 79 | 
 + | 
         String configName = "Host." + _socket.getInetAddress().getHostName().toLowerCase(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 80 | 
   | 
         try { | 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | 
 < | 
             String inBound = _socketIn.readLine(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 82 | 
 < | 
             if (!inBound.equals("STARTCONFIG")) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 83 | 
 < | 
                 _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 84 | 
 < | 
                 throw new IOException("protocol error - expected:STARTCONFIG got:" + inBound); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 85 | 
 < | 
             } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 86 | 
 < | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 87 | 
 < | 
             Configuration myConfig = _configManager.getConfiguration("Host." + _socket.getInetAddress().getHostName().toLowerCase()); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 88 | 
 < | 
             if (myConfig == null) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 89 | 
 < | 
                 _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 90 | 
 < | 
                 throw new IOException("error in host configuration"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 91 | 
 < | 
             } else { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 92 | 
 < | 
                 _socketOut.println("OK"); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 93 | 
 < | 
                  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 94 | 
 < | 
                 // get lastmodified | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 95 | 
 < | 
                 inBound = _socketIn.readLine(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 96 | 
 < | 
                 if(!inBound.equals("LASTMODIFIED")) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 97 | 
 < | 
                         // protocol error | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 81 | 
 > | 
             // try for STARTCONFIG | 
 
 
 
 
 
 | 82 | 
 > | 
             getInBound("STARTCONFIG"); | 
 
 
 
 
 
 | 83 | 
 > | 
             _socketOut.println("OK"); | 
 
 
 
 
 
 | 84 | 
 > | 
              | 
 
 
 
 
 
 | 85 | 
 > | 
             // try for LASTMODIFIED | 
 
 
 
 
 
 | 86 | 
 > | 
             getInBound("LASTMODIFIED"); | 
 
 
 
 
 
 | 87 | 
 > | 
             _socketOut.println(cp.getLastModified(configName)); | 
 
 
 
 
 
 | 88 | 
 > | 
              | 
 
 
 
 
 
 | 89 | 
 > | 
             // try for FILELIST | 
 
 
 
 
 
 | 90 | 
 > | 
             getInBound("FILELIST"); | 
 
 
 
 
 
 | 91 | 
 > | 
             _socketOut.println(cp.getFileList(configName)); | 
 
 
 
 
 
 | 92 | 
 > | 
              | 
 
 
 
 
 
 | 93 | 
 > | 
             // try for FQDN | 
 
 
 
 
 
 | 94 | 
 > | 
             getInBound("FQDN"); | 
 
 
 
 
 
 | 95 | 
 > | 
             _socketOut.println(_socket.getInetAddress().getHostName().toLowerCase()); | 
 
 
 
 
 
 | 96 | 
 > | 
              | 
 
 
 
 
 
 | 97 | 
 > | 
             // get properties | 
 
 
 
 
 
 | 98 | 
 > | 
             String reqProperty = getInBound(); | 
 
 
 
 
 
 | 99 | 
 > | 
             while(!reqProperty.equals("ENDCONFIG")) { | 
 
 
 
 
 
 | 100 | 
 > | 
                 // get the property | 
 
 
 
 
 
 | 101 | 
 > | 
                 try { | 
 
 
 
 
 
 | 102 | 
 > | 
                     String returnedProperty = cp.getProperty(configName, "Host."+reqProperty); | 
 
 
 
 
 
 | 103 | 
 > | 
                     _socketOut.println(returnedProperty); | 
 
 
 
 
 
 | 104 | 
 > | 
                 } catch (PropertyNotFoundException e) { | 
 
 
 
 
 
 
 
 
 
 
 
 | 105 | 
   | 
                     _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 
 | 72 | 
 – | 
                     throw new IOException("protocol error - expected:LASTMODIFIED got:" + inBound); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 106 | 
   | 
                 } | 
 
 
 
 
 
 
 
 
 
 
 
 | 107 | 
 < | 
                 else { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 108 | 
 < | 
                         // send info | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 109 | 
 < | 
                         _socketOut.println(myConfig.getLastModified()); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 107 | 
 > | 
                 // get the next request | 
 
 
 
 
 
 | 108 | 
 > | 
                 reqProperty = _socketIn.readLine(); | 
 
 
 
 
 
 | 109 | 
 > | 
             } | 
 
 
 
 
 
 | 110 | 
 > | 
             _logger.write(toString(), Logger.SYSMSG, "configured host"); | 
 
 
 
 
 
 | 111 | 
 > | 
             _socketOut.println("OK"); | 
 
 
 
 
 
 | 112 | 
 > | 
              | 
 
 
 
 
 
 | 113 | 
 > | 
             // get filter reference | 
 
 
 
 
 
 | 114 | 
 > | 
             getInBound("FILTER"); | 
 
 
 
 
 
 | 115 | 
 > | 
                 // send info | 
 
 
 
 
 
 | 116 | 
 > | 
                 String filterList = cp.getProperty(configName, "Host.filter"); | 
 
 
 
 
 
 | 117 | 
 > | 
                 FilterInfo filterInfoRef = null; | 
 
 
 
 
 
 | 118 | 
 > | 
                 String filter = null; | 
 
 
 
 
 
 | 119 | 
 > | 
                 StringTokenizer st = new StringTokenizer(filterList, ";"); | 
 
 
 
 
 
 | 120 | 
 > | 
             while (filterInfoRef==null && st.hasMoreTokens()) { | 
 
 
 
 
 
 | 121 | 
 > | 
                 filter = st.nextToken(); | 
 
 
 
 
 
 | 122 | 
 > | 
                 _logger.write(toString(), Logger.DEBUG, " looking for filter- " + filter); | 
 
 
 
 
 
 | 123 | 
 > | 
                 try { | 
 
 
 
 
 
 | 124 | 
 > | 
                     filterInfoRef = FilterInfoHelper.narrow(ReferenceManager.getInstance().getCORBARef("iscream.FilterInfo." + filter)); | 
 
 
 
 
 
 | 125 | 
 > | 
                 } catch (ComponentCORBAException e) { | 
 
 
 
 
 
 | 126 | 
 > | 
                     _logger.write(toString(), Logger.DEBUG, " unable to find filter- " + filter); | 
 
 
 
 
 
 
 
 
 
 
 
 | 127 | 
   | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 78 | 
 – | 
                  | 
 
 
 
 
 
 
 
 
 
 | 79 | 
 – | 
                 // get config fileList | 
 
 
 
 
 
 
 
 
 
 | 80 | 
 – | 
                 inBound = _socketIn.readLine(); | 
 
 
 
 
 
 
 
 
 
 | 81 | 
 – | 
                 if(!inBound.equals("FILELIST")) { | 
 
 
 
 
 
 
 
 
 
 | 82 | 
 – | 
                         // protocol error | 
 
 
 
 
 
 
 
 
 
 | 83 | 
 – | 
                     _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 
 | 84 | 
 – | 
                     throw new IOException("protocol error - expected:FILELIST got:" + inBound); | 
 
 
 
 
 
 
 
 
 
 | 85 | 
 – | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 86 | 
 – | 
                 else { | 
 
 
 
 
 
 
 
 
 
 | 87 | 
 – | 
                         // send info | 
 
 
 
 
 
 
 
 
 
 | 88 | 
 – | 
                         _socketOut.println(myConfig.getFileList()); | 
 
 
 
 
 
 
 
 
 
 | 89 | 
 – | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 90 | 
 – | 
                  | 
 
 
 
 
 
 
 
 
 
 | 91 | 
 – | 
                 // send the FQDN to the host | 
 
 
 
 
 
 
 
 
 
 | 92 | 
 – | 
                 inBound = _socketIn.readLine(); | 
 
 
 
 
 
 
 
 
 
 | 93 | 
 – | 
                 if(!inBound.equals("FQDN")) { | 
 
 
 
 
 
 
 
 
 
 | 94 | 
 – | 
                         // protocol error | 
 
 
 
 
 
 
 
 
 
 | 95 | 
 – | 
                     _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 
 | 96 | 
 – | 
                     throw new IOException("protocol error - expected:FQDN got:" + inBound); | 
 
 
 
 
 
 
 
 
 
 | 97 | 
 – | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 98 | 
 – | 
                 else { | 
 
 
 
 
 
 
 
 
 
 | 99 | 
 – | 
                     try { | 
 
 
 
 
 
 
 
 
 
 | 100 | 
 – | 
                         // try to send the fqdn to the host | 
 
 
 
 
 
 
 
 
 
 | 101 | 
 – | 
                             _socketOut.println(_socket.getInetAddress().getHostName()); | 
 
 
 
 
 
 
 
 
 
 | 102 | 
 – | 
                         } | 
 
 
 
 
 
 
 
 
 
 | 103 | 
 – | 
                         catch(UnknownHostException e) { | 
 
 
 
 
 
 
 
 
 
 | 104 | 
 – | 
                             // we failed for some reason | 
 
 
 
 
 
 
 
 
 
 | 105 | 
 – | 
                             _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 
 | 106 | 
 – | 
                         } | 
 
 
 
 
 
 
 
 
 
 | 107 | 
 – | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 108 | 
 – | 
                  | 
 
 
 
 
 
 
 
 
 
 | 109 | 
 – | 
                 // get properties | 
 
 
 
 
 
 
 
 
 
 | 110 | 
 – | 
                 inBound = _socketIn.readLine(); | 
 
 
 
 
 
 
 
 
 
 | 111 | 
 – | 
                 while(!inBound.equals("ENDCONFIG")) { | 
 
 
 
 
 
 
 
 
 
 | 112 | 
 – | 
                            | 
 
 
 
 
 
 
 
 
 
 | 113 | 
 – | 
                     // get the property | 
 
 
 
 
 
 
 
 
 
 | 114 | 
 – | 
                     try { | 
 
 
 
 
 
 
 
 
 
 | 115 | 
 – | 
                         String returnedProperty = myConfig.getProperty("Host."+inBound);     | 
 
 
 
 
 
 
 
 
 
 | 116 | 
 – | 
                          | 
 
 
 
 
 
 
 
 
 
 | 117 | 
 – | 
                         _socketOut.println(returnedProperty); | 
 
 
 
 
 
 
 
 
 
 | 118 | 
 – | 
      | 
 
 
 
 
 
 
 
 
 
 | 119 | 
 – | 
                     } catch (org.omg.CORBA.MARSHAL e) { | 
 
 
 
 
 
 
 
 
 
 | 120 | 
 – | 
                         _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 
 | 121 | 
 – | 
                     } | 
 
 
 
 
 
 
 
 
 
 | 122 | 
 – | 
                     inBound = _socketIn.readLine(); | 
 
 
 
 
 
 
 
 
 
 | 123 | 
 – | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 124 | 
 – | 
                 _logger.write(toString(), Logger.SYSMSG, "configured host"); | 
 
 
 
 
 
 
 
 
 
 | 125 | 
 – | 
                 _socketOut.println("OK"); | 
 
 
 
 
 
 
 
 
 
 | 126 | 
 – | 
                  | 
 
 
 
 
 
 
 
 
 
 | 127 | 
 – | 
                 // get filter reference | 
 
 
 
 
 
 
 
 
 
 | 128 | 
 – | 
                 inBound = _socketIn.readLine(); | 
 
 
 
 
 
 
 
 
 
 | 129 | 
 – | 
                 if(!inBound.equals("FILTER")) { | 
 
 
 
 
 
 
 
 
 
 | 130 | 
 – | 
                         // protocol error | 
 
 
 
 
 
 
 
 
 
 | 131 | 
 – | 
                     _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 
 | 132 | 
 – | 
                     throw new IOException("protocol error - expected:FILTER got:" + inBound); | 
 
 
 
 
 
 
 
 
 
 | 133 | 
 – | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 134 | 
 – | 
                 else { | 
 
 
 
 
 
 
 
 
 
 | 135 | 
 – | 
                         // send info | 
 
 
 
 
 
 
 
 
 
 | 136 | 
 – | 
                         String parentFilter =  myConfig.getProperty("Host.filter"); | 
 
 
 
 
 
 
 
 
 
 | 137 | 
 – | 
                         _logger.write(toString(), Logger.DEBUG, " looking for parent - " + parentFilter); | 
 
 
 
 
 
 
 
 
 
 | 138 | 
 – | 
                     Filter filter = FilterHelper.narrow(ReferenceManager.getInstance().getCORBARef("iscream.Filter." + parentFilter)); | 
 
 
 
 
 
 
 
 
 
 | 139 | 
 – | 
                         _socketOut.println(filter.getHostName() + ";" | 
 
 
 
 
 
 
 
 
 
 | 140 | 
 – | 
                                          + filter.getUDPPort() + ";" | 
 
 
 
 
 
 
 
 
 
 | 141 | 
 – | 
                                          + filter.getTCPPort()); | 
 
 
 
 
 
 
 
 
 
 | 142 | 
 – | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 143 | 
 – | 
                  | 
 
 
 
 
 
 
 
 
 
 | 144 | 
 – | 
                 // confirm that all is ok | 
 
 
 
 
 
 
 
 
 
 | 145 | 
 – | 
                 inBound = _socketIn.readLine(); | 
 
 
 
 
 
 
 
 
 
 | 146 | 
 – | 
                 if(!inBound.equals("END")) { | 
 
 
 
 
 
 
 
 
 
 | 147 | 
 – | 
                         // protocol error | 
 
 
 
 
 
 
 
 
 
 | 148 | 
 – | 
                     _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 
 | 149 | 
 – | 
                     throw new IOException("protocol error - expected:END got:" + inBound); | 
 
 
 
 
 
 
 
 
 
 | 150 | 
 – | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 151 | 
 – | 
                 else { | 
 
 
 
 
 
 
 
 
 
 | 152 | 
 – | 
                         // send ok | 
 
 
 
 
 
 
 
 
 
 | 153 | 
 – | 
                         _socketOut.println("OK"); | 
 
 
 
 
 
 
 
 
 
 | 154 | 
 – | 
                 } | 
 
 
 
 
 
 
 
 
 
 | 155 | 
 – | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 128 | 
   | 
             } | 
 
 
 
 
 
 
 
 
 | 129 | 
 + | 
                  | 
 
 
 
 
 
 
 
 
 | 130 | 
 + | 
             // hopefully we found a filter | 
 
 
 
 
 
 
 
 
 | 131 | 
 + | 
             if(filterInfoRef != null) { | 
 
 
 
 
 
 
 
 
 | 132 | 
 + | 
                 _logger.write(toString(), Logger.DEBUG, " found filter- " + filter); | 
 
 
 
 
 
 
 
 
 | 133 | 
 + | 
                 try { | 
 
 
 
 
 
 
 
 
 | 134 | 
 + | 
                     // tell the host about it... | 
 
 
 
 
 
 
 
 
 | 135 | 
 + | 
                         _socketOut.println(filterInfoRef.getHostName() + ";" | 
 
 
 
 
 
 
 
 
 | 136 | 
 + | 
                                          + filterInfoRef.getUDPPort() + ";" | 
 
 
 
 
 
 
 
 
 | 137 | 
 + | 
                                          + filterInfoRef.getTCPPort()); | 
 
 
 
 
 
 
 
 
 | 138 | 
 + | 
                     } | 
 
 
 
 
 
 
 
 
 | 139 | 
 + | 
                     catch(org.omg.CORBA.COMM_FAILURE e) { | 
 
 
 
 
 
 
 
 
 | 140 | 
 + | 
                         // failed to talk to filter, lets signal an error | 
 
 
 
 
 
 
 
 
 | 141 | 
 + | 
                         _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 | 142 | 
 + | 
                         throw new IOException("error communicating with filter - " + e); | 
 
 
 
 
 
 
 
 
 | 143 | 
 + | 
                     } | 
 
 
 
 
 
 
 
 
 | 144 | 
 + | 
                 } | 
 
 
 
 
 
 
 
 
 | 145 | 
 + | 
                 else { | 
 
 
 
 
 
 
 
 
 | 146 | 
 + | 
                     // ...or throw a wobbly (and tell the host!) | 
 
 
 
 
 
 
 
 
 | 147 | 
 + | 
                     _socketOut.println("ERROR"); | 
 
 
 
 
 
 
 
 
 | 148 | 
 + | 
                     throw new IOException("unable to find filter for host"); | 
 
 
 
 
 
 
 
 
 | 149 | 
 + | 
                 } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 150 | 
   | 
              | 
 
 
 
 
 
 
 
 
 | 151 | 
 + | 
             // confirm ok with END | 
 
 
 
 
 
 
 
 
 | 152 | 
 + | 
             getInBound("END"); | 
 
 
 
 
 
 
 
 
 | 153 | 
 + | 
             _socketOut.println("OK"); | 
 
 
 
 
 
 
 
 
 | 154 | 
 + | 
              | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 155 | 
   | 
         } catch (Exception e) { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 156 | 
   | 
             _logger.write(toString(), Logger.ERROR, "ERROR - " + e); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 157 | 
   | 
         } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 158 | 
   | 
          | 
 
 
 
 
 
 
 
 
 
 | 162 | 
 – | 
         _socketOut.flush(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 159 | 
   | 
         // Disconnect streams & socket | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 160 | 
   | 
         try { | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 161 | 
   | 
             _socketIn.close(); | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 171 | 
   | 
      * Overrides the {@link java.lang.Object#toString() Object.toString()} | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 172 | 
   | 
      * method to provide clean logging (every class should have this). | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 173 | 
   | 
      * | 
 
 
 
 
 
 
 
 
 
 
 
 | 174 | 
 < | 
      * This uses the uk.ac.ukc.iscream.util.NameFormat class | 
 
 
 
 
 
 
 
 
 
 | 174 | 
 > | 
      * This uses the uk.org.iscream.cms.server.util.NameFormat class | 
 
 
 
 
 
 
 
 
 
 
 
 | 175 | 
   | 
      * to format the toString() | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 176 | 
   | 
      * | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 177 | 
   | 
      * @return the name of this class and its CVS revision | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 184 | 
   | 
     } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 185 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 186 | 
   | 
 //---PRIVATE METHODS--- | 
 
 
 
 
 
 
 
 
 | 187 | 
 + | 
  | 
 
 
 
 
 
 
 
 
 | 188 | 
 + | 
     private String getInBound(String expected) throws IOException { | 
 
 
 
 
 
 
 
 
 | 189 | 
 + | 
         // grab the input | 
 
 
 
 
 
 
 
 
 | 190 | 
 + | 
         String inBound = getInBound(); | 
 
 
 
 
 
 
 
 
 | 191 | 
 + | 
         // check if it's what we're expecting | 
 
 
 
 
 
 
 
 
 | 192 | 
 + | 
         if(!inBound.equals(expected)) { | 
 
 
 
 
 
 
 
 
 | 193 | 
 + | 
             throw new IOException("protocol error - expected:"+expected+" got:" + inBound); | 
 
 
 
 
 
 
 
 
 | 194 | 
 + | 
         } | 
 
 
 
 
 
 
 
 
 | 195 | 
 + | 
         // it should be ok then | 
 
 
 
 
 
 
 
 
 | 196 | 
 + | 
         return inBound; | 
 
 
 
 
 
 
 
 
 | 197 | 
 + | 
     } | 
 
 
 
 
 
 
 
 
 | 198 | 
 + | 
      | 
 
 
 
 
 
 
 
 
 | 199 | 
 + | 
     private String getInBound() throws IOException { | 
 
 
 
 
 
 
 
 
 | 200 | 
 + | 
         // grab the input | 
 
 
 
 
 
 
 
 
 | 201 | 
 + | 
         String inBound = _socketIn.readLine(); | 
 
 
 
 
 
 
 
 
 | 202 | 
 + | 
         // check for null's, likely disconnection | 
 
 
 
 
 
 
 
 
 | 203 | 
 + | 
         if(inBound == null) { | 
 
 
 
 
 
 
 
 
 | 204 | 
 + | 
             throw new IOException("got null from host, maybe it died"); | 
 
 
 
 
 
 
 
 
 | 205 | 
 + | 
         } | 
 
 
 
 
 
 
 
 
 | 206 | 
 + | 
         // it's a valid message it seems | 
 
 
 
 
 
 
 
 
 | 207 | 
 + | 
         return inBound; | 
 
 
 
 
 
 
 
 
 | 208 | 
 + | 
     } | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 209 | 
   | 
  | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 210 | 
   | 
 //---ACCESSOR/MUTATOR METHODS--- | 
 
 
 
 
 
 
 
 
 
 
 
 
 
 | 211 | 
   | 
  |