Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
fix to handling of address state persistence and reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
chris grzegorczyk committed Feb 2, 2012
1 parent fb74621 commit e0273b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Collection;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.ConcurrentNavigableMap;
Expand Down Expand Up @@ -139,10 +138,7 @@ public Address allocateSystemAddress( final Partition partition ) throws NotEnou
}

public void update( final Cluster cluster, final List<ClusterAddressInfo> ccList ) {
if ( !cluster.getState( ).isAddressingInitialized( ) ) {
Helper.loadStoredAddresses( );
cluster.getState( ).setAddressingInitialized( true );
}
Helper.loadStoredAddresses( );
for ( final ClusterAddressInfo addrInfo : ccList ) {
try {
final Address address = Helper.lookupOrCreate( cluster, addrInfo );
Expand Down Expand Up @@ -329,10 +325,12 @@ protected static void loadStoredAddresses( ) {
final EntityTransaction db = Entities.get( Address.class );
try {
for ( Address addr : Entities.query( clusterAddr ) ) {
try {
addr.init( );
} catch ( Exception ex ) {
LOG.error( ex, ex );
if ( !Addresses.getInstance( ).contains( addr.getName( ) ) ) {
try {
addr.init( );
} catch ( Exception ex ) {
LOG.error( ex, ex );
}
}
}
db.commit( );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,19 @@ private static void addAddress( final Address address ) {
Address addr = address;
EntityWrapper<Address> db = EntityWrapper.get( Address.class );
try {
addr = db.getUnique( new Address( address.getName( ) ) {
addr = db.getUnique( new Address( ) {
{
this.setOwnerAccountNumber( address.getOwnerAccountNumber( ) );
this.setDisplayName( address.getName( ) );
}
} );
addr.setOwner( address.getOwner( ) );
db.commit( );
} catch ( RuntimeException e ) {
db.rollback( );
LOG.error( e, e );
} catch ( EucalyptusCloudException e ) {
addr = new Address( address.getName( ) );
try {
db.add( addr );
db.add( address );
db.commit( );
} catch ( Exception e1 ) {
db.rollback( );
Expand Down

0 comments on commit e0273b1

Please sign in to comment.