/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/**
* AgentIndexRunner.
* @author Jan S Berg
*/
public final class AgentIndexRunner
{
private boolean enabled;
new HashSet<NotificationHolder>();
/**
* The only constructor is private, so other classes will only get an
* instance through the static factory method getInstance().
*/
}
/**
* Static factory method to get an instance of AgentIndexRunner.
* @param enabledParam If {@code true}, the initial instance should be
* running or not.
* @return a singleton
*/
@SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel")
if (indexerInstance == null) {
}
return indexerInstance;
}
/**
* {@inheritDoc}
*/
return name;
}
/**
* {@inheritDoc}
*/
// not used
}
/**
* {@inheritDoc}
*/
public void preDeregister() {
// not used
}
/**
* {@inheritDoc}
*/
public void postDeregister() {
// not used
}
/**
* {@inheritDoc}
*/
public void run() {
try {
//Indexer ind = new Indexer();
if (configfile == null) {
"Missing Configuration file", "");
}
.getNumberOfThreads().intValue();
} else {
"Published index", publishhost);
}
} else {
log.log(Level.WARNING, "Cannot Run indexing without proper configuration file ''{0}''", configfile);
"Configuration file not valid", configfile);
}
} catch (Exception e) {
lastException = e;
}
}
/**
* Disables indexer
*/
public void disable() {
enabled = false;
}
/**
* Enables the indexer
*/
public void enable() {
enabled = true;
}
/**
* Handle timer notifications to the purgatory.
* Will start the purger if it is enabled and return immediately.
*/
if (enabled) {
index(false);
} else {
}
} else {
n.getType());
}
}
/**
* The index method starts a thread that will
* start indexing part of the opengrok agent.
* @param waitForFinished if false the command returns immediately, if true
* it will return when the indexing is done.
*/
/*
* Synchronize here to make sure that you never get more than one
* indexing thread trying to start at the same time.
*/
synchronized (this) {
if (indexThread != null) {
if (indexThread.isAlive()) {
return;
}
}
indexThread = new Thread(this);
try {
indexThread.start();
if (!waitForFinished) {
return;
}
indexThread.join();
} catch (Exception e) {
+ e.getMessage());
}
return;
}
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
}
/**
* {@inheritDoc}
*/
}
}
}
private void sendNotifications() {
}
}
/**
* {@inheritDoc}
*/
public long lastIndexTimeFinished() {
return lastIndexFinish;
}
/**
* {@inheritDoc}
*/
public long lastIndexTimeStarted() {
return lastIndexStart;
}
/**
* {@inheritDoc}
*/
public long lastIndexTimeUsed() {
return lastIndexUsedTime;
}
/**
* {@inheritDoc}
*/
return lastException;
}
/**
* {@inheritDoc}
*/
{
if (notiflistener == null) {
throw new IllegalArgumentException("Must have legal NotificationListener");
}
synchronized (notifListeners) {
}
}
/**
* {@inheritDoc}
*/
throws ListenerNotFoundException
{
boolean removed = false;
synchronized (notifListeners) {
removed = true;
}
}
}
if (!removed) {
throw new ListenerNotFoundException("Didn't remove the given NotificationListener");
}
}
/**
* {@inheritDoc}
*/
{
boolean removed = false;
synchronized (notifListeners) {
removed = true;
}
}
}
if (!removed) {
throw new ListenerNotFoundException("Didn't remove the given NotificationListener");
}
}
/**
* Method that the subclass can override, but doesn't have to
* @return MBeanNotificationInfo array of notification (and types) this
* class can emitt.
*/
descr);
return info;
}
@SuppressWarnings("boxing")
try {
notifListeners.size());
sequenceNo++;
synchronized (notifListeners) {
try {
}
}
}
}
}
}
}