@Override
  public boolean process(String type, String message, Object object) {
    Topology topology = (Topology) object;

    if (MemberMaintenanceModeEvent.class.getName().equals(type)) {
      // Return if topology has not been initialized
      if (!TopologyManager.isInitialized()) return false;

      // Parse complete message and build event
      MemberMaintenanceModeEvent event =
          (MemberMaintenanceModeEvent)
              MessagingUtil.jsonToObject(message, MemberMaintenanceModeEvent.class);

      TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId());
      try {
        return doProcess(event, topology);

      } finally {
        TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId());
      }

    } else {
      if (nextProcessor != null) {
        // ask the next processor to take care of the message.
        return nextProcessor.process(type, message, topology);
      } else {
        throw new RuntimeException(
            String.format(
                "Failed to process message using available message processors: [type] %s [body] %s",
                type, message));
      }
    }
  }
  /**
   * Assert application activation
   *
   * @param applicationName
   * @param tenantId
   */
  private void assertClusterWithScalingup(String applicationName, int tenantId) {
    Application application =
        ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
    assertNotNull(
        String.format("Application is not found: [application-id] %s", applicationName),
        application);
    boolean clusterScaleup = false;
    String clusterId = null;
    long startTime = System.currentTimeMillis();
    while (!clusterScaleup) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ignore) {
      }
      Set<ClusterDataHolder> clusterDataHolderSet = application.getClusterDataRecursively();
      for (ClusterDataHolder clusterDataHolder : clusterDataHolderSet) {
        String serviceUuid = clusterDataHolder.getServiceUuid();
        clusterId = clusterDataHolder.getClusterId();
        Service service = TopologyManager.getTopology().getService(serviceUuid);
        assertNotNull(
            String.format(
                "Service is not found: [application-id] %s [service] %s",
                applicationName, serviceUuid),
            service);

        Cluster cluster = service.getCluster(clusterId);
        assertNotNull(
            String.format(
                "Cluster is not found: [application-id] %s [service] %s [cluster-id] %s",
                applicationName, serviceUuid, clusterId),
            cluster);
        for (ClusterInstance instance : cluster.getInstanceIdToInstanceContextMap().values()) {
          int activeInstances = 0;
          for (Member member : cluster.getMembers()) {
            if (member.getClusterInstanceId().equals(instance.getInstanceId())) {
              if (member.getStatus().equals(MemberStatus.Active)) {
                activeInstances++;
              }
            }
          }
          clusterScaleup = activeInstances >= clusterDataHolder.getMinInstances();
          if (clusterScaleup) {
            activeInstancesAfterScaleup = activeInstances;
            break;
          }
        }
        application =
            ApplicationManager.getApplications().getApplicationByTenant(applicationName, tenantId);
        if ((System.currentTimeMillis() - startTime) > CLUSTER_SCALE_UP_TIMEOUT) {
          break;
        }
      }
    }
    assertEquals(
        true,
        clusterScaleup,
        String.format("Cluster did not get scaled up: [cluster-id] %s", clusterId));
  }