Package org.ardverk.lang

Examples of org.ardverk.lang.TimeStamp


 
  public DHTFuture<QuickenEntity> quicken(QuickenConfig config) {
   
    QuickenConfig cfg = configProvider.get(config);
   
    TimeStamp creationTime = TimeStamp.now();
   
    List<DHTFuture<PingEntity>> pingFutures = new ArrayList<>();
    List<DHTFuture<NodeEntity>> discoveryFutures = new ArrayList<>();
   
    synchronized (routeTable) {
      int pingCount = (int)(routeTable.getK() * cfg.getPingCount());
     
      Contact localhost = routeTable.getIdentity();
      KUID localhostId = localhost.getId();

      if (0 < pingCount) {
        PingConfig pingConfig = cfg.getPingConfig();
        long contactTimeout = cfg.getContactTimeoutInMillis();
       
        Contact[] contacts = routeTable.select(localhostId, pingCount);
        for (Contact contact : contacts) {
          // Don't send PINGs to the localhost!
          if (contact.equals(localhost)) {
            continue;
          }
         
          if (contact.isTimeout(contactTimeout, TimeUnit.MILLISECONDS)) {
            DHTFuture<PingEntity> future
              = pingManager.ping(contact, pingConfig);
            pingFutures.add(future);
          }
        }
      }
     
      NodeConfig lookupConfig = cfg.getLookupConfig();
      long bucketTimeout = cfg.getBucketTimeoutInMillis();
     
      Bucket[] buckets = routeTable.getBuckets();
      IdentifierUtils.byXor(buckets, localhostId);
     
      for (Bucket bucket : buckets) {
        if (bucket.contains(localhostId)) {
          continue;
        }
       
        TimeStamp timeStamp = bucket.getTimeStamp();
        if (timeStamp.getAgeInMillis() < bucketTimeout) {
          continue;
        }
       
        // Select a random ID with this prefix
        KUID randomId = KUID.createWithPrefix(
View Full Code Here


  /**
   * Returns the mount of time that has passed since the last message
   * has been sent or -1 if no messages have been sent yet.
   */
  public long getLastSendTime(TimeUnit unit) {
    TimeStamp lastSendTime = this.lastSendTime;
    return lastSendTime != null ? lastSendTime.getAge(unit) : -1L;
  }
View Full Code Here

  /**
   * Returns the mount of time that has passed since the last message
   * has been received or -1 if no messages have been received yet.
   */
  public long getLastResponseTime(TimeUnit unit) {
    TimeStamp lastResponseTime = this.lastResponseTime;
    return lastResponseTime != null ? lastResponseTime.getAge(unit) : -1L;
  }
View Full Code Here

TOP

Related Classes of org.ardverk.lang.TimeStamp

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.