Hi there,

to enable outside interaction and monitoring for a tool i wrote, i 
embedded restlet so server some status information in json form.

while everything worked fine, when i queries using a browser, i got 
some hickups when using pythin urllib to make the url request.

curl worked fine too, but apache bench did not work either.

as I am not experienced at all, i wanted some feedback on that issue. I 
am now using http client in python, which solved the problem there.

when I do: urllib.request.urlopen('http://localhost:8182').read()

i get the following issue/exception thrown:

Unable to block the thread at the cyclic barrier

java.util.concurrent.TimeoutException
at java.util.concurrent.CyclicBarrier.dowait(CyclicBarrier.java:222)
at java.util.concurrent.CyclicBarrier.await(CyclicBarrier.java:399)
at 
org.restlet.util.SelectionRegistration.block(SelectionRegistration.java:173)
at 
org.restlet.engine.io.NbChannelInputStream.onFill(NbChannelInputStream.java:226)
at org.restlet.engine.io.Buffer.process(Buffer.java:594)
at 
org.restlet.engine.io.NbChannelInputStream.read(NbChannelInputStream.java:309)
at java.io.InputStream.read(InputStream.java:85)
at org.restlet.engine.io.BioUtils.exhaust(BioUtils.java:235)
at 
org.restlet.representation.Representation.exhaust(Representation.java:244)
at 
org.restlet.engine.connector.ServerOutboundWay.onCompleted(ServerOutboundWay.java:172)
at 
org.restlet.engine.connector.HttpServerOutboundWay.onCompleted(HttpServerOutboundWay.java:114)
at 
org.restlet.engine.connector.OutboundWay.processIoBuffer(OutboundWay.java:407)
at org.restlet.engine.connector.Way.onSelected(Way.java:409)
at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:284)
at 
org.restlet.engine.connector.Connection.onSelected(Connection.java:579)
at 
org.restlet.util.SelectionRegistration.onSelected(SelectionRegistration.java:284)
at 
org.restlet.engine.connector.ConnectionController.onSelected(ConnectionController.java:187)
at 
org.restlet.engine.connector.ServerConnectionController.onSelected(ServerConnectionController.java:97)
at 
org.restlet.engine.connector.ConnectionController.selectKeys(ConnectionController.java:260)
at 
org.restlet.engine.connector.ConnectionController.doRun(ConnectionController.java:145)
at org.restlet.engine.connector.Controller.run(Controller.java:155)
at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)


My Code to start the server:

         try {
             new Server(Protocol.HTTP, 8182, 
JobStatusResource.class).start();
         } catch (Exception ex) {
             
Logger.getLogger(PGMonitor.class.getName()).log(Level.SEVERE, null, ex);
         }

My Server Resource class: In my test case no jobs are running, 
otherwise I have one scheduledthreadpool executor per server i connect 
to with ~4 tasks waiting at different intervals.

public class JobStatusResource extends ServerResource {

     @Get
     public String overview() {
         System.out.println("got request");
         String result = "";
         for( AGatherer g : PGMonitor.getJobList() ) {
             if(!result.equals("")) result += ",";
             result += "{ \"name\": \"" + g.getName() + "\", 
\"lastRun\": " + g.getLastRunFinishedInSeconds() + ", \"runtime\" :" + 
(g.getLastRunFinishedInSeconds()-g.getLastRunInSeconds())+ "} " ;
         }
         System.out.println("finished building content");
         return "{ \"current_time\" : " + 
System.currentTimeMillis()/1000 +" , \"jobs\": [" + result + "] }";
     }
}

any feedback on what I am doing wrong or should change is appreciaded.

thanks for your efforts,
Jan

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2848690

Reply via email to