Comp. intensive inferencing, Restlet Clusters, and 300 Redirects
Hey everyone - fairly new to the Restlet framework, but have found it quite valuable so far - thank you. I've been batting around an idea (explained below) and wanted to get a sound-off to see if my logic is heading in the right direction. Appreciate your input/insights. Basically, I'm using Restlet to expose some functionality of a Java-native ontology inferencing library (Pellet) over HTTP as a RESTful API-style wrapper against biomedical concepts. We use this for a large number of activities such as text mining and data annotation, and the access to web-wrapped Pellet logic is useful, especially since we are largely a .NET shop. The Restlet service is built, stable, and running great. However, based on the server load at any time, the call may take a minute to compute (since inferencing is fairly computationally-intensive). Calls issued to a server in rapid succession can result in a long request queue. We have a number of resources running the service and with an extension I wrote with JGroups, can communicate with each other via UDP multicast. I was hoping I could use this mechanism to, should a server detect a large queue of requests, query the cluster of resources to find a node which has less work allocated to it, craft a 300 redirect based on the response it receives, and send it off to the client. The client would then re-issue the HTTP call to the server specified in the redirect. The logic seems fairly sound in my head, but a few questions remain: 1. Does the Restlet framework provide any way to access lower-level threading objects to detect how much of a work payload it currently has? 2. Is there some more obvious/less painful way (i.e. some Restlet extension) of doing this? Seems like all I would have to do is implement some functionality which is executed before the request is processed, determine if the request can be processed in a reasonable amount of time, and if not, find a node which does. Hoping someone with a greater knowledge of the inner workings of the Restlet framework would be able to provide some insight. Thanks for your time in advance. Regards, Tim -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756181
how to serve static PDF with byte-range support
I am using restlet 2.0.7 to serve a PDF from a specific resource. I cannot figure out how to enable byte-range support via RangeService/RangeFilter/RangeRepresentation. The PDF I am serving has been saved for Fast Web Viewing in Acrobat. I am testing with both the latest Chrome 11.0.696.71 via its built-in reader, and with Firefox 3.6.17 via Acrobat Reader plugin 10.0.3.5. My resource serves the entire file just fine using the internal client connector to retrieve the file contents: @Override protected Representation get(Variant variant) throws ResourceException { if (variant.getMediaType().equals(MediaType.APPLICATION_PDF)) { Client c = getContext().getClientDispatcher(); Response r = c.handle(new Request(Method.GET, new Reference(file:///C:/foo.pdf))); return r.getEntity(); } return null; } In the application which sets up the router, I thought I could simply attach the range filter like this: Filter rangeFilter = getRangeService().createInboundFilter(getContext()); rangeFilter.setNext(MyPDFResource.class); router.attach(/booklet, bookletFilter); I thought I would see a bunch of little requests in the restlet log, but I see that the entire file continues to be retrieved. In the debugger I see then that the RangeFilter.afterHandle() is getting invoked, but is just falling through. My suspicion is that I cannot use the internal client connector as the underlying method to retrieve the file contents. Can someone shed some light on how to proceed with this use case? Thanks, Jason -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756191attachment: jason_guild.vcf
Custom Challenge Scheme
Having problems implementing a custom challenge scheme with an AuthenticatorHelper. I've read the documentation but I am still receiving this WARNING in the logs: WARNING: Couldn't find any helper support the HTTP_MYSCHEME challenge scheme. This is what I'm doing code-wise... public class MyAuthenticatorHelper extends org.restlet.engine.security.AuthenticatorHelper { public static final ChallengeScheme MYSCHEME = new ChallengeScheme( MYSCHEME, MYSCHEME, A custom challenge authentication scheme.); public MyAuthenticatorHelper() { super(MYSCHEME, false, true); } @Override public void formatRawRequest(ChallengeWriter cw, ChallengeRequest cr, Response response, SeriesParameter httpHeaders) throws IOException { if (cr.getRealm() != null) cw.appendQuotedChallengeParameter(realm, cr.getRealm()); } @Override public void parseResponse(ChallengeResponse cr, Request request, SeriesParameter httpHeaders) { cr.setRawValue(request.getChallengeResponse().getRawValue().replaceFirst(token=, )); } } Then to the Component I am adding this line: Engine.getInstance().getRegisteredAuthenticators().add(new MyAuthenticatorHelper()); Why isn't it seeing ny helper? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756279
RE: Re: Issue with Range
Hello Tom, Stephan, thanks for reporting this issue. The parsing of the range header has been fixed in the current trunk and the 2.0 branch. Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756653
Re: Using FileUpload Extension: Uploaded images are corrupt/distorted/lesser size
Hi, The problem occurs with text Files (with the pieces of text misplaced) as well and not just binary data. The users of this extension, please throw some light ! Regards Lokendra On Thu, Jun 2, 2011 at 4:16 PM, Lokendra Singh lsingh@gmail.com wrote: Hi, I am not able to properly upload an image file (binary) to the Restlet server using the Filepload extension. The uploaded images are either corrupt/distorted looking or they are of lesser size than original. I have tried using both FileItem.write(File f) method using the InputStream. Are there any special properties/methods to be set for uploading a binary data ? I have been using curl to upload the image with the following command curl -F upload=@img.jpg;type=image/jpg;filename=img.jpg http://localhost: One strange behavior is that, when in the curl command, the type parameter is changed to image/jpeg, the uploaded image is still corrupt distorted but looks differently in the picture manager than the one uploaded with image/jpg. Please help. PS: The versions of different libs used: restlet-2.1-SNAPSHOT commons-fileupload-1.2.1/1.2.2 (both tested) commons-io-1.3.1 servlet-api-2.4 portlet-api-1.0 Following is the code snippet. DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(1000240); RestletFileUpload upload = new RestletFileUpload(factory); ListFileItem items = upload.parseRequest(getRequest()) . . for (final IteratorFileItem it = items.iterator(); it.hasNext();) { DiskFileItem fi = (DiskFileItem) it.next(); // Process the items that *really* contains an uploaded // file and save them on disk if (fi.getName() != null) { InputStream is = fi.getInputStream(); final int size=1024; byte[] buf; int ByteRead,ByteWritten=0; BufferedOutputStream outStream = new BufferedOutputStream(new FileOutputStream(uploadedFile), size); buf = new byte[size]; while ((ByteRead = is.read(buf, 0, size)) != -1) { outStream.write(buf, 0, ByteRead); ByteWritten += ByteRead; } outStream.flush(); outStream.close(); is.close(); //fi.write(uploadedFile) } Regards Lokendra -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756665
Re: Custom Challenge Scheme
I had the same problem. If i remember correctly, i solved it by changing the Constructor of my Custom scheme. As you can see, the restlet-Engine automatically adds HTTP_ to your Scheme name and searches the registered Schemes only for that name. Don't know if its a bug or intended this way. Either way, try to change your code like this: public static final ChallengeScheme MYSCHEME = new ChallengeScheme( HTTP_MYSCHEME, MYSCHEME, A custom challenge authentication scheme.); -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Custom-Challenge-Scheme-tp6434473p6435068.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756726
Re: Error in returning a list on Get Method
Maybe you could try returning a JSONArray containing all the JSONObjects in the List instead. -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Error-in-returning-a-list-on-Get-Method-tp6412562p6435097.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756727
Re: IncompatibleClassChangeError with ConcurrentMap
Hello Thierry, Thanks, i haven't tried it yet but im sure it will work now. However, since i added the new Snapshot to my Project, i don't get any JsonObjects back with an JsonRepresentation... My methods all look like this: @Get public Representation get(){ JsonRepresentation response = new JsonRepresentation(SomeJsonObject); getResponse().setStatus(Status.SUCCESS_OK); return response; } When called, all i get is an Empty page in my browser, not even empty curly brackets. Curl doesn't give me anything either. The Status is correctly set, as well as the JsonRepresentation as the Response's Entity though. Any ideas? Best Regards, Sebastian -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6435505.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756740
Re: Custom Challenge Scheme
Hi Paul, As Sebastian responded, part of the solution is to match up the ChallengeScheme name with what Restlet expects. The other part is to register your helper as being both for client-side and server-side. I'm not sure why this is, but Restlet[1] always looks for a client-side helper during parseResponse. Rhett [1]: At least in 2.0; I haven't looked at 2.1. On Jun 2, 2011, at 5:59 PM, Paul Morris wrote: Having problems implementing a custom challenge scheme with an AuthenticatorHelper. I've read the documentation but I am still receiving this WARNING in the logs: WARNING: Couldn't find any helper support the HTTP_MYSCHEME challenge scheme. This is what I'm doing code-wise... public class MyAuthenticatorHelper extends org.restlet.engine.security.AuthenticatorHelper { public static final ChallengeScheme MYSCHEME = new ChallengeScheme( MYSCHEME, MYSCHEME, A custom challenge authentication scheme.); public MyAuthenticatorHelper() { super(MYSCHEME, false, true); } @Override public void formatRawRequest(ChallengeWriter cw, ChallengeRequest cr, Response response, SeriesParameter httpHeaders) throws IOException { if (cr.getRealm() != null) cw.appendQuotedChallengeParameter(realm, cr.getRealm()); } @Override public void parseResponse(ChallengeResponse cr, Request request, SeriesParameter httpHeaders) { cr.setRawValue(request.getChallengeResponse().getRawValue().replaceFirst(token=, )); } } Then to the Component I am adding this line: Engine.getInstance().getRegisteredAuthenticators().add(new MyAuthenticatorHelper()); Why isn't it seeing ny helper? -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756279 -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756760