<commit_before>package de.cinovo.cloudconductor.server;

/*
 * #%L
 * cloudconductor-server
 * %%
 * Copyright (C) 2013 - 2014 Cinovo AG
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 * #L%
 */

import java.lang.management.ManagementFactory;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.velocity.app.Velocity;

import de.cinovo.cloudconductor.server.repo.IndexTask;
import de.cinovo.cloudconductor.server.util.CleanUpTask;
import de.cinovo.cloudconductor.server.util.JMXResourceProvider;
import de.taimos.daemon.DaemonStarter;
import de.taimos.daemon.LifecyclePhase;
import de.taimos.daemon.properties.FilePropertyProvider;
import de.taimos.daemon.properties.IPropertyProvider;
import de.taimos.springcxfdaemon.SpringDaemonAdapter;

/**
 * Copyright 2012 Cinovo AG<br>
 * <br>
 * Starter program for the Config Server.
 *
 * @author mhilbert
 */
public class ServerStarter extends SpringDaemonAdapter {
	
	private static final String CLOUDCONDUCTOR_PROPERTIES = "cloudconductor.properties";
	// Exception messages.
	private static final String EXCEPTION_IN_PHASE = "Exception in phase %s.";
	/** the name of the server daemon */
	public static final String DAEMON_NAME = "cloudconductor";
	/** the logger */
	private static final Logger log = Logger.getLogger(ServerStarter.class);
	
	/** scheduler service */
	public static final ScheduledExecutorService ses = Executors.newScheduledThreadPool(10);
	
	private static final int CLEANUP_TIMER = 30;
	private static final int INDEX_TIMER = 10;
	
	
	/**
	 * Main method.
	 *
	 * @param args the command line arguments
	 */
	public static void main(final String[] args) {
		DaemonStarter.startDaemon(ServerStarter.DAEMON_NAME, new ServerStarter());
	}
	
	@Override
	protected void doBeforeSpringStart() {
		// In dev mode all classes related to the config server should log on the level DEBUG.
		if (DaemonStarter.isDevelopmentMode()) {
			Logger.getLogger("de.cinovo.cloudconductor.server").setLevel(Level.DEBUG);
		}
		Velocity.setProperty("runtime.log.logsystem.log4j.logger", "org.apache.velocity");
		super.doBeforeSpringStart();
	}
	
	@Override
	protected void doAfterSpringStart() {
		CleanUpTask cleanup = this.getContext().getBean("cleanuptask", CleanUpTask.class);
		ServerStarter.ses.scheduleAtFixedRate(cleanup, 0, ServerStarter.CLEANUP_TIMER, TimeUnit.MINUTES);
		
		if (System.getProperty("repo.indexscan", "false").equals("true")) {
			IndexTask index = this.getContext().getBean("indextask", IndexTask.class);
			ServerStarter.ses.scheduleAtFixedRate(index, 0, ServerStarter.INDEX_TIMER, TimeUnit.SECONDS);
		}
		
		JMXResourceProvider prov = this.getContext().getBean(JMXResourceProvider.class);
		final String name = prov.getClass().getName() + ":type=" + prov.getClass().getSimpleName();
		try {
			ManagementFactory.getPlatformMBeanServer().registerMBean(prov, new ObjectName(name));
		} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | MalformedObjectNameException e) {
			ServerStarter.log.warn("Failed to init JMX", e);
		}
		super.doAfterSpringStart();
	}
	
	@Override
	public void exception(LifecyclePhase phase, Throwable exception) {
		ServerStarter.log.error(String.format(ServerStarter.EXCEPTION_IN_PHASE, phase.name()), exception);
	}
	
	@Override
	public IPropertyProvider getPropertyProvider() {
		return new FilePropertyProvider(ServerStarter.CLOUDCONDUCTOR_PROPERTIES);
	}
}<commit_msg>better schedule time (1 minute)<commit_after>package de.cinovo.cloudconductor.server;

/*
 * #%L cloudconductor-server %% Copyright (C) 2013 - 2014 Cinovo AG %% Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License. #L%
 */

import java.lang.management.ManagementFactory;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.velocity.app.Velocity;

import de.cinovo.cloudconductor.server.repo.IndexTask;
import de.cinovo.cloudconductor.server.util.CleanUpTask;
import de.cinovo.cloudconductor.server.util.JMXResourceProvider;
import de.taimos.daemon.DaemonStarter;
import de.taimos.daemon.LifecyclePhase;
import de.taimos.daemon.properties.FilePropertyProvider;
import de.taimos.daemon.properties.IPropertyProvider;
import de.taimos.springcxfdaemon.SpringDaemonAdapter;

/**
 * Copyright 2012 Cinovo AG<br>
 * <br>
 * Starter program for the Config Server.
 *
 * @author mhilbert
 */
public class ServerStarter extends SpringDaemonAdapter {

	private static final String CLOUDCONDUCTOR_PROPERTIES = "cloudconductor.properties";
	// Exception messages.
	private static final String EXCEPTION_IN_PHASE = "Exception in phase %s.";
	/** the name of the server daemon */
	public static final String DAEMON_NAME = "cloudconductor";
	/** the logger */
	private static final Logger log = Logger.getLogger(ServerStarter.class);

	/** scheduler service */
	public static final ScheduledExecutorService ses = Executors.newScheduledThreadPool(10);

	private static final int CLEANUP_TIMER = 30;
	private static final int INDEX_TIMER = 60;


	/**
	 * Main method.
	 *
	 * @param args the command line arguments
	 */
	public static void main(final String[] args) {
		DaemonStarter.startDaemon(ServerStarter.DAEMON_NAME, new ServerStarter());
	}

	@Override
	protected void doBeforeSpringStart() {
		// In dev mode all classes related to the config server should log on the level DEBUG.
		if (DaemonStarter.isDevelopmentMode()) {
			Logger.getLogger("de.cinovo.cloudconductor.server").setLevel(Level.DEBUG);
		}
		Velocity.setProperty("runtime.log.logsystem.log4j.logger", "org.apache.velocity");
		super.doBeforeSpringStart();
	}

	@Override
	protected void doAfterSpringStart() {
		CleanUpTask cleanup = this.getContext().getBean("cleanuptask", CleanUpTask.class);
		ServerStarter.ses.scheduleAtFixedRate(cleanup, 0, ServerStarter.CLEANUP_TIMER, TimeUnit.MINUTES);

		if (System.getProperty("repo.indexscan", "false").equals("true")) {
			IndexTask index = this.getContext().getBean("indextask", IndexTask.class);
			ServerStarter.ses.scheduleAtFixedRate(index, 0, ServerStarter.INDEX_TIMER, TimeUnit.SECONDS);
		}

		JMXResourceProvider prov = this.getContext().getBean(JMXResourceProvider.class);
		final String name = prov.getClass().getName() + ":type=" + prov.getClass().getSimpleName();
		try {
			ManagementFactory.getPlatformMBeanServer().registerMBean(prov, new ObjectName(name));
		} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException | MalformedObjectNameException e) {
			ServerStarter.log.warn("Failed to init JMX", e);
		}
		super.doAfterSpringStart();
	}

	@Override
	public void exception(LifecyclePhase phase, Throwable exception) {
		ServerStarter.log.error(String.format(ServerStarter.EXCEPTION_IN_PHASE, phase.name()), exception);
	}

	@Override
	public IPropertyProvider getPropertyProvider() {
		return new FilePropertyProvider(ServerStarter.CLOUDCONDUCTOR_PROPERTIES);
	}
}
{'fraction_non_alphanumeric': 0.10065797067990304, 'fraction_numerical': 0.006348839893801223, 'mean_word_length': 5.446428571428571, 'pattern_counts': {'":': 2, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5216952', 'n_tokens_mistral': 2661, 'n_tokens_neox': 2473, 'n_words': 628}