Some statements not persisting

5 views
Skip to first unread message

Michael McIntosh

unread,
Feb 10, 2011, 6:42:36 PM2/10/11
to open...@googlegroups.com
I am debugging the strangest problem. I am saving three statements to a graph, one of them consistently gets peristed to the server graph correctly. The other two consistently do not. 

The scenario is as follows...

The following calls seem to update the statement correctly:
higgins.anzoClient.begin();
// Get rid of old email address
var emailStatements = higgins.anzoClient.replicaFind(higgins.userRootPersonURI, higgins.vEMailURI, null, higgins.userRootGraphURI);
if (0 != emailStatements.length) {
console.log("Removing: " + JSON.stringify(emailStatements));
higgins.userRootGraph.remove(emailStatements);
}
// Set new email address
var emailAddressLiteral = anzo.createLiteral(emailAddress, "http://www.w3.org/2001/XMLSchema#string");
var currentEMail = anzo.createStatement(higgins.userRootPersonURI, higgins.vEMailURI, emailAddressLiteral, higgins.userRootGraphURI);
console.log("Adding: " + JSON.stringify(currentEMail));
higgins.userRootGraph.add(currentEMail);
higgins.anzoClient.commit();
higgins.anzoClient.updateRepository();
The following calls update the local replica, but the statements never end up on the server:
higgins.anzoClient.begin();
// Get rid of old latitude and longitude
var latitudeStatements = higgins.anzoClient.replicaFind(higgins.userRootPersonURI, higgins.vLatitudeURI, null, higgins.userRootGraphURI);
if (0 != latitudeStatements.length) {
console.log("Removing: " + JSON.stringify(latitudeStatements));
higgins.userRootGraph.remove(latitudeStatements);
}
var longitudeStatements = higgins.anzoClient.replicaFind(higgins.userRootPersonURI, higgins.vLongitudeURI, null, higgins.userRootGraphURI);
if (0 != latitudeStatements.length) {
console.log("Removing: " + JSON.stringify(longitudeStatements));
higgins.userRootGraph.remove(longitudeStatements);
}
// add current latitude and longitude
var latitudeLiteral = anzo.createLiteral(coords.latitude, "http://www.w3.org/2001/XMLSchema#string");
var currentLatitude = anzo.createStatement(higgins.userRootPersonURI, higgins.vLatitudeURI, latitudeLiteral, higgins.userRootGraphURI);
var longitudeLiteral = anzo.createLiteral(coords.longitude, "http://www.w3.org/2001/XMLSchema#string");
var currentLongitude = anzo.createStatement(higgins.userRootPersonURI, higgins.vLongitudeURI, longitudeLiteral, higgins.userRootGraphURI);
console.log("Adding: " + JSON.stringify(currentLatitude));
higgins.userRootGraph.add(currentLatitude);
console.log("Adding: " + JSON.stringify(currentLongitude));
higgins.userRootGraph.add(currentLongitude);
higgins.anzoClient.commit();
higgins.anzoClient.updateRepository();

The console log for the sequence that works correctly contains:

The console log for the sequence that works incorrectly contains:
Adding: {"subject":{"value":"http://higgins.eclipse.org/pds/mike/root#me","namespace":"http://higgins.eclipse.org/pds/mike/root#","localname":"me"},"predicate":{"value":"http://www.w3.org/2006/vcard/latitude","namespace":"http://www.w3.org/2006/vcard/","localname":"latitude"},"object":{"value":"40.858432","language":"http://www.w3.org/2001/XMLSchema#string","_string":"\"40.858432\"@http://www.w3.org/2001/XMLSchema#string"},"namedGraphUri":{"value":"http://higgins.eclipse.org/pds/mike/root","namespace":"http://higgins.eclipse.org/pds/mike/","localname":"root"}}
Adding: {"subject":{"value":"http://higgins.eclipse.org/pds/mike/root#me","namespace":"http://higgins.eclipse.org/pds/mike/root#","localname":"me"},"predicate":{"value":"http://www.w3.org/2006/vcard/longitude","namespace":"http://www.w3.org/2006/vcard/","localname":"longitude"},"object":{"value":"-74.163755","language":"http://www.w3.org/2001/XMLSchema#string","_string":"\"-74.163755\"@http://www.w3.org/2001/XMLSchema#string"},"namedGraphUri":{"value":"http://higgins.eclipse.org/pds/mike/root","namespace":"http://higgins.eclipse.org/pds/mike/","localname":"root"}}

The major difference between the two is that the statements that don't persist are missing the _dictionaryKey element. 

Can anyone provide some guidance on why this is happening?

Regards,
Mike

Michael McIntosh

unread,
Feb 10, 2011, 7:05:42 PM2/10/11
to OpenAnzo
I did just try "fixing" the statements with this function, but got
the same result (statements not persisted on server):

higgins.fixDictionaryKey = function(statement) {
if (null == statement._dictionaryKey) {
statement._dictionaryKey = "{ " + statement.subject.value + ", "
+ statement.predicate.value + ", "
+ statement.object._string + ", "
+ statement.namedGraphUri.value + " }";
}
};
> ","localname":"Email"},"object":{"value":"tcarr...@azigo.com","language":"http://www.w3.org/2001/XMLSchema#string","_string":"\"tcarr...@azigo.com\"@http://www.w3.org/2001/XMLSchema#string"},"namedGraphUri":{"value":"http://higgins.eclipse.org/pds/mike/root","namespace":"http://higgins.eclipse.org/pds/mike/","localname":"root"},"_dictionaryKey":"{http://higgins.eclipse.org/pds/mike/root#me,http://www.w3.org/2006/vcard/Email, \"tcarr...@azigo.com\"@http://www.w3.org/2001/XMLSchema#string,http://higgins.eclipse.org/pds/mike/root}"}]
> Adding: {"subject":{"value":"http://higgins.eclipse.org/pds/mike/root#me
> ","namespace":"http://higgins.eclipse.org/pds/mike/root#
> ","localname":"me"},"predicate":{"value":"http://www.w3.org/2006/vcard/Email
> ","namespace":"http://www.w3.org/2006/vcard/
> ","localname":"Email"},"object":{"value":"tcarr...@azigo.com","language":"http://www.w3.org/2001/XMLSchema#string","_string":"\"tcarr...@azigo.com\"@http://www.w3.org/2001/XMLSchema#string"},"namedGraphUri":{"value":"http://higgins.eclipse.org/pds/mike/root","namespace":"http://higgins.eclipse.org/pds/mike/","localname":"root"},"_dictionaryKey":"{http://higgins.eclipse.org/pds/mike/root#me,http://www.w3.org/2006/vcard/Email, \"tcarr...@azigo.com\"@http://www.w3.org/2001/XMLSchema#string,http://higgins.eclipse.org/pds/mike/root}"}

Michael McIntosh

unread,
Feb 10, 2011, 8:43:10 PM2/10/11
to OpenAnzo

Michael McIntosh

unread,
Feb 10, 2011, 9:35:02 PM2/10/11
to OpenAnzo
Now that I am leaving myself logged in longer, I find that I can't login simultaneously on multiple tabs/browsers. Is this a known issue?


--
You received this message because you are currently subscribed to the "OpenAnzo" group.

To post to this group, send email to open...@googlegroups.com
To unsubscribe from this group, send email to openanzo-u...@googlegroups.com

For more options, visit this group at http://groups.google.com/group/openanzo?hl=en

Jordi Albornoz Mulligan

unread,
Feb 11, 2011, 12:01:35 PM2/11/11
to open...@googlegroups.com
On 2/10/2011 9:35 PM, Michael McIntosh wrote:
> Now that I am leaving myself logged in longer, I find that I can't login
> simultaneously on multiple tabs/browsers. Is this a known issue?

Hi Michael,

I'm glad you found your issue.

An important part of the Anzo.js API is that is can replicate a graph to
memory and that replica is automatically kept up-to-date when data
changes on the server. The way that the Anzo.js API accomplishes that is
using a COMET technique
(http://en.wikipedia.org/wiki/Comet_%28programming%29). One downside to
that technique is that you can end up hitting the browser-imposed limit
on the number of simultaneous open connections to a single hostname.
Opening multiple tabs or windows of the same browser instance is the
most common way to hit that limit. The limit can range from 2 to 8
depending on browser vendor, version, and settings. There are ways
around that, such as wildcard DNS. A recommended technique, especially
since you mentioned you are working in a browser plugin, is to share a
single connection among tabs, if possible.

Relating to your problem of logging out too early, I have some other advice:

Almost everything that the Anzo.js does is asynchronous so you
definitely have to watch out when you are closing things. There is an
event that might be useful to you:
updateRepositoryComplete

It is fired whenever an updateRepository() operation actually is
finished. If you call updateRepository(), you may want to wait for
updateRepositoryComplete to fire before doing more things.

In the AnzoClient.js file, the comments for the updateRepository method
explain some of how to listen. It says something like:

One can register listeners to the updateRepositoryComplete method by
using dojo's connect method:
var handle = dojo.connect(anzoClient, 'updateRepositoryComplete',
function(success, errors) { <DO SOMETHING> });

Later, to disconnect the event handler you can do:
dojo.disconnect(handle);

The updateRepositoryComplete handler is given the following argument:
success: Boolean
True if update was successful, false otherwise.

errors: The errors object contain raw information about errors that may
have happened during update. This is opaque debugging data mainly.
Rendering as a JSON string is recommended.


On a slightly separate note, in your code I see that you use replicaFind
to look for data and then you add data to a graph using the graph
object's 'add' method (e.g. higgins.userRootGraph.add(currentEMail) ).
Presumably, userRootGraph was obtained using the getReplicaGraph method.
If so, then you can get the same effect as replicaFind by just calling
userRootGraph.find(). If you use the find method on the graph, you can
omit the last parameter (the namedGraphUri) since the named graph URI is
implicit from the fact that you are calling find on that graph. The
results will be limited to data inside that graph. The only reason to
use replicaFind is if you need to search across more than one graph.

Also, I notice that you often create a statement object using a call to
anzo.createStatement and then pass that directly to an 'add' method.
That is fine but you the 'add' method has another form that can save you
that step. You can just do:


var longitudeLiteral = anzo.createLiteral(coords.longitude,
"http://www.w3.org/2001/XMLSchema#string");

higgins.userRootGraph.add(higgins.userRootPersonURI,
higgins.vLongitudeURI, currentLatitude);

Notice the form of add that just takes the subject, predicate, and
object as separate arguments. The fourth part of the statement, the
named graph uri, is implicit because you are calling 'add' on a graph.
So that graph's uri will be used as the named graph uri for the added
statement.

Hope that helps.

> On Thu, Feb 10, 2011 at 8:43 PM, Michael McIntosh
> <mike.g....@gmail.com <mailto:mike.g....@gmail.com>> wrote:
>
> Nevermind - it looks like I logged out too early.
>
> On Feb 10, 6:42 pm, Michael McIntosh <mmcint...@acm.org

> <mailto:tcarr...@azigo.com>","language":"http://www.w3.org/2001/XMLSchema#string","_string":"\"tcarr...@azigo.com
> <mailto:tcarr...@azigo.com>\"@http://www.w3.org/2001/XMLSchema#string"},"namedGraphUri":{"value":"http://higgins.eclipse.org/pds/mike/root","namespace":"http://higgins.eclipse.org/pds/mike/","localname":"root"},"_dictionaryKey":"{http://higgins.eclipse.org/pds/mike/root#me,http://www.w3.org/2006/vcard/Email,
> \"tcarr...@azigo.com
> <mailto:tcarr...@azigo.com>\"@http://www.w3.org/2001/XMLSchema#string,http://higgins.eclipse.org/pds/mike/root}"}]


> > Adding:
> {"subject":{"value":"http://higgins.eclipse.org/pds/mike/root#me
> > ","namespace":"http://higgins.eclipse.org/pds/mike/root#
> >
> ","localname":"me"},"predicate":{"value":"http://www.w3.org/2006/vcard/Email
> > ","namespace":"http://www.w3.org/2006/vcard/
> > ","localname":"Email"},"object":{"value":"tcarr...@azigo.com

> <mailto:tcarr...@azigo.com>","language":"http://www.w3.org/2001/XMLSchema#string","_string":"\"tcarr...@azigo.com
> <mailto:tcarr...@azigo.com>\"@http://www.w3.org/2001/XMLSchema#string"},"namedGraphUri":{"value":"http://higgins.eclipse.org/pds/mike/root","namespace":"http://higgins.eclipse.org/pds/mike/","localname":"root"},"_dictionaryKey":"{http://higgins.eclipse.org/pds/mike/root#me,http://www.w3.org/2006/vcard/Email,
> \"tcarr...@azigo.com
> <mailto:tcarr...@azigo.com>\"@http://www.w3.org/2001/XMLSchema#string,http://higgins.eclipse.org/pds/mike/root}"}


> >
> > The console log for the sequence that works incorrectly contains:
> > Adding:
> {"subject":{"value":"http://higgins.eclipse.org/pds/mike/root#me
> > ","namespace":"http://higgins.eclipse.org/pds/mike/root#
> >
> ","localname":"me"},"predicate":{"value":"http://www.w3.org/2006/vcard/latitude","namespace":"http://www.w3.org/2006/vcard/
> >
> ","localname":"latitude"},"object":{"value":"40.858432","language":"http://www.w3.org/2001/XMLSchema#string","_string":"\"40.858432\"@http://www.w3.org/2001/XMLSchema#string"},"namedGraphUri":{"value":"http://higgins.eclipse.org/pds/mike/root","namespace":"http://higgins.eclipse.org/pds/mike/","localname":"root"}}
> > Adding:
> {"subject":{"value":"http://higgins.eclipse.org/pds/mike/root#me
> > ","namespace":"http://higgins.eclipse.org/pds/mike/root#
> >
> ","localname":"me"},"predicate":{"value":"http://www.w3.org/2006/vcard/longitude","namespace":"http://www.w3.org/2006/vcard/
> >
> ","localname":"longitude"},"object":{"value":"-74.163755","language":"http://www.w3.org/2001/XMLSchema#string","_string":"\"-74.163755\"@http://www.w3.org/2001/XMLSchema#string"},"namedGraphUri":{"value":"http://higgins.eclipse.org/pds/mike/root","namespace":"http://higgins.eclipse.org/pds/mike/","localname":"root"}}
> >
> > The major difference between the two is that the statements that
> don't
> > persist are missing the _dictionaryKey element.
> >
> > Can anyone provide some guidance on why this is happening?
> >
> > Regards,
> > Mike
>
> --
> You received this message because you are currently subscribed to
> the "OpenAnzo" group.
>
> To post to this group, send email to open...@googlegroups.com

> <mailto:open...@googlegroups.com>


> To unsubscribe from this group, send email to
> openanzo-u...@googlegroups.com

> <mailto:openanzo-u...@googlegroups.com>


>
> For more options, visit this group at
> http://groups.google.com/group/openanzo?hl=en
>
>
> --
> You received this message because you are currently subscribed to the
> "OpenAnzo" group.
>
> To post to this group, send email to open...@googlegroups.com
> To unsubscribe from this group, send email to
> openanzo-u...@googlegroups.com
>
> For more options, visit this group at
> http://groups.google.com/group/openanzo?hl=en


--
Jordi Albornoz Mulligan
Founding Engineer - Cambridge Semantics
jo...@cambridgesemantics.com
(617) 401-7321

Reply all
Reply to author
Forward
0 new messages