Permalink
Browse files

fix to handling of address state persistence and reloading

  • Loading branch information...
1 parent fb74621 commit e0273b18ac3624d72baf2efe0d9203cc53df0703 @grze grze committed Feb 2, 2012
@@ -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( );
@@ -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 e0273b1

Please sign in to comment.