KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > plugins > discovery > AutoDiscoveryPlugin


1 /*
2  /*
3  * Copyright 2002 by
4  * <a HREF="http://www.coridan.com">Coridan</a>
5  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with the
9  * License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is "MantaRay" (TM).
18  *
19  * The Initial Developer of the Original Code is Amir Shevat and Yuval Lubowich .
20  * Portions created by the Initial Developer are Copyright (C) 2006
21  * Coridan Inc. All Rights Reserved.
22  *
23  * Contributor(s): all the names of the contributors are added in the source
24  * code where applicable.
25  *
26  * Alternatively, the contents of this file may be used under the terms of the
27  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
28  * provisions of LGPL are applicable instead of those above. If you wish to
29  * allow use of your version of this file only under the terms of the LGPL
30  * License and not to allow others to use your version of this file under
31  * the MPL, indicate your decision by deleting the provisions above and
32  * replace them with the notice and other provisions required by the LGPL.
33  * If you do not delete the provisions above, a recipient may use your version
34  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
35  
36  *
37  * This library is free software; you can redistribute it and/or modify it
38  * under the terms of the MPL as stated above or under the terms of the GNU
39  * Lesser General Public License as published by the Free Software Foundation;
40  * either version 2.1 of the License, or any later version.
41  *
42  * This library is distributed in the hope that it will be useful, but WITHOUT
43  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
44  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
45  * License for more details.
46  */

47 package org.mr.plugins.discovery;
48
49 import java.util.ArrayList JavaDoc;
50 import java.util.Collection JavaDoc;
51 import java.util.HashMap JavaDoc;
52 import java.util.Iterator JavaDoc;
53 import java.util.List JavaDoc;
54 import java.util.Map JavaDoc;
55 import java.util.Set JavaDoc;
56
57 import org.apache.commons.logging.Log;
58 import org.apache.commons.logging.LogFactory;
59 import org.mr.MantaAgent;
60 import org.mr.MantaException;
61 import org.mr.core.configuration.ConfigManager;
62 import org.mr.core.groups.GroupKey;
63 import org.mr.core.groups.GroupMessageListener;
64 import org.mr.core.groups.GroupsException;
65 import org.mr.core.groups.MutlicastGroupManager;
66 import org.mr.core.net.TransportInfo;
67 import org.mr.core.net.TransportType;
68 import org.mr.core.protocol.MantaBusMessage;
69 import org.mr.core.util.SystemTime;
70 import org.mr.core.util.byteable.ByteableList;
71 import org.mr.core.util.byteable.ByteableMap;
72 import org.mr.kernel.Plugin;
73 import org.mr.kernel.control.ControlSignalMessageSender;
74 import org.mr.kernel.services.MantaService;
75 import org.mr.kernel.services.ServiceActor;
76 import org.mr.kernel.services.ServiceActorInfoContainer;
77 import org.mr.kernel.services.ServiceConsumer;
78 import org.mr.kernel.services.ServiceProducer;
79 import org.mr.kernel.services.queues.QueueMaster;
80 import org.mr.kernel.services.queues.VirtualQueuesManager;
81 import org.mr.kernel.services.topics.VirtualTopicManager;
82 import org.mr.kernel.world.WorldModeler;
83
84
85
86 /**
87  * Loads the plug-in by starting the ADControlSender and receives and updates the world maps.
88  * @author Amir Shevat and Yuval Lubowich
89  */

90 public class AutoDiscoveryPlugin implements Plugin, GroupMessageListener {
91
92     public static long refreshInterval = 500; //1 second intevals
93
private MantaAgent manta = null;
94     private MutlicastGroupManager groupsManager = null;
95     private Log log = null;
96     private ADControlSender adControlSender = null;
97     private ControlSignalMessageSender controlSignalMessageSender = null;
98     private Map JavaDoc addressTOAgentMap = null;
99     private WorldModeler worldModeler = null;
100     private Thread JavaDoc adControlSenderThread = null;
101     public static GroupKey groupKey = null;
102     
103     public static final String JavaDoc MANTA_GROUP_NAME = "manta";
104     public static final String JavaDoc MANTA_AD_SUBJECT_NAME = "ad";
105
106
107     public static final String JavaDoc AGENT_NAME = "AGENT_NAME";
108     public static final String JavaDoc SERVICE_ACTOR = "SERVICE_ACTOR";
109     public static final String JavaDoc TRANSPORT_INFO = "TRANSPORT_INFO";
110     public static final String JavaDoc REMOVED_DURABLE = "REMOVED_DURABLE";
111     
112     
113
114
115     public AutoDiscoveryPlugin() throws GroupsException {
116         
117         manta =MantaAgent.getInstance();
118         ConfigManager config = manta.getSingletonRepository().getConfigManager();
119         String JavaDoc multicastIPForAD = config.getStringProperty("plug-ins.auto-discovery.auto_discovery_multicast_ip");
120         if(multicastIPForAD ==null ){
121             throw new GroupsException("missing configuration 'plug-ins.auto-discovery.auto_discovery_multicast_ip' ");
122         }
123         int multicastPortForAD=0;
124         try{
125             multicastPortForAD = config.getIntProperty("plug-ins.auto-discovery.auto_discovery_multicast_port");
126         }catch(Throwable JavaDoc t){
127             throw new GroupsException("error in configuration 'plug-ins.auto-discovery.auto_discovery_multicast_port'",t);
128         }
129         String JavaDoc multicastLocalBind = config.getStringProperty("plug-ins.auto-discovery.auto_discovery_local_interface", "0.0.0.0");
130         if(multicastLocalBind.equals("0.0.0.0")){
131             multicastLocalBind= ADControlSender.getValidLocalAddress();
132         }
133         
134         groupKey = new GroupKey(multicastIPForAD,multicastPortForAD);
135         groupsManager = manta.getSingletonRepository().getGroupsManager();
136         controlSignalMessageSender = manta.getSingletonRepository().getServiceActorControlCenter().getDefaultSender();
137         worldModeler = manta.getSingletonRepository().getWorldModeler();
138         adControlSender = new ADControlSender();
139         addressTOAgentMap = new HashMap JavaDoc();
140         log=LogFactory.getLog("AutoDiscoveryPlugin");
141         manta = MantaAgent.getInstance();
142         groupsManager = manta.getSingletonRepository().getGroupsManager();
143
144         //do some groups stuff
145
groupsManager.joinGroup(groupKey,multicastLocalBind);
146         groupsManager.registerListenerToSubject(groupKey, MANTA_AD_SUBJECT_NAME+worldModeler.getDefaultDomainName(), this);
147
148         adControlSenderThread = new Thread JavaDoc(adControlSender);
149         adControlSenderThread.setName("ADControlSenderThread");
150         refreshInterval = config.getLongProperty("plug-ins.auto-discovery.auto_discovery_refresh_interval",refreshInterval);
151         
152         // write the multicast configuration into the log
153
if (log.isInfoEnabled()) {
154             log.info("Multicast Address: "+multicastIPForAD+", Multicast Port: "+multicastPortForAD);
155         }
156     }//AutoDiscoveryPlugin
157

158
159     /**
160      * This method is used to get the name of the plugin.
161      *
162      * @return The name of the Plugin
163      */

164     public String JavaDoc getName() {
165         return "AutoDiscoveryPlugin";
166     }//getName
167

168
169     /**
170      * This method is used retreive the version of the plugin.
171      *
172      * @return the version number of the plugin
173      */

174     public float getVersion() {
175         return 0.1f;
176     }//getVersion
177

178
179     /**
180      * This method is used to start the plugin. As the thread starting the plugin is
181      * the main Agent's thread the start method should return quickly.
182      */

183     public void start() {
184         MantaAgent.getInstance().getSingletonRepository().getServiceActorControlCenter().setDefaultSender(adControlSender);
185         adControlSenderThread.start();
186     }//start
187

188     /**
189      * This method is used to stop the plugin.
190      */

191     public void stop() {
192         MantaAgent.getInstance().getSingletonRepository().getServiceActorControlCenter().setDefaultSender(controlSignalMessageSender);
193     }//stop
194

195    
196     public synchronized void onMessage(GroupKey key, String JavaDoc subject, MantaBusMessage msg) {
197
198         boolean isSaveWorldModeler = false;
199         if(ADControlSender.serviceProducer!= null && msg.getSource().equals(ADControlSender.serviceProducer)){
200             //this is a loopback
201
return;
202         }
203
204         String JavaDoc defaultDomainName = worldModeler.getDefaultDomainName();
205         ByteableMap infoMap = (ByteableMap) msg.getPayload();
206         ByteableList newAgentTransportList = (ByteableList) infoMap.get(AutoDiscoveryPlugin.TRANSPORT_INFO);
207         ByteableList serviceActorList = (ByteableList) infoMap.get(AutoDiscoveryPlugin.SERVICE_ACTOR);
208         ByteableList removedDurable = (ByteableList) infoMap.get(AutoDiscoveryPlugin.REMOVED_DURABLE);
209         
210         String JavaDoc agentName = (String JavaDoc) infoMap.get(AutoDiscoveryPlugin.AGENT_NAME);
211         
212         Object JavaDoc senderMemberKey = msg.getSource();
213         //locate the suspected manta on the AD plugin intermal mapping
214
ByteableMap knownAgentInfo = (ByteableMap) addressTOAgentMap.get(senderMemberKey);
215
216         Set JavaDoc currentAgentTransportInfo = worldModeler.getAgentTransportInfo(defaultDomainName, agentName);
217
218         //Add the new InfoMap (Agent information) to the MAP
219
if (knownAgentInfo == null) {
220             ///////////////////////////
221
//Handle the Agent stuff
222
///////////////////////////
223
addressTOAgentMap.put(senderMemberKey, infoMap);
224
225             //check to see if the world modeler "knows" the manta
226
if (currentAgentTransportInfo == null) {
227                 //This is a brand new Agent --> add it to the WM.
228
if(log.isInfoEnabled()){
229                     log.info("Discovered a new MantaRay peer called "+agentName+ " at "+newAgentTransportList);
230                 }//if
231
worldModeler.addAgent(defaultDomainName, agentName, newAgentTransportList);
232                 isSaveWorldModeler = true;
233             }//if
234
else { //manta exists, need to find out the Delta between the new info and the old one
235
if (removeAgentTransportInfo(currentAgentTransportInfo, newAgentTransportList, agentName, defaultDomainName) == true)
236                         isSaveWorldModeler = true;
237                 if (addAgentTransportInfo(currentAgentTransportInfo, newAgentTransportList, agentName, defaultDomainName) == true)
238                         isSaveWorldModeler = true;
239             }//else
240

241             ///////////////////////////////////
242
//Handle the Service Actors stuff
243
///////////////////////////////////
244
//add
245
//add manta-service map to the world mapper
246
addServiceActors(serviceActorList, defaultDomainName);
247
248             //remove, no need as this is the first time we see this manta --> only add new services.
249
}//if
250
else { // Handle a known Agent.
251

252             //knownAgentInfo --> the manta information as we know it.
253
ByteableList currentAgentTransportList = (ByteableList) knownAgentInfo.get(AutoDiscoveryPlugin.TRANSPORT_INFO);
254
255             //if (removeAgentTransportInfo(currentAgentTransportList, newAgentTransportList, agentName, defaultDomainName) == true)
256
if (removeAgentTransportInfo(currentAgentTransportInfo, newAgentTransportList, agentName, defaultDomainName) == true)
257                     isSaveWorldModeler = true;
258
259             if (addAgentTransportInfo(currentAgentTransportInfo, newAgentTransportList, agentName, defaultDomainName) == true)
260                     isSaveWorldModeler = true;
261
262             ///////////////////////////////////
263
//Handle the Service Actors stuff
264
///////////////////////////////////
265

266             
267             // remove service actors that are not longer in the info sent
268
ByteableList oldServiceActorList = (ByteableList) knownAgentInfo.get(AutoDiscoveryPlugin.SERVICE_ACTOR);
269             removeServiceActors(serviceActorList,oldServiceActorList, defaultDomainName);
270             //add manta-service map to the world mapper
271
addServiceActors(serviceActorList,oldServiceActorList, defaultDomainName);
272             
273             ByteableList oldRemovedDurableList = (ByteableList) knownAgentInfo.get(AutoDiscoveryPlugin.REMOVED_DURABLE);
274             
275             removeDurableActors(removedDurable,oldRemovedDurableList, defaultDomainName);
276             
277             
278             
279             // replace info to new one
280
addressTOAgentMap.put(senderMemberKey, infoMap);
281         }//else
282

283         /*if (isSaveWorldModeler) {
284             saveSaveWorldModeler();
285         }//if*/

286         
287         //###
288
//manta.getSingletonRepository().getVirtualQueuesManager().printMasters();
289
}//OnMessage
290

291
292     
293     
294     /*private void saveSaveWorldModeler() {
295         try {
296             worldModeler.save(new File("d:\\projects\\manta\\myworld.xml"));
297         } catch (IOException e) {
298             if(log.isErrorEnabled()){
299                 log.error("Could not save new world modeler view in saveSaveWorldModeler().", e);
300             }//if
301         }
302     }//saveSaveWorldModeler
303     */

304     
305     
306
307     /**
308      * This method is used to remove a service actors that have been recalled by the remove manta
309      * @param serviceActorList the list fo service actors from the remote manta
310      * @param oldServiceActorList the last know info from old updates
311      * @param defaultDomainName today only the default domain
312      */

313     private void removeServiceActors(ByteableList newServiceActorList, ByteableList oldServiceActorList, String JavaDoc defaultDomainName) {
314         ServiceActor actor = null;
315         MantaService service = null;
316         
317         int count=0;
318         for (Iterator JavaDoc iter = oldServiceActorList.iterator(); iter.hasNext();) {
319             ServiceActorInfoContainer element = (ServiceActorInfoContainer) iter.next();
320             if(!newServiceActorList.contains(element)){
321                 count++;
322                 actor = element.getActor();
323                 if(actor.getServiceType() == MantaService.SERVICE_TYPE_TOPIC && actor.getType() == ServiceActor.CONSUMER){
324                     // topic consumer is different TH
325
if(log.isInfoEnabled()){
326                         log.info("Removing service consumer "+actor);
327                     }//if
328
manta.getSingletonRepository().getVirtualTopicManager()
329                         .removeConsumer((ServiceConsumer) actor);
330                 }else{
331                     service = MantaAgent.getInstance().getService(actor.getServiceName(), actor.getServiceType());
332
333                     if (service != null) {
334                         if (actor.getType()== ServiceActor.CONSUMER) {
335                             if(log.isInfoEnabled()){
336                                 log.info("Removing service consumer "+actor);
337                             }//if
338
service.removeConsumer((ServiceConsumer) actor);
339                         }//if
340
else if (actor.getType()== ServiceActor.PRODUCER) {
341                             if(log.isInfoEnabled()){
342                                 log.info("Removing service producer "+actor);
343                             }//if
344
service.removeProducer((ServiceProducer) actor);
345                         }else{
346                             VirtualQueuesManager vqm = manta.getSingletonRepository().getVirtualQueuesManager();
347                             QueueMaster qm = vqm.getQueueMaster(service.getServiceName());
348                             if (qm != null && qm.getAgentName().equals(actor.getAgentName())) {
349                                 // the queue master went down
350
if(log.isInfoEnabled()){
351                                     log.info("Removing service coordinator "+actor);
352                                 }//if
353
vqm.setQueueMaster(service.getServiceName(), null);
354                             }
355                         }// else
356
}//if
357
}
358             }
359         }//for
360
}
361     
362     /**
363      * This method is used to remove a durable service actors that have been unsubscribed by the remove manta
364      * @param serviceActorList the list fo service actors from the remote manta
365      * @param oldServiceActorList the last know info from old updates
366      * @param defaultDomainName today only the default domain
367      */

368     private void removeDurableActors(ByteableList newRemovedDurable, ByteableList oldRemovedDurable, String JavaDoc defaultDomainName) {
369         ServiceActor actor = null;
370         MantaService service = null;
371         if(newRemovedDurable != null){
372             for (Iterator JavaDoc iter = newRemovedDurable.iterator(); iter.hasNext();) {
373                 ServiceActorInfoContainer element = (ServiceActorInfoContainer) iter.next();
374                 if(!oldRemovedDurable.contains(element)){
375                     actor = element.getActor();
376                     service = MantaAgent.getInstance().getService(actor.getServiceName(), actor.getServiceType());
377
378                     if (service != null) {
379                         
380                         if (actor.getType()== ServiceActor.CONSUMER) {
381                             VirtualTopicManager topicManager =MantaAgent.getInstance().getSingletonRepository().getVirtualTopicManager();
382                             if(log.isInfoEnabled()){
383                                 log.info("Removing durable service consumer "+actor);
384                             }//if
385
topicManager.removeDurableConsumer(service.getServiceName(),(ServiceConsumer) actor);
386                         }//if
387

388                     }//if
389
}
390                 
391             }//for
392

393         }
394         
395     }
396
397     /**
398      * This method is used to add a new service actor to an manta.
399      *
400      * @param serviceActorList The list fo service actors to add.
401      * @param domainName
402      */

403     private void addServiceActors(ByteableList serviceActorList, String JavaDoc domainName) {
404         ServiceActor actor = null;
405         MantaService service = null;
406
407         for (Iterator JavaDoc iter = serviceActorList.iterator(); iter.hasNext();) {
408             ServiceActorInfoContainer element = (ServiceActorInfoContainer) iter.next();
409             actor = element.getActor();
410             if((actor.getServiceType() == MantaService.SERVICE_TYPE_TOPIC)&&
411                     (actor.getType()== ServiceActor.CONSUMER )){
412                     // topic consumers need special attention
413
if(log.isInfoEnabled()){
414                         log.info("Discovered service consumer "+actor);
415                     }
416                     MantaAgent.getInstance().getSingletonRepository()
417                         .getVirtualTopicManager().addConsumer((ServiceConsumer) actor);
418             }else{
419                 service = MantaAgent.getInstance().getService(actor.getServiceName(), actor.getServiceType());
420
421                 if (service != null) {
422                      if (actor.getType()== ServiceActor.CONSUMER) {
423                         if(log.isInfoEnabled()){
424                             log.info("Discovered service consumer "+actor);
425                         }//if
426
service.addConsumer((ServiceConsumer) actor);
427                         
428                     }//if
429
else if (actor.getType()== ServiceActor.PRODUCER) {
430                         if(log.isInfoEnabled()){
431                             log.info("Discovered service producer "+actor);
432                         }//if
433
service.addProducer((ServiceProducer) actor);
434                     }else{
435                         QueueMaster coordinator = (QueueMaster) actor;
436                         coordinator.setValidUntil(SystemTime.currentTimeMillis()+5000);
437                         if(log.isInfoEnabled()){
438                             log.info("Discovered service coordinator "+actor);
439                         }//if
440
manta.getSingletonRepository().getVirtualQueuesManager().
441                                   setQueueMaster(service.getServiceName(),
442                                                  (QueueMaster) coordinator);
443                         
444                     }// else
445
}//if
446

447             }
448         }//for
449
}//addNewServiceActor
450
/**
451      * @param serviceActorList the list fo service actors from the remote manta
452      * @param oldServiceActorList the last know info from old updates
453      * @param defaultDomainName today only the default domain
454      */

455     private void addServiceActors(ByteableList serviceActorList, ByteableList oldServiceActorList, String JavaDoc defaultDomainName) {
456         ServiceActor actor = null;
457         MantaService service = null;
458
459         for (Iterator JavaDoc iter = serviceActorList.iterator(); iter.hasNext();) {
460             ServiceActorInfoContainer element = (ServiceActorInfoContainer) iter.next();
461             actor = element.getActor();
462             if((actor.getServiceType() == MantaService.SERVICE_TYPE_TOPIC)&&
463                 (actor.getType()== ServiceActor.CONSUMER )){
464                 // topic consumers need special attention
465
if( !oldServiceActorList.contains(element)){
466                     if(log.isInfoEnabled()){
467                         log.info("Discovered service consumer "+actor);
468                     }//if
469
MantaAgent.getInstance().getSingletonRepository()
470                     .getVirtualTopicManager().addConsumer((ServiceConsumer) actor);
471                 }
472             }else{
473                 service = MantaAgent.getInstance().getService(actor.getServiceName(), actor.getServiceType());
474
475                 if (service != null ) {
476                     if (actor.getType()== ServiceActor.CONSUMER ) {
477                         if( !oldServiceActorList.contains(element)){
478                             if(log.isInfoEnabled()){
479                                 log.info("Discovered service consumer "+actor);
480                             }//if
481
service.addConsumer((ServiceConsumer) actor);
482                         }
483                     }//if CONSUMER
484
else if (actor.getType()== ServiceActor.PRODUCER) {
485                         if( !oldServiceActorList.contains(element)){
486                             if(log.isInfoEnabled()){
487                                 log.info("Discovered service producer "+actor);
488                             }//if
489
service.addProducer((ServiceProducer) actor);
490                         }
491                     }else{
492                         VirtualQueuesManager vqm = manta.getSingletonRepository().getVirtualQueuesManager();
493                         QueueMaster current = vqm.getQueueMaster(service.getServiceName());
494                         //if(current== null|| !current.equals(actor)){
495
if(current == null) {
496                             if(log.isInfoEnabled()){
497                                 log.info("Discovered service coordinator (no coordinator defined yet): "+actor);
498                                 log.info("Setting the newly discovered coordinator as queue coordinator: "+actor);
499                             }//if
500
QueueMaster coordinator = (QueueMaster) actor;
501                             coordinator.setValidUntil(SystemTime.currentTimeMillis()+5000);
502                             vqm.setQueueMaster(service.getServiceName(), coordinator);
503                         }
504                         else if (!current.equals(actor)) {
505                             // this is the case that manta finds more than one coordinator
506
// on a queue. The reaction to this is recalling the current
507
// coordinator (giving up in case this is the controling manta)
508
// and letting the dynamic queue coordination do it thing.
509
if(log.isInfoEnabled()) {
510                                 log.info("Discovered service coordinator (another coordinator is already defined): found: "+actor+" existing: "+current);
511                                 log.info("Setting the newly discovered coordinator as queue coordinator: "+actor);
512                             }
513                             QueueMaster coordinator = (QueueMaster) actor;
514                             coordinator.setValidUntil(SystemTime.currentTimeMillis()+5000);
515                             vqm.setQueueMaster(service.getServiceName(), coordinator);
516                             
517                             if (current.getAgentName().equals(this.manta.getAgentName())) {
518                                 if(log.isInfoEnabled())
519                                     log.info("Recalling current coordinator to resolve the conflict: "+current);
520                                 try {
521                                     this.manta.recallService(current);
522                                 } catch (MantaException e) {
523                                     if (log.isErrorEnabled())
524                                         log.error("Error while recalling coordinator. "+e);
525                                 }
526                             }
527                             //if(log.isInfoEnabled())
528
//log.info("Setting the newly discovered corrdinator as queue coordinator: "+actor);
529

530                             //vqm.setQueueMaster(service.getServiceName(), null);
531
}
532                             else{
533                             vqm.getQueueMaster(service.getServiceName()).setValidUntil(SystemTime.currentTimeMillis()+5000);
534                         }
535                     }// else
536
}//if
537
}
538          }//for
539
}
540
541
542     /**
543      * @param currentAgentTransportInfo
544      * @param currentAgentTransportInfo2
545      * @param agentName
546      * @param defaultDomainName
547      */

548     private boolean addAgentTransportInfo(Set JavaDoc currentAgentTransportInfo, ByteableList newAgentTransportList, String JavaDoc agentName, String JavaDoc defaultDomainName) {
549         TransportInfo newInfo = null;
550         boolean result = false;
551
552         for (int i = 0; i < newAgentTransportList.size(); i++) {
553             newInfo = (TransportInfo) newAgentTransportList.get(i);
554             if (currentAgentTransportInfo == null || !currentAgentTransportInfo.contains(newInfo)) {
555                 if(log.isInfoEnabled()){
556                     log.info("Discovered transport for peer "+agentName+", transport "+newInfo);
557                 }//if
558
worldModeler.addTransportInfoToAgent(defaultDomainName, agentName, newInfo);
559                 result = true;
560             }
561         }//for
562
return result;
563     }//addAgentTransportInfo
564

565
566    
567     private boolean removeAgentTransportInfo(Collection JavaDoc currentAgentTransportInfo, List JavaDoc newAgentTransportList, String JavaDoc agentName, String JavaDoc domainName) {
568         TransportInfo info = null;
569         boolean result = false;
570         ArrayList JavaDoc copy = new ArrayList JavaDoc();
571         copy.addAll(currentAgentTransportInfo);
572         Iterator JavaDoc i = copy.iterator();
573         
574         while (i.hasNext()) {
575             info = (TransportInfo) i.next();
576             if (!newAgentTransportList.contains(info) && info.getTransportInfoType() != TransportType.MWB) {
577                 if(log.isInfoEnabled()){
578                     log.info("Removed transport for peer "+agentName+", transport "+info);
579                 }//if
580
worldModeler.removeTransportInfoFromAgent(domainName, agentName, info);
581                 result = true;
582             }//if
583
}//for
584
return result;
585     }//removeAgentTransportInfo
586

587
588     
589 }//AutoDiscoveryPlugin
590

591
Popular Tags