<commit_before>package org.cohorte.eclipse.runner.basic;

import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Provides;
import org.apache.felix.ipojo.annotations.Requires;
import org.apache.felix.ipojo.annotations.ServiceProperty;
import org.cohorte.herald.HeraldException;
import org.cohorte.herald.IHerald;
import org.cohorte.herald.IMessageListener;
import org.cohorte.herald.Message;
import org.cohorte.herald.MessageReceived;
import org.cohorte.herald.NoTransport;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.psem2m.isolates.base.IIsolateLoggerSvc;

/**
 * Gogo command to stop all Isolate on Eclipse developpement environement.
 *
 * @author bdebbabi
 *
 */
@Component
@Instantiate
@Provides(specifications = { CShutdownGogoCommand.class, IMessageListener.class })
public class CShutdownGogoCommand implements IConstants, IMessageListener {

	/**
	 * OSGi Bundle Context
	 */
	BundleContext pBundleContext;

	/** The Gogo commands */
	@ServiceProperty(name = "osgi.command.function", value = "{shutdown}")
	private String[] pCommands;

	/** Herald message filters */
	@ServiceProperty(name = org.cohorte.herald.IConstants.PROP_FILTERS, value = "{"
			+ IConstants.SHUTDOWN_MESSAGE + "}")
	private String[] pFilters;

	@Requires
	private IHerald pHerald;

	/**
	 * Cohorte Logger service
	 */
	@Requires
	private IIsolateLoggerSvc pLogger;
	/**
	 * The Gogo commands scope
	 */
	@ServiceProperty(name = "osgi.command.scope", value = "runner")
	private String pScope;

	/**
	 * Constructor
	 *
	 * @param aBundleContext
	 */
	public CShutdownGogoCommand(final BundleContext aBundleContext) {
		pBundleContext = aBundleContext;
	}

	/**
	 * Stops bundle 0 (OSGi framework).
	 */
	private void doShutdown() {
		pLogger.logInfo(this, "doShutdown", "trying to stop bundle 0...");
		try {
			pBundleContext.getBundle(0).stop();
			pLogger.logInfo(this, "doShutdown", "bundle 0 stopped");
		} catch (BundleException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void heraldMessage(final IHerald aHerald,
			final MessageReceived aMessage) throws HeraldException {
		pLogger.logInfo(this, "heraldMessage", "receiving a message...");
		String wSubject = aMessage.getSubject();
		pLogger.logInfo(this, "heraldMessage", "subject=" + "wSubject");
		if (wSubject.equalsIgnoreCase(SHUTDOWN_MESSAGE)) {
			doShutdown();
		}
	}

	/**
	 * Shutdown Gogo command.
	 */
	public void shutdown() {
		// dispatch SHUTDOWN message to all other isolates
		pLogger.logInfo(this, "shutdown",
				"sending SHUTDOWN message to all isolates");
		try {
			pHerald.fireGroup("all", new Message(SHUTDOWN_MESSAGE));
		} catch (NoTransport e) {
			e.printStackTrace();
		}
		// stop actual isolate
		try {
			// wait the broadcast message to be sent
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		doShutdown();
	}<commit_msg>Adjusting the sleep time (2 seconds) before stopping the isolate<commit_after>package org.cohorte.eclipse.runner.basic;

import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Provides;
import org.apache.felix.ipojo.annotations.Requires;
import org.apache.felix.ipojo.annotations.ServiceProperty;
import org.cohorte.herald.HeraldException;
import org.cohorte.herald.IHerald;
import org.cohorte.herald.IMessageListener;
import org.cohorte.herald.Message;
import org.cohorte.herald.MessageReceived;
import org.cohorte.herald.NoTransport;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.psem2m.isolates.base.IIsolateLoggerSvc;

/**
 * Gogo command to stop all Isolate on Eclipse developpement environement.
 *
 * @author bdebbabi
 *
 */
@Component
@Instantiate
@Provides(specifications = { CShutdownGogoCommand.class, IMessageListener.class })
public class CShutdownGogoCommand implements IConstants, IMessageListener {

	/**
	 * OSGi Bundle Context
	 */
	BundleContext pBundleContext;

	/** The Gogo commands */
	@ServiceProperty(name = "osgi.command.function", value = "{shutdown}")
	private String[] pCommands;

	/** Herald message filters */
	@ServiceProperty(name = org.cohorte.herald.IConstants.PROP_FILTERS, value = "{"
			+ IConstants.SHUTDOWN_MESSAGE + "}")
	private String[] pFilters;

	@Requires
	private IHerald pHerald;

	/**
	 * Cohorte Logger service
	 */
	@Requires
	private IIsolateLoggerSvc pLogger;
	/**
	 * The Gogo commands scope
	 */
	@ServiceProperty(name = "osgi.command.scope", value = "runner")
	private String pScope;

	/**
	 * Constructor
	 *
	 * @param aBundleContext
	 */
	public CShutdownGogoCommand(final BundleContext aBundleContext) {
		pBundleContext = aBundleContext;
	}

	/**
	 * Stops bundle 0 (OSGi framework).
	 */
	private void doShutdown() {
		pLogger.logInfo(this, "doShutdown",
				"trying to stop bundle 0 after 2 second...");
		// stop actual isolate
		try {
			// wait the broadcast message to be sent
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		try {
			pBundleContext.getBundle(0).stop();
			pLogger.logInfo(this, "doShutdown", "bundle 0 stopped");
		} catch (BundleException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void heraldMessage(final IHerald aHerald,
			final MessageReceived aMessage) throws HeraldException {
		pLogger.logInfo(this, "heraldMessage", "receiving a message...");
		String wSubject = aMessage.getSubject();
		pLogger.logInfo(this, "heraldMessage", "subject=" + "wSubject");
		if (wSubject.equalsIgnoreCase(SHUTDOWN_MESSAGE)) {
			doShutdown();
		}
	}

	/**
	 * Shutdown Gogo command.
	 */
	public void shutdown() {
		// dispatch SHUTDOWN message to all other isolates
		pLogger.logInfo(this, "shutdown",
				"sending SHUTDOWN message to all isolates");
		try {
			pHerald.fireGroup("all", new Message(SHUTDOWN_MESSAGE));
		} catch (NoTransport e) {
			e.printStackTrace();
		}
		doShutdown();
	}
{'fraction_non_alphanumeric': 0.12005277044854881, 'fraction_numerical': 0.0032981530343007917, 'mean_word_length': 4.5086285195277025, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6207787', 'n_tokens_mistral': 2119, 'n_tokens_neox': 1928, 'n_words': 426}