Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto E. Escobar2014-11-21 00:18:39 +0000
committerAngel Avila2014-11-21 00:18:39 +0000
commitfb951a7abaafdd80831632cd2d1e3784a30ef470 (patch)
tree66eb6e40f05ea3b295d1146a18163d36b6ac86b0 /plugins
parent73de4729644cf1d176259476940d4be3abf10e44 (diff)
downloadorg.eclipse.osee-fb951a7abaafdd80831632cd2d1e3784a30ef470.tar.gz
org.eclipse.osee-fb951a7abaafdd80831632cd2d1e3784a30ef470.tar.xz
org.eclipse.osee-fb951a7abaafdd80831632cd2d1e3784a30ef470.zip
refinement[ats_ATS140743]: Improve Join table cleaner
Change join table cleaner to use expiration time instead of sessions. Allow join expiration to vary based on where joins are used. Add default join expiration values to info table. Change-Id: I680a1cc4d2c1654c0ea508e60ef020c96161e4ef
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/OSGI-INF/join.cleanup.task.provider.xml10
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/task/CleanJoinTablesServerTask.java183
-rw-r--r--plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/task/SessionUtil.java47
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java25
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java5
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java4
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java52
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java2
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java6
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java53
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zipbin58958 -> 58905 bytes
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQueryTest.java19
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQueryTest.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQueryTest.java15
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQueryTest.java13
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/MockJoinAccessor.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQueryTest.java13
-rw-r--r--plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java18
-rw-r--r--plugins/org.eclipse.osee.orcs.db/OSGI-INF/orcs.sql.join.factory.xml2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/schema/SKYNET.VERSIONING.SCHEMA.xml19
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/AbstractJoinQuery.java25
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java5
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQuery.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java42
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IJoinAccessor.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/JoinCleanerCallable.java85
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/SqlJoinFactory.java94
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java5
-rw-r--r--plugins/org.eclipse.osee.x.server.p2/demo/hsql.zipbin119198 -> 119154 bytes
40 files changed, 350 insertions, 467 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.server/OSGI-INF/join.cleanup.task.provider.xml b/plugins/org.eclipse.osee.framework.core.server/OSGI-INF/join.cleanup.task.provider.xml
deleted file mode 100644
index dc37edcba7..0000000000
--- a/plugins/org.eclipse.osee.framework.core.server/OSGI-INF/join.cleanup.task.provider.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="join.cleanup.task.provider">
- <implementation class="org.eclipse.osee.framework.core.server.internal.task.CleanJoinTablesServerTask"/>
- <service>
- <provide interface="org.eclipse.osee.framework.core.server.IServerTask"/>
- </service>
- <reference bind="setLogger" cardinality="1..1" interface="org.eclipse.osee.logger.Log" name="Log" policy="static"/>
- <reference bind="setDbService" cardinality="1..1" interface="org.eclipse.osee.framework.database.IOseeDatabaseService" name="IOseeDatabaseService" policy="static"/>
- <reference bind="setSessionManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.ISessionManager" name="ISessionManager" policy="static"/>
-</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/task/CleanJoinTablesServerTask.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/task/CleanJoinTablesServerTask.java
deleted file mode 100644
index 04c87cf190..0000000000
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/task/CleanJoinTablesServerTask.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.server.internal.task;
-
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osee.framework.core.server.IServerTask;
-import org.eclipse.osee.framework.core.server.ISession;
-import org.eclipse.osee.framework.core.server.ISessionManager;
-import org.eclipse.osee.framework.core.server.SchedulingScheme;
-import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.IOseeStatement;
-import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.Pair;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.logger.Log;
-
-/**
- * @author Roberto E. Escobar
- */
-public class CleanJoinTablesServerTask implements IServerTask {
-
- private final static String DELETE_JOIN_TIME = "DELETE FROM %s WHERE insert_time < ?";
- private final static String DELETE_JOIN_CLEANUP = "DELETE FROM osee_join_cleanup WHERE query_id = ?";
- private final static String DELETE_JOIN_TABLE_SESSION = "DELETE FROM %s WHERE query_id = ?";
- private final static String SELECT_SESSION_FROM_JOIN = "SELECT * from osee_join_cleanup order by session_id";
- private final static long SIXTY_MINUTES = 60;
- private final static long THREE_HOURS = 1000 * 60 * 60 * 3;
-
- private static final String NAME = "Clean up join tables";
-
- private static final String[] TABLES = new String[] {
- "osee_join_artifact",
- "osee_join_transaction",
- "osee_join_export_import",
- "osee_tag_gamma_queue",
- "osee_join_id"};
-
- private IOseeDatabaseService dbService;
- private Log logger;
- private ISessionManager sessionManager;
- private IStatus lastStatus = Status.OK_STATUS;
- private final Map<String, Integer> deletedByTime = new ConcurrentHashMap<String, Integer>();
- private final CompositeKeyHashMap<String, String, Integer> sessionDeletes =
- new CompositeKeyHashMap<String, String, Integer>(10, true);
- private long lastRan = 0;
-
- public void setDbService(IOseeDatabaseService dbService) {
- this.dbService = dbService;
- }
-
- public void setLogger(Log logger) {
- this.logger = logger;
- }
-
- public void setSessionManager(ISessionManager sessionManager) {
- this.sessionManager = sessionManager;
- }
-
- @Override
- public String getName() {
- return NAME;
- }
-
- @Override
- public void run() {
- try {
- lastRan = System.currentTimeMillis();
- deletedByTime.clear();
- sessionDeletes.clear();
-
- Timestamp time = new Timestamp(lastRan - THREE_HOURS);
- for (String table : TABLES) {
- int rows = dbService.runPreparedUpdate(String.format(DELETE_JOIN_TIME, table), time);
- deletedByTime.put(table, rows);
- }
- deleteFromJoinCleanup();
- lastStatus = Status.OK_STATUS;
- } catch (OseeCoreException ex) {
- String message = "Error cleaning up tables";
- logger.warn(ex, message);
- lastStatus = new Status(IStatus.ERROR, CleanJoinTablesServerTask.class.getName(), message, ex);
- }
- }
-
- private void deleteFromJoinCleanup() throws OseeCoreException {
- List<Integer[]> queryIds = new ArrayList<Integer[]>();
- IOseeStatement chStmt = dbService.getStatement();
- boolean isAlive = false;
- ISessionManager manager = sessionManager;
- try {
- chStmt.runPreparedQuery(SELECT_SESSION_FROM_JOIN);
-
- String prevSessionId = "";
- while (chStmt.next()) {
- String sessionId = chStmt.getString("session_id");
- String tableName = chStmt.getString("table_name");
- Integer queryId = chStmt.getInt("query_id");
- if (!sessionId.equals(prevSessionId)) {
- ISession sessionById = manager.getSessionById(sessionId);
- isAlive = sessionById != null && SessionUtil.isAlive(sessionById);
- }
- if (!isAlive) {
- queryIds.add(new Integer[] {queryId});
- int rows = dbService.runPreparedUpdate(String.format(DELETE_JOIN_TABLE_SESSION, tableName), queryId);
- sessionDeletes.put(sessionId, tableName, rows);
- }
- prevSessionId = sessionId;
- }
- dbService.runBatchUpdate(DELETE_JOIN_CLEANUP, queryIds);
- } finally {
- chStmt.close();
- }
- }
-
- @Override
- public long getInitialDelay() {
- return getPeriod();
- }
-
- @Override
- public long getPeriod() {
- return SIXTY_MINUTES;
- }
-
- @Override
- public SchedulingScheme getSchedulingScheme() {
- return SchedulingScheme.FIXED_RATE;
- }
-
- @Override
- public TimeUnit getTimeUnit() {
- return TimeUnit.MINUTES;
- }
-
- @Override
- public IStatus getLastStatus() {
- IStatus toReturn = lastStatus;
- if (toReturn.isOK()) {
- String message = buildMessage();
- toReturn = new Status(IStatus.OK, CleanJoinTablesServerTask.class.getName(), message.toString());
- }
- return toReturn;
- }
-
- private String buildMessage() {
- StringBuilder message = new StringBuilder();
- message.append(String.format("[%s] - Last ran: [", getName()));
- if (lastRan != 0) {
- message.append(Lib.getElapseString(lastRan));
- message.append(" ago]\n");
- } else {
- message.append("Never]\n");
- }
- for (Entry<String, Integer> entry : deletedByTime.entrySet()) {
- message.append(String.format("Deleted [%s] from table [%s]\n", entry.getValue(), entry.getKey()));
- }
-
- for (Entry<Pair<String, String>, Integer> entry : sessionDeletes.entrySet()) {
- String sessionId = entry.getKey().getFirst();
- String tableName = entry.getKey().getSecond();
- Integer rows = entry.getValue();
- message.append(String.format("Deleted [%s] from table [%s] for sessionId [%s]\n", rows, tableName, sessionId));
- }
- return message.toString();
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/task/SessionUtil.java b/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/task/SessionUtil.java
deleted file mode 100644
index 392765eb07..0000000000
--- a/plugins/org.eclipse.osee.framework.core.server/src/org/eclipse/osee/framework/core/server/internal/task/SessionUtil.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.server.internal.task;
-
-import java.io.ByteArrayOutputStream;
-import java.net.URL;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.core.server.ISession;
-import org.eclipse.osee.framework.core.util.HttpProcessor;
-import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-
-public final class SessionUtil {
-
- private SessionUtil() {
-
- }
-
- public static boolean isAlive(ISession session) throws OseeCoreException {
- boolean wasAlive = false;
- try {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- URL url =
- new URL(String.format("http://%s:%s/osee/request?cmd=pingId", session.getClientAddress(),
- session.getClientPort()));
- AcquireResult result = HttpProcessor.acquire(url, outputStream);
- if (result.wasSuccessful()) {
- String sessionId = outputStream.toString(result.getEncoding());
- if (Strings.isValid(sessionId)) {
- wasAlive = sessionId.contains(session.getGuid());
- }
- }
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- return wasAlive;
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java
index f84b8f3e86..d317689bd4 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/AbstractJoinQuery.java
@@ -10,16 +10,13 @@
*******************************************************************************/
package org.eclipse.osee.framework.database.core;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
/**
* @author Roberto E. Escobar
@@ -35,19 +32,19 @@ public abstract class AbstractJoinQuery {
private final IJoinAccessor joinAccessor;
private final JoinItem joinItem;
+ private final Long expiresIn;
private final int queryId;
- private final Timestamp insertTime;
protected final Set<IJoinRow> entries = new HashSet<IJoinRow>();
private boolean wasStored;
private int storedSize;
- protected AbstractJoinQuery(IJoinAccessor joinAccessor, JoinItem joinItem, int queryId) {
+ protected AbstractJoinQuery(IJoinAccessor joinAccessor, JoinItem joinItem, Long expiresIn, int queryId) {
this.joinAccessor = joinAccessor;
this.joinItem = joinItem;
+ this.expiresIn = expiresIn;
this.queryId = queryId;
- this.insertTime = GlobalTime.GreenwichMeanTimestamp();
this.storedSize = -1;
this.wasStored = false;
}
@@ -64,10 +61,6 @@ public abstract class AbstractJoinQuery {
return queryId;
}
- public Timestamp getInsertTime() {
- return insertTime;
- }
-
public String getJoinTableName() {
return joinItem.getJoinTableName();
}
@@ -82,15 +75,23 @@ public abstract class AbstractJoinQuery {
for (IJoinRow joinArray : entries) {
data.add(joinArray.toArray());
}
- joinAccessor.store(connection, joinItem, getQueryId(), data);
+ joinAccessor.store(connection, joinItem, getQueryId(), data, getIssuedAt(), getExpiresIn());
this.storedSize = this.entries.size();
this.wasStored = true;
this.entries.clear();
} else {
- throw new OseeDataStoreException("Cannot store query id twice");
+ throw new OseeCoreException("Cannot store query id twice");
}
}
+ private Long getIssuedAt() {
+ return System.currentTimeMillis() / 1000L;
+ }
+
+ public Long getExpiresIn() {
+ return expiresIn;
+ }
+
public int delete(OseeConnection connection) throws OseeCoreException {
return joinAccessor.delete(connection, joinItem, getQueryId());
}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
index ee58f2dba0..e6b2ff258e 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ArtifactJoinQuery.java
@@ -35,7 +35,6 @@ public class ArtifactJoinQuery extends AbstractJoinQuery {
public Object[] toArray() {
return new Object[] {
getQueryId(),
- getInsertTime(),
artId,
branchUuid,
transactionId != null ? transactionId : SQL3DataType.INTEGER};
@@ -101,8 +100,8 @@ public class ArtifactJoinQuery extends AbstractJoinQuery {
}
}
- public ArtifactJoinQuery(IJoinAccessor joinAccessor, int queryId, int maxJoinSize) {
- super(joinAccessor, JoinItem.ARTIFACT, queryId);
+ public ArtifactJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId, int maxJoinSize) {
+ super(joinAccessor, JoinItem.ARTIFACT, expiresIn, queryId);
this.maxJoinSize = maxJoinSize;
}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java
index 62e5102052..fde4635aa7 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/CharJoinQuery.java
@@ -73,8 +73,8 @@ public final class CharJoinQuery extends AbstractJoinQuery {
}
}
- protected CharJoinQuery(IJoinAccessor joinAccessor, int queryId) {
- super(joinAccessor, JoinItem.CHAR_ID, queryId);
+ public CharJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
+ super(joinAccessor, JoinItem.CHAR_ID, expiresIn, queryId);
}
public void add(String value) {
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java
index cd72c9d88f..eb35381ab8 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/DatabaseJoinAccessor.java
@@ -24,40 +24,27 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
private static final String SELECT_QUERY_IDS = "select DISTINCT query_id from %s";
private static final String INSERT_INTO_JOIN_ARTIFACT =
- "INSERT INTO osee_join_artifact (query_id, insert_time, art_id, branch_id, transaction_id) VALUES (?, ?, ?, ?, ?)";
-
+ "INSERT INTO osee_join_artifact (query_id, art_id, branch_id, transaction_id) VALUES (?, ?, ?, ?)";
private static final String INSERT_INTO_JOIN_TRANSACTION =
- "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id, branch_id) VALUES (?, ?, ?, ?, ?)";
-
- private static final String INSERT_INTO_TAG_GAMMA_QUEUE =
- "INSERT INTO osee_tag_gamma_queue (query_id, insert_time, gamma_id) VALUES (?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_EXPORT_IMPORT =
- "INSERT INTO osee_join_export_import (query_id, insert_time, id1, id2) VALUES (?, ?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_ID =
- "INSERT INTO osee_join_id (query_id, insert_time, id) VALUES (?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_CLEANUP =
- "INSERT INTO osee_join_cleanup (query_id, table_name, session_id) VALUES (?, ?, ?)";
-
+ "INSERT INTO osee_join_transaction (query_id, gamma_id, transaction_id, branch_id) VALUES (?, ?, ?, ?)";
+
+ private static final String INSERT_INTO_JOIN_ID = "INSERT INTO osee_join_id (query_id, id) VALUES (?, ?)";
private static final String INSERT_INTO_JOIN_CHAR_ID = "INSERT INTO osee_join_char_id (query_id, id) VALUES (?, ?)";
private static final String DELETE_FROM_JOIN_ID = "DELETE FROM osee_join_id WHERE query_id = ?";
private static final String DELETE_FROM_JOIN_TRANSACTION = "DELETE FROM osee_join_transaction WHERE query_id = ?";
private static final String DELETE_FROM_JOIN_ARTIFACT = "DELETE FROM osee_join_artifact WHERE query_id = ?";
- private static final String DELETE_FROM_TAG_GAMMA_QUEUE = "DELETE FROM osee_tag_gamma_queue WHERE query_id = ?";
- private static final String DELETE_FROM_JOIN_EXPORT_IMPORT = "DELETE FROM osee_join_export_import WHERE query_id =?";
- private static final String DELETE_FROM_JOIN = "DELETE FROM osee_join_cleanup WHERE query_id =?";
private static final String DELETE_FROM_JOIN_CHAR_ID = "DELETE FROM osee_join_char_id WHERE query_id =?";
+ private static final String INSERT_INTO_JOIN_CLEANUP =
+ "INSERT INTO osee_join_cleanup (query_id, table_name, issued_at, expires_in) VALUES (?,?,?,?)";
+
+ private static final String DELETE_FROM_JOIN_CLEANUP = "DELETE FROM osee_join_cleanup WHERE query_id =?";
+
public enum JoinItem {
TRANSACTION("osee_join_transaction", INSERT_INTO_JOIN_TRANSACTION, DELETE_FROM_JOIN_TRANSACTION),
ARTIFACT("osee_join_artifact", INSERT_INTO_JOIN_ARTIFACT, DELETE_FROM_JOIN_ARTIFACT),
- TAG_GAMMA_QUEUE("osee_tag_gamma_queue", INSERT_INTO_TAG_GAMMA_QUEUE, DELETE_FROM_TAG_GAMMA_QUEUE),
- EXPORT_IMPORT("osee_join_export_import", INSERT_INTO_JOIN_EXPORT_IMPORT, DELETE_FROM_JOIN_EXPORT_IMPORT),
ID("osee_join_id", INSERT_INTO_JOIN_ID, DELETE_FROM_JOIN_ID),
- JOIN("osee_join_cleanup", INSERT_INTO_JOIN_CLEANUP, DELETE_FROM_JOIN),
CHAR_ID("osee_join_char_id", INSERT_INTO_JOIN_CHAR_ID, DELETE_FROM_JOIN_CHAR_ID);
private final String tableName;
@@ -84,16 +71,10 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
}
private final IOseeDatabaseService databaseService;
- private final String sessionId;
- public DatabaseJoinAccessor(IOseeDatabaseService databaseService, String sessionId) {
+ public DatabaseJoinAccessor(IOseeDatabaseService databaseService) {
super();
this.databaseService = databaseService;
- this.sessionId = sessionId;
- }
-
- public DatabaseJoinAccessor(IOseeDatabaseService databaseService) {
- this(databaseService, null);
}
@Override
@@ -101,21 +82,17 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
int updated = 0;
if (queryId != -1) {
updated = databaseService.runPreparedUpdate(connection, joinItem.getDeleteSql(), queryId);
- if (sessionId != null) {
- databaseService.runPreparedUpdate(connection, DELETE_FROM_JOIN, queryId);
- }
+ databaseService.runPreparedUpdate(connection, DELETE_FROM_JOIN_CLEANUP, queryId);
}
return updated;
}
@SuppressWarnings("unchecked")
@Override
- public void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList) throws OseeCoreException {
+ public void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList, Long issuedAt, Long expiresIn) throws OseeCoreException {
+ databaseService.runPreparedUpdate(connection, INSERT_INTO_JOIN_CLEANUP, queryId, joinItem.getJoinTableName(),
+ issuedAt, expiresIn);
databaseService.runBatchUpdate(connection, joinItem.getInsertSql(), dataList);
- if (sessionId != null) {
- databaseService.runPreparedUpdate(connection, INSERT_INTO_JOIN_CLEANUP, queryId, joinItem.getJoinTableName(),
- sessionId);
- }
}
@Override
@@ -133,5 +110,4 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
}
return queryIds;
}
-
}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java
index 0b506f4ecb..21a98e2931 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IJoinAccessor.java
@@ -20,7 +20,7 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
*/
public interface IJoinAccessor {
- void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList) throws OseeCoreException;
+ void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList, Long issuedAt, Long expiresIn) throws OseeCoreException;
int delete(OseeConnection connection, JoinItem joinItem, int queryId) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java
index 97383d0c55..c2a8c736bb 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/IdJoinQuery.java
@@ -26,7 +26,7 @@ public class IdJoinQuery extends AbstractJoinQuery {
@Override
public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), id};
+ return new Object[] {getQueryId(), id};
}
@Override
@@ -52,8 +52,8 @@ public class IdJoinQuery extends AbstractJoinQuery {
}
}
- protected IdJoinQuery(IJoinAccessor joinAccessor, int queryId) {
- super(joinAccessor, JoinItem.ID, queryId);
+ public IdJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
+ super(joinAccessor, JoinItem.ID, expiresIn, queryId);
}
public void add(Number id) {
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
index 13bd80a78a..435d268dbe 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/JoinUtility.java
@@ -21,6 +21,13 @@ import org.eclipse.osee.framework.jdk.core.util.Strings;
*/
public class JoinUtility {
+ private static final Long DEFAULT_JOIN_EXPIRATION_SECONDS = 3L * 60L * 60L; // 3 hours
+
+ private static final String EXPIRATION_SECS__ARTIFACT_JOIN_QUERY = "artifact.join.expiration.secs";
+ private static final String EXPIRATION_SECS__CHAR_JOIN_QUERY = "char.join.expiration.secs";
+ private static final String EXPIRATION_SECS__ID_JOIN_QUERY = "id.join.expiration.secs";
+ private static final String EXPIRATION_SECS__TX_JOIN_QUERY = "tx.join.expiration.secs";
+
private static final Random random = new Random();
private JoinUtility() {
@@ -36,19 +43,40 @@ public class JoinUtility {
}
public static CharJoinQuery createCharJoinQuery(IOseeDatabaseService service) {
- return new CharJoinQuery(createAccessor(service), getNewQueryId());
+ return createCharJoinQuery(service, null);
+ }
+
+ public static CharJoinQuery createCharJoinQuery(IOseeDatabaseService service, Long expiresIn) {
+ Long actualExpiration = getExpiresIn(service, expiresIn, EXPIRATION_SECS__CHAR_JOIN_QUERY);
+ return new CharJoinQuery(createAccessor(service), actualExpiration, getNewQueryId());
}
- public static IdJoinQuery createIdJoinQuery(IOseeDatabaseService service) throws OseeDataStoreException {
- return new IdJoinQuery(createAccessor(service), getNewQueryId());
+ public static IdJoinQuery createIdJoinQuery(IOseeDatabaseService service) {
+ return createIdJoinQuery(service, null);
+ }
+
+ public static IdJoinQuery createIdJoinQuery(IOseeDatabaseService service, Long expiresIn) {
+ Long actualExpiration = getExpiresIn(service, expiresIn, EXPIRATION_SECS__ID_JOIN_QUERY);
+ return new IdJoinQuery(createAccessor(service), actualExpiration, getNewQueryId());
}
public static ArtifactJoinQuery createArtifactJoinQuery(IOseeDatabaseService service) {
- return new ArtifactJoinQuery(createAccessor(service), getNewQueryId(), getMaxArtifactJoinSize(service));
+ return createArtifactJoinQuery(service, null);
+ }
+
+ public static ArtifactJoinQuery createArtifactJoinQuery(IOseeDatabaseService service, Long expiresIn) {
+ Long actualExpiration = getExpiresIn(service, expiresIn, EXPIRATION_SECS__ARTIFACT_JOIN_QUERY);
+ return new ArtifactJoinQuery(createAccessor(service), actualExpiration, getNewQueryId(),
+ getMaxArtifactJoinSize(service));
}
public static TransactionJoinQuery createTransactionJoinQuery(IOseeDatabaseService service) {
- return new TransactionJoinQuery(createAccessor(service), getNewQueryId());
+ return createTransactionJoinQuery(service, null);
+ }
+
+ public static TransactionJoinQuery createTransactionJoinQuery(IOseeDatabaseService service, Long expiresIn) {
+ Long actualExpiration = getExpiresIn(service, expiresIn, EXPIRATION_SECS__TX_JOIN_QUERY);
+ return new TransactionJoinQuery(createAccessor(service), actualExpiration, getNewQueryId());
}
////////////////// Static Legacy Calls /////////////////////////
@@ -57,7 +85,7 @@ public class JoinUtility {
}
public static IdJoinQuery createIdJoinQuery() throws OseeDataStoreException {
- return new IdJoinQuery(createAccessor(getDatabase()), getNewQueryId());
+ return createIdJoinQuery(getDatabase());
}
public static ArtifactJoinQuery createArtifactJoinQuery() {
@@ -78,4 +106,17 @@ public class JoinUtility {
}
return toReturn;
}
+
+ private static Long getExpiresIn(IOseeDatabaseService service, Long actual, String defaultKey) {
+ Long toReturn = DEFAULT_JOIN_EXPIRATION_SECONDS;
+ if (actual != null) {
+ toReturn = actual;
+ } else {
+ String expiration = OseeInfo.getCachedValue(service, defaultKey);
+ if (Strings.isNumeric(expiration)) {
+ toReturn = Long.parseLong(expiration);
+ }
+ }
+ return toReturn;
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java
index 05ffe37602..d0a2d46a93 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/TransactionJoinQuery.java
@@ -32,7 +32,6 @@ public final class TransactionJoinQuery extends AbstractJoinQuery {
public Object[] toArray() {
return new Object[] {
getQueryId(),
- getInsertTime(),
gammaId,
transactionId,
branchUuid != null ? branchUuid : SQL3DataType.BIGINT};
@@ -98,8 +97,8 @@ public final class TransactionJoinQuery extends AbstractJoinQuery {
}
}
- protected TransactionJoinQuery(IJoinAccessor joinAccessor, int queryId) {
- super(joinAccessor, JoinItem.TRANSACTION, queryId);
+ protected TransactionJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
+ super(joinAccessor, JoinItem.TRANSACTION, expiresIn, queryId);
}
public void add(Long gammaId, Integer transactionId) {
diff --git a/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip b/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip
index 2e495a2231..4fa6bfb026 100644
--- a/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip
+++ b/plugins/org.eclipse.osee.orcs.db.mock/data/hsql.zip
Binary files differ
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java
index 99d454962a..ea16098df7 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/loader/DataLoaderFactoryImplTest.java
@@ -59,7 +59,6 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Matchers;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -125,16 +124,16 @@ public class DataLoaderFactoryImplTest {
@Override
public ArtifactJoinQuery answer(InvocationOnMock invocation) throws Throwable {
- return new ArtifactJoinQuery(joinAccessor, 23, Integer.MAX_VALUE);
+ return new ArtifactJoinQuery(joinAccessor, -1L, 23, Integer.MAX_VALUE);
}
});
- when(joinFactory.createIdJoinQuery(Mockito.anyString())).thenAnswer(new Answer<IdJoinQuery>() {
+ when(joinFactory.createIdJoinQuery()).thenAnswer(new Answer<IdJoinQuery>() {
@Override
public IdJoinQuery answer(InvocationOnMock invocation) throws Throwable {
- return new IdJoinQuery(joinAccessor, 23);
+ return new IdJoinQuery(joinAccessor, -1L, 23);
}
});
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java
index d527dd52d2..181e6d3e62 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/ArtifactQuerySqlContextFactoryImplTest.java
@@ -14,7 +14,6 @@ import static java.util.Arrays.asList;
import static org.eclipse.osee.orcs.db.internal.search.handlers.SqlHandlerFactoryUtil.createArtifactSqlHandlerFactory;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
@@ -162,19 +161,19 @@ public class ArtifactQuerySqlContextFactoryImplTest {
}
}).when(tagProcessor).collectFromString(eq(QUICK_SEARCH_VALUE), any(TagCollector.class));
- when(joinFactory.createIdJoinQuery(anyString())).thenAnswer(new Answer<IdJoinQuery>() {
+ when(joinFactory.createIdJoinQuery()).thenAnswer(new Answer<IdJoinQuery>() {
@Override
public IdJoinQuery answer(InvocationOnMock invocation) throws Throwable {
- return new IdJoinQuery(null, 23);
+ return new IdJoinQuery(null, -1L, 23);
}
});
- when(joinFactory.createCharJoinQuery(anyString())).thenAnswer(new Answer<CharJoinQuery>() {
+ when(joinFactory.createCharJoinQuery()).thenAnswer(new Answer<CharJoinQuery>() {
@Override
public CharJoinQuery answer(InvocationOnMock invocation) throws Throwable {
- return new CharJoinQuery(null, 23);
+ return new CharJoinQuery(null, -1L, 23);
}
});
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java
index cf65a371c6..8fe775f682 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/BranchQuerySqlContextFactoryImplTest.java
@@ -18,7 +18,6 @@ import static org.eclipse.osee.framework.core.enums.BranchType.SYSTEM_ROOT;
import static org.eclipse.osee.framework.core.enums.BranchType.WORKING;
import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.Iterator;
@@ -102,11 +101,11 @@ public class BranchQuerySqlContextFactoryImplTest {
queryData = new QueryData(criteriaSet, options);
when(sqlProvider.getSql(OseeSql.QUERY_BUILDER)).thenReturn("/*+ ordered */");
- when(joinFactory.createIdJoinQuery(anyString())).thenAnswer(new Answer<IdJoinQuery>() {
+ when(joinFactory.createIdJoinQuery()).thenAnswer(new Answer<IdJoinQuery>() {
@Override
public IdJoinQuery answer(InvocationOnMock invocation) throws Throwable {
- return new IdJoinQuery(null, 23);
+ return new IdJoinQuery(null, -1L, 23);
}
});
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java
index dd48226dd0..2afacbb048 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/search/engines/TxQuerySqlContextFactoryImplTest.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.orcs.db.internal.search.engines;
import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;
import java.sql.Timestamp;
import java.util.Arrays;
@@ -99,11 +98,11 @@ public class TxQuerySqlContextFactoryImplTest {
queryData = new QueryData(criteriaSet, options);
when(sqlProvider.getSql(OseeSql.QUERY_BUILDER)).thenReturn("/*+ ordered */");
- when(joinFactory.createIdJoinQuery(anyString())).thenAnswer(new Answer<IdJoinQuery>() {
+ when(joinFactory.createIdJoinQuery()).thenAnswer(new Answer<IdJoinQuery>() {
@Override
public IdJoinQuery answer(InvocationOnMock invocation) throws Throwable {
- return new IdJoinQuery(null, 23);
+ return new IdJoinQuery(null, -1L, 23);
}
});
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQueryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQueryTest.java
index 70063bd5f5..49d27790d2 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQueryTest.java
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.sql.join;
-import java.sql.Timestamp;
import java.util.List;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.junit.Assert;
import org.junit.Test;
@@ -27,7 +25,7 @@ public class ArtifactJoinQueryTest {
@Test
public void testAdd() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, 999, 10);
+ ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, -1L, 999, 10);
Assert.assertEquals(0, join.size());
Assert.assertEquals(true, join.isEmpty());
@@ -49,18 +47,17 @@ public class ArtifactJoinQueryTest {
Assert.assertEquals(1, data.size());
Object[] entry = data.get(0);
- Assert.assertEquals(5, entry.length);
+ Assert.assertEquals(4, entry.length);
Assert.assertEquals(999, entry[0]);
- Assert.assertTrue(entry[1] instanceof Timestamp);
- Assert.assertEquals(1234, entry[2]);
- Assert.assertEquals(5678L, entry[3]);
+ Assert.assertEquals(1234, entry[1]);
+ Assert.assertEquals(5678L, entry[2]);
}
- @Test(expected = OseeDataStoreException.class)
+ @Test(expected = OseeCoreException.class)
public void testStoreTwice() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, 1000, 10);
+ ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, -1L, 1000, 10);
Assert.assertEquals(false, join.wasStored());
join.store();
@@ -72,11 +69,11 @@ public class ArtifactJoinQueryTest {
join.store();
}
- @Test(expected = OseeDataStoreException.class)
+ @Test(expected = OseeCoreException.class)
public void testMoreThanAllowed() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
int maxSize = 5;
- ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, 1000, maxSize);
+ ArtifactJoinQuery join = new ArtifactJoinQuery(joinAccessor, -1L, 1000, maxSize);
for (int i = 0; i < maxSize + 1; i++) {
join.add(i + 1, 1123L, null);
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQueryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQueryTest.java
index 64677a18e2..2a295d229a 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQueryTest.java
@@ -11,7 +11,6 @@
package org.eclipse.osee.orcs.db.internal.sql.join;
import java.util.List;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.junit.Assert;
import org.junit.Test;
@@ -26,7 +25,7 @@ public class CharJoinQueryTest {
@Test
public void testAdd() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- CharJoinQuery join = new CharJoinQuery(joinAccessor, 999);
+ CharJoinQuery join = new CharJoinQuery(joinAccessor, -1L, 999);
Assert.assertEquals(0, join.size());
Assert.assertEquals(true, join.isEmpty());
@@ -53,10 +52,10 @@ public class CharJoinQueryTest {
Assert.assertEquals("hello", entry[1]);
}
- @Test(expected = OseeDataStoreException.class)
+ @Test(expected = OseeCoreException.class)
public void testStoreTwice() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- CharJoinQuery join = new CharJoinQuery(joinAccessor, 1000);
+ CharJoinQuery join = new CharJoinQuery(joinAccessor, -1L, 1000);
Assert.assertEquals(false, join.wasStored());
join.store();
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQueryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQueryTest.java
index 540bdec52a..8308b21613 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQueryTest.java
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.sql.join;
-import java.sql.Timestamp;
import java.util.List;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.junit.Assert;
import org.junit.Test;
@@ -27,7 +25,7 @@ public class ExportImportJoinQueryTest {
@Test
public void testAdd() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- ExportImportJoinQuery join = new ExportImportJoinQuery(joinAccessor, 999);
+ ExportImportJoinQuery join = new ExportImportJoinQuery(joinAccessor, -1L, 999);
Assert.assertEquals(0, join.size());
Assert.assertEquals(true, join.isEmpty());
@@ -49,18 +47,17 @@ public class ExportImportJoinQueryTest {
Assert.assertEquals(1, data.size());
Object[] entry = data.get(0);
- Assert.assertEquals(4, entry.length);
+ Assert.assertEquals(3, entry.length);
Assert.assertEquals(999, entry[0]);
- Assert.assertTrue(entry[1] instanceof Timestamp);
- Assert.assertEquals(1234L, entry[2]);
- Assert.assertEquals(5678L, entry[3]);
+ Assert.assertEquals(1234L, entry[1]);
+ Assert.assertEquals(5678L, entry[2]);
}
- @Test(expected = OseeDataStoreException.class)
+ @Test(expected = OseeCoreException.class)
public void testStoreTwice() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- ExportImportJoinQuery join = new ExportImportJoinQuery(joinAccessor, 1000);
+ ExportImportJoinQuery join = new ExportImportJoinQuery(joinAccessor, -1L, 1000);
Assert.assertEquals(false, join.wasStored());
join.store();
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQueryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQueryTest.java
index 52453c6b7b..3b9ff651f0 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQueryTest.java
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.sql.join;
-import java.sql.Timestamp;
import java.util.List;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.junit.Assert;
import org.junit.Test;
@@ -27,7 +25,7 @@ public class IdJoinQueryTest {
@Test
public void testAdd() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- IdJoinQuery join = new IdJoinQuery(joinAccessor, 999);
+ IdJoinQuery join = new IdJoinQuery(joinAccessor, -1L, 999);
Assert.assertEquals(0, join.size());
Assert.assertEquals(true, join.isEmpty());
@@ -49,17 +47,16 @@ public class IdJoinQueryTest {
Assert.assertEquals(1, data.size());
Object[] entry = data.get(0);
- Assert.assertEquals(3, entry.length);
+ Assert.assertEquals(2, entry.length);
Assert.assertEquals(999, entry[0]);
- Assert.assertTrue(entry[1] instanceof Timestamp);
- Assert.assertEquals(1234L, entry[2]);
+ Assert.assertEquals(1234L, entry[1]);
}
- @Test(expected = OseeDataStoreException.class)
+ @Test(expected = OseeCoreException.class)
public void testStoreTwice() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- IdJoinQuery join = new IdJoinQuery(joinAccessor, 1000);
+ IdJoinQuery join = new IdJoinQuery(joinAccessor, -1L, 1000);
Assert.assertEquals(false, join.wasStored());
join.store();
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/MockJoinAccessor.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/MockJoinAccessor.java
index 94bc6c1f40..597748a98c 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/MockJoinAccessor.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/MockJoinAccessor.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.orcs.db.internal.sql.join;
import java.util.Collection;
import java.util.List;
import org.eclipse.osee.framework.database.core.OseeConnection;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem;
/**
@@ -26,7 +27,7 @@ public class MockJoinAccessor implements IJoinAccessor {
private List<Object[]> dataList;
@Override
- public void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList) {
+ public void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList, Long issuedAt, Long expiresIn) throws OseeCoreException {
this.connection = connection;
this.joinItem = joinItem;
this.queryId = queryId;
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQueryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQueryTest.java
index f0bdb8b636..7fdefd4021 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQueryTest.java
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.sql.join;
-import java.sql.Timestamp;
import java.util.List;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.junit.Assert;
import org.junit.Test;
@@ -27,7 +25,7 @@ public class TagQueueJoinQueryTest {
@Test
public void testAdd() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- TagQueueJoinQuery join = new TagQueueJoinQuery(joinAccessor, 999);
+ TagQueueJoinQuery join = new TagQueueJoinQuery(joinAccessor, -1L, 999);
Assert.assertEquals(0, join.size());
Assert.assertEquals(true, join.isEmpty());
@@ -49,17 +47,16 @@ public class TagQueueJoinQueryTest {
Assert.assertEquals(1, data.size());
Object[] entry = data.get(0);
- Assert.assertEquals(3, entry.length);
+ Assert.assertEquals(2, entry.length);
Assert.assertEquals(999, entry[0]);
- Assert.assertTrue(entry[1] instanceof Timestamp);
- Assert.assertEquals(1234L, entry[2]);
+ Assert.assertEquals(1234L, entry[1]);
}
- @Test(expected = OseeDataStoreException.class)
+ @Test(expected = OseeCoreException.class)
public void testStoreTwice() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- TagQueueJoinQuery join = new TagQueueJoinQuery(joinAccessor, 1000);
+ TagQueueJoinQuery join = new TagQueueJoinQuery(joinAccessor, -1L, 1000);
Assert.assertEquals(false, join.wasStored());
join.store();
diff --git a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java
index 542e37564c..73fc0c4ccf 100644
--- a/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java
+++ b/plugins/org.eclipse.osee.orcs.db.test/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQueryTest.java
@@ -10,9 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.sql.join;
-import java.sql.Timestamp;
import java.util.List;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.database.core.SQL3DataType;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.junit.Assert;
@@ -28,7 +26,7 @@ public class TransactionJoinQueryTest {
@Test
public void testAdd() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- TransactionJoinQuery join = new TransactionJoinQuery(joinAccessor, 999);
+ TransactionJoinQuery join = new TransactionJoinQuery(joinAccessor, -1L, 999);
Assert.assertEquals(0, join.size());
Assert.assertEquals(true, join.isEmpty());
@@ -50,19 +48,17 @@ public class TransactionJoinQueryTest {
Assert.assertEquals(1, data.size());
Object[] entry = data.get(0);
- Assert.assertEquals(5, entry.length);
+ Assert.assertEquals(4, entry.length);
Assert.assertEquals(999, entry[0]);
- Assert.assertTrue(entry[1] instanceof Timestamp);
- Assert.assertEquals(1234L, entry[2]);
- Assert.assertEquals(5678, entry[3]);
- Assert.assertEquals(SQL3DataType.BIGINT, entry[4]);
-
+ Assert.assertEquals(1234L, entry[1]);
+ Assert.assertEquals(5678, entry[2]);
+ Assert.assertEquals(SQL3DataType.BIGINT, entry[3]);
}
- @Test(expected = OseeDataStoreException.class)
+ @Test(expected = OseeCoreException.class)
public void testStoreTwice() throws OseeCoreException {
MockJoinAccessor joinAccessor = new MockJoinAccessor();
- TransactionJoinQuery join = new TransactionJoinQuery(joinAccessor, 1000);
+ TransactionJoinQuery join = new TransactionJoinQuery(joinAccessor, -1L, 1000);
Assert.assertEquals(false, join.wasStored());
join.store();
diff --git a/plugins/org.eclipse.osee.orcs.db/OSGI-INF/orcs.sql.join.factory.xml b/plugins/org.eclipse.osee.orcs.db/OSGI-INF/orcs.sql.join.factory.xml
index 2b3a002332..ce46779b9b 100644
--- a/plugins/org.eclipse.osee.orcs.db/OSGI-INF/orcs.sql.join.factory.xml
+++ b/plugins/org.eclipse.osee.orcs.db/OSGI-INF/orcs.sql.join.factory.xml
@@ -4,6 +4,8 @@
<service>
<provide interface="org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory"/>
</service>
+ <reference bind="setLogger" cardinality="1..1" interface="org.eclipse.osee.logger.Log" name="Log" policy="static"/>
<reference bind="setDatabaseService" cardinality="1..1" interface="org.eclipse.osee.framework.database.IOseeDatabaseService" name="IOseeDatabaseService" policy="static"/>
<reference bind="setSystemPreferences" cardinality="1..1" interface="org.eclipse.osee.orcs.core.SystemPreferences" name="SystemPreferences" policy="static"/>
+ <reference bind="setExecutorAdmin" cardinality="1..1" interface="org.eclipse.osee.executor.admin.ExecutorAdmin" name="ExecutorAdmin" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.orcs.db/schema/SKYNET.VERSIONING.SCHEMA.xml b/plugins/org.eclipse.osee.orcs.db/schema/SKYNET.VERSIONING.SCHEMA.xml
index 20b129a9d6..6af2b09a2b 100644
--- a/plugins/org.eclipse.osee.orcs.db/schema/SKYNET.VERSIONING.SCHEMA.xml
+++ b/plugins/org.eclipse.osee.orcs.db/schema/SKYNET.VERSIONING.SCHEMA.xml
@@ -284,7 +284,6 @@
<Table name="OSEE_TAG_GAMMA_QUEUE" schema="OSEE" tablespace="osee_data">
<Column id="QUERY_ID" defaultValue="not null" type="INTEGER" />
<Column id="GAMMA_ID" defaultValue="not null" type="BIGINT" />
- <Column id="INSERT_TIME" defaultValue="not null" type="TIMESTAMP" />
<Constraint schema="OSEE" id="OSEE_JOIN_GAMMA_Q_G_PK" type="PRIMARY KEY" appliesTo="QUERY_ID, GAMMA_ID" />
</Table>
@@ -292,7 +291,6 @@
<Note purpose="Core table describing ?"/>
<Column id="QUERY_ID" description="randomly generated identifier for this short-lived join" />
<Column id="GAMMA_ID" description="" />
- <Column id="INSERT_TIME" description="" />
</TableDescription>
<!-- __________________________________________________________ -->
@@ -384,7 +382,6 @@
<Column id="QUERY_ID" defaultValue="not null" type="INTEGER" />
<Column id="ID1" defaultValue="not null" type="BIGINT" />
<Column id="ID2" defaultValue="not null" type="BIGINT" />
- <Column id="INSERT_TIME" defaultValue="not null" type="TIMESTAMP" />
<Index id="OSEE_JOIN_EXPORT_IMPORT_Q_IDX" tablespace="osee_index">
<AppliesTo id="QUERY_ID"/>
</Index>
@@ -501,7 +498,6 @@
<Column id="ART_ID" defaultValue="not null" type="INTEGER" />
<Column id="BRANCH_ID" defaultValue="not null" type="BIGINT" />
<Column id="TRANSACTION_ID" type="INTEGER" />
- <Column id="INSERT_TIME" defaultValue="not null" type="TIMESTAMP" />
<Index id="OSEE_JOIN_ART__Q_A_IDX" tablespace="osee_index">
<AppliesTo id="QUERY_ID"/>
<AppliesTo id="ART_ID"/>
@@ -514,13 +510,11 @@
<Column id="ART_ID" description="application specific INTEGER identifier" />
<Column id="BRANCH_ID" description="application specific INTEGER identifier" />
<Column id="TRANSACTION_ID" description="application specific INTEGER identifier" />
- <Column id="INSERT_TIME" description="time this join query was started" />
</TableDescription>
<Table name="OSEE_JOIN_ID" schema="OSEE" tablespace="osee_data">
<Column id="QUERY_ID" defaultValue="not null" type="INTEGER" />
<Column id="ID" type="BIGINT" />
- <Column id="INSERT_TIME" type="TIMESTAMP" />
<Index id="OSEE_JOIN_ID__Q_I_IDX" type="UNIQUE" tablespace="osee_index">
<AppliesTo id="QUERY_ID"/>
<AppliesTo id="ID"/>
@@ -531,16 +525,14 @@
<Note purpose="Temporary working table to improve performance of joins"/>
<Column id="QUERY_ID" description="randomly generated identifier for this short-lived join"/>
<Column id="ID" description="application specific NUMBER identifier"/>
- <Column id="INSERT_TIME" description="time this join query was started"/>
</TableDescription>
<Table name="OSEE_JOIN_CLEANUP" schema="OSEE" tablespace="osee_data">
- <Column id="QUERY_ID" defaultValue="not null" type="INTEGER" />
- <Column id="SESSION_ID" defaultValue="not null" type="VARCHAR" limits="28" />
+ <Column id="QUERY_ID" defaultValue="not null" type="INTEGER" />
<Column id="TABLE_NAME" defaultValue="not null" type="VARCHAR" limits="28"/>
- <Index id="OSEE_JOIN_CLEANUP__Q_IDX" type="UNIQUE" tablespace="osee_index">
- <AppliesTo id="QUERY_ID"/>
- </Index>
+ <Column id="ISSUED_AT" defaultValue="not null" type="BIGINT" />
+ <Column id="EXPIRES_IN" defaultValue="not null" type="BIGINT" />
+ <Constraint schema="OSEE" id="OSEE_JOIN_CLEANUP__PK" type="PRIMARY KEY" appliesTo="QUERY_ID" />
</Table>
<TableDescription referenceTable="OSEE_JOIN_CLEANUP">
@@ -548,7 +540,6 @@
This cleanup is only needed if the application/server fails to do the expected delete
based on the corresponding query id. Cleanup is performed when the corresponding session has been closed."/>
<Column id="QUERY_ID" description="randomly generated identifier for this short-lived join"/>
- <Column id="SESSION_ID" description="unique identifier of the session that issued the query"/>
<Column id="TABLE_NAME" description="name of the join table that stores the join with this query_id"/>
</TableDescription>
@@ -571,7 +562,6 @@
<Column id="QUERY_ID" defaultValue="not null" type="INTEGER" />
<Column id="TRANSACTION_ID" defaultValue="not null" type="INTEGER" />
<Column id="GAMMA_ID" defaultValue="not null" type="BIGINT" />
- <Column id="INSERT_TIME" defaultValue="not null" type="TIMESTAMP" />
<Column id="BRANCH_ID" type="BIGINT" />
<Index id="OSEE_JOIN_TRANSACTION_Q_IDX" tablespace="osee_index">
<AppliesTo id="QUERY_ID"/>
@@ -583,6 +573,5 @@
<Column id="QUERY_ID" description="randomly generated identifier for this short-lived join"/>
<Column id="TRANSACTION_ID" description="application specific INTEGER identifier"/>
<Column id="GAMMA_ID" description="application specific INTEGER identifier"/>
- <Column id="INSERT_TIME" description="time this join query was started"/>
</TableDescription>
</TableConfig>
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java
index 05e559be23..84b5ecbf0d 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/executors/UuidsLoadExecutor.java
@@ -65,7 +65,7 @@ public class UuidsLoadExecutor extends AbstractLoadExecutor {
ArtifactJoinQuery toReturn = joinFactory.createArtifactJoinQuery();
- CharJoinQuery guidJoin = joinFactory.createCharJoinQuery(session.getGuid());
+ CharJoinQuery guidJoin = joinFactory.createCharJoinQuery();
try {
for (String id : artifactIds) {
guidJoin.add(id);
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java
index 3ab620670b..e2d0e169e5 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/search/indexer/callable/consumer/IndexingTaskDatabaseTxCallable.java
@@ -21,7 +21,6 @@ import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
-import org.eclipse.osee.framework.database.core.DatabaseJoinAccessor.JoinItem;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.logger.Log;
@@ -34,6 +33,7 @@ import org.eclipse.osee.orcs.db.internal.search.indexer.IndexedResourceLoader;
import org.eclipse.osee.orcs.db.internal.search.tagger.TagCollector;
import org.eclipse.osee.orcs.db.internal.search.tagger.Tagger;
import org.eclipse.osee.orcs.db.internal.search.tagger.TaggingEngine;
+import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem;
import org.eclipse.osee.orcs.search.IndexerCollector;
/**
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java
index 678a1b05ba..74c04b6982 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/AbstractSqlWriter.java
@@ -317,7 +317,7 @@ public abstract class AbstractSqlWriter implements HasOptions {
}
public CharJoinQuery writeCharJoin(Collection<String> ids) {
- CharJoinQuery joinQuery = joinFactory.createCharJoinQuery(context.getSession().getGuid());
+ CharJoinQuery joinQuery = joinFactory.createCharJoinQuery();
for (String id : ids) {
joinQuery.add(id);
}
@@ -326,7 +326,7 @@ public abstract class AbstractSqlWriter implements HasOptions {
}
public IdJoinQuery writeIdJoin(Collection<? extends Number> ids) {
- IdJoinQuery joinQuery = joinFactory.createIdJoinQuery(context.getSession().getGuid());
+ IdJoinQuery joinQuery = joinFactory.createIdJoinQuery();
for (Number id : ids) {
joinQuery.add(id.longValue());
}
@@ -335,7 +335,7 @@ public abstract class AbstractSqlWriter implements HasOptions {
}
public IdJoinQuery writeIdentifiableJoin(Collection<? extends Identifiable<Long>> ids) {
- IdJoinQuery joinQuery = joinFactory.createIdJoinQuery(context.getSession().getGuid());
+ IdJoinQuery joinQuery = joinFactory.createIdJoinQuery();
for (Identity<Long> id : ids) {
joinQuery.add(id.getGuid());
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/AbstractJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/AbstractJoinQuery.java
index 7b0ac1a365..0a2b0662c2 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/AbstractJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/AbstractJoinQuery.java
@@ -10,16 +10,13 @@
*******************************************************************************/
package org.eclipse.osee.orcs.db.internal.sql.join;
-import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.database.core.OseeConnection;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem;
/**
@@ -36,19 +33,19 @@ public abstract class AbstractJoinQuery {
private final IJoinAccessor joinAccessor;
private final JoinItem joinItem;
+ private final Long expiresIn;
private final int queryId;
- private final Timestamp insertTime;
protected final Set<IJoinRow> entries = new HashSet<IJoinRow>();
private boolean wasStored;
private int storedSize;
- protected AbstractJoinQuery(IJoinAccessor joinAccessor, JoinItem joinItem, int queryId) {
+ protected AbstractJoinQuery(IJoinAccessor joinAccessor, JoinItem joinItem, Long expiresIn, int queryId) {
this.joinAccessor = joinAccessor;
this.joinItem = joinItem;
+ this.expiresIn = expiresIn;
this.queryId = queryId;
- this.insertTime = GlobalTime.GreenwichMeanTimestamp();
this.storedSize = -1;
this.wasStored = false;
}
@@ -65,10 +62,6 @@ public abstract class AbstractJoinQuery {
return queryId;
}
- public Timestamp getInsertTime() {
- return insertTime;
- }
-
public String getJoinTableName() {
return joinItem.getJoinTableName();
}
@@ -83,15 +76,23 @@ public abstract class AbstractJoinQuery {
for (IJoinRow joinArray : entries) {
data.add(joinArray.toArray());
}
- joinAccessor.store(connection, joinItem, getQueryId(), data);
+ joinAccessor.store(connection, joinItem, getQueryId(), data, getIssuedAt(), getExpiresIn());
this.storedSize = this.entries.size();
this.wasStored = true;
this.entries.clear();
} else {
- throw new OseeDataStoreException("Cannot store query id twice");
+ throw new OseeCoreException("Cannot store query id twice");
}
}
+ private Long getIssuedAt() {
+ return System.currentTimeMillis() / 1000L;
+ }
+
+ public Long getExpiresIn() {
+ return expiresIn;
+ }
+
public int delete(OseeConnection connection) throws OseeCoreException {
return joinAccessor.delete(connection, joinItem, getQueryId());
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java
index 0e7d1f3443..6a20b039ee 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ArtifactJoinQuery.java
@@ -36,7 +36,6 @@ public class ArtifactJoinQuery extends AbstractJoinQuery {
public Object[] toArray() {
return new Object[] {
getQueryId(),
- getInsertTime(),
artId,
branchUuid,
transactionId != null ? transactionId : SQL3DataType.INTEGER};
@@ -102,8 +101,8 @@ public class ArtifactJoinQuery extends AbstractJoinQuery {
}
}
- public ArtifactJoinQuery(IJoinAccessor joinAccessor, int queryId, int maxJoinSize) {
- super(joinAccessor, JoinItem.ARTIFACT, queryId);
+ public ArtifactJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId, int maxJoinSize) {
+ super(joinAccessor, JoinItem.ARTIFACT, expiresIn, queryId);
this.maxJoinSize = maxJoinSize;
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQuery.java
index df5736fc9f..7faca2b7b9 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/CharJoinQuery.java
@@ -73,8 +73,8 @@ public final class CharJoinQuery extends AbstractJoinQuery {
}
}
- public CharJoinQuery(IJoinAccessor joinAccessor, int queryId) {
- super(joinAccessor, JoinItem.CHAR_ID, queryId);
+ public CharJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
+ super(joinAccessor, JoinItem.CHAR_ID, expiresIn, queryId);
}
public void add(String value) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java
index fde6d3b60c..a4650f71d1 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/DatabaseJoinAccessor.java
@@ -26,22 +26,18 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
private static final String SELECT_QUERY_IDS = "select DISTINCT query_id from %s";
private static final String INSERT_INTO_JOIN_ARTIFACT =
- "INSERT INTO osee_join_artifact (query_id, insert_time, art_id, branch_id, transaction_id) VALUES (?, ?, ?, ?, ?)";
+ "INSERT INTO osee_join_artifact (query_id, art_id, branch_id, transaction_id) VALUES (?, ?, ?, ?)";
private static final String INSERT_INTO_JOIN_TRANSACTION =
- "INSERT INTO osee_join_transaction (query_id, insert_time, gamma_id, transaction_id, branch_id) VALUES (?, ?, ?, ?, ?)";
+ "INSERT INTO osee_join_transaction (query_id, gamma_id, transaction_id, branch_id) VALUES (?, ?, ?, ?)";
private static final String INSERT_INTO_TAG_GAMMA_QUEUE =
- "INSERT INTO osee_tag_gamma_queue (query_id, insert_time, gamma_id) VALUES (?, ?, ?)";
+ "INSERT INTO osee_tag_gamma_queue (query_id, gamma_id) VALUES (?, ?)";
private static final String INSERT_INTO_JOIN_EXPORT_IMPORT =
- "INSERT INTO osee_join_export_import (query_id, insert_time, id1, id2) VALUES (?, ?, ?, ?)";
+ "INSERT INTO osee_join_export_import (query_id, id1, id2) VALUES (?, ?, ?)";
- private static final String INSERT_INTO_JOIN_ID =
- "INSERT INTO osee_join_id (query_id, insert_time, id) VALUES (?, ?, ?)";
-
- private static final String INSERT_INTO_JOIN_CLEANUP =
- "INSERT INTO osee_join_cleanup (query_id, table_name, session_id) VALUES (?, ?, ?)";
+ private static final String INSERT_INTO_JOIN_ID = "INSERT INTO osee_join_id (query_id, id) VALUES (?, ?)";
private static final String INSERT_INTO_JOIN_CHAR_ID = "INSERT INTO osee_join_char_id (query_id, id) VALUES (?, ?)";
@@ -50,16 +46,19 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
private static final String DELETE_FROM_JOIN_ARTIFACT = "DELETE FROM osee_join_artifact WHERE query_id = ?";
private static final String DELETE_FROM_TAG_GAMMA_QUEUE = "DELETE FROM osee_tag_gamma_queue WHERE query_id = ?";
private static final String DELETE_FROM_JOIN_EXPORT_IMPORT = "DELETE FROM osee_join_export_import WHERE query_id =?";
- private static final String DELETE_FROM_JOIN = "DELETE FROM osee_join_cleanup WHERE query_id =?";
private static final String DELETE_FROM_JOIN_CHAR_ID = "DELETE FROM osee_join_char_id WHERE query_id =?";
+ private static final String INSERT_INTO_JOIN_CLEANUP =
+ "INSERT INTO osee_join_cleanup (query_id, table_name, issued_at, expires_in) VALUES (?,?,?,?)";
+
+ private static final String DELETE_FROM_JOIN_CLEANUP = "DELETE FROM osee_join_cleanup WHERE query_id =?";
+
public enum JoinItem {
TRANSACTION("osee_join_transaction", INSERT_INTO_JOIN_TRANSACTION, DELETE_FROM_JOIN_TRANSACTION),
ARTIFACT("osee_join_artifact", INSERT_INTO_JOIN_ARTIFACT, DELETE_FROM_JOIN_ARTIFACT),
TAG_GAMMA_QUEUE("osee_tag_gamma_queue", INSERT_INTO_TAG_GAMMA_QUEUE, DELETE_FROM_TAG_GAMMA_QUEUE),
EXPORT_IMPORT("osee_join_export_import", INSERT_INTO_JOIN_EXPORT_IMPORT, DELETE_FROM_JOIN_EXPORT_IMPORT),
ID("osee_join_id", INSERT_INTO_JOIN_ID, DELETE_FROM_JOIN_ID),
- JOIN("osee_join_cleanup", INSERT_INTO_JOIN_CLEANUP, DELETE_FROM_JOIN),
CHAR_ID("osee_join_char_id", INSERT_INTO_JOIN_CHAR_ID, DELETE_FROM_JOIN_CHAR_ID);
private final String tableName;
@@ -86,16 +85,10 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
}
private final IOseeDatabaseService databaseService;
- private final String sessionId;
- public DatabaseJoinAccessor(IOseeDatabaseService databaseService, String sessionId) {
+ public DatabaseJoinAccessor(IOseeDatabaseService databaseService) {
super();
this.databaseService = databaseService;
- this.sessionId = sessionId;
- }
-
- public DatabaseJoinAccessor(IOseeDatabaseService databaseService) {
- this(databaseService, null);
}
@Override
@@ -103,21 +96,17 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
int updated = 0;
if (queryId != -1) {
updated = databaseService.runPreparedUpdate(connection, joinItem.getDeleteSql(), queryId);
- if (sessionId != null) {
- databaseService.runPreparedUpdate(connection, DELETE_FROM_JOIN, queryId);
- }
+ databaseService.runPreparedUpdate(connection, DELETE_FROM_JOIN_CLEANUP, queryId);
}
return updated;
}
@SuppressWarnings("unchecked")
@Override
- public void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList) throws OseeCoreException {
+ public void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList, Long issuedAt, Long expiresIn) throws OseeCoreException {
+ databaseService.runPreparedUpdate(connection, INSERT_INTO_JOIN_CLEANUP, queryId, joinItem.getJoinTableName(),
+ issuedAt, expiresIn);
databaseService.runBatchUpdate(connection, joinItem.getInsertSql(), dataList);
- if (sessionId != null) {
- databaseService.runPreparedUpdate(connection, INSERT_INTO_JOIN_CLEANUP, queryId, joinItem.getJoinTableName(),
- sessionId);
- }
}
@Override
@@ -135,5 +124,4 @@ public class DatabaseJoinAccessor implements IJoinAccessor {
}
return queryIds;
}
-
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java
index 9b5fd24914..9c9a5d8a54 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/ExportImportJoinQuery.java
@@ -28,7 +28,7 @@ public final class ExportImportJoinQuery extends AbstractJoinQuery {
@Override
public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), id1, id2};
+ return new Object[] {getQueryId(), id1, id2};
}
@Override
@@ -83,8 +83,8 @@ public final class ExportImportJoinQuery extends AbstractJoinQuery {
}
}
- protected ExportImportJoinQuery(IJoinAccessor joinAccessor, int queryId) {
- super(joinAccessor, JoinItem.EXPORT_IMPORT, queryId);
+ protected ExportImportJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
+ super(joinAccessor, JoinItem.EXPORT_IMPORT, expiresIn, queryId);
}
public void add(Long id1, Long id2) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IJoinAccessor.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IJoinAccessor.java
index cf2f319c74..ffd4a9abbe 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IJoinAccessor.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IJoinAccessor.java
@@ -21,7 +21,7 @@ import org.eclipse.osee.orcs.db.internal.sql.join.DatabaseJoinAccessor.JoinItem;
*/
public interface IJoinAccessor {
- void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList) throws OseeCoreException;
+ void store(OseeConnection connection, JoinItem joinItem, int queryId, List<Object[]> dataList, Long issuedAt, Long expiresIn) throws OseeCoreException;
int delete(OseeConnection connection, JoinItem joinItem, int queryId) throws OseeCoreException;
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java
index f755294b67..b9205176fc 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/IdJoinQuery.java
@@ -26,7 +26,7 @@ public class IdJoinQuery extends AbstractJoinQuery {
@Override
public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), id};
+ return new Object[] {getQueryId(), id};
}
@Override
@@ -73,8 +73,8 @@ public class IdJoinQuery extends AbstractJoinQuery {
}
}
- public IdJoinQuery(IJoinAccessor joinAccessor, int queryId) {
- super(joinAccessor, JoinItem.ID, queryId);
+ public IdJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
+ super(joinAccessor, JoinItem.ID, expiresIn, queryId);
}
public void add(Number id) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/JoinCleanerCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/JoinCleanerCallable.java
new file mode 100644
index 0000000000..f309ac02f4
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/JoinCleanerCallable.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.orcs.db.internal.sql.join;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.eclipse.osee.database.schema.DatabaseCallable;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+import org.eclipse.osee.framework.database.IQueryProcessor;
+import org.eclipse.osee.framework.database.core.IOseeStatement;
+import org.eclipse.osee.logger.Log;
+import com.google.common.base.Supplier;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimaps;
+
+/**
+ * If -1 is found in the expires_in column, it means never expire.
+ *
+ * @author Roberto E. Escobar
+ */
+public class JoinCleanerCallable extends DatabaseCallable<Void> {
+
+ private final static String DELETE_JOIN_CLEANUP = "DELETE FROM osee_join_cleanup WHERE query_id = ?";
+ private final static String SELECT_FROM_JOIN_CLEANUP = "SELECT * from osee_join_cleanup";
+
+ public JoinCleanerCallable(Log logger, IOseeDatabaseService service) {
+ super(logger, service);
+ }
+
+ private boolean isExpired(Long issuedAt, Long lifetime) {
+ return lifetime != -1 && ((issuedAt + lifetime) < (System.currentTimeMillis() / 1000));
+ }
+
+ @Override
+ public Void call() throws Exception {
+ final ListMultimap<String, Object[]> expiredItems = newListMultimap();
+ getDatabaseService().runQuery(new IQueryProcessor() {
+
+ @Override
+ public void processNext(IOseeStatement chStmt) {
+ Long issuedAt = chStmt.getLong("issues_at");
+ Long expiresIn = chStmt.getLong("expires_in");
+ if (isExpired(issuedAt, expiresIn)) {
+ String tableName = chStmt.getString("table_name");
+ Integer queryId = chStmt.getInt("query_id");
+ expiredItems.put(tableName, new Integer[] {queryId});
+ }
+ }
+ }, SELECT_FROM_JOIN_CLEANUP);
+
+ if (!expiredItems.isEmpty()) {
+ IOseeDatabaseService dbService = getDatabaseService();
+ for (Entry<String, Collection<Object[]>> entry : expiredItems.asMap().entrySet()) {
+ String query = String.format("DELETE FROM %s WHERE query_id = ?", entry.getKey());
+ List<Object[]> ids = (List<Object[]>) entry.getValue();
+ dbService.runBatchUpdate(query, ids);
+ dbService.runBatchUpdate(DELETE_JOIN_CLEANUP, ids);
+ }
+ }
+ return null;
+ }
+
+ private static <K, V> ListMultimap<K, V> newListMultimap() {
+ Map<K, Collection<V>> map = Maps.newLinkedHashMap();
+ return Multimaps.newListMultimap(map, new Supplier<List<V>>() {
+ @Override
+ public List<V> get() {
+ return Lists.newArrayList();
+ }
+ });
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/SqlJoinFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/SqlJoinFactory.java
index b170dd10cb..4036f2c74c 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/SqlJoinFactory.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/SqlJoinFactory.java
@@ -11,8 +11,12 @@
package org.eclipse.osee.orcs.db.internal.sql.join;
import java.util.Random;
+import java.util.concurrent.Callable;
+import java.util.concurrent.TimeUnit;
+import org.eclipse.osee.executor.admin.ExecutorAdmin;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.core.SystemPreferences;
/**
@@ -20,10 +24,28 @@ import org.eclipse.osee.orcs.core.SystemPreferences;
*/
public class SqlJoinFactory {
+ public static final String JOIN_CLEANER__EXECUTOR_ID = "join.cleaner.executor.id";
+ private static final Long DEFAULT_JOIN_EXPIRATION_SECONDS = 3L * 60L * 60L; // 3 hours
+ private static final long DEFAULT_JOIN_CLEANER__PERIOD_MINUTES = 60L; // 60 minutes;
+
+ private static final String EXPIRATION_SECS__ARTIFACT_JOIN_QUERY = "artifact.join.expiration.secs";
+ private static final String EXPIRATION_SECS__CHAR_JOIN_QUERY = "char.join.expiration.secs";
+ private static final String EXPIRATION_SECS__EXPORT_IMPORT_JOIN_QUERY = "export.import.join.expiration.secs";
+ private static final String EXPIRATION_SECS__ID_JOIN_QUERY = "id.join.expiration.secs";
+ private static final String EXPIRATION_SECS__TAG_QUEUE_JOIN_QUERY = "tag.queue.join.expiration.secs";
+ private static final String EXPIRATION_SECS__TX_JOIN_QUERY = "tx.join.expiration.secs";
+
+ private Log logger;
private IOseeDatabaseService service;
private SystemPreferences preferences;
+ private ExecutorAdmin executorAdmin;
+
private Random random;
+ public void setLogger(Log logger) {
+ this.logger = logger;
+ }
+
public void setDatabaseService(IOseeDatabaseService service) {
this.service = service;
}
@@ -32,11 +54,22 @@ public class SqlJoinFactory {
this.preferences = preferences;
}
- public void start() {
+ public void setExecutorAdmin(ExecutorAdmin executorAdmin) {
+ this.executorAdmin = executorAdmin;
+ }
+
+ public void start() throws Exception {
random = new Random();
+
+ Callable<?> callable = new JoinCleanerCallable(logger, service);
+ executorAdmin.scheduleAtFixedRate(JOIN_CLEANER__EXECUTOR_ID, callable, DEFAULT_JOIN_CLEANER__PERIOD_MINUTES,
+ DEFAULT_JOIN_CLEANER__PERIOD_MINUTES, TimeUnit.MINUTES);
}
- public void stop() {
+ public void stop() throws Exception {
+ if (executorAdmin != null) {
+ executorAdmin.shutdown(JOIN_CLEANER__EXECUTOR_ID);
+ }
random = null;
}
@@ -48,40 +81,71 @@ public class SqlJoinFactory {
return new DatabaseJoinAccessor(service);
}
- private IJoinAccessor createAccessor(String sessionId) {
- return new DatabaseJoinAccessor(service, sessionId);
+ public TransactionJoinQuery createTransactionJoinQuery() {
+ return createTransactionJoinQuery(null);
}
- public TransactionJoinQuery createTransactionJoinQuery() {
- return new TransactionJoinQuery(createAccessor(), getNewQueryId());
+ public TransactionJoinQuery createTransactionJoinQuery(Long expiresIn) {
+ Long actualExpiration = getExpiresIn(expiresIn, EXPIRATION_SECS__TX_JOIN_QUERY);
+ return new TransactionJoinQuery(createAccessor(), actualExpiration, getNewQueryId());
}
public IdJoinQuery createIdJoinQuery() {
- return new IdJoinQuery(createAccessor(), getNewQueryId());
+ return createIdJoinQuery(null);
}
- public IdJoinQuery createIdJoinQuery(String sessionId) {
- return new IdJoinQuery(createAccessor(sessionId), getNewQueryId());
+ public IdJoinQuery createIdJoinQuery(Long expiresIn) {
+ Long actualExpiration = getExpiresIn(expiresIn, EXPIRATION_SECS__ID_JOIN_QUERY);
+ return new IdJoinQuery(createAccessor(), actualExpiration, getNewQueryId());
}
public ArtifactJoinQuery createArtifactJoinQuery() {
- return new ArtifactJoinQuery(createAccessor(), getNewQueryId(), getMaxArtifactJoinSize());
+ return createArtifactJoinQuery(null);
+ }
+
+ public ArtifactJoinQuery createArtifactJoinQuery(Long expiresIn) {
+ Long actualExpiration = getExpiresIn(expiresIn, EXPIRATION_SECS__ARTIFACT_JOIN_QUERY);
+ return new ArtifactJoinQuery(createAccessor(), actualExpiration, getNewQueryId(), getMaxArtifactJoinSize());
}
public TagQueueJoinQuery createTagQueueJoinQuery() {
- return new TagQueueJoinQuery(createAccessor(), getNewQueryId());
+ return createTagQueueJoinQuery(null);
+ }
+
+ public TagQueueJoinQuery createTagQueueJoinQuery(Long expiresIn) {
+ Long actualExpiration = getExpiresIn(expiresIn, EXPIRATION_SECS__TAG_QUEUE_JOIN_QUERY);
+ return new TagQueueJoinQuery(createAccessor(), actualExpiration, getNewQueryId());
}
public ExportImportJoinQuery createExportImportJoinQuery() {
- return new ExportImportJoinQuery(createAccessor(), getNewQueryId());
+ return createExportImportJoinQuery(null);
}
- public CharJoinQuery createCharJoinQuery(String sessionId) {
- return new CharJoinQuery(createAccessor(sessionId), getNewQueryId());
+ public ExportImportJoinQuery createExportImportJoinQuery(Long expiresIn) {
+ Long actualExpiration = getExpiresIn(expiresIn, EXPIRATION_SECS__EXPORT_IMPORT_JOIN_QUERY);
+ return new ExportImportJoinQuery(createAccessor(), actualExpiration, getNewQueryId());
}
public CharJoinQuery createCharJoinQuery() {
- return new CharJoinQuery(createAccessor(), getNewQueryId());
+ return createCharJoinQuery(null);
+ }
+
+ public CharJoinQuery createCharJoinQuery(Long expiresIn) {
+ Long actualExpiration = getExpiresIn(expiresIn, EXPIRATION_SECS__CHAR_JOIN_QUERY);
+ return new CharJoinQuery(createAccessor(), actualExpiration, getNewQueryId());
+ }
+
+ private Long getExpiresIn(Long actual, String defaultKey) {
+ Long toReturn = DEFAULT_JOIN_EXPIRATION_SECONDS;
+ if (actual != null) {
+ toReturn = actual;
+ } else {
+ String expiration = preferences.getCachedValue(defaultKey);
+ if (Strings.isNumeric(expiration)) {
+ toReturn = Long.parseLong(expiration);
+ }
+ }
+ return toReturn;
}
private int getMaxArtifactJoinSize() {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java
index 425fd55a53..c9364e0d66 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TagQueueJoinQuery.java
@@ -26,7 +26,7 @@ public final class TagQueueJoinQuery extends AbstractJoinQuery {
@Override
public Object[] toArray() {
- return new Object[] {getQueryId(), getInsertTime(), gammaId};
+ return new Object[] {getQueryId(), gammaId};
}
@Override
@@ -73,8 +73,8 @@ public final class TagQueueJoinQuery extends AbstractJoinQuery {
}
}
- protected TagQueueJoinQuery(IJoinAccessor joinAccessor, int queryId) {
- super(joinAccessor, JoinItem.TAG_GAMMA_QUEUE, queryId);
+ protected TagQueueJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
+ super(joinAccessor, JoinItem.TAG_GAMMA_QUEUE, expiresIn, queryId);
}
public void add(Long gammaId) {
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java
index 07849460f4..f363fb5fdf 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/sql/join/TransactionJoinQuery.java
@@ -33,7 +33,6 @@ public final class TransactionJoinQuery extends AbstractJoinQuery {
public Object[] toArray() {
return new Object[] {
getQueryId(),
- getInsertTime(),
gammaId,
transactionId,
branchUuid != null ? branchUuid : SQL3DataType.BIGINT};
@@ -99,8 +98,8 @@ public final class TransactionJoinQuery extends AbstractJoinQuery {
}
}
- protected TransactionJoinQuery(IJoinAccessor joinAccessor, int queryId) {
- super(joinAccessor, JoinItem.TRANSACTION, queryId);
+ protected TransactionJoinQuery(IJoinAccessor joinAccessor, Long expiresIn, int queryId) {
+ super(joinAccessor, JoinItem.TRANSACTION, expiresIn, queryId);
}
public void add(Long gammaId, Integer transactionId) {
diff --git a/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip b/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip
index 9d1e7dd489..57bdd45d91 100644
--- a/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip
+++ b/plugins/org.eclipse.osee.x.server.p2/demo/hsql.zip
Binary files differ

Back to the top