Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-18622

StorageService throws inconsistent exceptions for unknown hosts

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Normal
    • Resolution: Unresolved
    • 5.x
    • Legacy/Core
    • None
    • Correctness - API / Semantic Implementation
    • Normal
    • Normal
    • User Report
    • All
    • None

    Description

      When hosts are unknown, StorageService throws two types of exceptions. The following methods throw RuntimeException:

       

       public String getNativeaddress(InetAddressAndPort endpoint, boolean withPort){
        ...
        try{                
          InetAddressAndPort address =   InetAddressAndPort.getByName(Gossiper.instance.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.NATIVE_ADDRESS_AND_PORT).value);                
          return address.getHostAddress(withPort);            
      }catch (UnknownHostException e) {
            throw new RuntimeException(e);            
       }
      }
      public void onChange(InetAddressAndPort endpoint, ApplicationState state, VersionedValue value){
      ...
      try { 
        InetAddressAndPort address = InetAddressAndPort.getByName(value.value);   SystemKeyspace.updatePeerNativeAddress(endpoint, address); 
      } catch (UnknownHostException e) 
      { 
          throw new RuntimeException(e); 
      }
      ...
      }
      

      A method throws IllegalArgumentException

       public void rebuild(String sourceDc, String keyspace, String tokens, String specificSources, boolean excludeLocalDatacenterNodes){
        ...
        try                        {                            InetAddressAndPort endpoint = InetAddressAndPort.getByName(stringHost);                            if (FBUtilities.getBroadcastAddressAndPort().equals(endpoint))                            {                                throw new IllegalArgumentException("This host was specified as a source for rebuilding. Sources for a rebuild can only be other nodes in the cluster.");                            }                            sources.add(endpoint);                        }                        catch (UnknownHostException ex)                        {                            throw new IllegalArgumentException("Unknown host specified " + stringHost, ex);                        }
      } 

      A method throws no exceptions:

      private void handleStateBootreplacing(InetAddressAndPort newNode, String[] pieces){
       ...
      try {
            oldNode = InetAddressAndPort.getByName(pieces[1]);        
      } catch (Exception e) {            
         logger.error("Node {} tried to replace malformed endpoint {}.", newNode, pieces[1], e);            
         return;        
      }
      ...
      } 

      A method does not rethrow exceptions and throws 
      UnknownHostException

       public List<String> getTokens(String endpoint) throws UnknownHostException    {        return getTokens(InetAddressAndPort.getByName(endpoint));    } 

      The treatments look random.

      Attachments

        Activity

          People

            Unassigned Unassigned
            haozhong Hao Zhong
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: