public ConfigSection[] getConfigSections() { ArrayList<ConfigSection> list = ConfigSectionRepository.getInstance().getList(); for (Iterator<ConfigSection> iter = list.iterator(); iter.hasNext(); ) { ConfigSection configSection = iter.next(); if (configSection instanceof ConfigSectionHolder) { if (((ConfigSectionHolder) configSection).getPluginInterface() != this) { iter.remove(); } } } return list.toArray(new ConfigSection[0]); }
protected long allocateConnectionId(String client_address) { try { random_mon.enter(); long id = random.nextLong(); Long new_key = new Long(id); connectionData new_data = new connectionData(client_address, id); // check for timeouts if (new_data.getTime() - last_timeout_check > 500) { last_timeout_check = new_data.getTime(); Iterator<Long> it = connection_id_map.keySet().iterator(); while (it.hasNext()) { Long key = it.next(); connectionData data = connection_id_map.get(key); if (new_data.getTime() - data.getTime() > CONNECTION_ID_LIFETIME) { // System.out.println( "TRTrackerServerProcessorUDP: connection id timeout" ); it.remove(); List<connectionData> cds = connection_ip_map.get(client_address); if (cds != null) { Iterator<connectionData> it2 = cds.iterator(); while (it2.hasNext()) { if (it2.next().getID() == key) { it2.remove(); break; } } if (cds.size() == 0) { connection_ip_map.remove(client_address); } } } else { // insertion order into map is time based - LinkedHashMap returns keys in same order break; } } } List<connectionData> cds = connection_ip_map.get(client_address); if (cds == null) { cds = new ArrayList<connectionData>(); connection_ip_map.put(client_address, cds); } cds.add(new_data); if (cds.size() > 512) { connectionData dead = cds.remove(0); connection_id_map.remove(dead.getID()); } connection_id_map.put(new_key, new_data); // System.out.println( "TRTrackerServerProcessorUDP: allocated:" + id + ", connection id map // size = " + connection_id_map.size()); return (id); } finally { random_mon.exit(); } }