Class RecoveryTestClusterManager

  • All Implemented Interfaces:
    com.github.ambry.clustermap.ClusterMap, java.lang.AutoCloseable

    public class RecoveryTestClusterManager
    extends java.lang.Object
    implements com.github.ambry.clustermap.ClusterMap
    A cluster manager that is a composed of a StaticClusterManager and a HelixClusterManager. It provides a merged view of the static and helix clusters.
    • Field Summary

      • Fields inherited from interface com.github.ambry.clustermap.ClusterMap

        UNKNOWN_DATACENTER_ID
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      java.util.List<com.github.ambry.clustermap.PartitionId> getAllPartitionIds​(java.lang.String partitionClass)
      Get all partition ids from both the underlying StaticClusterManager.
      com.github.ambry.clustermap.ReplicaId getBootstrapReplica​(java.lang.String partitionIdStr, com.github.ambry.clustermap.DataNodeId dataNodeId)  
      java.lang.String getDatacenterName​(byte id)  
      com.github.ambry.clustermap.DataNodeId getDataNodeId​(java.lang.String hostname, int port)
      Return the DataNodeId associated with the given hostname and port in the underlying StaticClusterManager.
      java.util.List<? extends com.github.ambry.clustermap.DataNodeId> getDataNodeIds()
      The list of DataNodeIds present in the underlying HelixClusterManager
      byte getLocalDatacenterId()  
      com.codahale.metrics.MetricRegistry getMetricRegistry()  
      com.github.ambry.clustermap.PartitionId getPartitionIdFromStream​(java.io.InputStream stream)  
      com.github.ambry.clustermap.PartitionId getRandomWritablePartition​(java.lang.String partitionClass, java.util.List<com.github.ambry.clustermap.PartitionId> partitionsToExclude)  
      java.util.List<com.github.ambry.clustermap.ReplicaId> getReplicaIds​(com.github.ambry.clustermap.DataNodeId dataNodeId)
      Get the list of ReplicaIds associated with the given DataNodeId in the underlying StaticClusterManager.
      org.json.JSONObject getSnapshot()  
      java.util.List<com.github.ambry.clustermap.PartitionId> getWritablePartitionIds​(java.lang.String partitionClass)  
      boolean hasDatacenter​(java.lang.String datacenterName)
      Check for existence of the given datacenter from both the static and the helix based cluster managers and update a metric if there is a mismatch.
      void onReplicaEvent​(com.github.ambry.clustermap.ReplicaId replicaId, com.github.ambry.clustermap.ReplicaEventType event)
      Relay the event to both the underlying StaticClusterManager and the underlying HelixClusterManager.
      void registerClusterMapListener​(com.github.ambry.clustermap.ClusterMapChangeListener clusterMapChangeListener)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getPartitionIdFromStream

        public com.github.ambry.clustermap.PartitionId getPartitionIdFromStream​(java.io.InputStream stream)
                                                                         throws java.io.IOException
        Specified by:
        getPartitionIdFromStream in interface com.github.ambry.clustermap.ClusterMap
        Throws:
        java.io.IOException
      • getWritablePartitionIds

        public java.util.List<com.github.ambry.clustermap.PartitionId> getWritablePartitionIds​(java.lang.String partitionClass)
        Specified by:
        getWritablePartitionIds in interface com.github.ambry.clustermap.ClusterMap
      • getRandomWritablePartition

        public com.github.ambry.clustermap.PartitionId getRandomWritablePartition​(java.lang.String partitionClass,
                                                                                  java.util.List<com.github.ambry.clustermap.PartitionId> partitionsToExclude)
        Specified by:
        getRandomWritablePartition in interface com.github.ambry.clustermap.ClusterMap
      • getAllPartitionIds

        public java.util.List<com.github.ambry.clustermap.PartitionId> getAllPartitionIds​(java.lang.String partitionClass)
        Get all partition ids from both the underlying StaticClusterManager.
        Specified by:
        getAllPartitionIds in interface com.github.ambry.clustermap.ClusterMap
        Parameters:
        partitionClass - the partition class whose partitions are required. Can be null
        Returns:
        a list of partition ids from the underlying StaticClusterManager.
      • hasDatacenter

        public boolean hasDatacenter​(java.lang.String datacenterName)
        Check for existence of the given datacenter from both the static and the helix based cluster managers and update a metric if there is a mismatch.
        Specified by:
        hasDatacenter in interface com.github.ambry.clustermap.ClusterMap
        Parameters:
        datacenterName - name of datacenter
        Returns:
        true if the datacenter exists in the underlying StaticClusterManager; false otherwise.
      • getLocalDatacenterId

        public byte getLocalDatacenterId()
        Specified by:
        getLocalDatacenterId in interface com.github.ambry.clustermap.ClusterMap
      • getDatacenterName

        public java.lang.String getDatacenterName​(byte id)
        Specified by:
        getDatacenterName in interface com.github.ambry.clustermap.ClusterMap
      • getDataNodeId

        public com.github.ambry.clustermap.DataNodeId getDataNodeId​(java.lang.String hostname,
                                                                    int port)
        Return the DataNodeId associated with the given hostname and port in the underlying StaticClusterManager. If not found in static cluster map, then get the same from helix cluster map.
        Specified by:
        getDataNodeId in interface com.github.ambry.clustermap.ClusterMap
        Parameters:
        hostname - of the DataNodeId
        port - of the DataNodeId
        Returns:
        the DataNodeId associated with the given hostname and port.
      • getReplicaIds

        public java.util.List<com.github.ambry.clustermap.ReplicaId> getReplicaIds​(com.github.ambry.clustermap.DataNodeId dataNodeId)
        Get the list of ReplicaIds associated with the given DataNodeId in the underlying StaticClusterManager. The list of ReplicaIds is obtained by merging replica lists from HelixClusterManager and StaticClusterManager.
        Specified by:
        getReplicaIds in interface com.github.ambry.clustermap.ClusterMap
        Parameters:
        dataNodeId - the DataNodeId for which the replicas are to be listed.
        Returns:
        merged list of ReplicaIds as present in the underlying StaticClusterManager and HelixClusterManager for the given node.
      • getDataNodeIds

        public java.util.List<? extends com.github.ambry.clustermap.DataNodeId> getDataNodeIds()
        The list of DataNodeIds present in the underlying HelixClusterManager
        Specified by:
        getDataNodeIds in interface com.github.ambry.clustermap.ClusterMap
        Returns:
        the list of DataNodeIds present in the underlying HelixClusterManager
      • getMetricRegistry

        public com.codahale.metrics.MetricRegistry getMetricRegistry()
        Specified by:
        getMetricRegistry in interface com.github.ambry.clustermap.ClusterMap
      • onReplicaEvent

        public void onReplicaEvent​(com.github.ambry.clustermap.ReplicaId replicaId,
                                   com.github.ambry.clustermap.ReplicaEventType event)
        Relay the event to both the underlying StaticClusterManager and the underlying HelixClusterManager.
        Specified by:
        onReplicaEvent in interface com.github.ambry.clustermap.ClusterMap
        Parameters:
        replicaId - the ReplicaId for which this event has occurred.
        event - the ReplicaEventType.
      • getSnapshot

        public org.json.JSONObject getSnapshot()
        Specified by:
        getSnapshot in interface com.github.ambry.clustermap.ClusterMap
      • getBootstrapReplica

        public com.github.ambry.clustermap.ReplicaId getBootstrapReplica​(java.lang.String partitionIdStr,
                                                                         com.github.ambry.clustermap.DataNodeId dataNodeId)
        Specified by:
        getBootstrapReplica in interface com.github.ambry.clustermap.ClusterMap
      • registerClusterMapListener

        public void registerClusterMapListener​(com.github.ambry.clustermap.ClusterMapChangeListener clusterMapChangeListener)
        Specified by:
        registerClusterMapListener in interface com.github.ambry.clustermap.ClusterMap
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface com.github.ambry.clustermap.ClusterMap