Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2017-07-31 17:28:34 -0400
committerdonald.g.dunne2017-08-04 16:47:27 -0400
commit4ef08fed930a5564aada067eb1728e8a1f300178 (patch)
tree930345dd750b7f0af45da68fa4d99eadaed2264b
parent95a8ed1e6d8f1b9ed00308a5cd6405bc2f929070 (diff)
downloadorg.eclipse.osee-4ef08fed930a5564aada067eb1728e8a1f300178.tar.gz
org.eclipse.osee-4ef08fed930a5564aada067eb1728e8a1f300178.tar.xz
org.eclipse.osee-4ef08fed930a5564aada067eb1728e8a1f300178.zip
refinement: Add timer to ATS Server to reload caches
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsUtilCore.java2
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java18
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java10
3 files changed, 24 insertions, 6 deletions
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsUtilCore.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsUtilCore.java
index 525e66c9a6..43fde84a75 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsUtilCore.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AtsUtilCore.java
@@ -31,6 +31,8 @@ public class AtsUtilCore {
public static final String USER_CREATION_DISABLED = "UserCreationDisabled2";
public static final String ATS_CONFIG_ACTION_URL_KEY = "ActionUrl";
public static final String ATS_DEFAULT_ACTION_URL = "/ats/ui/action/UUID";
+ public final static String SERVER_CONFIG_RELOAD_MS_KEY = "server_config_reload_ms";
+ public final static long SERVER_CONFIG_RELOAD_MS_DEFAULT = 180000; // 3 minutes
private static Map<Long, String> uuidToGuidMap = new HashMap<>(50);
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java
index 216883903b..9eaa747f96 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/AtsConfigEndpointImpl.java
@@ -48,6 +48,7 @@ import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.api.workdef.JaxAtsWorkDef;
import org.eclipse.osee.ats.api.workdef.WorkDefData;
import org.eclipse.osee.ats.core.users.AtsCoreUsers;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.ats.rest.IAtsServer;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.ArtifactToken;
@@ -63,6 +64,7 @@ import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.type.ViewModel;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.jaxrs.OseeWebApplicationException;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsApi;
@@ -93,8 +95,20 @@ public final class AtsConfigEndpointImpl implements AtsConfigEndpointApi {
Thread thread = new Thread("ATS Configuration Re-Loader") {
@Override
public void run() {
- AtsConfigurations configs = getAtsConfigurationsFromDb();
- atsConfigurations = configs;
+ while (true) {
+ AtsConfigurations configs = getAtsConfigurationsFromDb();
+ atsConfigurations = configs;
+ try {
+ long reloadTime = AtsUtilCore.SERVER_CONFIG_RELOAD_MS_DEFAULT;
+ String reloadTimeStr = services.getConfigValue(AtsUtilCore.SERVER_CONFIG_RELOAD_MS_KEY);
+ if (Strings.isNumeric(reloadTimeStr)) {
+ reloadTime = Long.valueOf(reloadTimeStr);
+ }
+ Thread.sleep(reloadTime);
+ } catch (InterruptedException ex) {
+ // do nothing
+ }
+ }
}
};
thread.start();
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java
index 724932fd0e..98d1b4ce74 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/UpdateAtsConfiguration.java
@@ -25,6 +25,7 @@ import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.util.ColorColumns;
import org.eclipse.osee.ats.core.column.ColorTeamColumn;
import org.eclipse.osee.ats.core.users.AtsCoreUsers;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
import org.eclipse.osee.ats.rest.IAtsServer;
import org.eclipse.osee.ats.rest.internal.util.RestUtil;
import org.eclipse.osee.framework.core.data.ArtifactId;
@@ -72,6 +73,7 @@ public class UpdateAtsConfiguration {
} catch (Exception ex) {
rd.errorf("Error in createUpdateValidStateAttributes [%s]", Lib.exceptionToString(ex));
}
+ atsServer.setConfigValue(AtsUtilCore.SERVER_CONFIG_RELOAD_MS_KEY, AtsUtilCore.SERVER_CONFIG_RELOAD_MS_KEY);
return rd;
}
@@ -163,9 +165,8 @@ public class UpdateAtsConfiguration {
}
public ArtifactId getOrCreateConfigFolder(ArtifactId userArt, XResultData rd) {
- ArtifactReadable configFolderArt =
- atsServer.getOrcsApi().getQueryFactory().fromBranch(CoreBranches.COMMON).andId(
- AtsArtifactToken.ConfigFolder).getResults().getAtMostOneOrNull();
+ ArtifactReadable configFolderArt = atsServer.getOrcsApi().getQueryFactory().fromBranch(CoreBranches.COMMON).andId(
+ AtsArtifactToken.ConfigFolder).getResults().getAtMostOneOrNull();
if (configFolderArt == null) {
TransactionBuilder tx = atsServer.getOrcsApi().getTransactionFactory().createTransaction(CoreBranches.COMMON,
userArt, "Create Config Folder");
@@ -204,7 +205,8 @@ public class UpdateAtsConfiguration {
private void createUpdateValidStateAttributes(ArtifactReadable atsConfigArt, ArtifactReadable userArt, XResultData rd) throws Exception {
- Collection<String> validStateNames = atsServer.getWorkDefinitionService().getAllValidStateNames(new XResultData());
+ Collection<String> validStateNames =
+ atsServer.getWorkDefinitionService().getAllValidStateNames(new XResultData());
atsServer.setConfigValue(VALID_STATE_NAMES_KEY, Collections.toString(",", validStateNames));
}

Back to the top