Skip to content

Commit

Permalink
Support IsPartitionEmpty property for PartitionRuntimeInformation (Az…
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkwak authored Dec 14, 2018
1 parent 71f8562 commit 0dd058d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,24 @@ public final class PartitionRuntimeInformation {
private final long lastEnqueuedSequenceNumber;
private final String lastEnqueuedOffset;
private final Instant lastEnqueuedTimeUtc;
private final boolean isEmpty;

public PartitionRuntimeInformation(
final String eventHubPath,
final String partitionId,
final long beginSequenceNumber,
final long lastEnqueuedSequenceNumber,
final String lastEnqueuedOffset,
final Instant lastEnqueuedTimeUtc) {
final Instant lastEnqueuedTimeUtc,
final boolean isEmpty) {

this.eventHubPath = eventHubPath;
this.partitionId = partitionId;
this.beginSequenceNumber = beginSequenceNumber;
this.lastEnqueuedSequenceNumber = lastEnqueuedSequenceNumber;
this.lastEnqueuedOffset = lastEnqueuedOffset;
this.lastEnqueuedTimeUtc = lastEnqueuedTimeUtc;
this.isEmpty = isEmpty;
}

public String getEventHubPath() {
Expand All @@ -54,4 +57,8 @@ public String getLastEnqueuedOffset() {
public Instant getLastEnqueuedTimeUtc() {
return this.lastEnqueuedTimeUtc;
}

public boolean getIsEmpty() {
return this.isEmpty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public final class ClientConstants {
public static final String MANAGEMENT_RESULT_LAST_ENQUEUED_SEQUENCE_NUMBER = "last_enqueued_sequence_number";
public static final String MANAGEMENT_RESULT_LAST_ENQUEUED_OFFSET = "last_enqueued_offset";
public static final String MANAGEMENT_RESULT_LAST_ENQUEUED_TIME_UTC = "last_enqueued_time_utc";
public static final String MANAGEMENT_RESULT_PARTITION_IS_EMPTY = "is_partition_empty";
public static final String MANAGEMENT_STATUS_CODE_KEY = "status-code";
public static final String MANAGEMENT_STATUS_DESCRIPTION_KEY = "status-description";
public static final String MANAGEMENT_RESPONSE_ERROR_CONDITION = "error-condition";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,16 @@ public CompletableFuture<PartitionRuntimeInformation> getPartitionRuntimeInforma
if (future1 == null) {
future1 = managementWithRetry(request).thenComposeAsync(new Function<Map<String, Object>, CompletableFuture<PartitionRuntimeInformation>>() {
@Override
public CompletableFuture<PartitionRuntimeInformation> apply(Map<String, Object> rawdata) {
public CompletableFuture<PartitionRuntimeInformation> apply(Map<String, Object> rawData) {
CompletableFuture<PartitionRuntimeInformation> future2 = new CompletableFuture<PartitionRuntimeInformation>();
future2.complete(new PartitionRuntimeInformation(
(String) rawdata.get(ClientConstants.MANAGEMENT_ENTITY_NAME_KEY),
(String) rawdata.get(ClientConstants.MANAGEMENT_PARTITION_NAME_KEY),
(long) rawdata.get(ClientConstants.MANAGEMENT_RESULT_BEGIN_SEQUENCE_NUMBER),
(long) rawdata.get(ClientConstants.MANAGEMENT_RESULT_LAST_ENQUEUED_SEQUENCE_NUMBER),
(String) rawdata.get(ClientConstants.MANAGEMENT_RESULT_LAST_ENQUEUED_OFFSET),
((Date) rawdata.get(ClientConstants.MANAGEMENT_RESULT_LAST_ENQUEUED_TIME_UTC)).toInstant()));
(String) rawData.get(ClientConstants.MANAGEMENT_ENTITY_NAME_KEY),
(String) rawData.get(ClientConstants.MANAGEMENT_PARTITION_NAME_KEY),
(long) rawData.get(ClientConstants.MANAGEMENT_RESULT_BEGIN_SEQUENCE_NUMBER),
(long) rawData.get(ClientConstants.MANAGEMENT_RESULT_LAST_ENQUEUED_SEQUENCE_NUMBER),
(String) rawData.get(ClientConstants.MANAGEMENT_RESULT_LAST_ENQUEUED_OFFSET),
((Date) rawData.get(ClientConstants.MANAGEMENT_RESULT_LAST_ENQUEUED_TIME_UTC)).toInstant(),
(boolean)rawData.get(ClientConstants.MANAGEMENT_RESULT_PARTITION_IS_EMPTY)));
return future2;
}
}, this.executor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public void testGetRuntimeInfos(ConnectionStringBuilder connectionString) throws
Assert.assertNotNull(ehInfo);
Assert.assertTrue(connectionString.getEventHubName().equalsIgnoreCase(ehInfo.getPath()));
Assert.assertNotNull(ehInfo.getCreatedAt()); // creation time could be almost anything, can't really check value
Assert.assertTrue(ehInfo.getPartitionCount() >= 2); // max legal partition count is variable but 2 is hard minimum
Assert.assertTrue(ehInfo.getPartitionCount() >= 1); // max legal partition count is variable but 2 is hard minimum
Assert.assertEquals(ehInfo.getPartitionIds().length, ehInfo.getPartitionCount());
/*
System.out.println("Event hub name: " + ehInfo.getPath());
Expand Down

0 comments on commit 0dd058d

Please sign in to comment.