directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1791682 - in /directory/apacheds/branches/apacheds-value: core-integ/src/test/resources/org/apache/directory/server/core/schema/ installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/ installers-maven-plugin/src...
Date Mon, 17 Apr 2017 11:16:10 GMT
Author: elecharny
Date: Mon Apr 17 11:16:09 2017
New Revision: 1791682

URL: http://svn.apache.org/viewvc?rev=1791682&view=rev
Log:
Ported modifications made in trunk

Modified:
    directory/apacheds/branches/apacheds-value/core-integ/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode
    directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds
    directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh
    directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/sh.script.in
    directory/apacheds/branches/apacheds-value/installers/src/test/docker/archive.test
    directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin.test
    directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin2.test
    directory/apacheds/branches/apacheds-value/installers/src/test/docker/deb.test
    directory/apacheds/branches/apacheds-value/installers/src/test/docker/rpm.test
    directory/apacheds/branches/apacheds-value/interceptors/event/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
    directory/apacheds/branches/apacheds-value/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
    directory/apacheds/branches/apacheds-value/server-integ/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode
    directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/ApacheDsService.java
    directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/UberjarMain.java
    directory/apacheds/branches/apacheds-value/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
    directory/apacheds/branches/apacheds-value/wrapper/src/main/java/org/apache/directory/server/wrapper/ApacheDsTanukiWrapper.java

Modified: directory/apacheds/branches/apacheds-value/core-integ/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/core-integ/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
Binary files - no diff available.

Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds
(original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/apacheds
Mon Apr 17 11:16:09 2017
@@ -412,7 +412,7 @@ repair() {
      if [ "X$pid" = "X" ]
      then
          # The string passed to eval must handles spaces in paths correctly.
-         COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" set.INSTANCE_DIRECTORY=\"$INSTANCE_DIRECTORY\"
set.APACHEDS_COMMAND=\"repair\" set.INSTANCE=\"$INSTANCE\" wrapper.syslog.ident=\"$APP_NAME\"
wrapper.pidfile=\"$PIDFILE\" wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $LOCKPROP"
+         COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" \"$WRAPPER_CONF\" set.INSTANCE_DIRECTORY=\"$INSTANCE_DIRECTORY\"
set.APACHEDS_COMMAND=\"repair\" set.INSTANCE=\"$INSTANCE\" wrapper.syslog.ident=\"$APP_NAME\"
wrapper.pidfile=\"$PIDFILE\" $ANCHORPROP $LOCKPROP"
          eval $COMMAND_LINE
      else
          echo "$APP_LONG_NAME is already running."
@@ -555,7 +555,6 @@ case "$1" in
 
     'repair')
         checkUser touchlock $1 $INSTANCE
-        stopit
         repair
         start
         ;;

Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh
(original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/archive/apacheds.sh
Mon Apr 17 11:16:09 2017
@@ -175,7 +175,19 @@ elif [ "$ADS_ACTION" = "repair" ]; then
         -Dapacheds.shutdown.port="\"$ADS_SHUTDOWN_PORT\"" \
         -Dapacheds.log.dir="\"$ADS_INSTANCE/log\"" \
         -classpath "\"$CLASSPATH\"" \
-        org.apache.directory.server.UberjarMain "\"$ADS_INSTANCE\"" repair \
+        org.apache.directory.server.UberjarMain "\"$ADS_INSTANCE\"" repair
+        org.apache.directory.server.UberjarMain "\"$ADS_INSTANCE\"" repair
+    
+    # Printing instance information
+    [ $HAVE_TTY -eq 1 ] && echo "Starting ApacheDS instance '$ADS_INSTANCE_NAME'..."
+
+    # Launching ApacheDS
+    eval "\"$RUN_JAVA\"" $JAVA_OPTS $ADS_CONTROLS $ADS_EXTENDED_OPERATIONS \
+        -Dlog4j.configuration="\"file:$ADS_INSTANCE/conf/log4j.properties\"" \
+        -Dapacheds.shutdown.port="\"$ADS_SHUTDOWN_PORT\"" \
+        -Dapacheds.log.dir="\"$ADS_INSTANCE/log\"" \
+        -classpath "\"$CLASSPATH\"" \
+        org.apache.directory.server.UberjarMain "\"$ADS_INSTANCE\"" \
         > "$ADS_OUT" 2>&1 "&"
     echo $! > "$ADS_PID"
 elif [ "$ADS_ACTION" = "run" ]; then

Modified: directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/sh.script.in
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/sh.script.in?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/sh.script.in
(original)
+++ directory/apacheds/branches/apacheds-value/installers-maven-plugin/src/main/resources/org/apache/directory/server/installers/wrapper/src/sh.script.in
Mon Apr 17 11:16:09 2017
@@ -459,7 +459,7 @@ repair() {
      if [ "X$pid" = "X" ]
      then
          # The string passed to eval must handles spaces in paths correctly.
-         COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" repair \"$WRAPPER_CONF\" set.REPAIR_COMMAND=repair
set.INSTANCE_HOME=$INSTANCE_HOME set.INSTANCE=$INSTANCE wrapper.syslog.ident=$APP_NAME wrapper.pidfile=\"$PIDFILE\"
wrapper.daemonize=TRUE $ANCHORPROP $IGNOREPROP $LOCKPROP"
+         COMMAND_LINE="$CMDNICE \"$WRAPPER_CMD\" repair \"$WRAPPER_CONF\" set.REPAIR_COMMAND=repair
set.INSTANCE_HOME=$INSTANCE_HOME set.INSTANCE=$INSTANCE wrapper.syslog.ident=$APP_NAME wrapper.pidfile=\"$PIDFILE\"
$ANCHORPROP $LOCKPROP"
          eval $COMMAND_LINE
      else
          echo "$APP_LONG_NAME is already running."
@@ -582,7 +582,6 @@ case "$1" in
 
     'repair')
         checkUser touchlock $1 $INSTANCE
-        stopit
         repair
         start
         ;;

Modified: directory/apacheds/branches/apacheds-value/installers/src/test/docker/archive.test
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers/src/test/docker/archive.test?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers/src/test/docker/archive.test (original)
+++ directory/apacheds/branches/apacheds-value/installers/src/test/docker/archive.test Mon
Apr 17 11:16:09 2017
@@ -88,6 +88,16 @@ fi
 # search
 ldapsearch -h localhost -p 10389 -x -D "uid=admin,ou=system" -w secret -s base -b "dc=example,dc=com"
 
+# repair (stop before, should be started afterwards)
+/opt/${DIRNAME}/bin/apacheds.sh stop
+wait_for_apacheds_down
+/opt/${DIRNAME}/bin/apacheds.sh repair
+wait_for_apacheds_up
+if [ $HAVE_TTY -eq 1 ]
+then
+    /opt/${DIRNAME}/bin/apacheds.sh status | grep "ApacheDS is running"
+fi
+
 # restart and search a few times
 for i in 1 2 3
 do

Modified: directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin.test
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin.test?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin.test (original)
+++ directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin.test Mon Apr
17 11:16:09 2017
@@ -71,10 +71,16 @@ wait_for_apacheds
 service ${SERVICE_NAME} status | grep "ApacheDS - default is running"
 service ${SERVICE_NAME} status && test $? -eq 0
 
-
 # search
 ldapsearch -h localhost -p 10389 -x -D "uid=admin,ou=system" -w secret -s base -b "dc=example,dc=com"
 
+# repair (stop before, should be started afterwards)
+service ${SERVICE_NAME} stop
+service ${SERVICE_NAME} repair
+wait_for_apacheds
+service ${SERVICE_NAME} status | grep "ApacheDS - default is running"
+service ${SERVICE_NAME} status && test $? -eq 0
+
 # restart and search a few times
 for i in 1 2 3
 do

Modified: directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin2.test
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin2.test?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin2.test (original)
+++ directory/apacheds/branches/apacheds-value/installers/src/test/docker/bin2.test Mon Apr
17 11:16:09 2017
@@ -72,10 +72,16 @@ wait_for_apacheds
 service ${SERVICE_NAME} status | grep "ApacheDS - default is running"
 service ${SERVICE_NAME} status && test $? -eq 0
 
-
 # search
 ldapsearch -h localhost -p 10389 -x -D "uid=admin,ou=system" -w secret -s base -b "dc=example,dc=com"
 
+# repair (stop before, should be started afterwards)
+service ${SERVICE_NAME} stop
+service ${SERVICE_NAME} repair
+wait_for_apacheds
+service ${SERVICE_NAME} status | grep "ApacheDS - default is running"
+service ${SERVICE_NAME} status && test $? -eq 0
+
 # restart and search a few times
 for i in 1 2 3
 do

Modified: directory/apacheds/branches/apacheds-value/installers/src/test/docker/deb.test
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers/src/test/docker/deb.test?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers/src/test/docker/deb.test (original)
+++ directory/apacheds/branches/apacheds-value/installers/src/test/docker/deb.test Mon Apr
17 11:16:09 2017
@@ -65,6 +65,13 @@ service ${SERVICE_NAME} status && test $
 # search
 ldapsearch -h localhost -p 10389 -x -D "uid=admin,ou=system" -w secret -s base -b "dc=example,dc=com"
 
+# repair (stop before and start after)
+service ${SERVICE_NAME} stop
+service ${SERVICE_NAME} repair
+wait_for_apacheds
+service ${SERVICE_NAME} status | grep "ApacheDS - default is running"
+service ${SERVICE_NAME} status && test $? -eq 0
+
 # restart and search a few times
 for i in 1 2 3
 do

Modified: directory/apacheds/branches/apacheds-value/installers/src/test/docker/rpm.test
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/installers/src/test/docker/rpm.test?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/installers/src/test/docker/rpm.test (original)
+++ directory/apacheds/branches/apacheds-value/installers/src/test/docker/rpm.test Mon Apr
17 11:16:09 2017
@@ -71,6 +71,13 @@ wait_for_apacheds
 # search
 ldapsearch -h localhost -p 10389 -x -D "uid=admin,ou=system" -w secret -s base -b "dc=example,dc=com"
 
+# repair (stop before and start after)
+/etc/init.d/${SERVICE_NAME} stop
+/etc/init.d/${SERVICE_NAME} repair
+wait_for_apacheds
+/etc/init.d/${SERVICE_NAME} status | grep "ApacheDS - default is running"
+/etc/init.d/${SERVICE_NAME} status && test $? -eq 0
+
 # restart and search a few times
 for i in 1 2 3
 do

Modified: directory/apacheds/branches/apacheds-value/interceptors/event/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/interceptors/event/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/interceptors/event/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-value/interceptors/event/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
Mon Apr 17 11:16:09 2017
@@ -29,6 +29,8 @@ import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
@@ -95,6 +97,21 @@ public class EventInterceptor extends Ba
 
         evaluator = new ExpressionEvaluator( schemaManager );
         executor = new ThreadPoolExecutor( 1, 10, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(
100 ) );
+        
+        ThreadFactory threadFactory = new ThreadFactory() 
+        {
+            @Override
+            public Thread newThread( Runnable runnable ) 
+            {
+                Thread newThread = Executors.defaultThreadFactory().newThread( runnable );
+                newThread.setDaemon( true );
+                
+                return newThread;
+            }
+        };
+        
+        executor = new ThreadPoolExecutor( 1, 10, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(
100 ),
+            threadFactory );
 
         this.directoryService.setEventService( new DefaultEventService( directoryService
) );
         LOG.info( "Initialization complete." );

Modified: directory/apacheds/branches/apacheds-value/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
(original)
+++ directory/apacheds/branches/apacheds-value/mavibot-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/mavibot/MavibotStoreTest.java
Mon Apr 17 11:16:09 2017
@@ -35,7 +35,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
-import org.apache.directory.api.util.FileUtils;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.api.ldap.model.csn.CsnFactory;
 import org.apache.directory.api.ldap.model.entry.Attribute;
@@ -259,8 +258,7 @@ public class MavibotStoreTest
         assertEquals( 2, lookup.getDn().size() );
 
         // make sure all files are closed so that they can be deleted on Windows.
-        //store2.destroy();
-        FileUtils.deleteDirectory( wkdir2 );
+        // wkdir2 is deleted by TemporaryFolder rule
     }
 
 

Modified: directory/apacheds/branches/apacheds-value/server-integ/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/server-integ/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
Binary files - no diff available.

Modified: directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/ApacheDsService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/ApacheDsService.java?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/ApacheDsService.java
(original)
+++ directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/ApacheDsService.java
Mon Apr 17 11:16:09 2017
@@ -233,7 +233,7 @@ public class ApacheDsService
 
 
     /**
-     * Try to repair the partitions. For each partition, we need its directory and its DN
+     * Try to repair the partitions. Precondition is that this service was started before.
      *
      * @param instanceLayout the on disk location's layout of the intance to be repaired
      * @throws Exception If the repair failed
@@ -242,25 +242,8 @@ public class ApacheDsService
     {
         File partitionsDir = instanceLayout.getPartitionsDirectory();
 
-        if ( !partitionsDir.exists() )
-        {
-            System.out.println( "partition directory doesn't exist, creating " + partitionsDir.getAbsolutePath()
);
-
-            if ( !partitionsDir.mkdirs() )
-            {
-                throw new IOException( I18n.err( I18n.ERR_112_COULD_NOT_CREATE_DIRECORY,
partitionsDir ) );
-            }
-        }
-
         System.out.println( "Repairing partition dir " + partitionsDir.getAbsolutePath()
);
 
-        CacheService cacheService = new CacheService();
-        cacheService.initialize( instanceLayout );
-
-        initSchemaManager( instanceLayout );
-        DnFactory dnFactory = new DefaultDnFactory( schemaManager, cacheService.getCache(
"dnCache" ) );
-        initSchemaLdifPartition( instanceLayout, dnFactory );
-        initConfigPartition( instanceLayout, dnFactory, cacheService );
         Set<? extends Partition> partitions = getDirectoryService().getPartitions();
 
         // Iterate on the partitions to repair them

Modified: directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/UberjarMain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/UberjarMain.java?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/UberjarMain.java
(original)
+++ directory/apacheds/branches/apacheds-value/service/src/main/java/org/apache/directory/server/UberjarMain.java
Mon Apr 17 11:16:09 2017
@@ -175,14 +175,18 @@ public class UberjarMain
         
         try
         {
-            service.start( layout, false );
+            System.out.println( "Starting the service." );
+            // must start servers otherwise stop() won't work
+            service.start( layout, true );
+            // no need to start the shutdown listener
+            System.out.println( "Service started." );
         }
         catch ( Exception e )
         {
             return;
         }
 
-        // Initializing the service
+        // Repairing the database
         try
         {
             LOG.info( "Starting the service." );
@@ -191,9 +195,14 @@ public class UberjarMain
         }
         catch ( Exception e )
         {
-            LOG.error( "Failed to start the service.", e );
+            LOG.error( "Failed to repair the database.", e );
+            stop();
             System.exit( 1 );
         }
+        
+        // Stop the service
+        stop();
+
     }
     
 

Modified: directory/apacheds/branches/apacheds-value/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/service/src/test/java/org/apache/directory/server/UberJarMainTest.java?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
(original)
+++ directory/apacheds/branches/apacheds-value/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
Mon Apr 17 11:16:09 2017
@@ -360,12 +360,9 @@ public class UberJarMainTest
         // Stop the server
         uberjarMain.stop();
 
-        // Try to repair it
+        // Try to repair it (also starts and stops the server)
         uberjarMain.repair( instanceDirectory.toString() );
 
-        // Stop the server again
-        uberjarMain.stop();
-        
         // And restart it
         connectionVerificationThread = createServer();
         

Modified: directory/apacheds/branches/apacheds-value/wrapper/src/main/java/org/apache/directory/server/wrapper/ApacheDsTanukiWrapper.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-value/wrapper/src/main/java/org/apache/directory/server/wrapper/ApacheDsTanukiWrapper.java?rev=1791682&r1=1791681&r2=1791682&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-value/wrapper/src/main/java/org/apache/directory/server/wrapper/ApacheDsTanukiWrapper.java
(original)
+++ directory/apacheds/branches/apacheds-value/wrapper/src/main/java/org/apache/directory/server/wrapper/ApacheDsTanukiWrapper.java
Mon Apr 17 11:16:09 2017
@@ -21,14 +21,6 @@
 package org.apache.directory.server.wrapper;
 
 
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.net.Socket;
-import java.nio.charset.Charset;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-
-import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.server.ApacheDsService;
 import org.apache.directory.server.core.api.InstanceLayout;
@@ -65,23 +57,6 @@ public final class ApacheDsTanukiWrapper
         WrapperManager.start( new ApacheDsTanukiWrapper(), args );
     }
 
-
-    
-    private static int readShutdownPort( InstanceLayout layout ) throws IOException 
-    {
-        return Integer.parseInt( new String( Files.readAllBytes( 
-                Paths.get( layout.getRunDirectory().getAbsolutePath(), ".shutdown.port" )
),
-                Charset.forName( "utf-8" ) ) );
-    }
-    
-
-    private static String readShutdownPassword( InstanceLayout layout ) throws IOException

-    {
-        return new String( Files.readAllBytes( 
-                Paths.get( layout.getRunDirectory().getAbsolutePath(), ".shutdown.pwd" )
),
-                Charset.forName( "utf-8" ) );
-    }
-
     
     /**
      * Try to repair the databases
@@ -96,18 +71,22 @@ public final class ApacheDsTanukiWrapper
         // Creating ApacheDS service
         service = new ApacheDsService();
         
+        // Initializing the service
         try
         {
             System.out.println( "Starting the service." );
-            service.start( layout );
+            // must start servers otherwise stop() won't work
+            service.start( layout, true );
             System.out.println( "Service started." );
         }
         catch ( Exception e )
         {
-            return;
+            LOG.error( "Failed to start the service.", e );
+            stop( 1 );
+            System.exit( ExitCodes.START );
         }
 
-        // Initializing the service
+        // Repairing the database
         try
         {
             System.out.println( "Repairing the database." );
@@ -116,9 +95,13 @@ public final class ApacheDsTanukiWrapper
         }
         catch ( Exception e )
         {
-            LOG.error( "Failed to start the service.", e );
-            System.exit( 1 );
+            LOG.error( "Failed to repair the database.", e );
+            stop( 1 );
+            System.exit( ExitCodes.START );
         }
+        
+        // Stop the service
+        stop( 0 );
     }
 
 
@@ -172,18 +155,7 @@ public final class ApacheDsTanukiWrapper
                         case "stop" :
                             // Stops the server
                             LOG.debug( "Stopping runtime" );
-                            InstanceLayout layout = new InstanceLayout( instanceDirectory
);
-                            
-                            try ( Socket socket = new Socket( Network.LOOPBACK, readShutdownPort(
layout ) );
-                                    PrintWriter writer = new PrintWriter( socket.getOutputStream()
) )
-                            {
-                                writer.print( readShutdownPassword( layout ) );
-                            }
-                            catch ( IOException e )
-                            {
-                                // TODO Auto-generated catch block
-                                e.printStackTrace();
-                            }
+                            stop( 1 );
                             
                             break;
 



Mime
View raw message