Saturday, December 17, 2011

Using Neo4J to visualize SAP PI interface data.

Neo4j is a high-performance, NOSQL graph database with all the features of a mature and robust database. A graph database is ideally suited for highly connected data. Marko Rodrigues compares the performance of MySQL and Neo4J for a graph query with 1,2,3,4,5 connections.  The information model for a typical SAP PI setup is highly connected. Lets look through the concepts that I want to visualize and explore.

SAP PI system,
Party, Service (or Component), Interface, Interface Map, Message Map,
Communication Channel and   runtime information of all messages (approx 80K per day = 28 M per year).

It should be fast and let me navigate relationships between objects.  I would like to be able to make a query like
Show me all messages between 3:05am and 3:55am with all the relevant information about parties etc.
Show me summary of all messages between 3:05am and 3:55am with all the relevant information about parties etc.
Show me which interface flows (sender/receiver) are effected if a communication channel is down.

Some notes on implementing Neo4J
To setup Neo4J, download the Community version from http://neo4j.org .  After you get the Neo4J server running, launch the browser at http://localhost:7474. Alternatively, you can launch the neo4j-shell command to look around. These are the shell commands that got me started.

cd
mkrel --cd -c -d o -t system -v --np "{'name':'PXP'}"
mkrel --cd -c -d o -t party -v --np "{'name':'PCE_LNSFA','type':'XIParty', 'partyagency':'http://sap.com/xi/XI','partytype':'XIParty'}"

The first line takes you to the reference node which is created by default in the starting database. 
The second line creates an outbound relationship called "system" and a new node at the end of the relationship. The new node has the property "name" = "PXP". The "name" property is used by the shell to give a friendly name to the node id. The "--cd" option moves you to the newly created node.
The third line creates an outbound relationship called "party" and a new node at the end of the relationship. The new node has the property "name" = "PCE_LNSFA" and a few more properties. So lets take a look at our graph.
cd
trav

The first line takes you to the starting node and the second line will traverse the entire graph for you.

mkrel --cd -c -d o -t interface -v --np "{'name':'IOA_ChangeCRMTaskRequest','type':'XIInterface', 'namespace':'http://philips.com/pce/lotesnotes/sales/tasks','addressid':'4ACB55C22850085AE1008002828BD49C'}"
index -i interface addressid

The first line here creates outbound relationship called "interface" and a new node at the end of the relationship. The new node has the property "name" = "IOA_ChangeCRMTaskRequest". 
The second line adds the newly created node to an index called "interface", with the property addressid stored in the index. This makes it easy to look up the node later using the following
index --cd interface addressid "4ACB55C22850085AE1008002828BD49C"
This will find the interface node and take you directly to that node. If we had indexed the first two nodes like this
index -i myindex system
index -i myindex xitype
we could have searched using
index --ls -q myindex "system:PXP AND xitype:service"

Once you get used to the basics, you can try your hand at advanced queries (or traversals in case of a graph). Take a look at the syntax of Cypher query language to understand this.
start n = (0) 
match (n)-[:systems]->(sys)-[:party]->(parties)-[:service]->(service) 
where sys.name = 'PXP' 
return n,sys,parties,service

The variables are specified as (varname). Basic syntax is
start 
match
where
return

You can use aggregate functions as well.
start n = (0) match (n)-[^1..4]-()-[:xi_interface]-(i) return i
start n = (0) match (n)--(p)-[^1..4]-()-[:xi_interface]-(i) return n,p, count(*)
The first line will display all nodes that are linked 1-5 relationships away from the reference node and the last link is xi_interface.
The second line, sums this up - grouping by the (p) - i.e. the system. So it displays number of interfaces per system.



start n=(message,'firstday:20110930 AND firstts:[20110930000000 TO 20110930005900]') match (n)-[:sends]-(s) where s.system='PXP' return s.party,count(*)
start n=(message,'procmode:S') match (n)-[:sends]-(s) where s.system='PXP' return s.party,s.service,s.interface,count(*)
start n=(message,'procmode:S') match (r)-[:receives]-(n)-[:sends]-(s) where s.system='PP4' return r.party,r.count(*),avg(n.latency),avg(n.msgsize)
start n=(message,'procmode:S') match (r)-[:receives]-(n)-[:sends]-(s) where s.system='PXP' return r.party,r.service,r.interface,s.party,s.service,s.interface,n.firstts,n.lastts,n.latency,n.dbentry,n.maprequ,n.msgsize,n.msgid
start n = (0) match (n)--(sys)--()--()--(iface)--(message) where message.latency > 2000 return iface,count(message)




Thoughts after the experiment
After a certain number of records, the database slows down. I tried this with a database of 22GB. Some queries did not return after a long time. So you may want to split into multiple databases. The web interface is fine to visualize limited graph nodes - but does not scale up. Use the command line when you have too many nodes.

Sunday, September 04, 2011

My interview with Kevin Benedict

Kevin Benedict interview me at the Enterprise Mobility 2011 conference in Brussels, Belgium. We discussed topics that are important as you develop a mobility strategy for your business. The interview is a part of the Mobile Expert Video series.

See the interview at Kevin's site

See the interview directly on Youtube



Setup iPads for an Enterprise setup

After getting some requests on how we setup iPads at Philips, I'm sharing the basic setup that we use for iPads at Philips.

Request the Afaria user ID and password. This will be needed in the following steps. 
Install the SIM card
 Connect the iPad to a computer with iTunes. Disconnect once the “connect to itunes” disappears from the iPad. (i.e. do not setup the iPad in iTunes).
 On the iPad, go to Settings>Wifi and connect to WLAN-PUB.
 Click the URL http://t-systems.mobidm.com/start to start enrolling your device.
             Login to the system with your Afaria user ID and password.
        Click the first button to enroll your device. This will bring up a request to enroll your device and install a profile. Accept.
       Go back to the Safari browser and click the second button (to download Afaria).
 In the App-Store, click “free” to start the download. When the AppleID dialog is opened; click “Create new account”. Follow the steps to create a new account - however do not enter credit card details (i.e. select None for credit card type). (You can also click here to download Afaria).
Ask the secretary to forward the email to you.
Click the link in the email to verify the email and finish the verification / setup of the apple id.
Install Afaria. Then go back to the browser where T-Systems page is showing. Click the last button to configure Afaria.
Install Brainloop
Install Penultimate
Install Adobe Ideas
Install Socialcast (Note: After installation, start the app and click the Gear icon or setting icon - to change “api.socialcast.com” to “connectus.socialcast.com”)
Install Pages
Install Numbers
Install Keynote
Install Goodreader
===== (The rest needs personal information specific to the end user of the iPad) =====
Setup Passcode
Create a mail account with the exchange settings (Server:www.mail.philips.com Domain:Code1 UserName: (nly or usd etc.) Password)
Setup ConnectUs/Social cast.(Note: Start this, click the Gear icon or setting icon - to change “api.socialcast.com” to “connectus.socialcast.com”)
Setup Brainloop

Saturday, June 11, 2011

XCode 4.3 with IOS 5 beta

After downloading XCode 4.3 beta with the IOS 5 SDK, the Organizer function to share and archive stopped working with a cryptic error "No such file or directory found".
It turns out that this is related to having two different versions of codesign_allocate . To fix the problem, do the following in a terminal window.

sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin

After that you can share the IPA with organizer again.

You can also package from the Terminal window with the following commands in the directory containing your XCode project.

xcodebuild -target LocateCustomer -sdk iphoneos build


/usr/bin/codesign -f -vv -s "Divya Mahajan (5E58XNSTHR)" build/Release-iphoneos/LocateCustomer.app


xcrun -sdk iphoneos PackageApplication -v "build/Release-iphoneos/LocateCustomer.app" -o build/LocateCustomer.ipa --sign "iPhone Developer: K Developer (5E68XNSTHR)"

--- Here LocateCustomer  = Target name in the project.