AgentIndexRunner.java revision 1238
/*
* 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
*/
private boolean enabled;
private long lastIndexStart = 0;
private long lastIndexFinish = 0;
private long lastIndexUsedTime = 0;
new HashSet<NotificationHolder>();
private static long sequenceNo = 0;
private static final int MAXMESSAGELENGTH = 50000;
/**
* The only constructor is private, so other classes will only get an
* instance through the static factory method getInstance().
*/
private AgentIndexRunner(boolean enabledParam) {
}
/**
* Static factory method to get an instance of AgentIndexRunner.
* @param enabledParam if true, the initial instance should be running or not
*/
@SuppressWarnings("PMD.AvoidSynchronizedAtMethodLevel")
if (indexerInstance == null) {
}
return indexerInstance;
}
return name;
}
// not used
}
public void preDeregister() {
// not used
}
public void postDeregister() {
// not used
}
public void run() {
try {
//Indexer ind = new Indexer();
if (configfile == null) {
}
log.log(Level.INFO, "Starting index, update {0} noThreads {1} subfiles {2}", new Object[]{String.valueOf(update), String.valueOf(noThreads), String.valueOf(subFiles.size())});
} else {
}
} else {
}
} catch (Exception e) {
"Exception running indexing ", 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 {
}
}
/**
* 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.
*/
public void index(boolean waitForFinished) {
/*
* 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) {
"Caught Exception while waiting for indexing to finish.", e);
}
return;
}
}
}
}
}
}
}
}
}
private void sendNotifications() {
}
}
public long lastIndexTimeFinished() {
return lastIndexFinish;
}
public long lastIndexTimeStarted() {
return lastIndexStart;
}
public long lastIndexTimeUsed() {
return lastIndexUsedTime;
}
public Exception getExceptions() {
return lastException;
}
public void addNotificationListener(NotificationListener notiflistener, NotificationFilter notfilt, Object obj) throws IllegalArgumentException {
if (notiflistener == null) {
throw new IllegalArgumentException("Must have legal NotificationListener");
}
synchronized (notifListeners) {
}
}
public void removeNotificationListener(NotificationListener notiflistener) throws ListenerNotFoundException {
boolean removed = false;
synchronized (notifListeners) {
removed = true;
}
}
}
if (!removed) {
throw new ListenerNotFoundException("Didn't remove the given NotificationListener");
}
}
public void removeNotificationListener(NotificationListener notiflistener, NotificationFilter filt, Object obj) throws ListenerNotFoundException {
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.
*/
public MBeanNotificationInfo[] getNotificationInfo() {
String[] supptypes = {NOTIFICATIONACTIONTYPE, NOTIFICATIONINFOLONGTYPE, NOTIFICATIONINFOSTRINGTYPE};
descr);
return info;
}
try {
sequenceNo++;
synchronized (notifListeners) {
try {
}
}
}
}
ex);
}
}
}