<commit_before>package net.floodlightcontroller.sos;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import org.projectfloodlight.openflow.protocol.match.MatchField;
import org.projectfloodlight.openflow.protocol.OFFactory;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPacketOut;
import org.projectfloodlight.openflow.protocol.OFPortDesc;
import org.projectfloodlight.openflow.protocol.OFVersion;
import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.EthType;
import org.projectfloodlight.openflow.types.IPv4Address;
import org.projectfloodlight.openflow.types.IPv6Address;
import org.projectfloodlight.openflow.types.IpProtocol;
import org.projectfloodlight.openflow.types.MacAddress;
import org.projectfloodlight.openflow.types.OFBufferId;
import org.projectfloodlight.openflow.types.OFPort;
import org.projectfloodlight.openflow.types.U64;
import org.projectfloodlight.openflow.types.VlanVid;
import org.projectfloodlight.openflow.protocol.OFType;
import org.projectfloodlight.openflow.protocol.action.OFAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.floodlightcontroller.core.FloodlightContext;
import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.core.IOFMessageListener;
import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.IOFSwitchListener;
import net.floodlightcontroller.core.PortChangeType;
import net.floodlightcontroller.core.internal.IOFSwitchService;
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.devicemanager.IDevice;
import net.floodlightcontroller.devicemanager.IDeviceService;
import net.floodlightcontroller.devicemanager.SwitchPort;
import net.floodlightcontroller.packet.ARP;
import net.floodlightcontroller.packet.Data;
import net.floodlightcontroller.packet.Ethernet;
import net.floodlightcontroller.packet.IPacket;
import net.floodlightcontroller.packet.IPv4;
import net.floodlightcontroller.packet.TCP;
import net.floodlightcontroller.packet.UDP;
import net.floodlightcontroller.restserver.IRestApiService;
import net.floodlightcontroller.routing.IRoutingService;
import net.floodlightcontroller.routing.Route;
import net.floodlightcontroller.sos.web.SOSWebRoutable;
import net.floodlightcontroller.staticflowentry.IStaticFlowEntryPusherService;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import net.floodlightcontroller.topology.ITopologyService;

/**
 * Steroid OpenFlow Service Module
 * @author <NAME>, <EMAIL>
 * 
 */
public class SOS implements IOFMessageListener, IOFSwitchListener, IFloodlightModule, ISOSService  {
	private static final Logger log = LoggerFactory.getLogger(SOS.class);
	protected static IFloodlightProviderService floodlightProvider;
	protected static IOFSwitchService switchService;
	private static IRoutingService routingService;
	private static IDeviceService deviceService;
	protected static IStaticFlowEntryPusherService sfp;
	private static IRestApiService restApiService;
	private static ITopologyService topologyService;
	private static IThreadPoolService threadPoolService;

	private static ScheduledFuture<?> agentMonitor;

	private static MacAddress controllerMac;

	private static SOSConnections sosConnections;
	private static Set<SOSAgent> agents;

	private static boolean enabled;

	/* These needs to be constant b/t agents, thus we'll keep them global for now */
	private static int bufferSize;
	private static int agentQueueCapacity;
	private static int agentNumParallelSockets;
	private static short flowTimeout;

	/* Keep tabs on our agents; make sure dev mgr will have them cached */
	private class SOSAgentMonitor implements Runnable {
		@Override
		public void run() {
			try {
				for (SOSAgent a : agents) {
					/* Lookup agent's last known location */
					Iterator<? extends IDevice> i = deviceService.queryDevices(MacAddress.NONE, null, a.getIPAddr(), IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO);
					SwitchPort sp = null;
					if (i.hasNext()) {
						IDevice d = i.next();
						SwitchPort[] agentAps = d.getAttachmentPoints();
						if (agentAps.length > 0) {
							SwitchPort agentTrueAp = findTrueAttachmentPoint(agentAps);<commit_msg>Adding log for agents global variable in ARP thread<commit_after>package net.floodlightcontroller.sos;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;

import org.projectfloodlight.openflow.protocol.match.MatchField;
import org.projectfloodlight.openflow.protocol.OFFactory;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPacketOut;
import org.projectfloodlight.openflow.protocol.OFPortDesc;
import org.projectfloodlight.openflow.protocol.OFVersion;
import org.projectfloodlight.openflow.types.DatapathId;
import org.projectfloodlight.openflow.types.EthType;
import org.projectfloodlight.openflow.types.IPv4Address;
import org.projectfloodlight.openflow.types.IPv6Address;
import org.projectfloodlight.openflow.types.IpProtocol;
import org.projectfloodlight.openflow.types.MacAddress;
import org.projectfloodlight.openflow.types.OFBufferId;
import org.projectfloodlight.openflow.types.OFPort;
import org.projectfloodlight.openflow.types.U64;
import org.projectfloodlight.openflow.types.VlanVid;
import org.projectfloodlight.openflow.protocol.OFType;
import org.projectfloodlight.openflow.protocol.action.OFAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.floodlightcontroller.core.FloodlightContext;
import net.floodlightcontroller.core.IFloodlightProviderService;
import net.floodlightcontroller.core.IOFMessageListener;
import net.floodlightcontroller.core.IOFSwitch;
import net.floodlightcontroller.core.IOFSwitchListener;
import net.floodlightcontroller.core.PortChangeType;
import net.floodlightcontroller.core.internal.IOFSwitchService;
import net.floodlightcontroller.core.module.FloodlightModuleContext;
import net.floodlightcontroller.core.module.FloodlightModuleException;
import net.floodlightcontroller.core.module.IFloodlightModule;
import net.floodlightcontroller.core.module.IFloodlightService;
import net.floodlightcontroller.devicemanager.IDevice;
import net.floodlightcontroller.devicemanager.IDeviceService;
import net.floodlightcontroller.devicemanager.SwitchPort;
import net.floodlightcontroller.packet.ARP;
import net.floodlightcontroller.packet.Data;
import net.floodlightcontroller.packet.Ethernet;
import net.floodlightcontroller.packet.IPacket;
import net.floodlightcontroller.packet.IPv4;
import net.floodlightcontroller.packet.TCP;
import net.floodlightcontroller.packet.UDP;
import net.floodlightcontroller.restserver.IRestApiService;
import net.floodlightcontroller.routing.IRoutingService;
import net.floodlightcontroller.routing.Route;
import net.floodlightcontroller.sos.web.SOSWebRoutable;
import net.floodlightcontroller.staticflowentry.IStaticFlowEntryPusherService;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import net.floodlightcontroller.topology.ITopologyService;

/**
 * Steroid OpenFlow Service Module
 * @author <NAME>, <EMAIL>
 * 
 */
public class SOS implements IOFMessageListener, IOFSwitchListener, IFloodlightModule, ISOSService  {
	private static final Logger log = LoggerFactory.getLogger(SOS.class);
	protected static IFloodlightProviderService floodlightProvider;
	protected static IOFSwitchService switchService;
	private static IRoutingService routingService;
	private static IDeviceService deviceService;
	protected static IStaticFlowEntryPusherService sfp;
	private static IRestApiService restApiService;
	private static ITopologyService topologyService;
	private static IThreadPoolService threadPoolService;

	private static ScheduledFuture<?> agentMonitor;

	private static MacAddress controllerMac;

	private static SOSConnections sosConnections;
	private static Set<SOSAgent> agents;

	private static boolean enabled;

	/* These needs to be constant b/t agents, thus we'll keep them global for now */
	private static int bufferSize;
	private static int agentQueueCapacity;
	private static int agentNumParallelSockets;
	private static short flowTimeout;

	/* Keep tabs on our agents; make sure dev mgr will have them cached */
	private class SOSAgentMonitor implements Runnable {
		@Override
		public void run() {
			try {
				log.info("ARP THREAD, AGENTS: {}", agents);
				for (SOSAgent a : agents) {
					/* Lookup agent's last known location */
					Iterator<? extends IDevice> i = deviceService.queryDevices(MacAddress.NONE, null, a.getIPAddr(), IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO);
					SwitchPort sp = null;
					if (i.hasNext()) {
						IDevice d = i.next();
						SwitchPort[] agentAps = d.getAttachmentPoints();
						if (agentAps.length > 0) {
							SwitchPort agentTrueAp = findTrueAttachmentPoint(agentAps);
{'fraction_non_alphanumeric': 0.07995518435526584, 'fraction_numerical': 0.001833367284579344, 'mean_word_length': 6.73758865248227, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4258675', 'n_tokens_mistral': 3110, 'n_tokens_neox': 2904, 'n_words': 583}