public AssignAddressCallback(Address address) {
   super(
       new AssignAddressType(
           address.getStateUuid(),
           address.getName(),
           address.getInstanceAddress(),
           address.getInstanceId()));
   this.address = address;
   this.vm = lookupVm();
 }
 public void update(final Cluster cluster, final List<ClusterAddressInfo> ccList) {
   Helper.loadStoredAddresses();
   for (final ClusterAddressInfo addrInfo : ccList) {
     try {
       final Address address = Helper.lookupOrCreate(cluster, addrInfo);
       if (address.isAssigned() && !addrInfo.hasMapping() && !address.isPending()) {
         if (Principals.nobodyFullName().equals(address.getOwner())) {
           Helper.markAsAllocated(cluster, addrInfo, address);
         }
         try {
           final VmInstance vm = VmInstances.lookupByPrivateIp(addrInfo.getInstanceIp());
           clearOrphan(addrInfo);
         } catch (final NoSuchElementException e) {
           try {
             final VmInstance vm = VmInstances.lookup(address.getInstanceId());
             clearOrphan(addrInfo);
           } catch (final NoSuchElementException ex) {
             InetAddress addr = null;
             try {
               addr = Inet4Address.getByName(addrInfo.getInstanceIp());
             } catch (final UnknownHostException e1) {
               LOG.debug(e1, e1);
             }
             if ((addr == null) || !addr.isLoopbackAddress()) {
               handleOrphan(cluster, addrInfo);
             }
           }
         }
       } else if (address.isAllocated()
           && Principals.nobodyFullName().equals(address.getOwner())
           && !address.isPending()) {
         Helper.markAsAllocated(cluster, addrInfo, address);
       }
     } catch (final Exception e) {
       LOG.debug(e, e);
     }
   }
 }
 protected static Address lookupOrCreate(
     final Cluster cluster, final ClusterAddressInfo addrInfo) {
   Address addr = null;
   VmInstance vm = null;
   try {
     addr = Addresses.getInstance().lookupDisabled(addrInfo.getAddress());
     LOG.trace("Found address in the inactive set cache: " + addr);
   } catch (final NoSuchElementException e1) {
     try {
       addr = Addresses.getInstance().lookup(addrInfo.getAddress());
       LOG.trace("Found address in the active set cache: " + addr);
     } catch (final NoSuchElementException e) {
     }
   }
   if (addrInfo.hasMapping()) {
     vm =
         Helper.maybeFindVm(
             addr != null ? addr.getInstanceId() : null,
             addrInfo.getAddress(),
             addrInfo.getInstanceIp());
     if ((addr != null) && (vm != null)) {
       Helper.ensureAllocated(addr, vm);
       clearOrphan(addrInfo);
     } else if (addr != null && !addr.isPending() && vm != null && VmStateSet.DONE.apply(vm)) {
       handleOrphan(cluster, addrInfo);
     } else if ((addr != null && addr.isAssigned() && !addr.isPending()) && (vm == null)) {
       handleOrphan(cluster, addrInfo);
     } else if ((addr == null) && (vm != null)) {
       addr =
           new Address(
               Principals.systemFullName(),
               addrInfo.getAddress(),
               vm.getInstanceUuid(),
               vm.getInstanceId(),
               vm.getPrivateAddress());
       clearOrphan(addrInfo);
     } else if ((addr == null) && (vm == null)) {
       addr = new Address(addrInfo.getAddress(), cluster.getPartition());
       handleOrphan(cluster, addrInfo);
     }
   } else {
     if ((addr != null) && addr.isAssigned() && !addr.isPending()) {
       handleOrphan(cluster, addrInfo);
     } else if ((addr != null)
         && !addr.isAssigned()
         && !addr.isPending()
         && addr.isSystemOwned()) {
       try {
         addr.release();
       } catch (final Exception ex) {
         LOG.error(ex);
       }
     } else if ((addr != null) && Address.Transition.system.equals(addr.getTransition())) {
       handleOrphan(cluster, addrInfo);
     } else if (addr == null) {
       addr = new Address(addrInfo.getAddress(), cluster.getPartition());
       Helper.clearVmState(addrInfo);
     }
   }
   return addr;
 }