You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2018/09/15 03:40:48 UTC
[directory-server] branch master updated: o Fixed the
StartTransaction implementation: we now generate a transactionID o
Referencing the LDAP API 2.0.0-AM3 in ApacheDS
This is an automated email from the ASF dual-hosted git repository.
elecharny pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-server.git
The following commit(s) were added to refs/heads/master by this push:
new e5d1491 o Fixed the StartTransaction implementation: we now generate a transactionID o Referencing the LDAP API 2.0.0-AM3 in ApacheDS
e5d1491 is described below
commit e5d1491d66375bf5f6284359210720a80dd3d40b
Author: Emmanuel Lécharny <el...@symas.com>
AuthorDate: Sat Sep 15 05:40:45 2018 +0200
o Fixed the StartTransaction implementation: we now generate a
transactionID
o Referencing the LDAP API 2.0.0-AM3 in ApacheDS
---
.../apache/directory/server/core/api/CoreSession.java | 4 +++-
.../directory/server/core/api/MockCoreSession.java | 3 ++-
.../server/core/shared/DefaultCoreSession.java | 8 +++++++-
pom.xml | 3 ++-
.../handlers/extended/StartTransactionHandler.java | 19 +++++++++++++------
.../server/factory/ServerAnnotationProcessor.java | 3 ++-
6 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/core-api/src/main/java/org/apache/directory/server/core/api/CoreSession.java b/core-api/src/main/java/org/apache/directory/server/core/api/CoreSession.java
index 942f8aa..80f2dd9 100644
--- a/core-api/src/main/java/org/apache/directory/server/core/api/CoreSession.java
+++ b/core-api/src/main/java/org/apache/directory/server/core/api/CoreSession.java
@@ -834,8 +834,10 @@ public interface CoreSession
/**
* Set the flag indicating we have received the startTransaction extended operation
+ *
+ * @return The transaction ID
*/
- void beginSessionTransaction();
+ long beginSessionTransaction();
/**
diff --git a/core-api/src/test/java/org/apache/directory/server/core/api/MockCoreSession.java b/core-api/src/test/java/org/apache/directory/server/core/api/MockCoreSession.java
index 4d7c86e..bb07daa 100644
--- a/core-api/src/test/java/org/apache/directory/server/core/api/MockCoreSession.java
+++ b/core-api/src/test/java/org/apache/directory/server/core/api/MockCoreSession.java
@@ -1001,9 +1001,10 @@ public class MockCoreSession implements CoreSession
* {@inheritDoc}
*/
@Override
- public void beginSessionTransaction()
+ public long beginSessionTransaction()
{
// Nothing to do
+ return 0L;
}
diff --git a/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java b/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java
index 3a150bf..61105ba 100644
--- a/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java
+++ b/core-shared/src/main/java/org/apache/directory/server/core/shared/DefaultCoreSession.java
@@ -30,6 +30,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
import jdbm.recman.BaseRecordManager;
@@ -138,6 +139,9 @@ public class DefaultCoreSession implements CoreSession
/** The Map containing the transactions associated with each partition */
private Map<String, PartitionTxn> transactionMap = new HashMap<>();
+
+ /** The transaction ID */
+ private AtomicLong transactionId = new AtomicLong( 0 );
/**
* Creates a new instance of a DefaultCoreSession
@@ -1484,9 +1488,11 @@ public class DefaultCoreSession implements CoreSession
* {@inheritDoc}
*/
@Override
- public void beginSessionTransaction()
+ public long beginSessionTransaction()
{
hasSessionTransaction = true;
+
+ return transactionId.getAndIncrement();
}
diff --git a/pom.xml b/pom.xml
index a37d839..abec467 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,7 +46,7 @@
<!--additionalparam>-Xdoclint:none</additionalparam-->
<!-- Set versions for depending projects -->
- <org.apache.directory.api.version>2.0.0.AM2-SNAPSHOT</org.apache.directory.api.version>
+ <org.apache.directory.api.version>2.0.0.AM3-SNAPSHOT</org.apache.directory.api.version>
<org.apache.directory.mavibot.version>1.0.0-M8</org.apache.directory.mavibot.version>
<org.apache.directory.checkstyle-configuration.version>0.3</org.apache.directory.checkstyle-configuration.version>
<org.apache.directory.junit.junit-addons.version>2.0.0</org.apache.directory.junit.junit-addons.version>
@@ -106,6 +106,7 @@
<module>all</module>
<module>jdbm-partition</module>
<module>mavibot-partition</module>
+ <!--module>lmdb-partition</module-->
<!--module>mavibotv2-partition</module-->
<module>xdbm-partition</module>
<module>core-shared</module>
diff --git a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTransactionHandler.java b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTransactionHandler.java
index b79d358..60b3f18 100644
--- a/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTransactionHandler.java
+++ b/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTransactionHandler.java
@@ -27,19 +27,24 @@ import java.util.Set;
import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionRequest;
import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionResponse;
import org.apache.directory.api.ldap.extras.extended.startTransaction.StartTransactionResponseImpl;
+import org.apache.directory.api.ldap.model.message.ExtendedRequest;
+import org.apache.directory.api.ldap.model.message.ExtendedResponse;
+import org.apache.directory.server.core.api.CoreSession;
import org.apache.directory.server.ldap.ExtendedOperationHandler;
import org.apache.directory.server.ldap.LdapServer;
import org.apache.directory.server.ldap.LdapSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import jdbm.helper.Conversion;
+
/**
* An handler to manage the StartTransaction extended request operation
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class StartTransactionHandler implements ExtendedOperationHandler<StartTransactionRequest, StartTransactionResponse>
+public class StartTransactionHandler implements ExtendedOperationHandler<ExtendedRequest, ExtendedResponse>
{
private static final Logger LOG = LoggerFactory.getLogger( StartTransactionHandler.class );
public static final Set<String> EXTENSION_OIDS;
@@ -65,18 +70,20 @@ public class StartTransactionHandler implements ExtendedOperationHandler<StartTr
/**
* {@inheritDoc}
*/
- public void handleExtendedOperation( LdapSession requestor, StartTransactionRequest req ) throws Exception
+ public void handleExtendedOperation( LdapSession session, ExtendedRequest req ) throws Exception
{
LOG.debug( "StartTransaction requested" );
// We need to create a new transaction ID for the current session.
// If the current session is already processing a transaction, we will return an error
- StartTransactionResponse startTransactionResponse = new StartTransactionResponseImpl();
-
- requestor.getCoreSession().beginSessionTransaction();
+ CoreSession coreSession = session.getCoreSession();
+ long transactionId = coreSession.beginSessionTransaction();
+
+ StartTransactionResponse startTransactionResponse = new StartTransactionResponseImpl(
+ req.getMessageId(), Conversion.convertToByteArray( transactionId ) );
// write the response
- requestor.getIoSession().write( startTransactionResponse );
+ session.getIoSession().write( startTransactionResponse );
}
diff --git a/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java b/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java
index 8963367..6dfd003 100644
--- a/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java
+++ b/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java
@@ -522,6 +522,7 @@ public final class ServerAnnotationProcessor
throw new IllegalArgumentException( I18n.err( I18n.ERR_689, protocol ) );
}
+
private static int getFreePort() throws IOException
{
ServerSocket ss = new ServerSocket( 0 );
@@ -531,11 +532,11 @@ public final class ServerAnnotationProcessor
return port;
}
+
public static KdcServer getKdcServer( Description description, DirectoryService directoryService, int startPort )
{
CreateKdcServer createLdapServer = description.getAnnotation( CreateKdcServer.class );
return createKdcServer( createLdapServer, directoryService );
}
-
}