You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kudu.apache.org by Mike Percy <mp...@cloudera.com> on 2016/03/25 19:54:39 UTC

Kudu client error codes

So I am looking at the way the error codes are propagated in the Java
client and we don't currently have something approximating what is in the
C++ code for the Status object.

C++ Status class:
https://github.com/apache/incubator-kudu/blob/master/src/kudu/util/status.h
Java RowError class:
https://github.com/apache/incubator-kudu/blob/master/java/kudu-client/src/main/java/org/kududb/client/RowError.java

This means that people who want to do specific error handling for things
like rows that are always present need to write something like this:

      List<OperationResponse> responses = session.flush();
      for (OperationResponse r : responses) {
        if (r.getStatus().equals("ALREADY_PRESENT")) {
          // Handle already present case...
        } else if (...) {
          // etc.
        }
      }

Hard-coding string values is unfortunate and error prone so I think we can
do better. It turns out that the values are already encoded in a protobuf @
https://github.com/apache/incubator-kudu/blob/master/src/kudu/common/wire_protocol.proto
so possibly the best approach would be to codegen a Java Status class from
the AppStatusPB somehow. Thoughts?

--
Mike Percy
Software Engineer, Cloudera

Re: Kudu client error codes

Posted by Mike Percy <mp...@cloudera.com>.
I just posted http://gerrit.cloudera.org:8080/2640

--
Mike Percy
Software Engineer, Cloudera

On Fri, Mar 25, 2016 at 2:40 PM, Jean-Daniel Cryans <jd...@apache.org>
wrote:

> Also there's https://issues.apache.org/jira/browse/KUDU-839.
>
> On Fri, Mar 25, 2016 at 2:38 PM, Mike Percy <mp...@cloudera.com> wrote:
>
> > OK, that's reasonable. I'm going to write one.
> >
> > --
> > Mike Percy
> > Software Engineer, Cloudera
> >
> > On Fri, Mar 25, 2016 at 12:14 PM, Adar Dembo <ad...@cloudera.com> wrote:
> >
> > > We don't autogenerate the C++ Status class, so I think a minimally
> viable
> > > Java implementation could be hand-written too, manually updated when a
> > new
> > > code is added. It's annoying but it's not the end of the world; error
> > codes
> > > are rarely added.
> > >
> > >
> > > On Fri, Mar 25, 2016 at 11:54 AM, Mike Percy <mp...@cloudera.com>
> > wrote:
> > >
> > > > So I am looking at the way the error codes are propagated in the Java
> > > > client and we don't currently have something approximating what is in
> > the
> > > > C++ code for the Status object.
> > > >
> > > > C++ Status class:
> > > >
> > >
> >
> https://github.com/apache/incubator-kudu/blob/master/src/kudu/util/status.h
> > > > Java RowError class:
> > > >
> > > >
> > >
> >
> https://github.com/apache/incubator-kudu/blob/master/java/kudu-client/src/main/java/org/kududb/client/RowError.java
> > > >
> > > > This means that people who want to do specific error handling for
> > things
> > > > like rows that are always present need to write something like this:
> > > >
> > > >       List<OperationResponse> responses = session.flush();
> > > >       for (OperationResponse r : responses) {
> > > >         if (r.getStatus().equals("ALREADY_PRESENT")) {
> > > >           // Handle already present case...
> > > >         } else if (...) {
> > > >           // etc.
> > > >         }
> > > >       }
> > > >
> > > > Hard-coding string values is unfortunate and error prone so I think
> we
> > > can
> > > > do better. It turns out that the values are already encoded in a
> > > protobuf @
> > > >
> > > >
> > >
> >
> https://github.com/apache/incubator-kudu/blob/master/src/kudu/common/wire_protocol.proto
> > > > so possibly the best approach would be to codegen a Java Status class
> > > from
> > > > the AppStatusPB somehow. Thoughts?
> > > >
> > > > --
> > > > Mike Percy
> > > > Software Engineer, Cloudera
> > > >
> > >
> >
>

Re: Kudu client error codes

Posted by Jean-Daniel Cryans <jd...@apache.org>.
Also there's https://issues.apache.org/jira/browse/KUDU-839.

On Fri, Mar 25, 2016 at 2:38 PM, Mike Percy <mp...@cloudera.com> wrote:

> OK, that's reasonable. I'm going to write one.
>
> --
> Mike Percy
> Software Engineer, Cloudera
>
> On Fri, Mar 25, 2016 at 12:14 PM, Adar Dembo <ad...@cloudera.com> wrote:
>
> > We don't autogenerate the C++ Status class, so I think a minimally viable
> > Java implementation could be hand-written too, manually updated when a
> new
> > code is added. It's annoying but it's not the end of the world; error
> codes
> > are rarely added.
> >
> >
> > On Fri, Mar 25, 2016 at 11:54 AM, Mike Percy <mp...@cloudera.com>
> wrote:
> >
> > > So I am looking at the way the error codes are propagated in the Java
> > > client and we don't currently have something approximating what is in
> the
> > > C++ code for the Status object.
> > >
> > > C++ Status class:
> > >
> >
> https://github.com/apache/incubator-kudu/blob/master/src/kudu/util/status.h
> > > Java RowError class:
> > >
> > >
> >
> https://github.com/apache/incubator-kudu/blob/master/java/kudu-client/src/main/java/org/kududb/client/RowError.java
> > >
> > > This means that people who want to do specific error handling for
> things
> > > like rows that are always present need to write something like this:
> > >
> > >       List<OperationResponse> responses = session.flush();
> > >       for (OperationResponse r : responses) {
> > >         if (r.getStatus().equals("ALREADY_PRESENT")) {
> > >           // Handle already present case...
> > >         } else if (...) {
> > >           // etc.
> > >         }
> > >       }
> > >
> > > Hard-coding string values is unfortunate and error prone so I think we
> > can
> > > do better. It turns out that the values are already encoded in a
> > protobuf @
> > >
> > >
> >
> https://github.com/apache/incubator-kudu/blob/master/src/kudu/common/wire_protocol.proto
> > > so possibly the best approach would be to codegen a Java Status class
> > from
> > > the AppStatusPB somehow. Thoughts?
> > >
> > > --
> > > Mike Percy
> > > Software Engineer, Cloudera
> > >
> >
>

Re: Kudu client error codes

Posted by Mike Percy <mp...@cloudera.com>.
OK, that's reasonable. I'm going to write one.

--
Mike Percy
Software Engineer, Cloudera

On Fri, Mar 25, 2016 at 12:14 PM, Adar Dembo <ad...@cloudera.com> wrote:

> We don't autogenerate the C++ Status class, so I think a minimally viable
> Java implementation could be hand-written too, manually updated when a new
> code is added. It's annoying but it's not the end of the world; error codes
> are rarely added.
>
>
> On Fri, Mar 25, 2016 at 11:54 AM, Mike Percy <mp...@cloudera.com> wrote:
>
> > So I am looking at the way the error codes are propagated in the Java
> > client and we don't currently have something approximating what is in the
> > C++ code for the Status object.
> >
> > C++ Status class:
> >
> https://github.com/apache/incubator-kudu/blob/master/src/kudu/util/status.h
> > Java RowError class:
> >
> >
> https://github.com/apache/incubator-kudu/blob/master/java/kudu-client/src/main/java/org/kududb/client/RowError.java
> >
> > This means that people who want to do specific error handling for things
> > like rows that are always present need to write something like this:
> >
> >       List<OperationResponse> responses = session.flush();
> >       for (OperationResponse r : responses) {
> >         if (r.getStatus().equals("ALREADY_PRESENT")) {
> >           // Handle already present case...
> >         } else if (...) {
> >           // etc.
> >         }
> >       }
> >
> > Hard-coding string values is unfortunate and error prone so I think we
> can
> > do better. It turns out that the values are already encoded in a
> protobuf @
> >
> >
> https://github.com/apache/incubator-kudu/blob/master/src/kudu/common/wire_protocol.proto
> > so possibly the best approach would be to codegen a Java Status class
> from
> > the AppStatusPB somehow. Thoughts?
> >
> > --
> > Mike Percy
> > Software Engineer, Cloudera
> >
>

Re: Kudu client error codes

Posted by Adar Dembo <ad...@cloudera.com>.
We don't autogenerate the C++ Status class, so I think a minimally viable
Java implementation could be hand-written too, manually updated when a new
code is added. It's annoying but it's not the end of the world; error codes
are rarely added.


On Fri, Mar 25, 2016 at 11:54 AM, Mike Percy <mp...@cloudera.com> wrote:

> So I am looking at the way the error codes are propagated in the Java
> client and we don't currently have something approximating what is in the
> C++ code for the Status object.
>
> C++ Status class:
> https://github.com/apache/incubator-kudu/blob/master/src/kudu/util/status.h
> Java RowError class:
>
> https://github.com/apache/incubator-kudu/blob/master/java/kudu-client/src/main/java/org/kududb/client/RowError.java
>
> This means that people who want to do specific error handling for things
> like rows that are always present need to write something like this:
>
>       List<OperationResponse> responses = session.flush();
>       for (OperationResponse r : responses) {
>         if (r.getStatus().equals("ALREADY_PRESENT")) {
>           // Handle already present case...
>         } else if (...) {
>           // etc.
>         }
>       }
>
> Hard-coding string values is unfortunate and error prone so I think we can
> do better. It turns out that the values are already encoded in a protobuf @
>
> https://github.com/apache/incubator-kudu/blob/master/src/kudu/common/wire_protocol.proto
> so possibly the best approach would be to codegen a Java Status class from
> the AppStatusPB somehow. Thoughts?
>
> --
> Mike Percy
> Software Engineer, Cloudera
>