Permalink
Browse files

fix to handling of address state persistence and reloading

  • Loading branch information...
2 parents eb4ebd4 + e0273b1 commit 08dbead16da8efae0efbf706d797b28085b2eed5 @grze grze committed Feb 2, 2012
View
16 ...es/cluster-manager/src/main/java/com/eucalyptus/address/AbstractSystemAddressManager.java
@@ -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;
@@ -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 );
@@ -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( );
View
8 clc/modules/cluster-manager/src/main/java/com/eucalyptus/address/Address.java
@@ -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( );

0 comments on commit 08dbead

Please sign in to comment.