@Test public void testUpdateMembershipUpdatesLocalServiceInstanceWhenMetadataNull() { when(localServiceInstance.getMetadata()).thenReturn(null); CommandMessageFilter commandNameFilter = new CommandNameFilter(String.class.getName()); testSubject.updateMembership(LOAD_FACTOR, commandNameFilter); verifyZeroInteractions(consistentHashChangeListener); }
@Override public void updateMembership(int loadFactor, CommandMessageFilter commandFilter) { Map<String, String> localServiceInstanceMetadata = localServiceInstance.getMetadata(); if (localServiceInstanceMetadata != null) { localServiceInstanceMetadata.put(LOAD_FACTOR, Integer.toString(loadFactor)); SerializedObject<String> serializedCommandFilter = serializer.serialize(commandFilter, String.class); localServiceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER, serializedCommandFilter.getData()); localServiceInstanceMetadata.put( SERIALIZED_COMMAND_FILTER_CLASS_NAME, serializedCommandFilter.getType().getName() ); } updateMembershipForServiceInstance(localServiceInstance, atomicConsistentHash) .ifPresent(consistentHashChangeListener::onConsistentHashChanged); }
SpringCloudCommandRouter implements CommandRouter { @Override public void updateMembership(int loadFactor, CommandMessageFilter commandFilter) { Map<String, String> localServiceInstanceMetadata = localServiceInstance.getMetadata(); if (localServiceInstanceMetadata != null) { localServiceInstanceMetadata.put(LOAD_FACTOR, Integer.toString(loadFactor)); SerializedObject<String> serializedCommandFilter = serializer.serialize(commandFilter, String.class); localServiceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER, serializedCommandFilter.getData()); localServiceInstanceMetadata.put( SERIALIZED_COMMAND_FILTER_CLASS_NAME, serializedCommandFilter.getType().getName() ); } updateMembershipForServiceInstance(localServiceInstance, atomicConsistentHash) .ifPresent(consistentHashChangeListener::onConsistentHashChanged); } }
SpringCloudCommandRouter implements CommandRouter { @Override public void updateMembership(int loadFactor, CommandMessageFilter commandFilter) { Map<String, String> localServiceInstanceMetadata = localServiceInstance.getMetadata(); if (localServiceInstanceMetadata != null) { localServiceInstanceMetadata.put(LOAD_FACTOR, Integer.toString(loadFactor)); SerializedObject<String> serializedCommandFilter = serializer.serialize(commandFilter, String.class); localServiceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER, serializedCommandFilter.getData()); localServiceInstanceMetadata.put( SERIALIZED_COMMAND_FILTER_CLASS_NAME, serializedCommandFilter.getType().getName() ); } updateMembershipForServiceInstance(localServiceInstance, atomicConsistentHash) .ifPresent(consistentHashChangeListener::onConsistentHashChanged); } protected  SpringCloudCommandRouter(Builder builder); }
SpringCloudCommandRouter implements CommandRouter { @Override public void updateMembership(int loadFactor, CommandMessageFilter commandFilter) { Map<String, String> localServiceInstanceMetadata = localServiceInstance.getMetadata(); if (localServiceInstanceMetadata != null) { localServiceInstanceMetadata.put(LOAD_FACTOR, Integer.toString(loadFactor)); SerializedObject<String> serializedCommandFilter = serializer.serialize(commandFilter, String.class); localServiceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER, serializedCommandFilter.getData()); localServiceInstanceMetadata.put( SERIALIZED_COMMAND_FILTER_CLASS_NAME, serializedCommandFilter.getType().getName() ); } updateMembershipForServiceInstance(localServiceInstance, atomicConsistentHash) .ifPresent(consistentHashChangeListener::onConsistentHashChanged); } protected  SpringCloudCommandRouter(Builder builder); static Builder builder(); static boolean serviceInstanceMetadataContainsMessageRoutingInformation(ServiceInstance serviceInstance); @Override Optional<Member> findDestination(CommandMessage<?> commandMessage); @Override void updateMembership(int loadFactor, CommandMessageFilter commandFilter); @EventListener @SuppressWarnings("UnusedParameters") void resetLocalMembership(InstanceRegisteredEvent event); @EventListener @SuppressWarnings("UnusedParameters") void updateMemberships(HeartbeatEvent event); }
SpringCloudCommandRouter implements CommandRouter { @Override public void updateMembership(int loadFactor, CommandMessageFilter commandFilter) { Map<String, String> localServiceInstanceMetadata = localServiceInstance.getMetadata(); if (localServiceInstanceMetadata != null) { localServiceInstanceMetadata.put(LOAD_FACTOR, Integer.toString(loadFactor)); SerializedObject<String> serializedCommandFilter = serializer.serialize(commandFilter, String.class); localServiceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER, serializedCommandFilter.getData()); localServiceInstanceMetadata.put( SERIALIZED_COMMAND_FILTER_CLASS_NAME, serializedCommandFilter.getType().getName() ); } updateMembershipForServiceInstance(localServiceInstance, atomicConsistentHash) .ifPresent(consistentHashChangeListener::onConsistentHashChanged); } protected  SpringCloudCommandRouter(Builder builder); static Builder builder(); static boolean serviceInstanceMetadataContainsMessageRoutingInformation(ServiceInstance serviceInstance); @Override Optional<Member> findDestination(CommandMessage<?> commandMessage); @Override void updateMembership(int loadFactor, CommandMessageFilter commandFilter); @EventListener @SuppressWarnings("UnusedParameters") void resetLocalMembership(InstanceRegisteredEvent event); @EventListener @SuppressWarnings("UnusedParameters") void updateMemberships(HeartbeatEvent event);  }