You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by er...@apache.org on 2007/05/28 10:14:21 UTC

svn commit: r542147 - in /directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared: crypto/encryption/DesStringToKey.java messages/value/HostAddress.java

Author: erodriguez
Date: Mon May 28 01:14:21 2007
New Revision: 542147

URL: http://svn.apache.org/viewvc?view=rev&rev=542147
Log:
Warnings clean-up in kerberos-shared.

Modified:
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java
    directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java

Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java?view=diff&rev=542147&r1=542146&r2=542147
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java (original)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java Mon May 28 01:14:21 2007
@@ -327,6 +327,7 @@
         }
         catch ( UnsupportedEncodingException ue )
         {
+            // Shouldn't ever happen for UTF-8.
         }
 
         return encodedByteArray;

Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java?view=diff&rev=542147&r1=542146&r2=542147
==============================================================================
--- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java (original)
+++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java Mon May 28 01:14:21 2007
@@ -129,6 +129,7 @@
         }
         catch ( UnknownHostException uhe )
         {
+            // Allow default to return.
         }
 
         return result;



Re: svn commit: r542147 - in /directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared: crypto/encryption/DesStringToKey.java messages/value/HostAddress.java

Posted by Enrique Rodriguez <en...@gmail.com>.
On 5/28/07, Emmanuel Lecharny <el...@gmail.com> wrote:
> ...
> in order to avoid having to add those try...catch when converting
> String to byte[], we have created a static method in StringTools (in
> the shared-ldap project) :
> ...
> Another suggestion, while we are discussing about the code : in the
> Bind hndler (and in some other classes), you have added a lot of debug
> traces, which is good (in general, I think we don't have enough
> debugging logs in the serever, but that's another story ...), but the
> way you did it can be very costly.
> ...

Thanks for the tips; I'll start to work them into the codebase.

Enrique

Re: svn commit: r542147 - in /directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared: crypto/encryption/DesStringToKey.java messages/value/HostAddress.java

Posted by Alex Karasulu <ak...@apache.org>.
On 5/28/07, Emmanuel Lecharny <el...@gmail.com> wrote:

> For instance, in ChainGuard.java, you have such invocations in the
> execute method :
>         log.debug( "Is simple:       " + request.isSimple() );
>         log.debug( "SASL mechanism:  " + request.getSaslMechanism() );
>         log.debug( "Credentials:     " + request.getCredentials() );
>
> Even if debug is disabled, this will invoke the request.XXX methods,
> and create a String concatenating the result with the message, String
> which will be discarded immediatly. When I did some profiling, I found
> that such calls cost as much as 5 to 10 % of the global CPU consummed
> inside the server.


Yes yes this is a needless waste of CPU cycles.

Alex

Re: svn commit: r542147 - in /directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared: crypto/encryption/DesStringToKey.java messages/value/HostAddress.java

Posted by Emmanuel Lecharny <el...@gmail.com>.
Hi Enrique,

in order to avoid having to add those try...catch when converting
String to byte[], we have created a static method in StringTools (in
the shared-ldap project) :

    /**
     * Return UTF-8 encoded byte[] representation of a String
     *
     * @param string
     *            The string to be transformed to a byte array
     * @return The transformed byte array
     */
    public static final byte[] getBytesUtf8( String string )

In your case,  it can be used instead of the method :
    /**
     * Encodes string with UTF-8 encoding.
     *
     * @param string The String to encode.
     * @return The encoded String.
     */
    protected byte[] characterEncodeString( String string )

Another suggestion, while we are discussing about the code : in the
Bind hndler (and in some other classes), you have added a lot of debug
traces, which is good (in general, I think we don't have enough
debugging logs in the serever, but that's another story ...), but the
way you did it can be very costly.

For instance, in ChainGuard.java, you have such invocations in the
execute method :
        log.debug( "Is simple:       " + request.isSimple() );
        log.debug( "SASL mechanism:  " + request.getSaslMechanism() );
        log.debug( "Credentials:     " + request.getCredentials() );

Even if debug is disabled, this will invoke the request.XXX methods,
and create a String concatenating the result with the message, String
which will be discarded immediatly. When I did some profiling, I found
that such calls cost as much as 5 to 10 % of the global CPU consummed
inside the server.

You have two ways to avoid such CPU consumption :
- simply declare a static final DEBUG which will be set to the value
returned by a call to isDebugEnabled() and before calling the
log.debug( blah ) method, check this static field (of course, that
means that you will lose the ability to switch to debug level at run
time, but is this a big deal anyway ?)
- if you need to keep this ability to switch debug mode at run time,
then you should use the log.debug this way :
log.debug( "Is simple:       {}", request.isSimple() );
so that even if the method is called, the String won't be constructed
at all if not in debug mode. The cost will greatly decrease.

Thanks !

On 5/28/07, erodriguez@apache.org <er...@apache.org> wrote:
> Author: erodriguez
> Date: Mon May 28 01:14:21 2007
> New Revision: 542147
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=542147
> Log:
> Warnings clean-up in kerberos-shared.
>
> Modified:
>     directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java
>     directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java
>
> Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java?view=diff&rev=542147&r1=542146&r2=542147
> ==============================================================================
> --- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java (original)
> +++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/crypto/encryption/DesStringToKey.java Mon May 28 01:14:21 2007
> @@ -327,6 +327,7 @@
>          }
>          catch ( UnsupportedEncodingException ue )
>          {
> +            // Shouldn't ever happen for UTF-8.
>          }
>
>          return encodedByteArray;
>
> Modified: directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java
> URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java?view=diff&rev=542147&r1=542146&r2=542147
> ==============================================================================
> --- directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java (original)
> +++ directory/apacheds/trunk/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/HostAddress.java Mon May 28 01:14:21 2007
> @@ -129,6 +129,7 @@
>          }
>          catch ( UnknownHostException uhe )
>          {
> +            // Allow default to return.
>          }
>
>          return result;
>
>
>


-- 
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com