Class ServerDescriptor

    • Constructor Detail

      • ServerDescriptor

        protected ServerDescriptor()
        Default constructor.
    • Method Detail

      • getReplicas

        public Set<ReplicaDescriptor> getReplicas()
        Returns the replicas contained on the server.
        Returns:
        the replicas contained on the server.
      • setReplicas

        public void setReplicas​(Set<ReplicaDescriptor> replicas)
        Sets the replicas contained on the server.
        Parameters:
        replicas - the replicas contained on the server.
      • getAdsProperties

        public Map<ADSContext.ServerProperty,​Object> getAdsProperties()
        Returns a Map containing the ADS properties of the server.
        Returns:
        a Map containing the ADS properties of the server.
      • getServerProperties

        public Map<ServerDescriptor.ServerProperty,​Object> getServerProperties()
        Returns a Map containing the properties of the server.
        Returns:
        a Map containing the properties of the server.
      • isRegistered

        public boolean isRegistered()
        Tells whether this server is registered in the ADS.
        Returns:
        true if the server is registered in the ADS and false otherwise.
      • isReplicationServer

        public boolean isReplicationServer()
        Tells whether this server is a replication server.
        Returns:
        true if the server is a replication server and false otherwise.
      • isReplicationEnabled

        public boolean isReplicationEnabled()
        Tells whether replication is enabled on this server.
        Returns:
        true if replication is enabled and false otherwise.
      • getReplicationServerHostPort

        public HostPort getReplicationServerHostPort()
        Returns the String representation of this replication server based on the information we have ("hostname":"replication port") and null if this is not a replication server.
        Returns:
        the String representation of this replication server based on the information we have ("hostname":"replication port") and null if this is not a replication server.
      • getReplicationServerId

        public int getReplicationServerId()
        Returns the replication server ID of this server and -1 if this is not a replications server.
        Returns:
        the replication server ID of this server and -1 if this is not a replications server.
      • getReplicationServerPort

        public int getReplicationServerPort()
        Returns the replication port of this server and -1 if this is not a replications server.
        Returns:
        the replication port of this server and -1 if this is not a replications server.
      • isReplicationSecure

        public boolean isReplicationSecure()
        Returns whether the communication with the replication port on the server is encrypted.
        Returns:
        true if the communication with the replication port on the server is encrypted and false otherwise.
      • setAdsProperties

        public void setAdsProperties​(Map<ADSContext.ServerProperty,​Object> adsProperties)
        Sets the ADS properties of the server.
        Parameters:
        adsProperties - a Map containing the ADS properties of the server.
      • getHostName

        public String getHostName()
        Returns the host name of the server.
        Returns:
        the host name of the server.
      • getLdapHostPort

        public HostPort getLdapHostPort()
        Returns the HostPort to access this server using LDAP.
        Returns:
        the HostPort to access this server using LDAP, null if the server is not configured to listen on an LDAP port.
      • getLdapsHostPort

        public HostPort getLdapsHostPort()
        Returns the HostPort to access this server using LDAPS.
        Returns:
        the HostPort to access this server using LDAPS, null if the server is not configured to listen on an LDAPS port.
      • getAdminConnectorHostPort

        public HostPort getAdminConnectorHostPort()
        Returns the HostPort to access this server using the administration connector.
        Returns:
        the HostPort to access this server using the administration connector, null if the server cannot get the administration connector.
      • getEnabledAdministrationPorts

        public List<Integer> getEnabledAdministrationPorts()
        Returns the list of enabled administration ports.
        Returns:
        the list of enabled administration ports.
      • getHostPort

        public HostPort getHostPort​(boolean securePreferred)
        Returns a String of type host-name:port-number for the server. If the provided securePreferred is set to true the port that will be used will be the administration connector port.
        Parameters:
        securePreferred - whether to try to use the secure port as part of the returning String.
        Returns:
        a String of type host-name:port-number for the server.
      • getId

        public String getId()
        Returns an Id that is unique for this server.
        Returns:
        an Id that is unique for this server.
      • getInstancePublicKeyCertificate

        public byte[] getInstancePublicKeyCertificate()
        Returns the instance-key public-key certificate retrieved from the truststore backend of the instance referenced through this descriptor.
        Returns:
        The public-key certificate of the instance.
      • getSchemaReplicationID

        public String getSchemaReplicationID()
        Returns the schema generation ID of the server.
        Returns:
        the schema generation ID of the server.
      • getLastException

        public TopologyCacheException getLastException()
        Returns the last exception that was encountered reading the configuration of the server. Returns null if there was no problem loading the configuration of the server.
        Returns:
        the last exception that was encountered reading the configuration of the server. Returns null if there was no problem loading the configuration of the server.
      • setLastException

        public void setLastException​(TopologyCacheException lastException)
        Sets the last exception that occurred while reading the configuration of the server.
        Parameters:
        lastException - the last exception that occurred while reading the configuration of the server.
      • updateAdsPropertiesWithServerProperties

        public void updateAdsPropertiesWithServerProperties()
        This methods updates the ADS properties (the ones that were read from the ADS) with the contents of the server properties (the ones that were read directly from the server).
      • createStandalone

        public static ServerDescriptor createStandalone​(Map<ADSContext.ServerProperty,​Object> adsProperties)
        Creates a ServerDescriptor object based on some ADS properties provided.
        Parameters:
        adsProperties - the ADS properties of the server.
        Returns:
        a ServerDescriptor object that corresponds to the provided ADS properties.
      • createStandalone

        public static ServerDescriptor createStandalone​(ConnectionWrapper conn,
                                                        TopologyCacheFilter filter)
                                                 throws IOException
        Creates a ServerDescriptor object based on the configuration that we read using the provided connection.
        Parameters:
        conn - the connection that will be used to read the configuration of the server.
        filter - the topology cache filter describing the information that must be retrieved.
        Returns:
        a ServerDescriptor object that corresponds to the read configuration.
        Throws:
        IOException - if a problem occurred reading the server configuration.
      • seedAdsTrustStore

        public static void seedAdsTrustStore​(ConnectionWrapper connWrapper,
                                             Map<String,​byte[]> keyEntryMap)
                                      throws LdapException
        Seeds the bound instance's local ads-truststore with a set of instance key-pair public key certificates. The result is the instance will trust any instance possessing the private key corresponding to one of the public-key certificates. This trust is necessary at least to initialize replication, which uses the trusted certificate entries in the ads-truststore for server authentication.
        Parameters:
        connWrapper - The connection to the server.
        keyEntryMap - The set of valid (i.e., not tagged as compromised) instance key-pair public-key certificate entries in ADS represented as a map from keyID to public-key certificate (binary).
        Throws:
        LdapException - in case an error occurs while updating the instance's ads-truststore via LDAP.
      • getSuffixDisplay

        public static String getSuffixDisplay​(DN baseDN,
                                              Set<ServerDescriptor> servers)
        Returns a representation of a base DN for a set of servers.
        Parameters:
        baseDN - the base DN.
        servers - the servers.
        Returns:
        a representation of a base DN for a set of servers.
      • isSameServer

        public boolean isSameServer​(ServerDescriptor server)
        Tells whether the provided server descriptor represents the same server as this object.
        Parameters:
        server - the server to make the comparison.
        Returns:
        true if the provided server descriptor represents the same server as this object, false otherwise.