Skip to content

Commit

Permalink
Update event to indicate partition changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbwatson committed Jul 1, 2016
1 parent af21ff0 commit 46fddb9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,53 @@
import com.netflix.metacat.common.MetacatContext;
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.PartitionDto;
import com.netflix.metacat.common.dto.PartitionsSaveResponseDto;

import java.util.List;
import java.util.Objects;

public class MetacatSaveTablePartitionPostEvent extends MetacatEvent {
private final List<PartitionDto> partitions;
private final PartitionsSaveResponseDto partitionsSaveResults;

public MetacatSaveTablePartitionPostEvent(QualifiedName name, List<PartitionDto> partitions, MetacatContext metacatContext) {
super( name, metacatContext);
public MetacatSaveTablePartitionPostEvent(QualifiedName name, List<PartitionDto> partitions,
PartitionsSaveResponseDto partitionsSaveResults, MetacatContext metacatContext) {
super(name, metacatContext);
this.partitions = partitions;
this.partitionsSaveResults = partitionsSaveResults;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof MetacatSaveTablePartitionPostEvent)) return false;
if (!super.equals(o)) return false;
if (this == o)
return true;
if (!(o instanceof MetacatSaveTablePartitionPostEvent))
return false;
if (!super.equals(o))
return false;
MetacatSaveTablePartitionPostEvent that = (MetacatSaveTablePartitionPostEvent) o;
return Objects.equals(partitions, that.partitions);
return Objects.equals(partitions, that.partitions) && Objects.equals(partitionsSaveResults,
that.partitionsSaveResults);
}

public List<PartitionDto> getPartitions() {
return partitions;
}

public PartitionsSaveResponseDto getPartitionsSaveResults() {
return partitionsSaveResults;
}

@Override
public int hashCode() {
return 31 * super.hashCode() + Objects.hash(partitions);
return 31 * super.hashCode() + Objects.hash(partitions) + Objects.hash(partitionsSaveResults);
}

@Override
public String toString() {
return "MetacatSaveTablePartitionPostEvent{" +
"partitions=" + partitions +
"partitionsSaveResults=" + partitionsSaveResults +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public PartitionsSaveResponseDto savePartitions(
v1.updateTable(catalogName, databaseName, tableName, dto);
}

eventBus.post(new MetacatSaveTablePartitionPostEvent(name, partitionsToSave, metacatContext));
eventBus.post(new MetacatSaveTablePartitionPostEvent(name, partitionsToSave, result, metacatContext));
if( partitionIdsForDeletes != null && !partitionIdsForDeletes.isEmpty()){
eventBus.post(new MetacatDeleteTablePartitionPostEvent(name, partitionIdsForDeletes, metacatContext));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.netflix.metacat.common.QualifiedName;
import com.netflix.metacat.common.dto.BaseDto;
import com.netflix.metacat.common.dto.PartitionDto;
import com.netflix.metacat.common.dto.PartitionsSaveResponseDto;
import com.netflix.metacat.common.dto.TableDto;
import com.netflix.metacat.common.server.events.MetacatEventBus;
import com.netflix.metacat.common.server.events.MetacatSaveTablePartitionPostEvent;
Expand Down Expand Up @@ -85,7 +86,10 @@ public void postPostUpdateEvent(QualifiedName name, BaseDto dto, MetacatContext
if( dto != null) {
dtos.add((PartitionDto) dto);
}
eventBus.post(new MetacatSaveTablePartitionPostEvent(name, dtos, metacatContext));
// This request neither added nor updated partitions
PartitionsSaveResponseDto partitionsSaveResponseDto = new PartitionsSaveResponseDto();
eventBus.post(
new MetacatSaveTablePartitionPostEvent(name, dtos, partitionsSaveResponseDto, metacatContext));
} else if( name.isTableDefinition()){
MetacatUpdateTablePostEvent event = new MetacatUpdateTablePostEvent(name, metacatContext);
if( dto != null){
Expand Down

0 comments on commit 46fddb9

Please sign in to comment.