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);
     }
   }
 }
Пример #2
0
 public void init() { // Should only EVER be called externally after loading from the db
   this.atomicState = new AtomicMarkableReference<State>(State.unallocated, false);
   this.transition = this.QUIESCENT;
   this.getOwner(); // ensure to initialize
   if (this.instanceAddress == null || this.instanceId == null) {
     this.instanceAddress = UNASSIGNED_INSTANCEADDR;
     this.instanceUuid = UNASSIGNED_INSTANCEUUID;
     this.instanceId = UNASSIGNED_INSTANCEID;
   }
   if (Principals.nobodyFullName().equals(super.getOwner())) {
     this.atomicState.set(State.unallocated, true);
     this.instanceAddress = UNASSIGNED_INSTANCEADDR;
     this.instanceUuid = UNASSIGNED_INSTANCEUUID;
     this.instanceId = UNASSIGNED_INSTANCEID;
     Addresses.getInstance().registerDisabled(this);
     this.atomicState.set(State.unallocated, false);
   } else if (!this.instanceId.equals(UNASSIGNED_INSTANCEID)) {
     this.atomicState.set(State.assigned, true);
     Addresses.getInstance().register(this);
     this.atomicState.set(State.assigned, false);
   } else {
     this.atomicState.set(State.allocated, true);
     if (this.isSystemOwned()) {
       Addresses.getInstance().registerDisabled(this);
       this.setOwner(Principals.nobodyFullName());
       this.instanceAddress = UNASSIGNED_INSTANCEADDR;
       this.instanceUuid = UNASSIGNED_INSTANCEUUID;
       this.instanceId = UNASSIGNED_INSTANCEID;
       Address.removeAddress(this.getDisplayName());
       this.atomicState.set(State.unallocated, false);
     } else {
       Addresses.getInstance().register(this);
       this.atomicState.set(State.allocated, false);
     }
   }
   LOG.debug("Initialized address: " + this.toString());
 }
Пример #3
0
 public Address(final String ipAddress) {
   super(Principals.nobodyFullName(), ipAddress);
 }