Date: Thu, 28 Mar 2024 21:42:53 +0000 (UTC) Message-ID: <190293455.7061.1711662173849@ip-10-10-7-29.ec2.internal> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_7060_245770434.1711662173847" ------=_Part_7060_245770434.1711662173847 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The Grouper discovery client is a way to discover information about serv= ices using a failsafe cache. This is available in Grouper v2.1+ in gr= ouperClient.jar. It simply downloads a file from a web server. = The file can be a properties file that holds information about the URLs and= other metadata about a service. There should be multiple discovery U= RLs, and it uses the GrouperClient failover client s= o that communication is always available if there are no shared components = of the multiple discovery web servers. However, if there is only one = server, and it has been downloaded once in the past, then it will be in a f= ailsafe cache so that it will use that information instead of failing.
This client will be used for the GrouperClient WS and GrouperC= lient LDAP to make the service more highly available. It can u= sed as a command line utility or Java library for other non-Grouper service= s.
These settings in the grouper.client.properties configure the discovery = client:
# path = of a writable directory where files can be created or stored # for example, cache of discovery configuration, or failover state # dot is the current directory... note, this directory must exist # or it will be created (attempted) # if this is blank, none of these features will be used, and # no files will be saved grouperClient.cacheDirectory =3D . ######################################## ## Service discovery settings ######################################## # number of minutes to remember that a connection had errors grouperClient.minutesToKeepErrors =3D 2 # if you are using a discovery service, but a discovery properties # at a URL (preferably SSL with valid certificate) # you should have multiple discovery URLs hosted at independent locations # to add more, increment the integer grouperClient.urlOfDiscovery.0 =3D https://firstserver.school.edu/path/ grouperClient.urlOfDiscovery.1 =3D https://secondserver.school.edu/path/ # if your app has a slow startup time, and the initial connections are timi= ng out # esp if you arent just using the command line client (e.g. if using it as = a jar), # then add more time here grouperClient.secondsForClassesToLoad =3D 20 # this will save the failover state to a file so if the JVM is stopped, it # will be there when it starts again. # Set to 0 to store on every use (recommended if used command line) # or set to -1 to not store or read ever # grouperClient.cacheDirectory must be set grouperClient.saveFailoverStateEverySeconds =3D 60 # this will cache the discovery properties in memory or on disk # if you want to cache the discovery properties locally, put a directory he= re: # this is recommended especially if you are using the grouper client as a c= ommand # line application and the process is constantly restarting # note, this will be used for a failsafe cache if all discovery servers are= unavailable # grouperClient.cacheDirectory must be set # set to 0 or -1 to not cache grouperClient.cacheDiscoveryPropertiesForSeconds =3D 120
Just include the grouperClient.jar and grouper.client.properties in the = classpath, and call like this:
boolean= throwExceptionIfNotFound =3D true; File configFile =3D edu.internet2.middleware.grouperClient.discovery.Discov= eryClient.retrieveFile("myConfigFile.properties", throwExceptionIfNotFound)= ;
Note, if the URLs in the grouper.client.properties are:
https://firstserver.school.edu/path/https://secondserver.school.edu/pat= h/
then the path of the file downloaded from the web server would be
https://firstserver.school.edu/path/myConfigFile.pr= operties
-or-
https://secondserver.school.edu/path/myConfigFile.= properties
depending on which server is available and responds successfully. = See the Fail= overClient documentation for more information about how this works
C:\mchy= zer\grouper\trunk\grouperClient\dist>java -cp grouperClient.jar edu.inte= rnet2.middleware.grouperClient.discovery.DiscoveryClient --operation=3DgetF= ile --fileName=3DmyConfigFile.properties C:\mchyzer\grouper\trunk\grouperClient\dist\myConfigFile_20120208_141052_08= 8_Q8O0R25L.properties C:\mchyzer\grouper\trunk\grouperClient\dist>
See the Java library section above for more information, it just calls t= hat method and will fail if not there.
Not that the file returned does not have the same name as the file reque= sted, this is so that multiple processes can access the discovery client at= the same time and never have contention.
Note: you cannot rename or edit the file returned from the DiscoveryClie= nt since it will be reused by subsequent calls until it is expired.
Get a couple of web servers, and add a text file. For example:
http://www.internet2.edu/grouper/temp/temp.txt
https://grouperdemo.internet2.edu/temp/temp.txt
Then set the base URLS in the grouper.client.properties:
grouper= Client.urlOfDiscovery.0 =3D https://grouperdemo.internet2.edu/temp/ grouperClient.urlOfDiscovery.1 =3D http://www.internet2.edu/grouper/temp/
Then request the file, e.g. from command line:
C:\mchy= zer\grouper\trunk\grouperClient\dist>java -cp grouperClient.jar edu.inte= rnet2.middleware.grouperClient.discovery.DiscoveryClient --operation=3DgetF= ile --fileName=3Dtemp.txt C:\mchyzer\grouper\trunk\grouperClient\dist\temp_20120208_145738_982_Q8O2F8= SB.txt C:\mchyzer\grouper\trunk\grouperClient\dist>
Open that file on the local machine and make sure the contents are corre= ct:
C:\mchy= zer\grouper\trunk\grouperClient\dist>more C:\mchyzer\grouper\trunk\group= erClient\dist\temp_20120208_145738_982_Q8O2F8SB.txt Hey, this is my file, internet2.edu
That came from internet2. Change the grouper.client.properties to = make the internet2 URL wrong, and rename the result to be too old, and try = again. Note, there is a stderr stack, but it is successful and the st= dout still has the file contents ok
C:\mchy= zer\grouper\trunk\grouperClient\dist>ren temp_20120208_145738_982_Q8O2F8= SB.txt temp_20120208_145238_982_Q8O2F8SB.txt grouperClient.urlOfDiscovery.0 =3D https://grouperdemo.internet2.edu/temp/ grouperClient.urlOfDiscovery.1 =3D http://www.internet2.edu/grouper/temp2/ C:\mchyzer\grouper\trunk\grouperClient\dist>java -cp grouperClient.jar e= du.internet2.middleware.grouperClient.discovery.DiscoveryClient --operation= =3DgetFile --fileName=3Dtemp.txt Feb 8, 2012 3:03:23 PM edu.internet2.middleware.grouperClient.failover.Fail= overClient internal_failoverLogic WARNING: NON-FATAL error in failover connection: http://www.internet2.edu/g= rouper/temp2/, will try others in pool (1 tot al errors, 0 total timeouts, 0 total fatal errors): [THIS STACK]: java.lang= .RuntimeException: this stack at edu.internet2.middleware.grou= perClient.failover.FailoverClient.internal_failoverLogic(FailoverClient.jav= a:721) at edu.internet2.middleware.grou= perClient.failover.FailoverClient.failoverLogic(FailoverClient.java:521) at edu.internet2.middleware.grou= perClient.failover.FailoverClient.failoverLogic(FailoverClient.java:503) at edu.internet2.middleware.grou= perClient.discovery.DiscoveryClient.retrieveFileFromDiscoveryServer(Discove= ryClient.java:614) at edu.internet2.middleware.grou= perClient.discovery.DiscoveryClient.retrieveFile(DiscoveryClient.java:308) at edu.internet2.middleware.grou= perClient.discovery.DiscoveryClient.main(DiscoveryClient.java:130) java.lang.RuntimeException: Problem with url: http://www.internet2.edu/grou= per/temp2/temp.txt, and local file: C:\mchyzer\grouper\trunk\grouperClient\= dist\temp_20120208_150615_695_Q8O2RBNU.txt.discoverytmp at edu.internet2.middleware.grou= perClient.discovery.DiscoveryClient$1.logic(DiscoveryClient.java:755) at edu.internet2.middleware.grou= perClient.discovery.DiscoveryClient$1.logic(DiscoveryClient.java:614) at edu.internet2.middleware.grou= perClient.failover.FailoverClient$1.call(FailoverClient.java:631) at java.util.concurrent.FutureTa= sk$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTa= sk.run(FutureTask.java:138) at java.util.concurrent.ThreadPo= olExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPo= olExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.j= ava:619) Caused by: java.lang.RuntimeException: Expected 200, but received response = code: 404 at edu.internet2.middleware.grou= perClient.discovery.DiscoveryClient$1.logic(DiscoveryClient.java:723) ... 7 more C:\mchyzer\grouper\trunk\grouperClient\dist\temp_20120208_150323_221_Q8O2NM= KU.txt C:\mchyzer\grouper\trunk\grouperClient\dist>more temp_20120208_150323_22= 1_Q8O2NMKU.txt This is my file, from grouper build server
If you rename one to be 20 minutes old the old files will not be automat= ically deleted yet, however, rename two to be more than 20 minutes old, and= it will automatically delete the ones more than 20 minutes old except the = newest one over 20 minutes old.
C:\mchy= zer\grouper\trunk\grouperClient\dist>dir temp* Volume in drive C is OS Volume Serial Number is 4651-8CE1 Directory of C:\mchyzer\grouper\trunk\grouperClient\dist 02/08/2012 02:10 PM &n= bsp; 35 temp_20120208_141052_088_Q8O0R2= 5L.txt 02/08/2012 02:57 PM &n= bsp; 35 temp_20120208_145238_982_Q8O2F8= SB.txt 02/08/2012 03:03 PM &n= bsp; 42 temp_20120208_150323_221_Q8O2NM= KU.txt &nb= sp; 3 File(s) &n= bsp; 112 bytes &nb= sp; 0 Dir(s) 270,957,670,400 bytes free C:\mchyzer\grouper\trunk\grouperClient\dist>ren temp_20120208_145238_982= _Q8O2F8SB.txt temp_20120208_143238_982_Q8O2F8SB. txt C:\mchyzer\grouper\trunk\grouperClient\dist>dir temp* Volume in drive C is OS Volume Serial Number is 4651-8CE1 Directory of C:\mchyzer\grouper\trunk\grouperClient\dist 02/08/2012 02:10 PM &n= bsp; 35 temp_20120208_141052_088_Q8O0R2= 5L.txt 02/08/2012 02:57 PM &n= bsp; 35 temp_20120208_143238_982_Q8O2F8= SB.txt 02/08/2012 03:03 PM &n= bsp; 42 temp_20120208_150323_221_Q8O2NM= KU.txt &nb= sp; 3 File(s) &n= bsp; 112 bytes &nb= sp; 0 Dir(s) 270,956,908,544 bytes free C:\mchyzer\grouper\trunk\grouperClient\dist>java -cp grouperClient.jar e= du.internet2.middleware.grouperClient.discovery.DiscoveryClient --operation= =3DgetFile --fileName=3Dtemp.txt C:\mchyzer\grouper\trunk\grouperClient\dist\temp_20120208_150615_884_Q8O2RB= NV.txt C:\mchyzer\grouper\trunk\grouperClient\dist>dir temp* Volume in drive C is OS Volume Serial Number is 4651-8CE1 Directory of C:\mchyzer\grouper\trunk\grouperClient\dist 02/08/2012 02:57 PM &n= bsp; 35 temp_20120208_143238_982_Q8O2F8= SB.txt 02/08/2012 03:03 PM &n= bsp; 42 temp_20120208_150323_221_Q8O2NM= KU.txt 02/08/2012 03:06 PM &n= bsp; 42 temp_20120208_150615_884_Q8O2RB= NV.txt &nb= sp; 3 File(s) &n= bsp; 119 bytes &nb= sp; 0 Dir(s) 270,956,711,936 bytes free https://spaces.at.internet2.edu/display/Grouper/Grouper+Web+ServicesC:\mchy= zer\grouper\trunk\grouperClient\dist>
Note this file was deleted: temp_20120208_141052_088_Q8O0R25L.txt, since= it was 20 minutes old, and the one from 14:32.