Closed dloy closed 1 year ago
Design details if implemented as a ZKlock
Access method Consumer/onHold() is where the check for a HOLD file exists. This is the top level of where the switch to ZK will be.
Changes in ZK library
Changes in Access
Changes in Ingest
I tried using a slightly different approach using Mark's locking mechanism that currently exists in the inventory system. This approach uses the presence of a specific znode as the flag. The znode is similar to a file/directory that always contains content.
With this approach the apache zookeeper methods can then be used for what would be many file operation.
By using CreateMode.PERSISTENT in the create operation, the znode remains after the zookeeper session, or service has terminated. The current inventory locks for arks uses CreateMode.EPHEMERAL that terminates the znodes with the zookeeper session. It appears that only the zookeeper.delete will remove the znode - not affected by zookeeper.exists.
I have run a variety of tests:
All tests indicate that servers on the same zookeeper can detect the flag and changes to the flag - even if zookeeper has been shutdown and restarted and the detection server has been restarted.
I must admit my knowledge of the details on using zookeeper as a property service is sketchy! So far these tests have indicated that zookeeper can provide a properties file system that can persist over shutdowns of either the client or zookeeper service.
I put together a prototype/proof of concept version that runs from a zootoken branch for storage.
Prototype operations:
http://<store server>/flag/[status|state|set|clear]/<service>/<flag name>?t=[xml | json | anvl]
flag state:
curl -X POST 'http://uc3-mrtsandbox2-stg.cdlib.org:35121/storage/flag/state/access/LargeAccessHold?t=xml'
flag status:
curl -X POST 'http://uc3-mrtsandbox2-stg.cdlib.org:35121/storage/flag/status/access/LargeAccessHold?t=xml'
flag set large:
curl -X POST 'http://uc3-mrtsandbox2-stg.cdlib.org:35121/storage/flag/set/access/LargeAccessHold?t=xml'
flag clear large:
curl -X POST 'http://uc3-mrtsandbox2-stg.cdlib.org:35121/storage/flag/clear/access/LargeAccessHold?t=xml'
flag set small:
curl -X POST 'http://uc3-mrtsandbox2-stg.cdlib.org:35121/storage/flag/set/access/SmallAccessHold?t=xml'
flag clear small:
curl -X POST 'http://uc3-mrtsandbox2-stg.cdlib.org:35121/storage/flag/clear/access/SmallAccessHold?t=xml'
flag set 1 level:
curl -X POST 'http://uc3-mrtsandbox2-stg.cdlib.org:35121/storage/flag/set/access?t=xml'
flag clear 1 level:
curl -X POST 'http://uc3-mrtsandbox2-stg.cdlib.org:35121/storage/flag/clear/access?t=xml'
To set znode content example:
op=$1
curl -L -X POST \
-F "content=this is my data" \
-F "responseForm=xml" \
"http://uc3-mrtsandbox2-stg.cdlib.org:35121/storage/zoodata/${op}/access/LargeAccessHold
Jersey:
@POST
@Path("zoodata/{operation}/{service}/{flagName}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response callSetZooData(
@PathParam("operation") String operation,
@PathParam("service") String service,
@PathParam("flagName") String flagName,
@DefaultValue("") @FormDataParam("content") String payload,
@DefaultValue("xhtml") @FormDataParam("responseForm") String formatType,
operation: [status|state|set|clear]
service: here - access
flagName - znode path
payload: data saved in znode
formatType: xml, json, anvl
<?xml version="1.0" encoding="UTF-8"?>
<tok:zooTokenState xmlns:tok='http://uc3.cdlib.org/ontology/mrt/store/tok'>
<tok:data>this is my data</tok:data>
<tok:tokenStatus>true</tok:tokenStatus>
<tok:runDate>2022-10-24T12:35:36-07:00</tok:runDate>
<tok:zooProcess>state</tok:zooProcess>
<tok:zooConnectionString>uc3-mrtzk01x2-stg.cdlib.org:2181,uc3-mrtzk02x2-stg. cdlib.org:2181,uc3-mrtzk03x2-stg.cdlib.org:2181</tok:zooConnectionString>
<tok:zooFlagPath>access/LargeAccessHold</tok:zooFlagPath>
<tok:zooNodeBase>/mrt.lock</tok:zooNodeBase>
<tok:lockCreated>2022-10-24T12:35:21-07:00</tok:lockCreated>
</tok:zooTokenState>
data: content of znode
tokenStatus: true=flag exists; false=no flag
runDate: current run date
zooProcess: state | status | set | clear
zooConnectionString: zookeeper connection string
zooFlagPath: znode key
zooNodeBase: base for all znode properties and flags
lockCreated: lock creation data if present
Current
Currently at least two subsystem locks use the presents of a file to determine if the lock is in place:
The advantage of this feature is the simplicity for adding and deleting a file for setting the lock. And, the presence or non-presence of a file is a straight forward test.
The difficulty of continuing to use this method is that:
Requirements
Discussion
Two broad categories similar to this issue are
Several tools fall into these categories
Many tools provide a variety of complex features that are dynamically available to programs. Some of these features use webpages for updating. The commercial tools are expensive at either a subscription basis or on a quantity of access basis. They tend to be far more complex than what we require.
For our current environment this handling is possible through different services:
SSM
Advantages:
Disadvantages:
Zookeeper
Advantages:
Disadvantages: - needs more investigation
S3
Advantages:
Disadvantages:
Proof of concept
I am currently working on a simplified library for proof of concept using S3. Using a special jar for this handling will bring in the AWS jars needed for S3 handling.