Skip to content

Commit

Permalink
Asynchronization (add)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Apr 12, 2017
1 parent b5a5258 commit 9185513
Show file tree
Hide file tree
Showing 17 changed files with 375 additions and 153 deletions.
55 changes: 54 additions & 1 deletion infra/prism/src/main/resources/xml/ns/public/annotation-3.xsd
Expand Up @@ -19,7 +19,11 @@
<xsd:schema targetNamespace="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:tns="http://prism.evolveum.com/xml/ns/public/annotation-3"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="xjc"
jaxb:version="2.0">

<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -126,6 +130,55 @@
</xsd:annotation>
</xsd:element>

<xsd:element name="index" type="tns:IndexType">
<xsd:annotation>
<xsd:documentation>
Item annotation: Specifies type of index that is maintained for this
item. The data store maintains this type of index for the item.
This annotation may appear several times (maxOccurs=unbounded).
This annotation implies indexed=true.
WARNING: Presence of this annotation may impose some restriction on the
property, usually a length restriction. E.g. database systems usually
restrict the length of a datatype that can be efficiently indexed.
</xsd:documentation>
</xsd:annotation>
</xsd:element>

<xsd:simpleType name="IndexType">
<xsd:annotation>
<xsd:documentation>
Type of index maintained by the data store.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumClass/>
</xsd:appinfo>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="equality">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="EQUALITY"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="substring">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="SUBSTRING"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="presence">
<xsd:annotation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="PRESENCE"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>


<xsd:element name="ignore" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Expand Down
Expand Up @@ -13,23 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.provisioning.ucf.api;

import com.evolveum.midpoint.schema.result.OperationResult;
package com.evolveum.midpoint.schema.result;

/**
* Primary goal of this class is to support asynchronous operations.
* The call to UCF operation may return even if the resource operation
* The call to operation may return even if the resource operation
* is still in progress. The IN_PROGRESS status will be indicated in
* this class in the operation result. The connector may also include
* this class in the operation result. The result may also include
* the asynchronous operation reference in the operational status.
* This reference may be later used to check the status of the
* operation.
*
* This may seems too simple and maybe pointless now. But we expect
* that it may later evolve to something like future/promise.
*
* @author semancik
*
*/
public class ConnectorOperationResult {
public class AsynchronousOperationResult {

private OperationResult operationResult;

Expand All @@ -41,10 +42,13 @@ public void setOperationResult(OperationResult operationResult) {
this.operationResult = operationResult;
}

public static ConnectorOperationResult wrap(OperationResult result) {
ConnectorOperationResult ret = new ConnectorOperationResult();
public static AsynchronousOperationResult wrap(OperationResult result) {
AsynchronousOperationResult ret = new AsynchronousOperationResult();
ret.setOperationResult(result);
return ret;
}

public boolean isInProgress() {
return operationResult.isInProgress();
}
}
Expand Up @@ -13,15 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.evolveum.midpoint.provisioning.ucf.api;

import com.evolveum.midpoint.schema.result.OperationResult;
package com.evolveum.midpoint.schema.result;

/**
* This may seems too simple and maybe pointless now. But we expect
* that it may later evolve to something like future/promise.
*
* @author semancik
*
*/
public class ConnectorOperationReturnValue<T> extends ConnectorOperationResult {
public class AsynchronousOperationReturnValue<T> extends AsynchronousOperationResult {

private T returnValue;

Expand All @@ -33,8 +34,8 @@ public void setReturnValue(T returnValue) {
this.returnValue = returnValue;
}

public static <T> ConnectorOperationReturnValue<T> wrap(T returnValue, OperationResult result) {
ConnectorOperationReturnValue<T> ret = new ConnectorOperationReturnValue<>();
public static <T> AsynchronousOperationReturnValue<T> wrap(T returnValue, OperationResult result) {
AsynchronousOperationReturnValue<T> ret = new AsynchronousOperationReturnValue<>();
ret.setOperationResult(result);
ret.setReturnValue(returnValue);
return ret;
Expand Down
Expand Up @@ -113,7 +113,7 @@ public class OperationResult implements Serializable, DebugDumpable, Cloneable {
* format of this reference depends on the operation which is being
* executed.
*/
private String asyncronousOperationReference;
private String asynchronousOperationReference;

private static final Trace LOGGER = TraceManager.getTrace(OperationResult.class);

Expand Down Expand Up @@ -214,12 +214,12 @@ public OperationResult createMinorSubresult(String operation) {
* format of this reference depends on the operation which is being
* executed.
*/
public String getAsyncronousOperationReference() {
return asyncronousOperationReference;
public String getAsynchronousOperationReference() {
return asynchronousOperationReference;
}

public void setAsyncronousOperationReference(String asyncronousOperationReference) {
this.asyncronousOperationReference = asyncronousOperationReference;
public void setAsynchronousOperationReference(String asyncronousOperationReference) {
this.asynchronousOperationReference = asyncronousOperationReference;
}

/**
Expand Down Expand Up @@ -516,8 +516,8 @@ public void computeStatus() {
} else {
message = message + ": " + sub.getMessage();
}
if (asyncronousOperationReference == null) {
asyncronousOperationReference = sub.getAsyncronousOperationReference();
if (asynchronousOperationReference == null) {
asynchronousOperationReference = sub.getAsynchronousOperationReference();
}
return;
}
Expand Down Expand Up @@ -1296,9 +1296,9 @@ private void dumpIndent(StringBuilder sb, int indent, boolean printStackTrace) {
sb.append(" x");
sb.append(count);
}
if (asyncronousOperationReference != null) {
if (asynchronousOperationReference != null) {
sb.append("\n");
DebugUtil.debugDumpWithLabel(sb, "asyncronousOperationReference", asyncronousOperationReference, indent + 2);
DebugUtil.debugDumpWithLabel(sb, "asyncronousOperationReference", asynchronousOperationReference, indent + 2);
}
sb.append("\n");

Expand Down Expand Up @@ -1475,7 +1475,7 @@ public OperationResult clone() {
clone.summarizePartialErrors = summarizePartialErrors;
clone.summarizeSuccesses = summarizeSuccesses;
clone.minor = minor;
clone.asyncronousOperationReference = asyncronousOperationReference;
clone.asynchronousOperationReference = asynchronousOperationReference;

return clone;
}
Expand Down
103 changes: 103 additions & 0 deletions infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd
Expand Up @@ -7656,6 +7656,8 @@
<xsd:annotation>
<xsd:documentation>
Description of changes that happened to an resource object shadow.
This is still used in midPoint 3.6 for consistency mechanism. However, it is
deprecated. Later midPoint versions will use pendingOperation instead.
</xsd:documentation>
<xsd:appinfo>
<a:deprecated>true</a:deprecated>
Expand All @@ -7673,6 +7675,8 @@
<xsd:annotation>
<xsd:documentation>
Description of operation during the processing of account failed.
This is still used in midPoint 3.6 for consistency mechanism. However, it is
deprecated. Later midPoint versions will use pendingOperation instead.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>ShadowType.failedOperationType</a:displayName>
Expand All @@ -7691,6 +7695,24 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="pendingOperation" type="tns:PendingOperationType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Description of an operation which which execution is pending for this shadow.
This may be asynchronous operation in progress. E.g. operation that has to be
manually completed by human operator. It may also be operation that could not
be completed because there was a temporary error while communicating with the
resource. There may be also operations that are in fact already executed, but
we have not yet received the feedback. Or operations that are executed but are
still kept in the shadow for review by midPoint administrator.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>ShadowType.pendingOperation</a:displayName>
<a:since>3.6</a:since>
<a:index>presence</a:index>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="synchronizationSituation" type="tns:SynchronizationSituationType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -8006,6 +8028,87 @@
<xsd:attribute name="id" type="xsd:long" use="optional"/>
</xsd:complexType>

<xsd:complexType name="PendingOperationType">
<xsd:annotation>
<xsd:documentation>
Description of an operation that is pending (in progress) or that was
recently completed.
</xsd:documentation>
<xsd:appinfo>
<a:container/>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="delta" type="t:ObjectDeltaType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Operation delta. This is the change that is executed by the operation.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="requestTimestamp" type="xsd:dateTime" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
The timestamp of operation request. The point in time when the operation was
recoded and when it was initiated for the first time. It is set once and should never be changed.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="completionTimestamp" type="xsd:dateTime" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
The timestamp of operation completion. The point in time when the operation was
successful or when it has failed for the last time. No attempts to re-try the
operation were done after this timestamp.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="resultStatus" type="tns:OperationResultStatusType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
Operation status. If set to in_progress then the operation is
still executing. If not present at all then the operation was
not yet tried.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="asynchronousOperationReference" type="xsd:string" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
Reference to an asynchronous operation that can be used to refresh
the status of the running operation.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<!-- TODO operation type? E.g. distinguish between manual connector and consistency mechanism? Or is that implicit? -->
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long" use="optional"/>
</xsd:complexType>

<xsd:complexType name="SynchronizationSituationDescriptionType">
<xsd:annotation>
<xsd:documentation>
Expand Down

0 comments on commit 9185513

Please sign in to comment.