Ori Liel has posted comments on this change.
Change subject: restapi: Adding details to step as statistics
......................................................................
Patch Set 14:
(8 comments)
....................................................
File
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/AbstractStatisticalQuery.java
Line 13: import org.ovirt.engine.api.model.Value;
Line 14: import org.ovirt.engine.api.model.ValueType;
Line 15: import org.ovirt.engine.api.model.Values;
Line 16: import
org.ovirt.engine.api.restapi.resource.BaseBackendResource.BackendFailureException;
Line 17: import org.ovirt.engine.core.compat.Guid;
Moved for no reason, no big deal but patch would be cleaner without this
Line 18:
Line 19: /**
Line 20: * Subclasses encapsulate the subject-specific aspects of a
statistical query
Line 21: */
....................................................
File
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendStepResource.java
Line 67:
Line 68: @Override
Line 69: public StatisticsResource getStatisticsResource() {
Line 70:
Line 71: GlusterTaskStatisticalQuery query = new
GlusterTaskStatisticalQuery(new TaskQueryResolver<Guid>(), newModel(id));
The reason why get() or getEntity() don't work inside getStatisticsResource()
is that getStatisticsResource() is not annotated with @GET, @POST or @DELETE
and therefore RestEasy does not provide it with a context.
In a bit more detail, we have a class called 'Challanger' which implements the
RestEasy interface: 'PreProcessInterceptor'. For methods annotated with @GET,
@POST or @DELETE - RestEasy activates this interceptor, but if none of these
annotations is found, RestEasy doesn't activate it. It is 'Challanger' who sets
the session on the thread-local, so without it being invoked, log-in is not
possible.
Unfortunately, resolving this is complicated. Adding @GET for
getStatisticsResource() results in 'Challanger' being invoked, but at the same
time seems to create other problems, which I have not had the time to explore
in depth (maybe because of ambiguity - 2 different methods annotated with @GET
in the same context). I searched for a RestEasy annotation that would inject
context / cause the interceptor to run, without adverse effects, but I found no
such annotation.
Therefore, I think for now, because of this limitation, we will forego creating
different Query objects based on the step type, and stay with a single Query
class for all step statistics. This is the solution currently implemented in
your patch. The only thing I would ask you to do, is to rename the query to:
StepStatisticalQuery - since it now 'serves' all step types (not just Gluster).
Line 72: return inject(new BackendStatisticsResource<Step,
GlusterVolumeTaskStatusEntity>(GlusterVolumeTaskStatusEntity.class, guid,
query));
Line 73: }
Line 74:
Line 75: public class TaskQueryResolver<T> implements IResolver<Guid,
GlusterVolumeTaskStatusEntity> {
Line 67:
Line 68: @Override
Line 69: public StatisticsResource getStatisticsResource() {
Line 70:
Line 71: GlusterTaskStatisticalQuery query = new
GlusterTaskStatisticalQuery(new TaskQueryResolver<Guid>(), newModel(id));
I think you can simply do
Step step = get();
if (step.getExternalType==....) {
}
Line 72: return inject(new BackendStatisticsResource<Step,
GlusterVolumeTaskStatusEntity>(GlusterVolumeTaskStatusEntity.class, guid,
query));
Line 73: }
Line 74:
Line 75: public class TaskQueryResolver<T> implements IResolver<Guid,
GlusterVolumeTaskStatusEntity> {
....................................................
File
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/gluster/BackendGlusterVolumeResource.java
Line 126:
Line 127: public String getId() {
Line 128: return this.id;
Line 129: }
Line 130:
whitespace
....................................................
File
backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendStepResourceTest.java
Line 13: import org.ovirt.engine.core.common.queries.IdQueryParameters;
Line 14: import org.ovirt.engine.core.common.queries.VdcQueryType;
Line 15:
Line 16: public class BackendStepResourceTest
Line 17: extends AbstractBackendSubResourceTest<Step,
org.ovirt.engine.core.common.job.Step, BackendStepResource> {
whitespace
Line 18:
Line 19:
Line 20: public BackendStepResourceTest() {
Line 21: super(new BackendStepResource(GUIDS[0].toString(), new
BackendStepsResource(GUIDS[1])));
Line 45: @Test
Line 46: public void testEnd() throws Exception {
Line 47:
setUriInfo(setUpActionExpectations(VdcActionType.EndExternalStep,
Line 48: EndExternalStepParameters.class,
Line 49: new String[] { "Id", "Status"},
whitespace
Line 50: new Object[] { GUIDS[0], true}, true, true));
Line 51: Action action = new Action();
Line 52: action.setSucceeded(true);
Line 53: verifyActionResponse(resource.end(action));
Line 65: setUpGetEntityExpectations(VdcQueryType.GetStepByStepId,
Line 66: IdQueryParameters.class,
Line 67: new String[] { "Id" },
Line 68: new Object[] { GUIDS[0] },
Line 69: notFound ? null : entity);
You created a new signature, which excepts also the 'Step', but I don't see
invocation of this new signature anywhere. What is the purpose of this
signature? Am I missing something?
Line 70: }
Line 71:
Line 72: @Override
Line 73: protected org.ovirt.engine.core.common.job.Step getEntity(int
index) {
....................................................
File
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/StepMapper.java
Line 36: }
Line 37: model.setExternal(entity.isExternal());
Line 38: if (entity.getExternalSystem() != null &&
entity.getExternalSystem().getType() != null) {
Line 39:
model.setExternalType(entity.getExternalSystem().getType().name());
Line 40: }
Here you are dealing with enum values, we should have an ExternalSystemType
enum in the API and map values from engine explicitly, as we do with other
enums.
Line 41:
Line 42: return model;
Line 43: }
Line 44:
--
To view, visit http://gerrit.ovirt.org/19685
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: Ia1f7559d5700823cd4ee0a28a826074d22679d23
Gerrit-PatchSet: 14
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Sahina Bose <[email protected]>
Gerrit-Reviewer: Eli Mesika <[email protected]>
Gerrit-Reviewer: Michael Pasternak <[email protected]>
Gerrit-Reviewer: Ori Liel <[email protected]>
Gerrit-Reviewer: Sahina Bose <[email protected]>
Gerrit-Reviewer: Shubhendu Tripathi <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches