Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-07-15 20:05:38 +0000
committerrescobar2010-07-15 20:05:38 +0000
commitd5eec996d6737b06074f8779ee0195b76f3043a3 (patch)
tree21a2a70590b1b107ef7906a02325e35805b144e4 /plugins/org.eclipse.osee.framework.search.engine
parent767f4a24bea71c91b335b956a597689380395f92 (diff)
downloadorg.eclipse.osee-d5eec996d6737b06074f8779ee0195b76f3043a3.tar.gz
org.eclipse.osee-d5eec996d6737b06074f8779ee0195b76f3043a3.tar.xz
org.eclipse.osee-d5eec996d6737b06074f8779ee0195b76f3043a3.zip
Converted Sessions to use core model datastore pattern
Fixed Service Registration to use dependency tracker Fixed Servlet Registraction to user dependency tracker
Diffstat (limited to 'plugins/org.eclipse.osee.framework.search.engine')
-rw-r--r--plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngineTagger.java290
1 files changed, 145 insertions, 145 deletions
diff --git a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngineTagger.java b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngineTagger.java
index cd993129302..2de02eb3bef 100644
--- a/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngineTagger.java
+++ b/plugins/org.eclipse.osee.framework.search.engine/src/org/eclipse/osee/framework/search/engine/internal/SearchEngineTagger.java
@@ -20,7 +20,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.server.CoreServerActivator;
+import org.eclipse.osee.framework.core.server.ServerThreads;
import org.eclipse.osee.framework.database.core.DbTransaction;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.search.engine.ISearchEngineTagger;
@@ -32,148 +32,148 @@ import org.eclipse.osee.framework.search.engine.utility.SearchTagDataStore;
* @author Roberto E. Escobar
*/
public final class SearchEngineTagger implements ISearchEngineTagger {
- private static final int CACHE_LIMIT = 1000;
- private ExecutorService executor;
- private Map<Integer, FutureTask<?>> futureTasks;
- private TaggerStatistics statistics;
-
- public SearchEngineTagger() {
- this.statistics = new TaggerStatistics();
- this.futureTasks = Collections.synchronizedMap(new HashMap<Integer, FutureTask<?>>());
- this.executor = Executors.newFixedThreadPool(3, CoreServerActivator.createNewThreadFactory("tagger.worker"));
-
- Timer timer = new Timer("Start-Up Tagger");
- timer.schedule(new StartUpRunnable(this), 3000);
- }
-
- @Override
- public int deleteTags(int joinQueryId) throws Exception {
- DeleteTagsTx deleteTransaction = new DeleteTagsTx(joinQueryId);
- deleteTransaction.execute();
- return deleteTransaction.rowsDeleted();
- }
-
- @Override
- public void tagByQueueQueryId(int queryId) {
- tagByQueueQueryId(null, queryId);
- }
-
- @Override
- public void tagByQueueQueryId(ITagListener listener, int queryId) {
- TaggerRunnable runnable = new TaggerRunnable(queryId, false, CACHE_LIMIT);
- runnable.addListener(statistics);
- if (listener != null) {
- runnable.addListener(listener);
- listener.onTagQueryIdSubmit(queryId);
- }
- FutureTask<Object> futureTask = new FutureTaggingTask(runnable);
- this.futureTasks.put(queryId, futureTask);
- this.executor.submit(futureTask);
- }
-
- @Override
- public void tagByBranchId(ITagListener listener, int branchId) throws OseeCoreException {
- this.executor.submit(new BranchTaggerRunnable(this, listener, branchId, false, CACHE_LIMIT));
- }
-
- @Override
- public void tagByBranchId(int branchId) throws OseeCoreException {
- tagByBranchId(null, branchId);
- }
-
- @Override
- public void tagFromXmlStream(ITagListener listener, InputStream inputStream) throws Exception {
- InputStreamTagProcessor inputStreamTagProcessor =
- new InputStreamTagProcessor(this, listener, inputStream, false, CACHE_LIMIT);
- inputStreamTagProcessor.execute();
- }
-
- @Override
- public void tagFromXmlStream(InputStream inputStream) throws Exception {
- tagFromXmlStream(null, inputStream);
- }
-
- @Override
- public int getWorkersInQueue() {
- return futureTasks.size();
- }
-
- @Override
- public void clearStatistics() {
- this.statistics.clear();
- }
-
- @Override
- public ITaggerStatistics getStatistics() {
- try {
- return this.statistics.clone();
- } catch (CloneNotSupportedException ex) {
- return TaggerStatistics.EMPTY_STATS;
- }
- }
-
- @Override
- public int stopTaggingByQueueQueryId(int... queryId) {
- int toReturn = 0;
- for (int item : queryId) {
- FutureTask<?> task = futureTasks.get(item);
- if (task != null) {
- if (task.isDone()) {
- toReturn++;
- } else {
- if (task.cancel(true)) {
- toReturn++;
- }
- }
- }
- }
- return toReturn;
- }
-
- @Override
- public int stopAllTagging() {
- int index = 0;
- Set<Integer> list = futureTasks.keySet();
- int[] toProcess = new int[list.size()];
- for (Integer item : list) {
- toProcess[index] = item;
- index++;
- }
- return stopTaggingByQueueQueryId(toProcess);
- }
-
- private final class FutureTaggingTask extends FutureTask<Object> {
- private TaggerRunnable runnable;
-
- public FutureTaggingTask(TaggerRunnable runnable) {
- super(runnable, null);
- this.runnable = runnable;
- }
-
- @Override
- protected void done() {
- futureTasks.remove(runnable.getTagQueueQueryId());
- }
- }
-
- private final class DeleteTagsTx extends DbTransaction {
-
- private final int queryId;
- private int updated;
-
- public DeleteTagsTx(int queryId) throws OseeCoreException {
- super();
- this.queryId = queryId;
- this.updated = -1;
- }
-
- public int rowsDeleted() {
- return updated;
- }
-
- @Override
- protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
- this.updated = SearchTagDataStore.deleteTags(connection, queryId);
- }
- }
+ private static final int CACHE_LIMIT = 1000;
+ private final ExecutorService executor;
+ private final Map<Integer, FutureTask<?>> futureTasks;
+ private final TaggerStatistics statistics;
+
+ public SearchEngineTagger() {
+ this.statistics = new TaggerStatistics();
+ this.futureTasks = Collections.synchronizedMap(new HashMap<Integer, FutureTask<?>>());
+ this.executor = Executors.newFixedThreadPool(3, ServerThreads.createNewThreadFactory("tagger.worker"));
+
+ Timer timer = new Timer("Start-Up Tagger");
+ timer.schedule(new StartUpRunnable(this), 3000);
+ }
+
+ @Override
+ public int deleteTags(int joinQueryId) throws Exception {
+ DeleteTagsTx deleteTransaction = new DeleteTagsTx(joinQueryId);
+ deleteTransaction.execute();
+ return deleteTransaction.rowsDeleted();
+ }
+
+ @Override
+ public void tagByQueueQueryId(int queryId) {
+ tagByQueueQueryId(null, queryId);
+ }
+
+ @Override
+ public void tagByQueueQueryId(ITagListener listener, int queryId) {
+ TaggerRunnable runnable = new TaggerRunnable(queryId, false, CACHE_LIMIT);
+ runnable.addListener(statistics);
+ if (listener != null) {
+ runnable.addListener(listener);
+ listener.onTagQueryIdSubmit(queryId);
+ }
+ FutureTask<Object> futureTask = new FutureTaggingTask(runnable);
+ this.futureTasks.put(queryId, futureTask);
+ this.executor.submit(futureTask);
+ }
+
+ @Override
+ public void tagByBranchId(ITagListener listener, int branchId) throws OseeCoreException {
+ this.executor.submit(new BranchTaggerRunnable(this, listener, branchId, false, CACHE_LIMIT));
+ }
+
+ @Override
+ public void tagByBranchId(int branchId) throws OseeCoreException {
+ tagByBranchId(null, branchId);
+ }
+
+ @Override
+ public void tagFromXmlStream(ITagListener listener, InputStream inputStream) throws Exception {
+ InputStreamTagProcessor inputStreamTagProcessor =
+ new InputStreamTagProcessor(this, listener, inputStream, false, CACHE_LIMIT);
+ inputStreamTagProcessor.execute();
+ }
+
+ @Override
+ public void tagFromXmlStream(InputStream inputStream) throws Exception {
+ tagFromXmlStream(null, inputStream);
+ }
+
+ @Override
+ public int getWorkersInQueue() {
+ return futureTasks.size();
+ }
+
+ @Override
+ public void clearStatistics() {
+ this.statistics.clear();
+ }
+
+ @Override
+ public ITaggerStatistics getStatistics() {
+ try {
+ return this.statistics.clone();
+ } catch (CloneNotSupportedException ex) {
+ return TaggerStatistics.EMPTY_STATS;
+ }
+ }
+
+ @Override
+ public int stopTaggingByQueueQueryId(int... queryId) {
+ int toReturn = 0;
+ for (int item : queryId) {
+ FutureTask<?> task = futureTasks.get(item);
+ if (task != null) {
+ if (task.isDone()) {
+ toReturn++;
+ } else {
+ if (task.cancel(true)) {
+ toReturn++;
+ }
+ }
+ }
+ }
+ return toReturn;
+ }
+
+ @Override
+ public int stopAllTagging() {
+ int index = 0;
+ Set<Integer> list = futureTasks.keySet();
+ int[] toProcess = new int[list.size()];
+ for (Integer item : list) {
+ toProcess[index] = item;
+ index++;
+ }
+ return stopTaggingByQueueQueryId(toProcess);
+ }
+
+ private final class FutureTaggingTask extends FutureTask<Object> {
+ private final TaggerRunnable runnable;
+
+ public FutureTaggingTask(TaggerRunnable runnable) {
+ super(runnable, null);
+ this.runnable = runnable;
+ }
+
+ @Override
+ protected void done() {
+ futureTasks.remove(runnable.getTagQueueQueryId());
+ }
+ }
+
+ private final class DeleteTagsTx extends DbTransaction {
+
+ private final int queryId;
+ private int updated;
+
+ public DeleteTagsTx(int queryId) throws OseeCoreException {
+ super();
+ this.queryId = queryId;
+ this.updated = -1;
+ }
+
+ public int rowsDeleted() {
+ return updated;
+ }
+
+ @Override
+ protected void handleTxWork(OseeConnection connection) throws OseeCoreException {
+ this.updated = SearchTagDataStore.deleteTags(connection, queryId);
+ }
+ }
}

Back to the top