All of lore.kernel.org
 help / color / mirror / Atom feed
* Integers as String in osd_metadata (memory, rotational)
@ 2017-11-28 11:06 Wido den Hollander
  2017-11-28 11:53 ` John Spray
  0 siblings, 1 reply; 3+ messages in thread
From: Wido den Hollander @ 2017-11-28 11:06 UTC (permalink / raw)
  To: ceph-devel

Hi,

Looking at 'ceph osd metadata' I see that we return a lot of values as Strings in the JSON instead of a Integer, for example:

$ ceph osd metadata 2033

{
    "id": 2033,
    "arch": "x86_64",
    "journal_rotational": "0",
    "mem_swap_kb": "1046524",
    "mem_total_kb": "63641808",
    "rotational": "1"
}

Looking at some code I found this:

(*m)["mem_total_kb"] = std::to_string(size);
(*pm)["rotational"] = store_is_rotational ? "1" : "0";
(*pm)["journal_rotational"] = journal_is_rotational ? "1" : "0";

Why can't we return a int/long there? Is it the internal JSON parser which can't handle it?

Otherwise I'll write a PR for this. Saves me casting the things to Integers again afterwards in Python.

Wido

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Integers as String in osd_metadata (memory, rotational)
  2017-11-28 11:06 Integers as String in osd_metadata (memory, rotational) Wido den Hollander
@ 2017-11-28 11:53 ` John Spray
  2017-12-01  9:35   ` Wido den Hollander
  0 siblings, 1 reply; 3+ messages in thread
From: John Spray @ 2017-11-28 11:53 UTC (permalink / raw)
  To: Wido den Hollander; +Cc: ceph-devel

On Tue, Nov 28, 2017 at 11:06 AM, Wido den Hollander <wido@42on.com> wrote:
> Hi,
>
> Looking at 'ceph osd metadata' I see that we return a lot of values as Strings in the JSON instead of a Integer, for example:
>
> $ ceph osd metadata 2033
>
> {
>     "id": 2033,
>     "arch": "x86_64",
>     "journal_rotational": "0",
>     "mem_swap_kb": "1046524",
>     "mem_total_kb": "63641808",
>     "rotational": "1"
> }
>
> Looking at some code I found this:
>
> (*m)["mem_total_kb"] = std::to_string(size);
> (*pm)["rotational"] = store_is_rotational ? "1" : "0";
> (*pm)["journal_rotational"] = journal_is_rotational ? "1" : "0";
>
> Why can't we return a int/long there? Is it the internal JSON parser which can't handle it?

There are various places where we send metadata as map<string, string>
(in this instance, MOSDBoot), which is indeed kind of annoying --
converting them all to a JSON-ish structure would be a good thing.

I'm imagining a helper class that wraps boost::property_tree and slots
in everywhere we currently use map<string, string> for metadata.

John

> Otherwise I'll write a PR for this. Saves me casting the things to Integers again afterwards in Python.
>
> Wido
> --
> To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Integers as String in osd_metadata (memory, rotational)
  2017-11-28 11:53 ` John Spray
@ 2017-12-01  9:35   ` Wido den Hollander
  0 siblings, 0 replies; 3+ messages in thread
From: Wido den Hollander @ 2017-12-01  9:35 UTC (permalink / raw)
  To: John Spray; +Cc: ceph-devel


> Op 28 november 2017 om 12:53 schreef John Spray <jspray@redhat.com>:
> 
> 
> On Tue, Nov 28, 2017 at 11:06 AM, Wido den Hollander <wido@42on.com> wrote:
> > Hi,
> >
> > Looking at 'ceph osd metadata' I see that we return a lot of values as Strings in the JSON instead of a Integer, for example:
> >
> > $ ceph osd metadata 2033
> >
> > {
> >     "id": 2033,
> >     "arch": "x86_64",
> >     "journal_rotational": "0",
> >     "mem_swap_kb": "1046524",
> >     "mem_total_kb": "63641808",
> >     "rotational": "1"
> > }
> >
> > Looking at some code I found this:
> >
> > (*m)["mem_total_kb"] = std::to_string(size);
> > (*pm)["rotational"] = store_is_rotational ? "1" : "0";
> > (*pm)["journal_rotational"] = journal_is_rotational ? "1" : "0";
> >
> > Why can't we return a int/long there? Is it the internal JSON parser which can't handle it?
> 
> There are various places where we send metadata as map<string, string>
> (in this instance, MOSDBoot), which is indeed kind of annoying --
> converting them all to a JSON-ish structure would be a good thing.
> 

Yes, or at least have a difference between int and string.

> I'm imagining a helper class that wraps boost::property_tree and slots
> in everywhere we currently use map<string, string> for metadata.
> 

That is slightly out of my comfort zone. I wouldn't know where to start :-)

Wido

> John
> 
> > Otherwise I'll write a PR for this. Saves me casting the things to Integers again afterwards in Python.
> >
> > Wido
> > --
> > To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-12-01  9:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-28 11:06 Integers as String in osd_metadata (memory, rotational) Wido den Hollander
2017-11-28 11:53 ` John Spray
2017-12-01  9:35   ` Wido den Hollander

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.