You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Rohit Yadav <bh...@apache.org> on 2013/02/11 10:42:36 UTC

100 brownie points :P

Riddles in codebase: see SerialVersionUID in cloud-utils, git blame
and claim your 100 brownie points.
Will post my four liner python solution after the designated 72 hours :P

public interface SerialVersionUID {
    public static final long Base = 0x564D4F70 << 32;  // 100 brownie
points if you guess what this is and tell me.

Have fun!

RE: 100 brownie points :P

Posted by Donal Lafferty <do...@citrix.com>.
+1

> but you just never know what people
> would do.
> 
> --Alex
> 

RE: 100 brownie points :P

Posted by Alex Huang <Al...@citrix.com>.
Anything that's serializable should do it because you just can't don't know when someone will serialize a serializable object.

This class is a result of my problems with serializable before.

- You get presented with a serialized data and you have no idea what it is because the id is randomly generated.
- Upgrade or switch jvms and the ids get generated a different way and you can de-serialize the objects any more.

Largely, it no longer matters in CloudStack because we pretty much use xml or json as the serializing method now but you just never know what people would do.

--Alex

> -----Original Message-----
> From: rohityadav89@gmail.com [mailto:rohityadav89@gmail.com] On Behalf
> Of Rohit Yadav
> Sent: Monday, February 11, 2013 9:04 AM
> To: Nitin Mehta
> Cc: Donal Lafferty; cloudstack-dev@incubator.apache.org
> Subject: Re: 100 brownie points :P
> 
> Cool, thanks for the link.
> 
> Regards.
> 
> On Mon, Feb 11, 2013 at 7:42 PM, Nitin Mehta <Ni...@citrix.com>
> wrote:
> > I think the reason is that the exception class where these are used
> > implement the Serializable interface.
> >
> > The purpose of the serialization version UID is to keep track of different
> > versions of a class in order to perform valid serialization of objects.
> > The idea is to generate an ID that is unique to a certain version of an
> > class, which is then changed when there are new details added to the
> > class, such as a new field, which would affect the structure of the
> > serialized object. Best to read the link below.
> >
> >
> > http://stackoverflow.com/questions/285793/what-is-a-serialversionuid-
> and-wh
> > y-should-i-use-it
> >
> >
> > Having said that I do not feel we needed to do this because we are not
> > serializing the exception objects. Also not very sure why we needed to
> > start from such a big number as base ?
> >
> >
> > Thanks,
> > -Nitin
> >
> > On 11/02/13 6:24 PM, "Rohit Yadav" <bh...@apache.org> wrote:
> >
> >>On Mon, Feb 11, 2013 at 4:55 PM, Donal Lafferty
> >><do...@citrix.com> wrote:
> >>> "VMOp"
> >>>
> >>> I'll give half my points to whoever explains 'what it is used for' as
> >>>opposed to 'what this is' :)
> >>
> >>Kudos, if you found this on your own :)
> >>
> >>So, if you try to understand the code, we're just trying to create
> >>unique values for different variables and we chose a number and bit
> >>shift to 32 fields to get the BASE a random (not so random :) long int
> >>that can be OR-ed with incremental numbers, so we can have upto 2^32
> >>unique numbers in the range of BASE, they could also have used any
> >>whole number starting 1.
> >>I don't think there could be any other reason :)
> >>
> >>Regards.
> >>
> >>>
> >>>> -----Original Message-----
> >>>> From: rohityadav89@gmail.com [mailto:rohityadav89@gmail.com] On
> Behalf
> >>>> Of Rohit Yadav
> >>>> Sent: 11 February 2013 09:43
> >>>> To: cloudstack-dev@incubator.apache.org
> >>>> Subject: 100 brownie points :P
> >>>>
> >>>> Riddles in codebase: see SerialVersionUID in cloud-utils, git blame
> >>>>and claim
> >>>> your 100 brownie points.
> >>>> Will post my four liner python solution after the designated 72 hours
> >>>>:P
> >>>>
> >>>> public interface SerialVersionUID {
> >>>>     public static final long Base = 0x564D4F70 << 32;  // 100 brownie
> >>>>points if
> >>>> you guess what this is and tell me.
> >>>>
> >>>> Have fun!
> >

Re: 100 brownie points :P

Posted by Rohit Yadav <bh...@apache.org>.
Cool, thanks for the link.

Regards.

On Mon, Feb 11, 2013 at 7:42 PM, Nitin Mehta <Ni...@citrix.com> wrote:
> I think the reason is that the exception class where these are used
> implement the Serializable interface.
>
> The purpose of the serialization version UID is to keep track of different
> versions of a class in order to perform valid serialization of objects.
> The idea is to generate an ID that is unique to a certain version of an
> class, which is then changed when there are new details added to the
> class, such as a new field, which would affect the structure of the
> serialized object. Best to read the link below.
>
>
> http://stackoverflow.com/questions/285793/what-is-a-serialversionuid-and-wh
> y-should-i-use-it
>
>
> Having said that I do not feel we needed to do this because we are not
> serializing the exception objects. Also not very sure why we needed to
> start from such a big number as base ?
>
>
> Thanks,
> -Nitin
>
> On 11/02/13 6:24 PM, "Rohit Yadav" <bh...@apache.org> wrote:
>
>>On Mon, Feb 11, 2013 at 4:55 PM, Donal Lafferty
>><do...@citrix.com> wrote:
>>> "VMOp"
>>>
>>> I'll give half my points to whoever explains 'what it is used for' as
>>>opposed to 'what this is' :)
>>
>>Kudos, if you found this on your own :)
>>
>>So, if you try to understand the code, we're just trying to create
>>unique values for different variables and we chose a number and bit
>>shift to 32 fields to get the BASE a random (not so random :) long int
>>that can be OR-ed with incremental numbers, so we can have upto 2^32
>>unique numbers in the range of BASE, they could also have used any
>>whole number starting 1.
>>I don't think there could be any other reason :)
>>
>>Regards.
>>
>>>
>>>> -----Original Message-----
>>>> From: rohityadav89@gmail.com [mailto:rohityadav89@gmail.com] On Behalf
>>>> Of Rohit Yadav
>>>> Sent: 11 February 2013 09:43
>>>> To: cloudstack-dev@incubator.apache.org
>>>> Subject: 100 brownie points :P
>>>>
>>>> Riddles in codebase: see SerialVersionUID in cloud-utils, git blame
>>>>and claim
>>>> your 100 brownie points.
>>>> Will post my four liner python solution after the designated 72 hours
>>>>:P
>>>>
>>>> public interface SerialVersionUID {
>>>>     public static final long Base = 0x564D4F70 << 32;  // 100 brownie
>>>>points if
>>>> you guess what this is and tell me.
>>>>
>>>> Have fun!
>

Re: 100 brownie points :P

Posted by Nitin Mehta <Ni...@citrix.com>.
I think the reason is that the exception class where these are used
implement the Serializable interface.

The purpose of the serialization version UID is to keep track of different
versions of a class in order to perform valid serialization of objects.
The idea is to generate an ID that is unique to a certain version of an
class, which is then changed when there are new details added to the
class, such as a new field, which would affect the structure of the
serialized object. Best to read the link below.


http://stackoverflow.com/questions/285793/what-is-a-serialversionuid-and-wh
y-should-i-use-it 


Having said that I do not feel we needed to do this because we are not
serializing the exception objects. Also not very sure why we needed to
start from such a big number as base ?


Thanks,
-Nitin

On 11/02/13 6:24 PM, "Rohit Yadav" <bh...@apache.org> wrote:

>On Mon, Feb 11, 2013 at 4:55 PM, Donal Lafferty
><do...@citrix.com> wrote:
>> "VMOp"
>>
>> I'll give half my points to whoever explains 'what it is used for' as
>>opposed to 'what this is' :)
>
>Kudos, if you found this on your own :)
>
>So, if you try to understand the code, we're just trying to create
>unique values for different variables and we chose a number and bit
>shift to 32 fields to get the BASE a random (not so random :) long int
>that can be OR-ed with incremental numbers, so we can have upto 2^32
>unique numbers in the range of BASE, they could also have used any
>whole number starting 1.
>I don't think there could be any other reason :)
>
>Regards.
>
>>
>>> -----Original Message-----
>>> From: rohityadav89@gmail.com [mailto:rohityadav89@gmail.com] On Behalf
>>> Of Rohit Yadav
>>> Sent: 11 February 2013 09:43
>>> To: cloudstack-dev@incubator.apache.org
>>> Subject: 100 brownie points :P
>>>
>>> Riddles in codebase: see SerialVersionUID in cloud-utils, git blame
>>>and claim
>>> your 100 brownie points.
>>> Will post my four liner python solution after the designated 72 hours
>>>:P
>>>
>>> public interface SerialVersionUID {
>>>     public static final long Base = 0x564D4F70 << 32;  // 100 brownie
>>>points if
>>> you guess what this is and tell me.
>>>
>>> Have fun!


Re: 100 brownie points :P

Posted by Rohit Yadav <bh...@apache.org>.
On Mon, Feb 11, 2013 at 4:55 PM, Donal Lafferty
<do...@citrix.com> wrote:
> "VMOp"
>
> I'll give half my points to whoever explains 'what it is used for' as opposed to 'what this is' :)

Kudos, if you found this on your own :)

So, if you try to understand the code, we're just trying to create
unique values for different variables and we chose a number and bit
shift to 32 fields to get the BASE a random (not so random :) long int
that can be OR-ed with incremental numbers, so we can have upto 2^32
unique numbers in the range of BASE, they could also have used any
whole number starting 1.
I don't think there could be any other reason :)

Regards.

>
>> -----Original Message-----
>> From: rohityadav89@gmail.com [mailto:rohityadav89@gmail.com] On Behalf
>> Of Rohit Yadav
>> Sent: 11 February 2013 09:43
>> To: cloudstack-dev@incubator.apache.org
>> Subject: 100 brownie points :P
>>
>> Riddles in codebase: see SerialVersionUID in cloud-utils, git blame and claim
>> your 100 brownie points.
>> Will post my four liner python solution after the designated 72 hours :P
>>
>> public interface SerialVersionUID {
>>     public static final long Base = 0x564D4F70 << 32;  // 100 brownie points if
>> you guess what this is and tell me.
>>
>> Have fun!

RE: 100 brownie points :P

Posted by Donal Lafferty <do...@citrix.com>.
"VMOp"

I'll give half my points to whoever explains 'what it is used for' as opposed to 'what this is' :)

> -----Original Message-----
> From: rohityadav89@gmail.com [mailto:rohityadav89@gmail.com] On Behalf
> Of Rohit Yadav
> Sent: 11 February 2013 09:43
> To: cloudstack-dev@incubator.apache.org
> Subject: 100 brownie points :P
> 
> Riddles in codebase: see SerialVersionUID in cloud-utils, git blame and claim
> your 100 brownie points.
> Will post my four liner python solution after the designated 72 hours :P
> 
> public interface SerialVersionUID {
>     public static final long Base = 0x564D4F70 << 32;  // 100 brownie points if
> you guess what this is and tell me.
> 
> Have fun!