Permalink
Browse files

only send volume creation event on successfully submitting it to SC

  • Loading branch information...
1 parent f96272d commit 2117ce5e0412fd6f83d2c3b6682fd57a48be42ec @grze grze committed Jan 9, 2012
@@ -63,14 +63,11 @@
package com.eucalyptus.blockstorage;
-import java.util.HashMap;
import java.util.List;
-import java.util.NoSuchElementException;
import java.util.concurrent.ExecutionException;
import javax.persistence.EntityTransaction;
import org.apache.log4j.Logger;
import org.hibernate.criterion.Example;
-import org.hibernate.exception.ConstraintViolationException;
import com.eucalyptus.auth.principal.UserFullName;
import com.eucalyptus.cloud.CloudMetadata.VolumeMetadata;
import com.eucalyptus.component.Partitions;
@@ -80,7 +77,6 @@
import com.eucalyptus.crypto.Crypto;
import com.eucalyptus.entities.Entities;
import com.eucalyptus.entities.EntityWrapper;
-import com.eucalyptus.entities.TransactionException;
import com.eucalyptus.entities.Transactions;
import com.eucalyptus.event.ListenerRegistry;
import com.eucalyptus.reporting.event.StorageEvent;
@@ -94,8 +90,8 @@
import com.eucalyptus.ws.client.ServiceDispatcher;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
-import edu.ucsb.eucalyptus.msgs.AttachedVolume;
import edu.ucsb.eucalyptus.msgs.BaseMessage;
+import edu.ucsb.eucalyptus.msgs.CreateStorageVolumeResponseType;
import edu.ucsb.eucalyptus.msgs.CreateStorageVolumeType;
import edu.ucsb.eucalyptus.msgs.DescribeStorageVolumesResponseType;
import edu.ucsb.eucalyptus.msgs.DescribeStorageVolumesType;
@@ -196,12 +192,18 @@ public static Volume createStorageVolume( final ServiceConfiguration sc, final U
public void fire( final Volume t ) {
t.setState( State.GENERATING );
try {
+ final CreateStorageVolumeType req = new CreateStorageVolumeType( t.getDisplayName( ), t.getSize( ), snapId, null ).regardingUserRequest( request );
+ final CreateStorageVolumeResponseType ret = AsyncRequests.sendSync( sc, req );
+ LOG.debug( "Volume created: CreateStorageVolumeResponse: " +
+ ret.getVolumeId( ) + " " +
+ ret.getStatus( ) + " " +
+ ret.getSize( ) + " " +
+ ret.getSnapshotId( ) + " " +
+ ret.getCreateTime( ) );
ListenerRegistry.getInstance( ).fireEvent( new StorageEvent( StorageEvent.EventType.EbsVolume, true, t.getSize( ),
t.getOwnerUserId( ), t.getOwnerUserName( ),
t.getOwnerAccountNumber( ), t.getOwnerAccountName( ),
t.getScName( ), t.getPartition( ) ) );
- final CreateStorageVolumeType req = new CreateStorageVolumeType( t.getDisplayName( ), t.getSize( ), snapId, null ).regardingUserRequest( request );
- AsyncRequests.sendSync( sc, req );
} catch ( final Exception ex ) {
LOG.error( "Failed to create volume: " + t.toString( ), ex );
throw Exceptions.toUndeclared( ex );

0 comments on commit 2117ce5

Please sign in to comment.