Ejemplo n.º 1
0
 /** publishes only requested sensor data */
 public void publishdata() {
   RootFactory theRF = getFactory();
   if (!currentlypublishing.isEmpty()) {
     Task sensortask = null;
     SensorDataObj sensordata = null;
     for (int i = 0; i < currentlypublishing.size(); i++) {
       String type = (String) currentlypublishing.elementAt(i);
       System.out.println("In Sensor Plugin publishdata Type is :::::::::::::" + type);
       if (type.equalsIgnoreCase("SecurityException")) {
         if (fi.length > 0) {
           for (int z = 0; z < fi.length; z++) {
             Vector data = getsecurityevent(fi[z]);
             if (!data.isEmpty()) {
               for (int j = 0; j < data.size(); j++) {
                 sensordata =
                     new SensorDataObj(
                         (String) currentlypublishing.elementAt(i),
                         new Date(System.currentTimeMillis()),
                         (String) data.elementAt(j),
                         nodename[z]);
                 sensortask =
                     MonitoringUtils.createTask(
                         theRF,
                         sensordata,
                         MonitoringUtils.Send_SensorData_Preposition,
                         MonitoringUtils.Send_Sensor_Data);
                 publishAdd(sensortask);
                 if (MonitoringUtils.debug > 0)
                   System.out.println(
                       "*****In sensor Plugin  publishing security excep::****************************");
               }
             } else {
               if (MonitoringUtils.debug > 0)
                 System.out.println(
                     "In Sensor Plugin  got data vector for publishing security empty ********************************");
             }
           }
         }
       } else {
         if (MonitoringUtils.debug > 0)
           System.out.println(
               "Currently publishing::::" + (String) currentlypublishing.elementAt(i));
         sensordata =
             new SensorDataObj(
                 (String) currentlypublishing.elementAt(i),
                 new Date(System.currentTimeMillis()),
                 (String) currentlypublishing.elementAt(i));
         sensortask =
             MonitoringUtils.createTask(
                 theRF,
                 sensordata,
                 MonitoringUtils.Send_SensorData_Preposition,
                 MonitoringUtils.Send_Sensor_Data);
         publishAdd(sensortask);
       }
     }
   }
 }
Ejemplo n.º 2
0
 /**
  * Publishes capabilities to it superior in form of a Task with verb<b>
  * SEND_CAPABILITIES_Verb</B>. It first find the Organization it is associated with and then reads
  * capabilities from roles specified in clustername-prototype-ini.dat.
  *
  * <p><B>Note Roles are specified for sensor/analyzer plugins in different format compared to
  * roles specified in Ultra*Log cluster.</B> <br>
  * for e.g <br>
  * Roles specified in a typical prototype-ini.dat is<br>
  * [OrganizationPG] <br>
  * Roles Collection<Role> "StrategicTransportationProvider,TransportationProvider"<br>
  * <br>
  * Roles specified for sensor/analyzer prototype-ini.dat is <br>
  * [OrganizationPG] <br>
  * Roles Collection<Role> "Sensor-POD:TCPSCAN,Analyzer-TCPSCAN"<br>
  */
 public boolean publishcapabilities() {
   boolean published = false;
   if (self == null) {
     if (MonitoringUtils.debug > 0) System.out.println("Self was null in Sensor Plugin ");
     self = findself();
     if (self != null) {
       if (Services.isEmpty()) {
         for (Iterator e = self.getOrganizationPG().getRoles().iterator(); e.hasNext(); ) {
           String role = ((Role) e.next()).getName();
           if (MonitoringUtils.debug > 0)
             System.out.println("In Sensor Plugin publishcapabilities Role :" + role);
           if (role.startsWith(Type, 0)) {
             int index = role.indexOf('-');
             if (index == -1) {
               System.out.println("Got a wrong format from ini file");
             } else {
               Services = MonitoringUtils.parseString(role.substring(index + 1), ':');
             }
           }
         }
         if (MonitoringUtils.debug > 0) {
           // System.out.println("Got roles first time is::::::::::::::::::
           // :"+Services.toString());
           DumpVector(Services);
         }
       }
     }
   }
   if (self != null) {
     if (MonitoringUtils.debug > 0) {
       System.out.println(
           "In sensor Plugin Creating send cap obj:%%%%%%%%%%%%%%%%%%%%%%%%%"
               + publishedcapabilities);
       DumpVector(Services);
       System.out.println("first time going to publish capabilities::::::::");
     }
     SendCapabilitiesObj obj = new SendCapabilitiesObj(self, Type, Services);
     if (MonitoringUtils.debug > 0)
       System.out.println("In Sensor Plugin services to be send =" + obj.toString());
     Task task =
         MonitoringUtils.createTask(
             getFactory(),
             obj,
             MonitoringUtils.OtherPreposition,
             MonitoringUtils.SEND_CAPABILITIES_Verb);
     publishAdd(task);
     published = true;
   }
   return published;
 }