From: Tony Tkacik Date: Mon, 16 Jun 2014 16:33:40 +0000 (+0200) Subject: Bug 629: Introduction of Configuration Commit Handler X-Git-Tag: release/helium~648^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=5b322ec52a079aa43615637705e5ebcf8308c17d Bug 629: Introduction of Configuration Commit Handler One piece of functionality which was not-well defined in original APIs and was missing in new APIs is user-submitted commit handlers. Contract of Commit Handlers was updated to reflect more existing concept of three-phase commit and to allow commit handlers only for configuration subtree. Access to proposed data is done via read-only transaction instead of data change event, since commit handlers may want to cross-reference data with other and we need to capture this reads as preconditions for later commit phases. Change-Id: Id2049c05384dd74792f3cfbbb9f77bf684223be2 Signed-off-by: Tony Tkacik --- diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCohort.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCohort.java new file mode 100644 index 0000000000..9fb350b7c0 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCohort.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.md.sal.common.api.data; + +import org.opendaylight.yangtools.concepts.Path; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * + * Three phase Commit Cohort for subtree, which is + * uniquely associated with user submitted transcation. + * + * @param

+ * Type of path (subtree identifier), which represents location in + * tree + * @param + * Type of data (payload), which represents data payload + */ +public interface AsyncConfigurationCommitCohort

, D> { + + /** + * Initiates a pre-commit of associated request + * + * Implementation MUST NOT do any blocking calls during this callback, all + * pre-commit preparation SHOULD happen asynchronously and MUST result in + * completing returned future object. + * + * @param rebasedTransaction + * Read-only view of transaction as if happened on top of actual + * data store + * @return Future which is completed once pre-commit phase for this request + * is finished. + */ + ListenableFuture preCommit(AsyncReadTransaction rebasedTransaction); + + /** + * + * Initiates a commit phase of associated request + * + * Implementation MUST NOT do any blocking calls during this callback, all + * commit finalization SHOULD happen asynchronously and MUST result in + * completing returned future object. + * + * @return Future which is completed once commit phase for associated + * request is finished. + */ + ListenableFuture commit(); + + /** + * + * Initiates abort phase of associated request + * + * Implementation MUST NOT do any blocking calls during this callback, all + * commit finalization SHOULD happen asynchronously and MUST result in + * completing returned future object. + * + * @return Future which is completed once commit phase for associated + * request is finished. + */ + ListenableFuture abort(); + +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCoordinator.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCoordinator.java new file mode 100644 index 0000000000..6d669ab9df --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitCoordinator.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.md.sal.common.api.data; + +import org.opendaylight.yangtools.concepts.ObjectRegistration; +import org.opendaylight.yangtools.concepts.Path; + +/** + * Three Phase Commit Coordinator with support of user-supplied commit cohorts + * which participates in three-phase commit protocols + * + * @param

+ * Type of path (subtree identifier), which represents location in + * tree + * @param + * Type of data (payload), which represents data payload + */ +public interface AsyncConfigurationCommitCoordinator

, D> { + + /** + * Register configuration commit handler for particular subtree + * + * Configuration commit handler is invoked for all write transactions + * which modifies subtree + * + * @param subtree Subtree which configuration commit handler is interested it + * @param commitHandler Instance of user-provided commit handler + * @return Registration object representing this registration. Invoking {@link ObjectRegistration#close()} + * will unregister configuration commit handler. + */ + > ObjectRegistration registerConfigurationCommitHandler( + P subtree, C commitHandler); +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitHandler.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitHandler.java new file mode 100644 index 0000000000..6025e139ab --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/AsyncConfigurationCommitHandler.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.md.sal.common.api.data; + +import org.opendaylight.yangtools.concepts.Path; + +import com.google.common.util.concurrent.CheckedFuture; + +/** + * User-supplied participant in three-phase commit of transaction for configuration data tree + * + * Client-supplied implementation of commit handler for subtree, which + * is responsible for processing CAN-COMMIT phase of three-phase commit protocol + * and return CommitCohort, which provides access to additional transitions + * such as PRE-COMMIT, COMMIT and ABORT. + * + * @param

+ * Type of path (subtree identifier), which represents location in + * tree + * @param + * Type of data (payload), which represents data payload + */ +public interface AsyncConfigurationCommitHandler

, D> { + + /** + * + * Requests a can commit phase + * + * Implementations SHOULD NOT do any blocking operation during + * processing this callback. + * + * Implementation Notes + *