<commit_before>package com.researchworx.cresco.controller.communication;

import org.apache.activemq.broker.BrokerPlugin;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.filter.DestinationMapEntry;
import org.apache.activemq.network.NetworkConnector;
import org.apache.activemq.security.*;
import org.apache.activemq.util.ServiceStopper;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.ServerSocket;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;


public class ActiveBroker {
	private static final Logger logger = LoggerFactory.getLogger(ActiveBroker.class);

	public BrokerService broker;
	public TransportConnector connector;


	public ActiveBroker(String brokerName, String brokerUserNameAgent, String brokerPasswordAgent) {
		logger.info("Broker initialized");
		try {
			if(portAvailable(32010)) {
				PolicyEntry entry = new PolicyEntry();
		        entry.setGcInactiveDestinations(true);
		        entry.setInactiveTimeoutBeforeGC(5000);
		        PolicyMap map = new PolicyMap();
		        map.setDefaultEntry(entry);

				broker = new BrokerService();
				broker.setUseShutdownHook(false);
				broker.setPersistent(false);
				broker.setBrokerName(brokerName);
				broker.setSchedulePeriodForDestinationPurge(2500);
				broker.setDestinationPolicy(map);
				broker.setUseJmx(false);

                //auth
                AuthorizationPlugin authorizationPlugin = new AuthorizationPlugin();
                DefaultAuthorizationMap authMap = new DefaultAuthorizationMap();
                List<DestinationMapEntry> authEntries = new ArrayList();

                AuthorizationEntry authEntry = new AuthorizationEntry();
                authEntry.setGroupClass("org.apache.activemq.jaas.GroupPrincipal");
                authEntry.setTopic(">");
                //authEntry.setQueue(">");
                authEntry.setRead("agents");
                authEntry.setWrite("agents");
                authEntries.add(authEntry);<commit_msg>surf surf surf<commit_after>package com.researchworx.cresco.controller.communication;

import org.apache.activemq.broker.BrokerPlugin;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.broker.region.policy.PolicyEntry;
import org.apache.activemq.broker.region.policy.PolicyMap;
import org.apache.activemq.filter.DestinationMapEntry;
import org.apache.activemq.network.NetworkConnector;
import org.apache.activemq.security.*;
import org.apache.activemq.util.ServiceStopper;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.DatagramSocket;
import java.net.ServerSocket;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;


public class ActiveBroker {
	private static final Logger logger = LoggerFactory.getLogger(ActiveBroker.class);

	public BrokerService broker;
	public TransportConnector connector;


	public ActiveBroker(String brokerName, String brokerUserNameAgent, String brokerPasswordAgent) {
		logger.info("Broker initialized");
		try {
			if(portAvailable(32010)) {
				PolicyEntry entry = new PolicyEntry();
		        entry.setGcInactiveDestinations(true);
		        entry.setInactiveTimeoutBeforeGC(5000);
		        PolicyMap map = new PolicyMap();
		        map.setDefaultEntry(entry);

				broker = new BrokerService();
				broker.setUseShutdownHook(false);
				broker.setPersistent(false);
				broker.setBrokerName(brokerName);
				broker.setSchedulePeriodForDestinationPurge(2500);
				broker.setDestinationPolicy(map);
				broker.setUseJmx(false);

                //auth
                AuthorizationPlugin authorizationPlugin = new AuthorizationPlugin();
                DefaultAuthorizationMap authMap = new DefaultAuthorizationMap();
                List<DestinationMapEntry> authEntries = new ArrayList();

                AuthorizationEntry authEntry = new AuthorizationEntry();
                authEntry.setGroupClass("org.apache.activemq.jaas.GroupPrincipal");
                authEntry.setTopic(">");
                //authEntry.setQueue(">");
                authEntry.setRead("agents");
                authEntry.setWrite("agents");
                authEntry.setAdmin("agents");
                authEntries.add(authEntry);
{'fraction_non_alphanumeric': 0.09686609686609686, 'fraction_numerical': 0.006574621959237344, 'mean_word_length': 3.729533678756477, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1894152', 'n_tokens_mistral': 1366, 'n_tokens_neox': 1239, 'n_words': 212}