- Timestamp:
- 09/29/14 15:27:57 (10 years ago)
- Location:
- DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AnnotationResource.java
r5684 r5685 33 33 import eu.dasish.annotation.schema.ResponseBody; 34 34 import java.io.IOException; 35 import java.util.ArrayList; 35 36 import java.util.Arrays; 36 37 import java.util.HashMap; 37 38 import java.util.List; 38 39 import java.util.Map; 40 import java.util.Random; 39 41 import java.util.UUID; 40 42 import javax.servlet.http.HttpServletRequest; … … 177 179 } 178 180 } 181 182 @GET 183 @Produces(MediaType.TEXT_PLAIN) 184 @Path("stressTest") 185 @Transactional(readOnly = true) 186 public String getAnnotationsMultithread(@QueryParam("n") int n) throws IOException, NotInDataBaseException { 187 Number remotePrincipalID = this.getPrincipalID(); 188 if (remotePrincipalID == null) { 189 return "You are not logged in"; 190 } 191 String typeOfAccount = dbDispatcher.getTypeOfPrincipalAccount(remotePrincipalID); 192 if (typeOfAccount.equals(admin) || typeOfAccount.equals(DebugResource.developer)) { 193 194 System.out.print("Preparing the data: getting the list of all annotations, picking up "+n+" of them randomly, and initializing threads"); 195 final List<Number> annotationIDs = dbDispatcher.getFilteredAnnotationIDs(null, null, null, remotePrincipalID, "read", null, null, null); 196 final int size = annotationIDs.size(); 197 List<GetThread> threads = new ArrayList<GetThread>(n); 198 Random rand = new Random(); 199 for (int i=0; i<n; i++) { 200 int r = rand.nextInt(size); 201 String annotationExternalId = dbDispatcher.getResourceExternalIdentifier(annotationIDs.get(r), Resource.ANNOTATION).toString(); 202 GetThread thread = new GetThread(this, annotationExternalId); 203 threads.add(thread); 204 } 205 206 System.out.print("Running on getAnnotation(id) (no serialized output is shown to save time) on randomly selected annotation ids."); 207 for (int i=0; i<n; i++) { 208 threads.get(i).run(); 209 } 210 211 return "Stress-tested annotationrResource's getAnnotation(xxx): ok"; 212 } else { 213 httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN); 214 return "You cannot enjoy this priviledged service because youe are neither admin nor developer. Ask the admin for more priviledges"; 215 } 216 } 217 218 179 219 // TODO Unit test 180 220 … … 605 645 } 606 646 } 647 648 607 649 } -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/DebugResource.java
r5468 r5685 22 22 import eu.dasish.annotation.backend.NotInDataBaseException; 23 23 import eu.dasish.annotation.backend.Resource; 24 import eu.dasish.annotation.schema.AnnotationInfo; 24 25 import eu.dasish.annotation.schema.AnnotationInfoList; 25 26 import eu.dasish.annotation.schema.ObjectFactory; … … 29 30 import java.util.ArrayList; 30 31 import java.util.List; 32 import java.util.Random; 31 33 import java.util.UUID; 32 34 import javax.servlet.http.HttpServletResponse; … … 49 51 public class DebugResource extends ResourceResource { 50 52 51 p rivatefinal String developer = "developer";53 public static final String developer = "developer"; 52 54 53 55 … … 78 80 } 79 81 } 82 83 80 84 81 85 @GET -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/index.jsp
r5675 r5685 76 76 <br> 77 77 <b>Debugging URI's (only for developers)</b><br> 78 GET <a href="api/annotations/stressTest?n=33">api/annotations/stressTest?n=33</a> <br> 78 79 GET <a href="api/debug/remoteID">api/debug/remoteID</a> <br> 79 80 GET <a href="api/debug/uuid">api/debug/uuid</a> (random uuid) <br> -
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java
r5393 r5685 411 411 412 412 413 414 413 JAXBElement<ResponseBody> result = annotationResource.updateAnnotationHeadline("00000000-0000-0000-0000-000000000021", newHeadline); 415 414 Annotation newAnnotation = result.getValue().getAnnotation(); 416 415 assertEquals("new Headline", newAnnotation.getHeadline()); 417 416 } 417 418 419 418 420 }
Note: See TracChangeset
for help on using the changeset viewer.