2 Replies Latest reply: Apr 19, 2013 3:28 AM by Jonathan.Knight RSS

    Unique request identifier

      I'm looking for a mechanism to uniquely identify given request in the cluster. The purpose of having unique request identifier is to included it in every log record. It would facilitate troubleshooting and I'd be able to reconstruct the flow related to any given request.

      My first idea was to override methods in NamedCache implementation on the load balancing node (proxy). I would be able to generate an identifier and wrap key into a custom object holding original key and request identifier. It seems quite complex from the perspective of "unwrapping" key object before updating the backing map.
      Has anyone had a similar issue or do you have an idea how to approach it in Coherence?

      Thank you.
        • 1. Re: Unique request identifier
          I am assuming you need a unique id across the cluster, take a look at the coherence incubator, i believe that in the commons they have added something like a sequence generator which is unique across the cluster.

          Thanks a lot,
          Carlos Curotto.
          • 2. Re: Unique request identifier

            The Incubator sequence number generator will not do what you want - it is just for generating sequences, which is not your main issue.

            First the important bit - You should not mess with the keys of entries If you mutated the key of an entry (e.g. by adding a UID on the proxy) then that mutated key would be the key used in the cache. If you tried to do a get() then you would need to use the exact same key again with the exact same unique ID as the first time. Keys are the serialized binary representaion of the Java object so would include anything extra you add such as a UID.

            Out of the box there is not a way of passing a UID all the way through to the storage nodes for "normal" cache operations. You can pass tokens from an Extend client to a Proxy using the Security API, but these are lost after the Proxy. The only way to reliably pass a UID is to not use normal cache operations and use EnteryProcessors or Aggregators for everything instead of plain get() and put(). As the EntryProcessor or Aggregator is your own code you can add whatever UIDs and logging you want to them and they get passed through to the storage nodes. This is what we do in the parts of our system we want to track.