Examples of Lease


Examples of net.jini.core.lease.Lease

  LeaseRenewalSet set = lrs.createLeaseRenewalSet(renewSetDur);
  set = prepareSet(set);
  lrm.renewFor(prepareLease(set.getRenewalSetLease()), renewSetDur, null);

  // grab two instances of the renewal set lease
  Lease lease01 = prepareLease(set.getRenewalSetLease());
  Lease lease02 = prepareLease(set.getRenewalSetLease());

  // they should be the same
  if (lease01.equals(lease02) == false) {
      String message = "GetRenewalSetLease has returned an\n" +
           "invalid lease.";
View Full Code Here

Examples of net.jini.core.lease.Lease

  logger.log(Level.FINE, "Adding managed lease to lease renewal set.");
  set.renewFor(testLease, Long.MAX_VALUE);
 
  // Remove the lease. Removal should succeed.
  logger.log(Level.FINE, "Removing the managed lease from the set.");
  Lease managedLease = set.remove(testLease);
  if (managedLease == null) {
      String message = "Lease could not be removed from\n";
      message += "renewal set.";
      throw new TestException(message);
  }
View Full Code Here

Examples of net.jini.core.lease.Lease

  logger.log(Level.FINE, "Duration == Lease.FOREVER");
  TestLease testLease =
      leaseProvider.createNewLease(leaseOwner, Lease.FOREVER);

  // remove the lease
  Lease managedLease = set.remove(testLease);
  if (managedLease != null) {
      String message = "Removal of non-managed lease does NOT\n" +
           "return null as required.";
      throw new TestException(message);
  }
View Full Code Here

Examples of org.apache.curator.framework.recipes.locks.Lease

    this.semaphore = new InterProcessSemaphoreV2(client, path, numberOfLeases);
  }

  @Override
  public DistributedLease acquire(long time, TimeUnit unit) throws Exception {
    Lease lease = semaphore.acquire(time, unit);
    if(lease != null){
      return new LeaseHolder(lease);
    }else{
      return null;
    }
View Full Code Here

Examples of org.apache.directory.server.dhcp.service.Lease

            logger.warn( "Don't know anything about the sbnet containing " + selectionBase );
            return null;
        }

        // try to find existing lease
        Lease lease = null;
        lease = findExistingLease( hardwareAddress, lease );

        if ( null != lease )
        {
            return lease;
        }

        Host host = null;
        host = findDesignatedHost( hardwareAddress );

        if ( null != host )
        {
            // make sure that the host is actually within the subnet. Depending
            // on the way the DhcpStore configuration is implemented, it is not
            // possible to violate this condition, but we can't be sure.
            if ( !subnet.contains( host.getAddress() ) )
            {
                logger.warn( "Host " + host + " is not within the subnet for which an address is requested" );
            }
            else
            {
                // build properties map
                Map properties = getProperties( subnet );
                properties.putAll( getProperties( host ) );

                // build lease
                lease = new Lease();
                lease.setAcquired( System.currentTimeMillis() );

                long leaseTime = determineLeaseTime( requestedLeaseTime, properties );

                lease.setExpires( System.currentTimeMillis() + leaseTime );

                lease.setHardwareAddress( hardwareAddress );
                lease.setState( Lease.STATE_NEW );
                lease.setClientAddress( host.getAddress() );

                // set lease options
                OptionsField o = lease.getOptions();

                // set (client) host name
                o.add( new HostName( host.getName() ) );

                // add subnet settings
                o.add( new SubnetMask( subnet.getNetmask() ) );
                o.merge( subnet.getOptions() );

                // add the host's options. they override existing
                // subnet options as they take the precedence.
                o.merge( host.getOptions() );
            }
        }

        if ( null == lease )
        {
            // FIXME: use selection base to find a lease in a pool.
        }

        // update the lease state
        if ( null != lease && lease.getState() != Lease.STATE_ACTIVE )
        {
            lease.setState( Lease.STATE_OFFERED );
            updateLease( lease );
        }

        return lease;
    }
View Full Code Here

Examples of org.apache.directory.server.dhcp.service.Lease

        InetAddress selectionBase, long requestedLeaseTime, OptionsField options ) throws DhcpException
    {
        // try to find existing lease. if we don't find a lease based on the
        // client's
        // hardware address, we send a NAK.
        Lease lease = null;
        lease = findExistingLease( hardwareAddress, lease );

        if ( null == lease )
        {
            return null;
        }

        // check whether the notions of the client address match
        if ( !lease.getClientAddress().equals( requestedAddress ) )
        {
            logger.warn( "Requested address " + requestedAddress + " for " + hardwareAddress
                + " doesn't match existing lease " + lease );
            return null;
        }

        // check whether addresses and subnet match
        Subnet subnet = findSubnet( selectionBase );

        if ( null == subnet )
        {
            logger.warn( "No subnet found for existing lease " + lease );
            return null;
        }

        if ( !subnet.contains( lease.getClientAddress() ) )
        {
            logger.warn( "Client with existing lease " + lease + " is on wrong subnet " + subnet );
            return null;
        }

        if ( !subnet.isInRange( lease.getClientAddress() ) )
        {
            logger.warn( "Client with existing lease " + lease + " is out of valid range for subnet " + subnet );
            return null;
        }

        // build properties map
        Map properties = getProperties( subnet );

        // update lease options
        OptionsField o = lease.getOptions();
        o.clear();

        // add subnet settings
        o.add( new SubnetMask( subnet.getNetmask() ) );
        o.merge( subnet.getOptions() );

        // check whether there is a designated host.
        Host host = findDesignatedHost( hardwareAddress );
        if ( null != host )
        {
            // check whether the host matches the address (using a fixed
            // host address is mandatory).
            if ( host.getAddress() != null && !host.getAddress().equals( lease.getClientAddress() ) )
            {
                logger.warn( "Existing fixed address for " + hardwareAddress + " conflicts with existing lease "
                    + lease );
                return null;
            }

            properties.putAll( getProperties( host ) );

            // set (client) host name
            o.add( new HostName( host.getName() ) );

            // add the host's options
            o.merge( host.getOptions() );
        }

        // update other lease fields
        long leaseTime = determineLeaseTime( requestedLeaseTime, properties );
        lease.setExpires( System.currentTimeMillis() + leaseTime );
        lease.setHardwareAddress( hardwareAddress );

        // update the lease state
        if ( lease.getState() != Lease.STATE_ACTIVE )
        {
            lease.setState( Lease.STATE_ACTIVE );
            updateLease( lease );
        }

        // store information about the lease
        updateLease( lease );
View Full Code Here

Examples of org.apache.directory.server.dhcp.service.Lease

            logger.warn( "Don't know anything about the sbnet containing " + selectionBase );
            return null;
        }

        // try to find existing lease
        Lease lease = null;
        lease = findExistingLease( hardwareAddress, lease );
        if ( null != lease )
            return lease;

        Host host = null;
        host = findDesignatedHost( hardwareAddress );
        if ( null != host )
        {
            // make sure that the host is actually within the subnet. Depending
            // on the way the DhcpStore configuration is implemented, it is not
            // possible to violate this condition, but we can't be sure.
            if ( !subnet.contains( host.getAddress() ) )
            {
                logger.warn( "Host " + host + " is not within the subnet for which an address is requested" );
            }
            else
            {
                // build properties map
                Map properties = getProperties( subnet );
                properties.putAll( getProperties( host ) );

                // build lease
                lease = new Lease();
                lease.setAcquired( System.currentTimeMillis() );

                long leaseTime = determineLeaseTime( requestedLeaseTime, properties );

                lease.setExpires( System.currentTimeMillis() + leaseTime );

                lease.setHardwareAddress( hardwareAddress );
                lease.setState( Lease.STATE_NEW );
                lease.setClientAddress( host.getAddress() );

                // set lease options
                OptionsField o = lease.getOptions();

                // set (client) host name
                o.add( new HostName( host.getName() ) );

                // add subnet settings
                o.add( new SubnetMask( subnet.getNetmask() ) );
                o.merge( subnet.getOptions() );

                // add the host's options. they override existing
                // subnet options as they take the precedence.
                o.merge( host.getOptions() );
            }
        }

        if ( null == lease )
        {
            // FIXME: use selection base to find a lease in a pool.
        }

        // update the lease state
        if ( null != lease && lease.getState() != Lease.STATE_ACTIVE )
        {
            lease.setState( Lease.STATE_OFFERED );
            updateLease( lease );
        }

        return lease;
    }
View Full Code Here

Examples of org.apache.directory.server.dhcp.service.Lease

        InetAddress selectionBase, long requestedLeaseTime, OptionsField options ) throws DhcpException
    {
        // try to find existing lease. if we don't find a lease based on the
        // client's
        // hardware address, we send a NAK.
        Lease lease = null;
        lease = findExistingLease( hardwareAddress, lease );
        if ( null == lease )
            return null;

        // check whether the notions of the client address match
        if ( !lease.getClientAddress().equals( requestedAddress ) )
        {
            logger.warn( "Requested address " + requestedAddress + " for " + hardwareAddress
                + " doesn't match existing lease " + lease );
            return null;
        }

        // check whether addresses and subnet match
        Subnet subnet = findSubnet( selectionBase );
        if ( null == subnet )
        {
            logger.warn( "No subnet found for existing lease " + lease );
            return null;
        }
        if ( !subnet.contains( lease.getClientAddress() ) )
        {
            logger.warn( "Client with existing lease " + lease + " is on wrong subnet " + subnet );
            return null;
        }
        if ( !subnet.isInRange( lease.getClientAddress() ) )
        {
            logger.warn( "Client with existing lease " + lease + " is out of valid range for subnet " + subnet );
            return null;
        }

        // build properties map
        Map properties = getProperties( subnet );

        // update lease options
        OptionsField o = lease.getOptions();
        o.clear();

        // add subnet settings
        o.add( new SubnetMask( subnet.getNetmask() ) );
        o.merge( subnet.getOptions() );

        // check whether there is a designated host.
        Host host = findDesignatedHost( hardwareAddress );
        if ( null != host )
        {
            // check whether the host matches the address (using a fixed
            // host address is mandatory).
            if ( host.getAddress() != null && !host.getAddress().equals( lease.getClientAddress() ) )
            {
                logger.warn( "Existing fixed address for " + hardwareAddress + " conflicts with existing lease "
                    + lease );
                return null;
            }

            properties.putAll( getProperties( host ) );

            // set (client) host name
            o.add( new HostName( host.getName() ) );

            // add the host's options
            o.merge( host.getOptions() );
        }

        // update other lease fields
        long leaseTime = determineLeaseTime( requestedLeaseTime, properties );
        lease.setExpires( System.currentTimeMillis() + leaseTime );
        lease.setHardwareAddress( hardwareAddress );

        // update the lease state
        if ( lease.getState() != Lease.STATE_ACTIVE )
        {
            lease.setState( Lease.STATE_ACTIVE );
            updateLease( lease );
        }

        // store information about the lease
        updateLease( lease );
View Full Code Here

Examples of org.apache.hadoop.dfs.LeaseManager.Lease

        INodeFileUnderConstruction pendingFile = (INodeFileUnderConstruction) myFile;
        //
        // If the file is under construction , then it must be in our
        // leases. Find the appropriate lease record.
        //
        Lease lease = leaseManager.getLease(new StringBytesWritable(holder));
        //
        // We found the lease for this file. And surprisingly the original
        // holder is trying to recreate this file. This should never occur.
        //
        if (lease != null) {
          throw new AlreadyBeingCreatedException(
                                                 "failed to create file " + src + " for " + holder +
                                                 " on client " + clientMachine +
                                                 " because current leaseholder is trying to recreate file.");
        }
        //
        // Find the original holder.
        //
        lease = leaseManager.getLease(pendingFile.clientName);
        if (lease == null) {
          throw new AlreadyBeingCreatedException(
                                                 "failed to create file " + src + " for " + holder +
                                                 " on client " + clientMachine +
                                                 " because pendingCreates is non-null but no leases found.");
        }
        //
        // If the original holder has not renewed in the last SOFTLIMIT
        // period, then start lease recovery.
        //
        if (lease.expiredSoftLimit()) {
          LOG.info("startFile: recover lease " + lease + ", src=" + src);
          internalReleaseLease(lease, src);
        }
        throw new AlreadyBeingCreatedException("failed to create file " + src + " for " + holder +
                                               " on client " + clientMachine +
View Full Code Here

Examples of org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease

      }
      pendingFile.setTargets(targets);
    }
    // start lease recovery of the last block for this file.
    pendingFile.assignPrimaryDatanode();
    Lease reassignedLease = reassignLease(
      lease, src, HdfsConstants.NN_RECOVERY_LEASEHOLDER, pendingFile);
    leaseManager.renewLease(reassignedLease);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.