@Test public void logClusterStatusChangeUsageEvent() { util.logClusterStatusChangeUsageEvent(Status.AVAILABLE, cluster); util.logClusterStatusChangeUsageEvent(null, null); cluster.setStatus(null); util.logClusterStatusChangeUsageEvent(Status.AVAILABLE, cluster); }
public void logClusterStatusChangeUsageEvent(@Nullable Status oldClusterStatus, @Nullable Cluster cluster) { if (oldClusterStatus == null || cluster == null || cluster.getId() == null || cluster.getStatus() == null) { return; } Stack stack = cluster.getStack(); if (stack == null) { return; } UsageProto.CDPCloudbreakClusterStatus.Value oldStatusEnum = null; UsageProto.CDPCloudbreakClusterStatus.Value newStatusEnum = null; try { oldStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( oldClusterStatus.name().toUpperCase()); newStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( cluster.getStatus().name().toUpperCase()); } catch (IllegalArgumentException e) { return; } if (oldStatusEnum == newStatusEnum) { return; } if (stack.getDatalakeResourceId() != null) { UsageProto.CDPDatahubClusterStatusChanged proto = UsageProto.CDPDatahubClusterStatusChanged.newBuilder() .setClusterId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatahubClusterStatusChanged(proto); } else { UsageProto.CDPDatalakeClusterStatusChanged proto = UsageProto.CDPDatalakeClusterStatusChanged.newBuilder() .setDatalakeId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatalakeClusterStatusChanged(proto); } }
UsageLoggingUtil { public void logClusterStatusChangeUsageEvent(@Nullable Status oldClusterStatus, @Nullable Cluster cluster) { if (oldClusterStatus == null || cluster == null || cluster.getId() == null || cluster.getStatus() == null) { return; } Stack stack = cluster.getStack(); if (stack == null) { return; } UsageProto.CDPCloudbreakClusterStatus.Value oldStatusEnum = null; UsageProto.CDPCloudbreakClusterStatus.Value newStatusEnum = null; try { oldStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( oldClusterStatus.name().toUpperCase()); newStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( cluster.getStatus().name().toUpperCase()); } catch (IllegalArgumentException e) { return; } if (oldStatusEnum == newStatusEnum) { return; } if (stack.getDatalakeResourceId() != null) { UsageProto.CDPDatahubClusterStatusChanged proto = UsageProto.CDPDatahubClusterStatusChanged.newBuilder() .setClusterId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatahubClusterStatusChanged(proto); } else { UsageProto.CDPDatalakeClusterStatusChanged proto = UsageProto.CDPDatalakeClusterStatusChanged.newBuilder() .setDatalakeId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatalakeClusterStatusChanged(proto); } } }
UsageLoggingUtil { public void logClusterStatusChangeUsageEvent(@Nullable Status oldClusterStatus, @Nullable Cluster cluster) { if (oldClusterStatus == null || cluster == null || cluster.getId() == null || cluster.getStatus() == null) { return; } Stack stack = cluster.getStack(); if (stack == null) { return; } UsageProto.CDPCloudbreakClusterStatus.Value oldStatusEnum = null; UsageProto.CDPCloudbreakClusterStatus.Value newStatusEnum = null; try { oldStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( oldClusterStatus.name().toUpperCase()); newStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( cluster.getStatus().name().toUpperCase()); } catch (IllegalArgumentException e) { return; } if (oldStatusEnum == newStatusEnum) { return; } if (stack.getDatalakeResourceId() != null) { UsageProto.CDPDatahubClusterStatusChanged proto = UsageProto.CDPDatahubClusterStatusChanged.newBuilder() .setClusterId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatahubClusterStatusChanged(proto); } else { UsageProto.CDPDatalakeClusterStatusChanged proto = UsageProto.CDPDatalakeClusterStatusChanged.newBuilder() .setDatalakeId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatalakeClusterStatusChanged(proto); } }  }
UsageLoggingUtil { public void logClusterStatusChangeUsageEvent(@Nullable Status oldClusterStatus, @Nullable Cluster cluster) { if (oldClusterStatus == null || cluster == null || cluster.getId() == null || cluster.getStatus() == null) { return; } Stack stack = cluster.getStack(); if (stack == null) { return; } UsageProto.CDPCloudbreakClusterStatus.Value oldStatusEnum = null; UsageProto.CDPCloudbreakClusterStatus.Value newStatusEnum = null; try { oldStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( oldClusterStatus.name().toUpperCase()); newStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( cluster.getStatus().name().toUpperCase()); } catch (IllegalArgumentException e) { return; } if (oldStatusEnum == newStatusEnum) { return; } if (stack.getDatalakeResourceId() != null) { UsageProto.CDPDatahubClusterStatusChanged proto = UsageProto.CDPDatahubClusterStatusChanged.newBuilder() .setClusterId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatahubClusterStatusChanged(proto); } else { UsageProto.CDPDatalakeClusterStatusChanged proto = UsageProto.CDPDatalakeClusterStatusChanged.newBuilder() .setDatalakeId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatalakeClusterStatusChanged(proto); } }  void logClusterRequestedUsageEvent(@Nullable Cluster cluster); void logClusterStatusChangeUsageEvent(@Nullable Status oldClusterStatus, @Nullable Cluster cluster); }
UsageLoggingUtil { public void logClusterStatusChangeUsageEvent(@Nullable Status oldClusterStatus, @Nullable Cluster cluster) { if (oldClusterStatus == null || cluster == null || cluster.getId() == null || cluster.getStatus() == null) { return; } Stack stack = cluster.getStack(); if (stack == null) { return; } UsageProto.CDPCloudbreakClusterStatus.Value oldStatusEnum = null; UsageProto.CDPCloudbreakClusterStatus.Value newStatusEnum = null; try { oldStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( oldClusterStatus.name().toUpperCase()); newStatusEnum = UsageProto.CDPCloudbreakClusterStatus.Value.valueOf( cluster.getStatus().name().toUpperCase()); } catch (IllegalArgumentException e) { return; } if (oldStatusEnum == newStatusEnum) { return; } if (stack.getDatalakeResourceId() != null) { UsageProto.CDPDatahubClusterStatusChanged proto = UsageProto.CDPDatahubClusterStatusChanged.newBuilder() .setClusterId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatahubClusterStatusChanged(proto); } else { UsageProto.CDPDatalakeClusterStatusChanged proto = UsageProto.CDPDatalakeClusterStatusChanged.newBuilder() .setDatalakeId(cluster.getId().toString()) .setOldStatus(oldStatusEnum) .setNewStatus(newStatusEnum) .build(); usageReporter.cdpDatalakeClusterStatusChanged(proto); } }  void logClusterRequestedUsageEvent(@Nullable Cluster cluster); void logClusterStatusChangeUsageEvent(@Nullable Status oldClusterStatus, @Nullable Cluster cluster);  }