<commit_before>/*
 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

package org.opendaylight.controller.cluster.example;

import akka.actor.ActorRef;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.opendaylight.controller.cluster.example.messages.KeyValue;

/**
 * Created by kramesha on 7/16/14.
 */
public class LogGenerator {
    private final Map<ActorRef, LoggingThread> clientToLoggingThread = new HashMap<>();

    public void startLoggingForClient(ActorRef client) {
        LoggingThread lt = new LoggingThread(client);
        clientToLoggingThread.put(client, lt);
        new Thread(lt).start();
    }

    public void stopLoggingForClient(ActorRef client) {
        clientToLoggingThread.get(client).stopLogging();
        clientToLoggingThread.remove(client);
    }

    public static class LoggingThread implements Runnable {

        private final ActorRef clientActor;
        private volatile boolean stopLogging = false;

        public LoggingThread(ActorRef clientActor) {
            this.clientActor = clientActor;
        }

        @Override
        @SuppressWarnings("checkstyle:RegexpSingleLineJava")
        public void run() {
            Random random = new Random();
            while (true) {
                if (stopLogging) {
                    System.out.println("Logging stopped for client:" + clientActor.path());
                    break;
                }
                String key = clientActor.path().name();
                int randomInt = random.nextInt(100);
                clientActor.tell(new KeyValue(key + "-key-" + randomInt, "value-" + randomInt), null);
                try {
                    Thread.sleep(randomInt % 10 * 1000L);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }

        public void stopLogging() {
            stopLogging = true;
        }

        public void startLogging() {
            stopLogging = false;
        }
    }
}<commit_msg>Cleanup LogGenerator<commit_after>/*
 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.cluster.example;

import akka.actor.ActorRef;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.opendaylight.controller.cluster.example.messages.KeyValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by kramesha on 7/16/14.
 */
public class LogGenerator {
    private static final Logger LOG = LoggerFactory.getLogger(LogGenerator.class);

    private final Map<ActorRef, LoggingThread> clientToLoggingThread = new HashMap<>();

    public void startLoggingForClient(final ActorRef client) {
        LoggingThread lt = new LoggingThread(client);
        clientToLoggingThread.put(client, lt);
        new Thread(lt).start();
    }

    public void stopLoggingForClient(final ActorRef client) {
        clientToLoggingThread.get(client).stopLogging();
        clientToLoggingThread.remove(client);
    }

    public static class LoggingThread implements Runnable {

        private final ActorRef clientActor;
        private volatile boolean stopLogging = false;

        public LoggingThread(final ActorRef clientActor) {
            this.clientActor = clientActor;
        }

        @Override
        public void run() {
            Random random = new Random();
            while (true) {
                if (stopLogging) {
                    LOG.info("Logging stopped for client: {}", clientActor.path());
                    break;
                }
                String key = clientActor.path().name();
                int randomInt = random.nextInt(100);
                clientActor.tell(new KeyValue(key + "-key-" + randomInt, "value-" + randomInt), null);

                try {
                    Thread.sleep(randomInt % 10 * 1000L);
                } catch (InterruptedException e) {
                    LOG.info("Interrupted while sleeping", e);
                }
            }
        }

        public void stopLogging() {
            stopLogging = true;
        }

        public void startLogging() {
            stopLogging = false;
        }
    }
}
{'fraction_non_alphanumeric': 0.09324009324009325, 'fraction_numerical': 0.01144310235219326, 'mean_word_length': 2.228454172366621, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2776315', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1214, 'n_words': 326}