/** * Finds the self Organization from the list of Organization that satisfy the * OrganizationPredicate. * * @return Organization that it part of. */ protected Organization findself() { Organization org = null; ; for (Iterator orgIter = allorganization.getCollection().iterator(); orgIter.hasNext(); ) { Organization currentorg = (Organization) orgIter.next(); if (MonitoringUtils.debug > 0) System.out.println("IN Sensor PlugIN findself organization is :" + currentorg.toString()); if (currentorg.isSelf()) { return currentorg; } } return org; }
protected void configure() { Iterator new_orgs = queryService.query(orgsPredicate).iterator(); if (new_orgs.hasNext()) { myOrg = (Organization) new_orgs.next(); Service srvc = myOrg.getOrganizationPG().getService(); if (srvc != null) { service = srvc.toString(); configured = true; } } }
/** * 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; }