Skip to content

Commit 9f636c1

Browse files
committed
Skip data store for retrieval based on named flag.
Use a named flag based on the storage plugin's name. For example, if the name is LTS, the named flag SKIP_LTS_FOR_RETRIEVAL can used to temporarily turn off using the LTS for retrieval. Also add a BPL to get all named flags and their values
1 parent 61c7442 commit 9f636c1

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

docs/docs/source/sysadmin/admin.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,25 @@ Channel Access ( and PVAccess ). Here\'s an example of this process
168168
- Pausing and resuming the PV during packet capture will also enable
169169
the `cashark` plugin to track the life cycle of the Channel Access
170170
channel.
171+
172+
## Temporarily suspend using a store
173+
174+
If one of your data stores uses storage from elsewhere and you expect
175+
an outage or disruption of connectivity, you can
176+
temporarily suspend using the store for retrieval requests.
177+
This is especially useful if you mount the remote location using NFS
178+
which can sometimes suspend threads forever during
179+
periods of network disruptions ( see the hard/soft/intr options for NFS clients).
180+
For example, if you have a data store named `LTS`, you can set the
181+
`SKIP_LTS_FOR_RETRIEVAL` named flag to `true` and this will stop adding the `LTS`
182+
to retrieval requests ( both `getData` and `getDataAtTime` ). Once the outage
183+
is over, you can turn `LTS` back on by setting the `SKIP_LTS_FOR_RETRIEVAL`
184+
named flag to `false`. Named flags are `false` by default; so restarting the
185+
appliances should also accomplish the same.
186+
187+
188+
189+
Use a named flag based on the storage plugin's name.
190+
For example, if the name is LTS, the named flag
191+
SKIP_LTS_FOR_RETRIEVAL can used to temporarily turn off
192+
using the LTS for retrieval.

src/main/org/epics/archiverappliance/mgmt/BPLServlet.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.epics.archiverappliance.mgmt.bpl.MergeInDataFromExternalStore;
5151
import org.epics.archiverappliance.mgmt.bpl.ModifyMetaFieldsAction;
5252
import org.epics.archiverappliance.mgmt.bpl.ModifyStoreURLForPV;
53+
import org.epics.archiverappliance.mgmt.bpl.NamedFlagsAll;
5354
import org.epics.archiverappliance.mgmt.bpl.NamedFlagsGet;
5455
import org.epics.archiverappliance.mgmt.bpl.NamedFlagsSet;
5556
import org.epics.archiverappliance.mgmt.bpl.PauseArchivingPV;
@@ -149,6 +150,7 @@ public class BPLServlet extends HttpServlet {
149150
addAction("/resetFailoverCaches", ResetFailoverCaches.class);
150151
addAction("/getVersions", GetVersions.class);
151152
addAction("/modifyMetaFields", ModifyMetaFieldsAction.class);
153+
addAction("/getAllNamedFlags", NamedFlagsAll.class);
152154
addAction("/getNamedFlag", NamedFlagsGet.class);
153155
addAction("/setNamedFlag", NamedFlagsSet.class);
154156
addAction("/getTypeInfoKeys", GetPVTypeInfoKeys.class);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.epics.archiverappliance.mgmt.bpl;
2+
3+
import java.io.IOException;
4+
import java.io.PrintWriter;
5+
import java.util.HashMap;
6+
7+
import javax.servlet.http.HttpServletRequest;
8+
import javax.servlet.http.HttpServletResponse;
9+
10+
import org.apache.logging.log4j.LogManager;
11+
import org.apache.logging.log4j.Logger;
12+
import org.epics.archiverappliance.common.BPLAction;
13+
import org.epics.archiverappliance.config.ConfigService;
14+
import org.epics.archiverappliance.utils.ui.MimeTypeConstants;
15+
import org.json.simple.JSONObject;
16+
17+
/**
18+
*
19+
* @epics.BPLAction - Get all the named flags in the system and their values as a JSON dict
20+
* @epics.BPLActionEnd
21+
*
22+
* @author mshankar
23+
*
24+
*/
25+
public class NamedFlagsAll implements BPLAction {
26+
private static Logger logger = LogManager.getLogger(NamedFlagsAll.class.getName());
27+
@Override
28+
public void execute(HttpServletRequest req, HttpServletResponse resp, ConfigService configService) throws IOException {
29+
HashMap<String, Boolean> ret = new HashMap<String, Boolean>();
30+
for(String namedFlagName : configService.getNamedFlagNames()){
31+
boolean namedValue = configService.getNamedFlag(namedFlagName);
32+
ret.put(namedFlagName, namedValue);
33+
}
34+
35+
resp.setContentType(MimeTypeConstants.APPLICATION_JSON);
36+
try (PrintWriter out = resp.getWriter()) {
37+
out.println(JSONObject.toJSONString(ret));
38+
} catch(Exception ex) {
39+
logger.error("Exception getting all named flags", ex);
40+
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
41+
}
42+
}
43+
}

src/main/org/epics/archiverappliance/retrieval/DataSourceResolution.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ public LinkedList<UnitOfRetrieval> resolveDataSources(String pvName, Instant sta
103103

104104
for(TimeSpanDependentProcessor spannedProcessor : spannedProcessors) {
105105
for(DataSourceforPV dataSource : dataSources) {
106+
// Check to see if there is a named flag that turns off this data source.
107+
String namedFlagForSkippingDataSource = "SKIP_" + dataSource.getStoragePlugin().getName() + "_FOR_RETRIEVAL";
108+
if(configService.getNamedFlag(namedFlagForSkippingDataSource)) {
109+
logger.warn("Skipping " + dataSource.getStoragePlugin().getName() + " as the named flag " + namedFlagForSkippingDataSource + " is set");
110+
continue;
111+
}
112+
106113
// Ideally we'd check to see if this data source has data in this time span.
107114
// However, this means we have to keep all the various infos updated.
108115
// The MergeDedup now takes care of merging from multiple sources.

src/main/org/epics/archiverappliance/retrieval/GetDataAtTime.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,13 @@ private static PVWithData getDataAtTimeForPVFromStores(String pvName, Instant at
410410
Collections.reverse(datastores);
411411
for (String store : datastores) {
412412
StoragePlugin storagePlugin = StoragePluginURLParser.parseStoragePlugin(store, configService);
413+
// Check to see if there is a named flag that turns off this data source.
414+
String namedFlagForSkippingDataSource = "SKIP_" + storagePlugin.getName() + "_FOR_RETRIEVAL";
415+
if(configService.getNamedFlag(namedFlagForSkippingDataSource)) {
416+
logger.warn("Skipping " + storagePlugin.getName() + " as the named flag " + namedFlagForSkippingDataSource + " is set");
417+
continue;
418+
}
419+
413420
try (BasicContext context = new BasicContext()) {
414421
if(storagePlugin instanceof BiDirectionalIterable) {
415422
Instant startAtTime = atTime.plus(5, ChronoUnit.MINUTES);

0 commit comments

Comments
 (0)