Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CacheConnector

87 views
Skip to first unread message

Kevin M Lawlor

unread,
Jan 10, 2010, 5:15:31 AM1/10/10
to
I saw the CacheConnector you added on IBM Tivoli Directory Integrator
Users Group. It's probably overkill for what I need, but is there any
example on how to use it. I simply want to read a csv file with a
starting and ending range, cache it, and then be able to search on
it. I it copied to my Connector folder, and changed the connector
name. I am trying to search on it, but it says it's null. Thanks

Kevin M Lawlor

unread,
Jan 10, 2010, 8:09:03 AM1/10/10
to

Also I tried downloading the HashMap Connector, but I get 'java is
undefined' error.

Eddie Hartman

unread,
Jan 11, 2010, 9:33:32 AM1/11/10
to
Hi Kevin,

You have to edit the script and point it at a Connector
already configured in your Library (under the Connectors
folder in the Navigator). This Library Connector must
support Iterator mode and be configured to return the
data you want to search in; For example, a FileSystem
Connector with Parser reading from some file.

-Eddie

Kevin M Lawlor

unread,
Jan 12, 2010, 6:05:38 AM1/12/10
to

Do you have an example? I think I'm inputing into my cache

05:52:38 * 5 of 5 entries cached.
05:52:38 * Initializing Cache Connector using Connectors/
ReadScopeFile
05:52:38 CTGDJW002I Parser will use provide column names: '[name,
start, end]'.
05:52:38 * 5 of 5 entries cached.
05:52:38 * Initializing Cache Connector using Connectors/
ReadScopeFile
05:52:38 CTGDJW002I Parser will use provide column names: '[name,
start, end]'.
05:52:38 * 5 of 5 entries cached.

But not finding on lookup when I do I simple Link on "start equals"

[5:56:16 AM EST] java.lang.Exception: [CacheConnector_1] CTGDIS047W
Entry not found.

And get the following when I use a custom script
ret.filter = "start <= " + work.getString("ipAddress.dotNotation") +
" && end >= " + work.getString("ipAddress.dotNotation");

[6:01:01 AM EST] java.lang.ArrayIndexOutOfBoundsException: Array index
out of range: 0

It would be helpful if I could see an example. Thanks

Can I only search on the key attribute? I want to search between
start and end, and get the name.
var keyAttribute = "name"; // Unique Attribute to use

Eddie Hartman

unread,
Jan 13, 2010, 3:54:19 AM1/13/10
to
The HashMap Connector (the scripted one on tdi-users.org)
is very simple. It does not allow scripted Link Criteria and
only gives you a single index. That is defined at the top of
the script:
---
// url: http://www.tdi-users.org/twiki/bin/view/Integrator/HashMap
// ... a simple ReadMe at the top, omitted here
//
var connectorName = "ReadCSV"; // Connector to use
var keyAttribute = "id"; // Attribute to provide search key
for
---
So in the above example, there is a ReadCSV Connector
defined under Connectors and it will read in (at least) an
Attribute called "id" that will be the key for this data set.
As you can see from the script, it's pretty trivial - but still
a handy Connector.

I plan to roll out a TDI 7 version of this, with a config
parameters onscreen (like I did with the FileScan Connector:
http://www.tdi-users.org/twiki/bin/view/Integrator/FileList),
if my day-job permits :)

-Eddie

Kevin M Lawlor

unread,
Jan 13, 2010, 4:05:25 PM1/13/10
to

Ok,

Kevin M Lawlor

unread,
Jan 13, 2010, 4:20:50 PM1/13/10
to

Ok, I can get both connectors working when I use the simple Link
Criteria. But I get the following error when I build my criteria. It
would be great if you can give me the syntax. "start" is the field in
the hash. I tried "start[0]". How should it be referenced? Thanks

ret.filter = "start == " + work.getString("ipAddress.dotNotation");

Error
[4:13:58 PM EST] java.lang.ArrayIndexOutOfBoundsException: Array index
out of range: 0

Eddie Hartman

unread,
Jan 14, 2010, 4:51:45 AM1/14/10
to
Like I mentioned before, Kevin, you cannot script your Link Crit,
so no "ret.filter = ..." will work.

This simple Connector really just looks at the value you
pass in a Link Criteria (e.g. $work.AttName or literal value)
and applies this against the single index to this data (defined
by the keyAttribute variable. Have you tried a simple Link Crit
and just looked for a value that you know exists?

-Eddie

Kevin M Lawlor

unread,
Jan 18, 2010, 12:48:07 PM1/18/10
to

Yes that works, but I need to search for the range an ip falls into.
There for it can't be a simple match.

Eddie Hartman

unread,
Jan 19, 2010, 4:36:25 AM1/19/10
to
I see what you want to do now, Kevin, and you will
need to script a bit to get there.

First off, if you look at the start of the HashMap
Connector script you'll see the HashMap variable
I use to provide the simple lookup:
---
...
var hsh = new java.util.HashMap();
...
---
This gets populated with the entries read by the
library Connector you assigned to "connectorName".
So if you want to search for a range of ip addresses
(which you are using as the key for searches) then
you can ask the HashMap to return the keys as
a set:
---
keySet = hsh.keySet();
---
Then you can return the keySet as an Array of
Strings, sort the array and then use your favorite
search approach to determine the match:
---
keyArray = keySet.toArray();
java.util.Arrays.sort(keyArray);

function getInRange(startIP, endIP) {
// I'll return all entries found as values to an
// Attribute - it's a handy collection :)
retAtt = system.newAttribute("EntriesFound");
// Brute force search
for (var i = 0; i < keyArray.length; i++)
if (keyArray[i] > endIP)
break
else if (keyArray[i] >= startIP)
retAtt.addValue(hsh.get(keyArray[i]));
return retAtt;
}
---
Then you can check retAtt.size() to see how many
are returned, and then cycle through the values
any way you see fit (e.g. with an Attribute Value
Loop - that is, once you've put retAtt into the
Work Entry.

Your challenge here (should you choose to accept
it :) is that a scripted component lives "outside"
the scope of the AL Script engine - it has its own.
So you will need to modify the script in order to
put the HashMap (hsh) someplace that you can
reach outside. For example:
--- In the HashMap Connector script
...
var hsh = new java.util.HashMap();
java.lang.System.getProperties().put("HashM", hsh);
...
--- And then in your AL someplace
...
var hsh = java.lang.System.getProperties().get("HashM");
...
---
Hope this helps!
-Eddie

0 new messages