How do I create a lifepoint in the correct format for a specific date or time?

If you are writing a stream manually and want to create a lifepoint for a certain date, you can use the following trick changing the "minute" to "hour" or whatever is appropriate for you:

lifepoint=`date --date='now + 1 minute' -u +"%a, %d %b %Y %H:%M:%S %Z"` 

You can then insert this lifepoint data into a stream like this:

curl -L --post301 --data-binary @file -H "lifepoint: [${lifepoint}], deletable=True, [] delete" http://[node-ip]

This will tell the stream to be deleted in 1 minute.  

Here is a complete test:

[root@b-csn5 caringo]# if [ ! -f file ]; then echo "the time is now" > file;fi
[root@b-csn5 caringo]# lifepoint=`date --date='now + 1 minute' -u +"%a, %d %b %Y %H:%M:%S %Z"`
[root@b-csn5 caringo]# echo $lifepoint
Tue, 28 Jan 2014 22:34:34 UTC

Write the stream with the lifepoint specifying delete the stream in 1 minute:

[root@b-csn5 caringo]# curl -iL --post301 --data-binary @file -H "lifepoint: [${lifepoint}], deletable=True, [] delete" "http://b-csn5.enfield.com/support/time" -D write.out
HTTP/1.1 201 Created
Volume: c603ca71bc4cea70a39029ec51176a70
Last-Modified: Tue, 28 Jan 2014 22:33:34 GMT
Entity-MD5: g9kOqB0kgA6BEGpKtAUurg==
Stored-Digest: 83d90ea81d24800e81106a4ab4052eae
Castor-System-Version: 1390948414.327
Etag: "d9c55e812d873bfac0215ad6713e0e09"
Location: http://10.1.1.165:80/support/time?domain=b-csn5.enfield.com
Via: 1.1 b-csn5 (ScspProxyService/6.1.1)
X-Forwarded-For: b-csn5
X-Forwarded-Server: b-csn5
Scsp-Proxy-Agent: ScspProxyService/6.1.1
Date: Tue, 28 Jan 2014 22:33:34 GMT
Server: CAStor Cluster/6.1.3
Content-Length: 46
Content-Type: text/html
<html><body>New stream created</body></html>

Test reading the stream immediately:

[root@b-csn5 caringo]# curl -iL "http://b-csn5.enfield.com/support/time"
HTTP/1.1 200 OK
Castor-System-CID: 5b91305dbfb83f29bc163daf9af3052d
Castor-System-Cluster: b-csn5.enfield.com
Castor-System-Created: Tue, 28 Jan 2014 22:33:34 GMT
Castor-System-Name: time
Castor-System-Version: 1390948414.327
Content-Length: 20
Content-Type: application/x-www-form-urlencoded
Last-Modified: Tue, 28 Jan 2014 22:33:34 GMT
lifepoint: [Tue, 28 Jan 2014 22:34:34 UTC], deletable=True, [] delete
Etag: "d9c55e812d873bfac0215ad6713e0e09"
Volume: c603ca71bc4cea70a39029ec51176a70
Castor-System-Path: /b-csn5.enfield.com/support/time
Castor-System-Domain: b-csn5.enfield.com
Via: 1.1 b-csn5 (ScspProxyService/6.1.1)
X-Forwarded-For: b-csn5
X-Forwarded-Server: b-csn5
Scsp-Proxy-Agent: ScspProxyService/6.1.1
Date: Tue, 28 Jan 2014 22:33:34 GMT
Server: CAStor Cluster/6.1.3
the time is now\r\n

Wait for a couple of minutes, and you will see the stream has been deleted:

[root@b-csn5 caringo]# sleep 120; curl -iL "http://b-csn5.enfield.com/support/time"
HTTP/1.1 404 Not Found
Allow: HEAD, GET, PUT, POST, COPY, GEN, APPEND, DELETE
Via: 1.1 b-csn5 (ScspProxyService/6.1.1)
X-Forwarded-For: b-csn5
X-Forwarded-Server: b-csn5
Scsp-Proxy-Agent: ScspProxyService/6.1.1
Content-Length: 198
Content-Type: text/html
Date: Tue, 28 Jan 2014 22:35:34 GMT
Server: CAStor Cluster/6.1.3
<html><body><h2>Swarm Storage Error</h2><br>&lt;html&gt;&lt;body&gt;&lt;h2&gt;Swarm Storage Error&lt;/h2&gt;&lt;br&gt;Requested stream was not found (isDeletedByPolicy)&lt;/body&gt;&lt;/html&gt;
</body></html> 

If you are using a Mac with OS X, this "--date" option will not work.  You can use gdate by installing Homebrew's coreutils:

http://www.howtogeek.com/211541/homebrew-for-os-x-easily-installs-desktop-apps-and-terminal-utilities/

Then:

brew install coreutils 


© DataCore Software Corporation. · https://www.datacore.com · All rights reserved.