===================================================================== Found a 69 line (370 tokens) duplication in the following files: Starting at line 137 of /usr/local/dashboard/working/core/src/org/cougaar/core/plugin/freeze/FreezeServlet.java Starting at line 126 of /usr/local/dashboard/working/core/src/org/cougaar/core/plugin/freeze/FreezeTargetPlugin.java private Rules rules = new Rules(); private Set badGuys = new HashSet(); // Records the bad guys we have // seen enter the run state // that have not left the run // state public void unload() { if (threadControlService != null) { ServiceBroker sb = getServiceBroker(); sb.releaseService(this, ThreadListenerService.class, threadListenerService); sb.releaseService(this, ThreadControlService.class, threadControlService); } super.unload(); } private UnaryPredicate myThreadQualifier = new UnaryPredicate() { public boolean execute(Object o) { Schedulable schedulable = (Schedulable) o; Object consumer = schedulable.getConsumer(); return rules.allow(consumer); } }; // Thread control logic. Threads are classified as good or bad. When // frozen, we regulate the max running thread count to be no more // than the number of goodguys that are on the runnable queue. The // number of goodguys is the total of the known good guys (in the // goodGuys set) and the anonymous ones. We have to assume that any // thread we have never seen is a good guy. If an anonymous good guy // steps off the stage we will recognize him and reduce the // anonymousGoodGuys count. public synchronized void threadQueued(Schedulable schedulable, Object consumer) {} public synchronized void threadDequeued(Schedulable schedulable, Object consumer) {} public synchronized void threadStarted(Schedulable schedulable, Object consumer) { if (logger.isDetailEnabled()) logger.detail("threadStarted: " + consumer); if (!rules.allow(consumer)) { badGuys.add(new BadGuy(schedulable, Thread.currentThread())); } } public synchronized void threadStopped(Schedulable schedulable, Object consumer) { if (logger.isDetailEnabled()) logger.detail("threadStopped: " + consumer); if (!rules.allow(consumer)) { Thread currentThread = Thread.currentThread(); badGuys.remove(new BadGuy(schedulable, currentThread)); } } public void rightGiven(String consumer) {} public void rightReturned(String consumer) {} private void setThreadLimit() { threadControlService.setQualifier(myThreadQualifier); } private void unsetThreadLimit() { threadControlService.setQualifier(null); } public void setupSubscriptions() { super.setupSubscriptions(); rules.addAllowRule(FreezePlugin.class); // Hope this is a List cause order is important. Collection params = getParameters(); for (Iterator i = params.iterator(); i.hasNext(); ) { String ruleSpec = (String) i.next(); try { rules.addRule(ruleSpec); } catch (Exception e) { logger.error("Bad parameter: " + ruleSpec, e); ===================================================================== Found a 70 line (287 tokens) duplication in the following files: Starting at line 315 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/MessageSwitch.java Starting at line 243 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/Reconcile.java } private void register_persistence() { // get persistence pc = new PersistenceClient() { public PersistenceIdentity getPersistenceIdentity() { String id = getClass().getName(); return new PersistenceIdentity(id); } public List getPersistenceData() { Object o = captureState(); // must return mutable list! List l = new ArrayList(1); l.add(o); return l; } }; ps = (PersistenceService) sb.getService( pc, PersistenceService.class, null); } private void unregister_persistence() { if (ps != null) { sb.releaseService( pc, PersistenceService.class, ps); ps = null; pc = null; } } private Object rehydrate() { RehydrationData rd = ps.getRehydrationData(); if (rd == null) { if (log.isInfoEnabled()) { log.info("No rehydration data found"); } return null; } List l = rd.getObjects(); rd = null; int lsize = (l == null ? 0 : l.size()); if (lsize < 1) { if (log.isInfoEnabled()) { log.info("Invalid rehydration list? "+l); } return null; } Object o = l.get(0); if (o == null) { if (log.isInfoEnabled()) { log.info("Null rehydration state?"); } return null; } if (log.isInfoEnabled()) { log.info("Found rehydrated state"); if (log.isDetailEnabled()) { log.detail("state is "+o); } } return o; } private void resubscribe(Map m) { ===================================================================== Found a 71 line (287 tokens) duplication in the following files: Starting at line 249 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/FindComponentsEarly.java Starting at line 206 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/Topology.java moveId); } private void register_persistence() { // get persistence pc = new PersistenceClient() { public PersistenceIdentity getPersistenceIdentity() { String id = getClass().getName(); return new PersistenceIdentity(id); } public List getPersistenceData() { Object o = captureState(); // must return mutable list! List l = new ArrayList(1); l.add(o); return l; } }; ps = (PersistenceService) sb.getService( pc, PersistenceService.class, null); } private void unregister_persistence() { if (ps != null) { sb.releaseService( pc, PersistenceService.class, ps); ps = null; pc = null; } } private Object rehydrate() { RehydrationData rd = ps.getRehydrationData(); if (rd == null) { if (log.isInfoEnabled()) { log.info("No rehydration data found"); } return null; } List l = rd.getObjects(); rd = null; int lsize = (l == null ? 0 : l.size()); if (lsize < 1) { if (log.isInfoEnabled()) { log.info("Invalid rehydration list? "+l); } return null; } Object o = l.get(0); if (o == null) { if (log.isInfoEnabled()) { log.info("Null rehydration state?"); } return null; } if (log.isInfoEnabled()) { log.info("Found rehydrated state"); if (log.isDetailEnabled()) { log.detail("state is "+o); } } return o; } private static void initializeSkipReconciliation(LoggingService log) { ===================================================================== Found a 70 line (287 tokens) duplication in the following files: Starting at line 282 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/AcquireIdentity.java Starting at line 207 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/Topology.java } private void register_persistence() { // get persistence pc = new PersistenceClient() { public PersistenceIdentity getPersistenceIdentity() { String id = getClass().getName(); return new PersistenceIdentity(id); } public List getPersistenceData() { Object o = captureState(); // must return mutable list! List l = new ArrayList(1); l.add(o); return l; } }; ps = (PersistenceService) sb.getService( pc, PersistenceService.class, null); } private void unregister_persistence() { if (ps != null) { sb.releaseService( pc, PersistenceService.class, ps); ps = null; pc = null; } } private Object rehydrate() { RehydrationData rd = ps.getRehydrationData(); if (rd == null) { if (log.isInfoEnabled()) { log.info("No rehydration data found"); } return null; } List l = rd.getObjects(); rd = null; int lsize = (l == null ? 0 : l.size()); if (lsize < 1) { if (log.isInfoEnabled()) { log.info("Invalid rehydration list? "+l); } return null; } Object o = l.get(0); if (o == null) { if (log.isInfoEnabled()) { log.info("Null rehydration state?"); } return null; } if (log.isInfoEnabled()) { log.info("Found rehydrated state"); if (log.isDetailEnabled()) { log.detail("state is "+o); } } return o; } private static void initializeSkipReconciliation(LoggingService log) { ===================================================================== Found a 70 line (286 tokens) duplication in the following files: Starting at line 282 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/AcquireIdentity.java Starting at line 250 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/FindComponentsEarly.java Starting at line 315 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/MessageSwitch.java } private void register_persistence() { // get persistence pc = new PersistenceClient() { public PersistenceIdentity getPersistenceIdentity() { String id = getClass().getName(); return new PersistenceIdentity(id); } public List getPersistenceData() { Object o = captureState(); // must return mutable list! List l = new ArrayList(1); l.add(o); return l; } }; ps = (PersistenceService) sb.getService( pc, PersistenceService.class, null); } private void unregister_persistence() { if (ps != null) { sb.releaseService( pc, PersistenceService.class, ps); ps = null; pc = null; } } private Object rehydrate() { RehydrationData rd = ps.getRehydrationData(); if (rd == null) { if (log.isInfoEnabled()) { log.info("No rehydration data found"); } return null; } List l = rd.getObjects(); rd = null; int lsize = (l == null ? 0 : l.size()); if (lsize < 1) { if (log.isInfoEnabled()) { log.info("Invalid rehydration list? "+l); } return null; } Object o = l.get(0); if (o == null) { if (log.isInfoEnabled()) { log.info("Null rehydration state?"); } return null; } if (log.isInfoEnabled()) { log.info("Found rehydrated state"); if (log.isDetailEnabled()) { log.detail("state is "+o); } } return o; } private void load_unpend_messages() { ===================================================================== Found a 64 line (251 tokens) duplication in the following files: Starting at line 144 of /usr/local/dashboard/working/core/src/org/cougaar/core/mobility/arch/DispatchRemoteHandler.java Starting at line 164 of /usr/local/dashboard/working/core/src/org/cougaar/core/mobility/arch/DispatchTestHandler.java "Test dispatch on a non-local destination "+destNode); } // check agent assertion MessageAddress mobileAgent = moveTicket.getMobileAgent(); if ((mobileAgent != null) && (!(mobileAgent.equals(id)))) { throw new MobilityException( "Move agent "+id+ " doesn't match ticket agent "+mobileAgent); } // check origin assertion MessageAddress originNode = moveTicket.getOriginNode(); if ((originNode != null) && (!(originNode.equals(nodeId)))) { throw new MobilityException( "Move origin "+nodeId+" for "+id+ " doesn't match ticket origin "+originNode); } } private void suspendAgent() { if (log.isInfoEnabled()) { log.info("Suspend agent "+id); } model.suspend(); if (log.isInfoEnabled()) { log.info("Suspended agent "+id); } } private Object getAgentState() { // capture the agent state if (stateProvider == null) { if (log.isWarnEnabled()) { log.warn("Agent "+id+" has no state?"); } return null; } if (log.isInfoEnabled()) { log.info("Capture state for agent "+id); } Object state; try { state = stateProvider.getState(); } catch (Exception e) { // FIXME now what? // throw new MobilityException( "Unable to capture state for agent "+id+ ", will attempt resume", e); } if (log.isInfoEnabled()) { // FIXME maybe not log this -- state may be very verbose! log.info("Captured state for agent "+id+": "+state); } return state; } ===================================================================== Found a 52 line (216 tokens) duplication in the following files: Starting at line 109 of /usr/local/dashboard/working/core/src/org/cougaar/core/mobility/plugin/MoveAgentLoopTestPlugin.java Starting at line 197 of /usr/local/dashboard/working/core/src/org/cougaar/core/mobility/servlet/MoveAgentServlet.java } protected Collection queryAgentControls() { Collection ret = null; try { blackboard.openTransaction(); ret = blackboard.query(AGENT_CONTROL_PRED); } finally { blackboard.closeTransactionDontReset(); } return ret; } protected AgentControl queryAgentControl(final UID uid) { if (uid == null) { throw new IllegalArgumentException("null uid"); } UnaryPredicate pred = new UnaryPredicate() { public boolean execute(Object o) { return ((o instanceof AgentControl) && (uid.equals(((AgentControl) o).getUID()))); } }; AgentControl ret = null; try { blackboard.openTransaction(); Collection c = blackboard.query(pred); if ((c != null) && (c.size() >= 1)) { ret = (AgentControl) c.iterator().next(); } } finally { blackboard.closeTransactionDontReset(); } return ret; } protected AgentControl createAgentControl( UID ownerUID, MessageAddress target, AbstractTicket ticket) { if (mobilityFactory == null) { throw new RuntimeException( "Mobility factory (and domain) not enabled"); } AgentControl ac = mobilityFactory.createAgentControl( ownerUID, target, ticket); return ac; } protected void addAgentControl(AgentControl ac) { ===================================================================== Found a 47 line (172 tokens) duplication in the following files: Starting at line 77 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/bootstrap/http/HttpDiscovery.java Starting at line 72 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/bootstrap/multicast/MulticastDiscovery.java "org.cougaar.core.wp.resolver.multicast.maxLookup", "120000")); private ConfigService configService; private final ConfigService.Client configClient = new ConfigService.Client() { public void add(Bundle b) { addPoller(getBootEntry(b)); } public void change(Bundle b) { add(b); } public void remove(Bundle b) { removePoller(getBootEntry(b)); } }; public void load() { super.load(); configService = (ConfigService) sb.getService(configClient, ConfigService.class, null); if (configService == null) { throw new RuntimeException("Unable to obtain ConfigService"); } } public void unload() { if (configService != null) { sb.releaseService(configClient, ConfigService.class, configService); configService = null; } super.unload(); } protected long getMinDelay() { return MIN_DELAY; } protected long getMaxDelay() { return MAX_DELAY; } protected AddressEntry getBootEntry(Bundle b) { return MulticastUtil.getBootEntry(b); ===================================================================== Found a 41 line (171 tokens) duplication in the following files: Starting at line 345 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/MessageSwitch.java Starting at line 406 of /usr/local/dashboard/working/core/src/org/cougaar/core/node/AgentLoader.java } } private Object rehydrate() { RehydrationData rd = ps.getRehydrationData(); if (rd == null) { if (log.isInfoEnabled()) { log.info("No rehydration data found"); } return null; } // extract our ComponentDescriptions List l = rd.getObjects(); rd = null; int lsize = (l == null ? 0 : l.size()); if (lsize < 1) { if (log.isInfoEnabled()) { log.info("Invalid rehydration list? "+l); } return null; } Object o = l.get(0); if (o == null) { if (log.isInfoEnabled()) { log.info("Null rehydration state?"); } return null; } if (log.isInfoEnabled()) { log.info("Found rehydrated state"); if (log.isDetailEnabled()) { log.detail("state is "+o); } } return o; } private void add(MessageAddress addr) { ===================================================================== Found a 41 line (170 tokens) duplication in the following files: Starting at line 312 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/AcquireIdentity.java Starting at line 406 of /usr/local/dashboard/working/core/src/org/cougaar/core/node/AgentLoader.java } } private Object rehydrate() { RehydrationData rd = ps.getRehydrationData(); if (rd == null) { if (log.isInfoEnabled()) { log.info("No rehydration data found"); } return null; } // extract our ComponentDescriptions List l = rd.getObjects(); rd = null; int lsize = (l == null ? 0 : l.size()); if (lsize < 1) { if (log.isInfoEnabled()) { log.info("Invalid rehydration list? "+l); } return null; } Object o = l.get(0); if (o == null) { if (log.isInfoEnabled()) { log.info("Null rehydration state?"); } return null; } if (log.isInfoEnabled()) { log.info("Found rehydrated state"); if (log.isDetailEnabled()) { log.detail("state is "+o); } } return o; } private void add(MessageAddress addr) { ===================================================================== Found a 35 line (161 tokens) duplication in the following files: Starting at line 51 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/resolver/ResolverContainer.java Starting at line 50 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/server/ServerContainer.java private LoggingService logger; private MessageAddress agentId; public void setLoggingService(LoggingService logger) { this.logger = logger; } public void setAgentIdentificationService(AgentIdentificationService ais) { if (ais != null) { this.agentId = ais.getMessageAddress(); } } protected String specifyContainmentPoint() { return INSERTION_POINT; } protected ComponentDescriptions findInitialComponentDescriptions() { String cname = agentId.toString(); ServiceBroker sb = getServiceBroker(); ComponentInitializerService cis = (ComponentInitializerService) sb.getService(this, ComponentInitializerService.class, null); try { return new ComponentDescriptions( cis.getComponentDescriptions(cname, specifyContainmentPoint())); } catch (ComponentInitializerService.InitializerException cise) { if (logger.isInfoEnabled()) { logger.info("\nUnable to add "+cname+"'s plugins ",cise); } return null; } finally { sb.releaseService(this, ComponentInitializerService.class, cis); } } } ===================================================================== Found a 36 line (158 tokens) duplication in the following files: Starting at line 39 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/bootstrap/ServiceFinder.java Starting at line 41 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/resolver/ServiceFinder.java public class ServiceFinder { private ServiceFinder() {} public interface Callback { void foundService(Service s); } public static boolean findServiceLater( final ServiceBroker sb, final Class cl, final Object requestor, final Callback cb) { final Object req = (requestor == null ? ServiceFinder.class : requestor); if (sb.hasService(cl)) { Service s = (Service) sb.getService(req, cl, null); cb.foundService(s); return true; } ServiceAvailableListener sal = new ServiceAvailableListener() { public void serviceAvailable(ServiceAvailableEvent ae) { if (cl.isAssignableFrom(ae.getService())) { Service s = (Service) sb.getService(req, cl, null); cb.foundService(s); //sb.removeServiceListener(this); } } }; sb.addServiceListener(sal); return false; } } ===================================================================== Found a 26 line (136 tokens) duplication in the following files: Starting at line 102 of /usr/local/dashboard/working/core/src/org/cougaar/core/plugin/freeze/FreezeServlet.java Starting at line 95 of /usr/local/dashboard/working/core/src/org/cougaar/core/plugin/freeze/FreezeTargetPlugin.java public class FreezeTargetPlugin extends FreezePlugin implements ThreadListener { private static class BadGuy { private Thread thread; private Schedulable schedulable; int hc; public BadGuy(Schedulable s, Thread t) { thread = t; schedulable = s; hc = System.identityHashCode(t) + System.identityHashCode(s); } public int hashCode() { return hc; } public boolean equals(Object o) { if (o == this) return true; if (o instanceof BadGuy) { BadGuy that = (BadGuy) o; return this.thread == that.thread && this.schedulable == that.schedulable; } return false; } public String toString() { return schedulable.getState() + ": " + schedulable.getConsumer().toString(); } } private IncrementalSubscription relaySubscription; ===================================================================== Found a 26 line (132 tokens) duplication in the following files: Starting at line 60 of /usr/local/dashboard/working/core/src/org/cougaar/core/plugin/PluginManager.java Starting at line 59 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/resolver/ResolverContainer.java if (ais != null) { this.agentId = ais.getMessageAddress(); } } protected String specifyContainmentPoint() { return INSERTION_POINT; } protected ComponentDescriptions findInitialComponentDescriptions() { String cname = agentId.toString(); ServiceBroker sb = getServiceBroker(); ComponentInitializerService cis = (ComponentInitializerService) sb.getService(this, ComponentInitializerService.class, null); try { return new ComponentDescriptions( cis.getComponentDescriptions(cname, specifyContainmentPoint())); } catch (ComponentInitializerService.InitializerException cise) { if (logger.isInfoEnabled()) { logger.info("\nUnable to add "+cname+"'s plugins ",cise); } return null; } finally { sb.releaseService(this, ComponentInitializerService.class, cis); } } ===================================================================== Found a 35 line (131 tokens) duplication in the following files: Starting at line 44 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/BeginLogger.java Starting at line 44 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/EndLogger.java extends GenericStateModelAdapter implements Component { private ServiceBroker sb; private LoggingService log; public void setServiceBroker(ServiceBroker sb) { this.sb = sb; } public void load() { super.load(); // get our local agent's address MessageAddress localAgent = null; AgentIdentificationService ais = (AgentIdentificationService) sb.getService(this, AgentIdentificationService.class, null); if (ais != null) { localAgent = ais.getMessageAddress(); sb.releaseService( this, AgentIdentificationService.class, ais); } // get logging service log = (LoggingService) sb.getService(this, LoggingService.class, null); // prefix with agent name String prefix = localAgent+": "; log = LoggingServiceWithPrefix.add(log, prefix); if (log.isInfoEnabled()) { log.info("Loaded"); ===================================================================== Found a 35 line (121 tokens) duplication in the following files: Starting at line 242 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/Reconcile.java Starting at line 348 of /usr/local/dashboard/working/core/src/org/cougaar/core/node/AgentLoader.java return ret; } private void register_persistence() { // get persistence pc = new PersistenceClient() { public PersistenceIdentity getPersistenceIdentity() { String id = getClass().getName(); return new PersistenceIdentity(id); } public List getPersistenceData() { Object o = captureState(); // must return mutable list! List l = new ArrayList(1); l.add(o); return l; } }; ps = (PersistenceService) sb.getService( pc, PersistenceService.class, null); } private void unregister_persistence() { if (ps != null) { sb.releaseService( pc, PersistenceService.class, ps); ps = null; pc = null; } } private void persistNow() { ===================================================================== Found a 13 line (120 tokens) duplication in the following files: Starting at line 572 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/resolver/ClientTransport.java Starting at line 603 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/resolver/ClientTransport.java for (int t = 0; t < 2; t++) { boolean tlookup = (t == 0); Map table = (tlookup ? lookups : mods); int tsize = table.size(); if (tsize <= 0) { continue; } Set names = (tlookup ? lookupNames : modifyNames); Iterator iter = table.entrySet().iterator(); for (int i = 0; i < tsize; i++) { Map.Entry me = (Map.Entry) iter.next(); String name = (String) me.getKey(); Entry e = (Entry) me.getValue(); ===================================================================== Found a 22 line (120 tokens) duplication in the following files: Starting at line 62 of /usr/local/dashboard/working/core/src/org/cougaar/core/qos/metrics/MetricQueryServlet.java Starting at line 60 of /usr/local/dashboard/working/core/src/org/cougaar/core/qos/metrics/MetricsRSSFeedServlet.java public MetricsRSSFeedServlet(ServiceBroker sb) { // Register our servlet with servlet service ServletService servletService = (ServletService) sb.getService(this, ServletService.class, null); if (servletService == null) { throw new RuntimeException("Unable to obtain ServletService"); } try { servletService.register(getPath(), this); } catch (Exception e) { throw new RuntimeException("Unable to register servlet at path <" +getPath()+ ">: " +e.getMessage()); } // get metrics service try { metricsService = (MetricsService) sb.getService(this, MetricsService.class, null); } catch (Exception e) { throw new RuntimeException("Unable to get MetricsService at path <" +getPath()+ ">: " +e.getMessage()); } ===================================================================== Found a 25 line (119 tokens) duplication in the following files: Starting at line 323 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/bootstrap/AdvertiseBase.java Starting at line 324 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/bootstrap/DiscoveryBase.java enqueue(Destroy.getInstance()); } private void enqueue(Object o) { synchronized (queue) { queue.add(o); } thread.start(); } public void run() { // process queue int n; synchronized (queue) { n = queue.size(); if (n > 0) { tmp.addAll(queue); queue.clear(); } } for (int i = 0; i < n; i++) { Object o = tmp.get(i); if (o instanceof Start) { startNow(); } else if (o instanceof Stop) { stopNow(); } else if (o instanceof Destroy) { ===================================================================== Found a 34 line (119 tokens) duplication in the following files: Starting at line 282 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/AcquireIdentity.java Starting at line 349 of /usr/local/dashboard/working/core/src/org/cougaar/core/node/AgentLoader.java } private void register_persistence() { // get persistence pc = new PersistenceClient() { public PersistenceIdentity getPersistenceIdentity() { String id = getClass().getName(); return new PersistenceIdentity(id); } public List getPersistenceData() { Object o = captureState(); // must return mutable list! List l = new ArrayList(1); l.add(o); return l; } }; ps = (PersistenceService) sb.getService( pc, PersistenceService.class, null); } private void unregister_persistence() { if (ps != null) { sb.releaseService( pc, PersistenceService.class, ps); ps = null; pc = null; } } private void persistNow() { ===================================================================== Found a 27 line (117 tokens) duplication in the following files: Starting at line 252 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/DemoControl.java Starting at line 126 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/FindComponentsEarly.java } private MessageAddress find_local_agent() { AgentIdentificationService ais = (AgentIdentificationService) sb.getService(this, AgentIdentificationService.class, null); if (ais == null) { return null; } MessageAddress ret = ais.getMessageAddress(); sb.releaseService( this, AgentIdentificationService.class, ais); return ret; } private MessageAddress find_local_node() { NodeIdentificationService nis = (NodeIdentificationService) sb.getService(this, NodeIdentificationService.class, null); if (nis == null) { return null; } MessageAddress ret = nis.getMessageAddress(); sb.releaseService( this, NodeIdentificationService.class, nis); return ret; } private void get_logger() { ===================================================================== Found a 27 line (116 tokens) duplication in the following files: Starting at line 252 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/DemoControl.java Starting at line 91 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/NodeControlBlocker.java } private MessageAddress find_local_agent() { AgentIdentificationService ais = (AgentIdentificationService) sb.getService(this, AgentIdentificationService.class, null); if (ais == null) { return null; } MessageAddress ret = ais.getMessageAddress(); sb.releaseService( this, AgentIdentificationService.class, ais); return ret; } private MessageAddress find_local_node() { NodeIdentificationService nis = (NodeIdentificationService) sb.getService(this, NodeIdentificationService.class, null); if (nis == null) { return null; } MessageAddress ret = nis.getMessageAddress(); sb.releaseService( this, NodeIdentificationService.class, nis); return ret; } private static final class BlockSP ===================================================================== Found a 29 line (115 tokens) duplication in the following files: Starting at line 173 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/Bootstrap.java Starting at line 252 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/DemoControl.java } // // the rest is private! // private MessageAddress find_local_agent() { AgentIdentificationService ais = (AgentIdentificationService) sb.getService(this, AgentIdentificationService.class, null); if (ais == null) { return null; } MessageAddress ret = ais.getMessageAddress(); sb.releaseService( this, AgentIdentificationService.class, ais); return ret; } private MessageAddress find_local_node() { NodeIdentificationService nis = (NodeIdentificationService) sb.getService(this, NodeIdentificationService.class, null); if (nis == null) { return null; } MessageAddress ret = nis.getMessageAddress(); sb.releaseService( this, NodeIdentificationService.class, nis); return ret; } ===================================================================== Found a 10 line (110 tokens) duplication in the following files: Starting at line 166 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/AgentImpl.java Starting at line 314 of /usr/local/dashboard/working/core/src/org/cougaar/core/agent/RehydrateEarly.java public void initialize() { agentModel.initialize(); } public void load() { agentModel.load(); } public void start() { agentModel.start(); } public void suspend() { agentModel.suspend(); } public void resume() { agentModel.resume(); } public void stop() { agentModel.stop(); } public void halt() { agentModel.halt(); } public void unload() { agentModel.unload(); } public int getModelState() { return agentModel.getModelState(); } }; ===================================================================== Found a 15 line (104 tokens) duplication in the following files: Starting at line 82 of /usr/local/dashboard/working/core/src/org/cougaar/core/servlet/ServletUtil.java Starting at line 120 of /usr/local/dashboard/working/core/src/org/cougaar/core/servlet/ServletUtil.java public static final String encodeForJava(final String s) { int slen = ((s != null) ? s.length() : 0); StringBuffer sb = new StringBuffer((int)(1.10*(double)slen)); for (int i = 0; i < slen; i++) { char ci = s.charAt(i); switch (ci) { default: if ((ci >= ' ') && (ci <= '~')) { sb.append(ci); } else { // unsupported? sb.append("?"); } break; case '\"': ===================================================================== Found a 31 line (103 tokens) duplication in the following files: Starting at line 270 of /usr/local/dashboard/working/core/src/org/cougaar/core/thread/AgentLoadSensorPlugin.java Starting at line 173 of /usr/local/dashboard/working/core/src/org/cougaar/core/thread/PercentageLoadSelector.java ConsumerRecord findRecord(String name) { ConsumerRecord rec = null; synchronized (records) { rec = (ConsumerRecord) records.get(name); if (rec == null) { rec = new ConsumerRecord(name); records.put(name, rec); } } return rec; } public void threadQueued(Schedulable schedulable, Object consumer) { } public void threadDequeued(Schedulable schedulable, Object consumer) { } public void threadStarted(Schedulable schedulable, Object consumer) { } public void threadStopped(Schedulable schedulable, Object consumer) { } public void rightGiven(String consumer) { ===================================================================== Found a 15 line (102 tokens) duplication in the following files: Starting at line 79 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/ListAllAgents.java Starting at line 65 of /usr/local/dashboard/working/core/src/org/cougaar/core/wp/ListAllNodes.java } // recursive! private static void recurse( Set toSet, WhitePagesService wps, String suffix, long timeout) throws Exception { Set names = wps.list(suffix, timeout); for (Iterator iter = names.iterator(); iter.hasNext(); ) { String s = (String) iter.next(); if (s == null) { } else if (s.length() > 0 && s.charAt(0) == '.') { recurse(toSet, wps, s, timeout); } else { ===================================================================== Found a 47 line (100 tokens) duplication in the following files: Starting at line 108 of /usr/local/dashboard/working/core/src/org/cougaar/core/adaptivity/InterAgentCondition.java Starting at line 100 of /usr/local/dashboard/working/core/src/org/cougaar/core/adaptivity/InterAgentOperatingMode.java } /** * Get all the addresses of the target agents to which this Relay * should be sent. For this implementation this is always a * singleton set contain just one target. **/ public Set getTargets() { return targets; } /** * Get an object representing the value of this Relay suitable * for transmission. This implementation uses itself to represent * its Content. **/ public Object getContent() { return this; } /** * @return a factory to convert the content to a Relay Target. **/ public Relay.TargetFactory getTargetFactory() { return InterAgentConditionFactory.INSTANCE; } /** * Set the response that was sent from a target. For LP use only. * This implemenation does nothing because responses are not needed * or used. **/ public int updateResponse(MessageAddress target, Object response) { // No response expected return Relay.NO_CHANGE; } /** * This factory creates a new InterAgentCondition. **/ private static class InterAgentConditionFactory implements Relay.TargetFactory, java.io.Serializable { public static final InterAgentConditionFactory INSTANCE = new InterAgentConditionFactory(); private InterAgentConditionFactory() { } public Relay.Target create( UID uid, MessageAddress source, Object content, Relay.Token owner) {