/** * Adds a route to the routing table. Before adding a new kernel, it checks if the kernel's ID * already existes in the routing table. if it does, no action is taken and returns false. * * @param ka KernelAddress of the distant kernel to add. * @param addr AgentAddress of the P2PAgent responsable for the connection with the kernel * @param dkinfo SocketKernel of the distant Kernel * @return true iff the distant kernel was add. false if the kernel already has an entry in the * route table */ private boolean addRoute( KernelAddress ka, AgentAddress addr, SocketKernel dkinfo, String protocol) { DistantKernelInformation tmp = (DistantKernelInformation) routeTable.get(ka.getID()); if (tmp != null) { if (tmp.getProtocol().equals(CONFIG)) { if (protocol.equals(CONFIG)) { // Added by saber KernelAddress agency = tmp.getDistantKernelAddress(); if (!agency.getKernelName().equals(ka.getKernelName()) || (agency.supportMobility() != ka.supportMobility())) // the distantKernel has changed its name or mobility // aspect { agency.setKernelName(ka.getKernelName()); if (ka.supportMobility()) agency.enableMobility(); else agency.disableMobility(); return true; } else // end of saber modification return false; } else { routeTable.remove(ka.getID()); updateDistantAgencies(); } } else { debug("Kernel " + ka + " already added"); return false; } } debug("adding new kernel " + ka.getID()); routeTable.put(ka.getID(), new DistantKernelInformation(ka, addr, dkinfo, protocol)); updateDistantAgencies(); if (!protocol.equals(CONFIG)) sendConnectedKernelInformation(dkinfo, ka, addr, protocol); return true; }