[ovirt-devel] Change in ovirt-engine[master]: restapi: NUMA feature restful API support

Juan Hernandez juan.hernandez at redhat.com
Tue May 6 09:28:57 UTC 2014


On 05/01/2014 06:30 PM, Liao, Chuan (Jason Liao, HPservers-Core-OE-PSC)
wrote:
> Hi Juan, 
> 
> Thanks for your reply. I try to add them to interface, seems that we still meet some problem:
> 
> Call restful API: api/hosts/e225422a-aeab-453e-b7ac-56c9f5ce378c/numanodes
> 
> Error occur:
> java.lang.NullPointerException
> 	org.ovirt.engine.api.restapi.resource.AbstractBackendResource.linkSubCollections(AbstractBackendResource.java:264)
> 	org.ovirt.engine.api.restapi.resource.AbstractBackendResource.addLinks(AbstractBackendResource.java:206)
> 	org.ovirt.engine.api.restapi.resource.AbstractBackendResource.addLinks(AbstractBackendResource.java:196)
> 	org.ovirt.engine.api.restapi.resource.BackendHostNumaNodesResource.list(BackendHostNumaNodesResource.java:43)
> 	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 
> I am not sure that we have this links add into interface, could you give us some suggestion to debug it ?
> 
> Best Regards,
> Jason Liao
> 

There are two problems there:

1. You are putting the JAX-RS annotations @GET and @Formatted in the
implementation class and in the interface. RESTEasy is looking for the
@Produces annotation in the same class where you have the @GET
annotation, so in this case it is looking in
BackendHostNumaNodesResource, and they aren't there, but in the
interface. The solution to this is to avoid the annotations in the
implementation class, put them only in the interface (they are already
there).

2. You are adding back-links to the host resource, for example:

  <host_numa_nodes>
    <host_numa_node href="..." id="...">
      <host href="/api/hosts/{host:id}" id="{host:id}"/>
      ...
    </host_numa_node>
    ...
  </host_numa_node>

For this to work the NumaNode model that you are creating need to have a
reference to the corresponding Host model, and they won't have it unless
you override the "addParent()" method in BackendHostNumaNodesResource,
something like this:

  @Override
  public NumaNode addParents(NumaNode node) {
    Host host = new Host();
    host.setId(hostId);
    node.setHost(host);
    return node;
  }

I'm attaching a patch that you can apply on top of yours to make these
changes.

>> -----Original Message-----
>> From: Juan Hernandez [mailto:juan.hernandez at redhat.com]
>> Sent: 2014年4月30日 20:34
>> To: Liao, Chuan (Jason Liao, HPservers-Core-OE-PSC); devel at ovirt.org
>> Cc: Gilad Chaplik; Alexander Wels
>> Subject: Re: Change in ovirt-engine[master]: restapi: NUMA feature restful API support
>>
>> On 04/30/2014 02:10 PM, Liao, Chuan (Jason Liao, HPservers-Core-OE-PSC)
>> wrote:
>>> Hi,
>>>
>>> When we finish all the restful API code for NUMA feature and test it.
>>>
>>> We met one problem which is hard to debug, as attachment.
>>>
>>> Could you help us to review our code or give us some suggestion to debug this
>> problem ?
>>> The patch set link:
>>> http://gerrit.ovirt.org/26943
>>>
>>> Thank you very much.
>>>
>>> Best Regards,
>>> Jason Liao
>>>
>>
>> I think that the problem is that in the VmNumaNodeResource interface you didn't
>> specify the @Produces annotation. As a result when you call the GET operation the
>> server uses the default "text/html", and then it fails to find a writer that can convert
>> your object to HTML. You need to add this to annotation to the interface:
>>
>> You should add the following annotation to this class:
>>
>> @Produces({ApiMediaType.APPLICATION_XML, ApiMediaType.APPLICATION_JSON,
>> ApiMediaType.APPLICATION_X_Y
>> AML})
>>
>>>> -----Original Message-----
>>>> From: automation at ovirt.org [mailto:automation at ovirt.org]
>>>> Sent: 2014年4月30日 19:56
>>>> To: Liao, Chuan (Jason Liao, HPservers-Core-OE-PSC)
>>>> Cc: Juan Hernandez; Gilad Chaplik; Alexander Wels
>>>> Subject: Change in ovirt-engine[master]: restapi: NUMA feature
>>>> restful API support
>>>>
>>>> automation at ovirt.org has posted comments on this change.
>>>>
>>>> Change subject: restapi: NUMA feature restful API support
>>>> ......................................................................
>>>>
>>>>
>>>> Patch Set 2:
>>>>
>>>> * #1069303::Update tracker: OK
>>>> * Bug-Url: IGNORE, not in a monitored branch (ovirt-engine-3.4
>>>> * Check merged to previous: IGNORE, Not in stable branch
>>>> (['ovirt-engine-3.4', 'ovirt-engine-3.3', 'ovirt-engine-3.4.0',
>>>> 'ovirt-engine-3.3.4', 'ovirt-engine-3.3.3', 'ovirt-engine-3.3.2',
>>>> 'ovirt-engine-3.3.1'])
>>>>
>>>> --
>>>> To view, visit http://gerrit.ovirt.org/26943 To unsubscribe, visit
>>>> http://gerrit.ovirt.org/settings
>>>>
>>>> Gerrit-MessageType: comment
>>>> Gerrit-Change-Id: I72ed4b16c220decbf640f74c4aadffe423afc290
>>>> Gerrit-PatchSet: 2
>>>> Gerrit-Project: ovirt-engine
>>>> Gerrit-Branch: master
>>>> Gerrit-Owner: Jason Liao <chuan.liao at hp.com>
>>>> Gerrit-Reviewer: Alexander Wels <awels at redhat.com>
>>>> Gerrit-Reviewer: Gilad Chaplik <gchaplik at redhat.com>
>>>> Gerrit-Reviewer: Juan Hernandez <juan.hernandez at redhat.com>
>>>> Gerrit-Reviewer: automation at ovirt.org
>>>> Gerrit-Reviewer: oVirt Jenkins CI Server
>>>> Gerrit-HasComments: No
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: numa.patch
Type: text/x-patch
Size: 3376 bytes
Desc: not available
URL: <http://lists.ovirt.org/pipermail/devel/attachments/20140506/adc2b4ea/attachment-0001.bin>


More information about the Devel mailing list