-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serialisation fails when handling a single ContextProvider #7
Comments
I have been debugging and it seems to be caused by, for some reason, the ContextEventPattern to be serialized as part of the provider has rdf:type null. I still don't know why or how a ContextEventPattern could be of type null. It may be a problem in the class, or the ontology definition, or the way the serializer works to specialize it. I was wondering if it could be related to using an empty CEP, which is what I use in my test, but I see yours does contain something. |
I think you discovered something I marked as "potential bug", see issue M8 (although I didn't think it would materialize into an Exception..). Do you really need to serialize the ContextProvider and not the ContextEventPattern (as opposed to ServiceProfile)? Because the serialization of patterns works.. There is a quick workaround for this case: go to class ContextProvider and change the method getPropSerializationType to always return PROP_SERIALIZATION_FULL. This should fix the concrete issue, although it does not solve the general problem, i.e. the definition and handling of serialization type. Thus, this problem may occur again for a different class (other than ContextProvider). Help from Saied is needed to clarify, e.g., what exactly "reduced form" means.. very small things:
|
Thanks for the effort and the tips. on the second one, my intention is to go with junit removing bus.junit, and if you test it, the second test (creating the context event) fails because : @saiedt : please look into this issue when possible. |
I had forgotten about all that "serialization type" thing, since I almost always use FULL. |
@amedranogil : I just committed a fix for the bus test case to avoid the SecurityException (not the most elegant way, but sufficient for tests) @Alfiva : there is no serialization if the communication is within the same node. The serializer has no notion about where a message goes to or where it comes from (and serialization can also occur in different contexts other than bus communication). There are 4 options: undefined, optional, reduce, and full. For me, this is not clear.
I can see the benefit of this method, i.e. some properties are normally not needed for the typical usage of the middleware. Thus, the ContextProvider normally does not need to be fully serialized and getPropSerializationType should not return full. However, it should be possible to overwrite this somehow to allow for different UCs as it is now needed by @amedranogil . My idea (see M7) was to change the serializer interface by adding options (e.g. as Dictionary): But to make these mods, the meaning of serialization type must be clearly defined. |
Just realized what Serialization_Optional is for! This is for information that is represented in the ontology itself, so for example there shouldn't be any need to serialize enumeration instances; as these would be recognised by the remote peer when it has the same ontology installed. This means that there should be some type of protocol to know whether the serialization is needed. |
According to Resource.getPropSerializationType() javadoc:
Thus, PROP_SERIALIZATION_OPTIONAL seems like it is ignored by default, assuming serialisation is used to transmit information to another node. There should be another logic which changes whether the property is serialised or not; some examples above (a switch to serialise all optionals, or a list of known ontologies on the remote side). On the other side, Resource.PROP_SERIALIZATION_OPTIONAL Java doc says:
If "in a minimized way" is referring to PROP_SERIALIZATION_REDUCED, then this means that PROP_SERIALIZATION_OPTIONAL should only be considered in the context when serialising in reduced form (which means that all references to a resource have PROP_SERIALIZATION_REDUCED as PropSerializationType Or it is whithin a subtree of a reduced resource). This behaviour, although more complex, seems smarter for default behaviour. |
Two additional points:
|
While creating serialisation examples for REST users we need to serialise ContextProviders (as well as ServiceProfiles, ContextEvents, and ServiceCalls; although these seem to be fine).
take this example:
https://github.com/City4AgeProject/pilot-madrid/blob/master/city4age.madrid.ont/src/test/java/org/universAAL/ontology/test/SerializationTest.java
when executing testContextEvent() the produced error is:
java.lang.NullPointerException: null at org.universAAL.middleware.serialization.turtle.TurtleWriter.writeValue(TurtleWriter.java:989) at org.universAAL.middleware.serialization.turtle.TurtleWriter.handleStatement(TurtleWriter.java:540) at org.universAAL.middleware.serialization.turtle.TurtleWriter.handleResourceProps(TurtleWriter.java:511) at org.universAAL.middleware.serialization.turtle.TurtleWriter.writeResource(TurtleWriter.java:836) at org.universAAL.middleware.serialization.turtle.TurtleWriter.writeValue(TurtleWriter.java:928) at org.universAAL.middleware.serialization.turtle.TurtleWriter.writeValue(TurtleWriter.java:894) at org.universAAL.middleware.serialization.turtle.TurtleWriter.handleStatement(TurtleWriter.java:540) at org.universAAL.middleware.serialization.turtle.TurtleWriter.handleResourceProps(TurtleWriter.java:511) at org.universAAL.middleware.serialization.turtle.TurtleWriter.writeResource(TurtleWriter.java:800) at org.universAAL.middleware.serialization.turtle.TurtleWriter.serialize(TurtleWriter.java:649) at org.universAAL.middleware.serialization.turtle.TurtleWriter.serialize(TurtleWriter.java:178) at org.universAAL.middleware.serialization.turtle.TurtleSerializer.serialize(TurtleSerializer.java:52) at org.universAAL.ontology.test.SerializationTest.testContextProvider(SerializationTest.java:68)
The text was updated successfully, but these errors were encountered: