private <T> void dispatchMsg(ActorContext context, T localMsg, BiConsumer<String, T> biConsumer) {
   for (EndpointClusterAddress address : routes.getLocalRoutes()) {
     LOG.info("Forwarding {} to local endpoint actor {}", localMsg, address);
     ThriftEndpointActorMsg<T> msg =
         new ThriftEndpointActorMsg<>(
             address.toEndpointAddress(), ActorClassifier.LOCAL, localMsg);
     context.parent().tell(msg, context.self());
   }
   for (EndpointClusterAddress address : routes.getRemoteRoutes()) {
     LOG.info("Forwarding {} to remote endpoint actor {}", localMsg, address);
     biConsumer.accept(address.getNodeId(), localMsg);
   }
 }
 /**
  * Process a cluster update.
  *
  * @param context actor context
  */
 public void processClusterUpdate(ActorContext context) {
   if (!clusterService.isMainEntityNode(key)) {
     LOG.debug("[{}] No longer a global endpoint node for {}", endpointKey);
     routes.clear();
     context.stop(context.self());
   }
 }
 /**
  * Process an endpoint route message.
  *
  * @param message endpoint route message
  */
 public void processRouteMessage(EndpointRouteMessage message) {
   LOG.debug(
       "[{}] Processing {} operation for address {}",
       endpointKey,
       message.getOperation(),
       message.getAddress());
   switch (message.getOperation()) {
     case ADD:
     case UPDATE:
       routes.add(message.getAddress());
       break;
     case DELETE:
       routes.remove(message.getAddress());
       break;
     default:
       break;
   }
 }