Package org.commoncrawl.async

Examples of org.commoncrawl.async.Timer


      _reconnectDelay = INITIAL_RECONNECT_DELAY;
      connect();
    }
    // otherwise schedule a timer base on current reconnect interval
    else {
      _reconnectTimer = new Timer(_reconnectDelay, false,

      new Timer.Callback() {

        // @Override
        public void timerFired(Timer timer) {
View Full Code Here


    if (_reconnectDelay == 0) {
      _reconnectDelay = INITIAL_RECONNECT_DELAY;
      bind();
    } else {
      _reconnectTimer = new Timer(_reconnectDelay, false,

      new Timer.Callback() {

        // @Override
        public void timerFired(Timer timer) {
View Full Code Here

             int responseCount = 0;
            
             @Override
             public void hello(final IncomingMessageContext<UnitTestStruct1, UnitTestStruct1> rpcContext)throws RPCException {
               System.out.println("Actor Received Hello for Message:" + rpcContext.getInput().getIntType() + " Thread:" + Thread.currentThread().getId());
               outerEventLoop.setTimer(new Timer((long)(Math.random() * 10.0),false,new Timer.Callback() {

                @Override
                public void timerFired(Timer timer) {
                  System.out.println("Actor Processing Delayed Hello Response for Message:" + rpcContext.getInput().getIntType() + " Thread:" + Thread.currentThread().getId());
                  responseCount++;
View Full Code Here

            finishInitialize(messageContext);
          }
         
        });
   
    _pollTimer = new Timer(POLL_TIMER_DELAY,true, new Timer.Callback() {
     
      @Override
      public void timerFired(Timer timer) {
        potentiallyStartNextQuery();
      }
View Full Code Here

    _controller.slaveStatusChanged(getFullyQualifiedName(),status);
  }
 
 
  private void startHeartbeatTimer() {
    _heartbeatTimer = new Timer(HEARTBEAT_TIMER_INTERVAL,false,new Timer.Callback() {

      @Override
      public void timerFired(final Timer timer) {

        //LOG.info("Heartbeat Timer Fired. Sending heartbeat message to slave:" + getFullyQualifiedName());
View Full Code Here

  public void dispatch(EventLoop eventLoop) {

    final Semaphore waitState = new Semaphore(0);

    eventLoop.setTimer(new Timer(0, false, new Timer.Callback() {

      public void timerFired(Timer timer) {
        boolean isClosure = false;
        try {
          isClosure = handleRequest(waitState);
View Full Code Here

              }
             
              if (eventLoop != null) {
                final long finalResultCount = resultCount;
                //schedule call asynchronously ...
                eventLoop.setTimer(new Timer(0,false,new Timer.Callback() {
   
                  @Override
                  public void timerFired(Timer timer) {
                    // execute directly from thread ...
                    LOG.info(fqHostName + " Query:" + getQueryId() +" Completed with:" + finalResultCount + " results.");
                    // and complete...
                    completionCallback.queryComplete(Query.this,finalResultCount);
                  }
                }));
              }
              else {
                // execute directly from thread ...
                LOG.info(fqHostName + " Query:" + getQueryId() +" Completed with:" + resultCount + " results.");
                // and complete...
                completionCallback.queryComplete(Query.this,resultCount);
              }
            }
            finally {
              if (mergingSpillWriter != null) {
                try {
                  mergingSpillWriter.close();
                } catch (IOException e) {
                  LOG.error(CCStringUtils.stringifyException(e));
                }
              }
            }
          }
          finally {
            if (finalSpillWriter != null) {
              finalSpillWriter.close();
            }
          }
        }
        catch (final Exception e){
         
          synchronized (Query.this) {
            _queryStatus.setStatus(QueryStatus.Status.ERROR);
            _queryStatus.setOptErrorReason(CCStringUtils.stringifyException(e));
          }
         
          if (eventLoop != null) {
            //schedule call asynchronously ...
            eventLoop.setTimer(new Timer(0,false,new Timer.Callback() {

              @Override
              public void timerFired(Timer timer) {
                LOG.error(CCStringUtils.stringifyException(e));
                completionCallback.queryFailed(Query.this, "Query:" + getQueryId() +" Failed on Host:" + fqHostName + " with Exception:" + CCStringUtils.stringifyException(e));
View Full Code Here

              });
          // update status ?
          queryRequest.getQueryStatus().setProgress(.99f);

          // and callback in async thread context...
          eventLoop.setTimer(new Timer(0,false,new Timer.Callback() {
            @Override
            public void timerFired(Timer timer) {
              LOG.info("Local QueryComplete for Query:" + getQueryId());
              completionCallback.queryComplete(queryRequest.getSourceQuery(),resultCount);
            }
          }));
         
        } catch (final IOException e) {
          LOG.error("Query: " + getQueryId() + " Failed on executeLocal with Error:" + CCStringUtils.stringifyException(e));
          final String error = CCStringUtils.stringifyException(e);
          eventLoop.setTimer(new Timer(0,false,new Timer.Callback() {
            @Override
            public void timerFired(Timer timer) {
              completionCallback.queryFailed(queryRequest.getSourceQuery(),error);
            }
          }));
View Full Code Here

          executeCacheQuery(fileSystem,conf,eventLoop,controller,queryRequest, new QueryCompletionCallback<DataType,ResultKeyType,ResultValueType>() {

            @Override
            public void queryComplete(final QueryRequest<DataType,ResultKeyType,ResultValueType> request,final QueryResult<ResultKeyType,ResultValueType> queryResult) {
              // and call outer callback in async thread context...
              eventLoop.setTimer(new Timer(0,false,new Timer.Callback() {
                @Override
                public void timerFired(Timer timer) {
                  queryRequest.getQueryStatus().setProgress(1.0f);
                  LOG.info("Calling queryComplete on cacheRequest for Query:" + getQueryId());
                  completionCallback.queryComplete(queryRequest,queryResult);
                  //LOG.info("Finished Calling queryComplete for Query:" + getQueryId());

                }
              }));
            }

            @Override
            public void queryFailed(final QueryRequest<DataType,ResultKeyType,ResultValueType> request, final String reason) {
              // and call outer callback in async thread context...
              eventLoop.setTimer(new Timer(0,false,new Timer.Callback() {
                @Override
                public void timerFired(Timer timer) {
                  LOG.info("Calling queryFailed on cacheRequest for Query:" + getQueryId() + " Reason:" + reason);
                  completionCallback.queryFailed(queryRequest,reason);
                  //LOG.info("Finished Calling queryFailed for Query:" + getQueryId());
                }
              }));
            }


          });
         
        } catch (final IOException e) {
          LOG.error("Query: " + getQueryId() + " Failed on cacheQuery with Error:" + CCStringUtils.stringifyException(e));
          final String error = CCStringUtils.stringifyException(e);
          eventLoop.setTimer(new Timer(0,false,new Timer.Callback() {
            @Override
            public void timerFired(Timer timer) {
              completionCallback.queryFailed(queryRequest,error);
            }
          }));
View Full Code Here

      // add to map 
      _shardStatusMap.put(queryStatus.getShardId(),statusInfo);
    }
   
    // start a monitor timer
    _queryMonitorTimer = new Timer(500,true,new Timer.Callback() {
     
      @Override
      public void timerFired(Timer timer) {
        try {
          updateRemoteQueryStatus(request);
View Full Code Here

TOP

Related Classes of org.commoncrawl.async.Timer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.