Skip to content

Commit

Permalink
Fix dropping changes in LiveSync (MID-5513)
Browse files Browse the repository at this point in the history
This commit fixes handling of sync token in LiveSync tasks in the
presence of task suspension and unrecoverable (halting) errors.
Token is either set to the last change successfully processed
(for "precise token" resources) or not changed at all (for all the
others).

There are also some changes in error handling. But all of this is
yet to be resolved, see MID-5514.
  • Loading branch information
mederly committed Jul 4, 2019
1 parent 3272e84 commit b8290ff
Show file tree
Hide file tree
Showing 17 changed files with 920 additions and 127 deletions.
Expand Up @@ -1100,9 +1100,13 @@ public void sync(ObjectClass objectClass, SyncToken token, SyncResultsHandler ha
throw new IllegalStateException("Unknown delta type "+delta.getType());
}
deltaBuilder.setDeltaType(deltaType);

deltaBuilder.setToken(new SyncToken(delta.getSyncToken()));


if (configuration.isImpreciseTokenValues()) {
deltaBuilder.setToken(new SyncToken(resource.getLatestSyncToken()));
} else {
deltaBuilder.setToken(new SyncToken(delta.getSyncToken()));
}

Uid uid;
if (configuration.getUidMode().equals(DummyConfiguration.UID_MODE_NAME)) {
uid = new Uid(delta.getObjectName());
Expand Down
Expand Up @@ -73,6 +73,7 @@ public class DummyConfiguration extends AbstractConfiguration {
private String pagingStrategy = PAGING_STRATEGY_OFFSET;
private String connectorInstanceNumberAttribute = null;
private String connectorInstanceNameAttribute = null;
private boolean impreciseTokenValues = false;

/**
* Defines name of the dummy resource instance. There may be several dummy resource running in
Expand Down Expand Up @@ -427,6 +428,15 @@ public void setConnectorInstanceNameAttribute(String connectorInstanceNameAttrib
this.connectorInstanceNameAttribute = connectorInstanceNameAttribute;
}

@ConfigurationProperty
public boolean isImpreciseTokenValues() {
return impreciseTokenValues;
}

public void setImpreciseTokenValues(boolean impreciseTokenValues) {
this.impreciseTokenValues = impreciseTokenValues;
}

/**
* {@inheritDoc}
*/
Expand Down

Large diffs are not rendered by default.

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<!-- Slow sync resource. Moreover it provides imprecise (CSV/LDAP-like) token values. Used to test LiveSync task interruption. -->

<resource oid="e396b76e-e010-46ed-bbf5-a3da78d358ea"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3"
xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
xmlns:piracy="http://midpoint.evolveum.com/xml/ns/samples/piracy"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<name>Dummy Resource Slow Sync Imprecise</name>
<connectorRef type="c:ConnectorType">
<filter>
<q:and>
<q:equal>
<q:path>connectorType</q:path>
<q:value>com.evolveum.icf.dummy.connector.DummyConnector</q:value>
</q:equal>
<q:equal>
<q:path>connectorVersion</q:path>
<q:value>2.0</q:value>
</q:equal>
</q:and>
</filter>
</connectorRef>
<connectorConfiguration xmlns:icfi="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">
<icfc:configurationProperties>
<icfi:instanceId>interruptedSyncImprecise</icfi:instanceId>
<icfi:impreciseTokenValues>true</icfi:impreciseTokenValues>
</icfc:configurationProperties>
</connectorConfiguration>

<schemaHandling>
<objectType>
<displayName>Default Account</displayName>
<default>true</default>
<objectClass>ri:AccountObjectClass</objectClass>
<attribute>
<ref>icfs:name</ref>
<inbound>
<expression>
<script>
<code>
import com.evolveum.midpoint.model.intest.sync.TestLiveSyncTaskInterruption

if (input == TestLiveSyncTaskInterruption.errorOn) {
throw new IllegalStateException("Got error!")
} else {
Thread.sleep(TestLiveSyncTaskInterruption.delay)
input
}
</code>
</script>
</expression>
<target>
<path>name</path>
</target>
</inbound>
</attribute>
</objectType>
</schemaHandling>

<!-- No "preciseTokenValue" capability here -->

<synchronization>
<objectSynchronization>
<enabled>true</enabled>
<correlation>
<q:equal>
<q:path>name</q:path>
<expression>
<path>$account/attributes/icfs:name</path>
</expression>
</q:equal>
</correlation>
<reaction>
<situation>linked</situation>
<synchronize>true</synchronize>
</reaction>
<reaction>
<situation>deleted</situation>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#deleteFocus</handlerUri>
</action>
</reaction>
<reaction>
<situation>unlinked</situation>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#link</handlerUri>
</action>
</reaction>
<reaction>
<situation>unmatched</situation>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#addFocus</handlerUri>
</action>
</reaction>
</objectSynchronization>
</synchronization>
</resource>
Expand Up @@ -15,7 +15,7 @@
~ limitations under the License.
-->

<!-- Slow sync resource. Used to test LiveSync task interruption. -->
<!-- Used to test LiveSync task interruption. -->

<resource oid="7a58233a-1cfb-46d1-a404-08cdf4626ebb"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
Expand All @@ -27,7 +27,7 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<name>Dummy Resource Slow Sync</name>
<name>Dummy Resource Interrupted Sync</name>
<connectorRef type="c:ConnectorType">
<filter>
<q:and>
Expand All @@ -45,7 +45,7 @@
<connectorConfiguration xmlns:icfi="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/bundle/com.evolveum.icf.dummy/com.evolveum.icf.dummy.connector.DummyConnector"
xmlns:icfc="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/connector-schema-3">
<icfc:configurationProperties>
<icfi:instanceId>slowSync</icfi:instanceId>
<icfi:instanceId>interruptedSync</icfi:instanceId>
</icfc:configurationProperties>
</connectorConfiguration>

Expand All @@ -60,8 +60,14 @@
<expression>
<script>
<code>
Thread.sleep(com.evolveum.midpoint.model.intest.sync.TestLiveSyncTaskInterruption.delay)
input
import com.evolveum.midpoint.model.intest.sync.TestLiveSyncTaskInterruption

if (input == TestLiveSyncTaskInterruption.errorOn) {
throw new IllegalStateException("Got error!")
} else {
Thread.sleep(TestLiveSyncTaskInterruption.delay)
input
}
</code>
</script>
</expression>
Expand Down
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<task oid="dcfe4c53-a851-4fe1-90eb-f75d9c65d2e6"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:ext="http://midpoint.evolveum.com/xml/ns/public/model/extension-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">

<name>Live Sync Interrupted: Batched Imprecise</name>

<extension>
<ext:objectclass>ri:AccountObjectClass</ext:objectclass>
<ext:liveSyncBatchSize>10</ext:liveSyncBatchSize>
</extension>

<taskIdentifier>dcfe4c53-a851-4fe1-90eb-f75d9c65d2e6</taskIdentifier>
<ownerRef oid="00000000-0000-0000-0000-000000000002"/>
<executionStatus>runnable</executionStatus>

<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3</handlerUri>
<objectRef oid="e396b76e-e010-46ed-bbf5-a3da78d358ea" type="ResourceType"/>
<recurrence>single</recurrence>
</task>
Expand Up @@ -18,15 +18,14 @@
<task oid="ef22bf7b-5d28-4a57-b3a5-6fa58491eeb3"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:ext="http://midpoint.evolveum.com/xml/ns/public/model/extension-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">

<name>Live Sync: Slow Sync Dummy Batched</name>
<name>Live Sync Interrupted: Batched</name>

<extension>
<ext:objectclass>ri:AccountObjectClass</ext:objectclass>
<ext:liveSyncBatchSize>10</ext:liveSyncBatchSize>
<ext:retryLiveSyncErrors>false</ext:retryLiveSyncErrors>
</extension>

<taskIdentifier>ef22bf7b-5d28-4a57-b3a5-6fa58491eeb3</taskIdentifier>
Expand Down
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<task oid="c554ec0f-95c3-40ac-b069-876708d28393"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:ext="http://midpoint.evolveum.com/xml/ns/public/model/extension-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">

<name>Live Sync Interrupted: Error Imprecise</name>

<extension>
<ext:objectclass>ri:AccountObjectClass</ext:objectclass>
<ext:retryLiveSyncErrors>true</ext:retryLiveSyncErrors>
</extension>

<taskIdentifier>c554ec0f-95c3-40ac-b069-876708d28393</taskIdentifier>
<ownerRef oid="00000000-0000-0000-0000-000000000002"/>
<executionStatus>runnable</executionStatus>

<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3</handlerUri>
<objectRef oid="e396b76e-e010-46ed-bbf5-a3da78d358ea" type="ResourceType"/>
<recurrence>single</recurrence>
</task>
37 changes: 37 additions & 0 deletions model/model-intest/src/test/resources/sync/task-intsync-error.xml
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<task oid="b697f3a8-9d02-4924-8627-c1f216e88ed3"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:ext="http://midpoint.evolveum.com/xml/ns/public/model/extension-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">

<name>Live Sync Interrupted: Error</name>

<extension>
<ext:objectclass>ri:AccountObjectClass</ext:objectclass>
<ext:retryLiveSyncErrors>true</ext:retryLiveSyncErrors>
</extension>

<taskIdentifier>b697f3a8-9d02-4924-8627-c1f216e88ed3</taskIdentifier>
<ownerRef oid="00000000-0000-0000-0000-000000000002"/>
<executionStatus>runnable</executionStatus>

<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3</handlerUri>
<objectRef oid="7a58233a-1cfb-46d1-a404-08cdf4626ebb" type="ResourceType"/>
<recurrence>single</recurrence>
</task>
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010-2019 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<task oid="066c6993-8b94-445c-aaff-937184bbe6ca"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:ext="http://midpoint.evolveum.com/xml/ns/public/model/extension-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">

<name>Live Sync Interrupted: Slow Model Imprecise</name>

<extension>
<ext:objectclass>ri:AccountObjectClass</ext:objectclass>
</extension>

<taskIdentifier>066c6993-8b94-445c-aaff-937184bbe6ca</taskIdentifier>
<ownerRef oid="00000000-0000-0000-0000-000000000002"/>
<executionStatus>runnable</executionStatus>

<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/synchronization/task/live-sync/handler-3</handlerUri>
<objectRef oid="e396b76e-e010-46ed-bbf5-a3da78d358ea" type="ResourceType"/>
<recurrence>single</recurrence>
</task>
Expand Up @@ -18,11 +18,9 @@
<task oid="c37dda96-e547-41c2-b343-b890bc7fade9"
xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
xmlns:ext="http://midpoint.evolveum.com/xml/ns/public/model/extension-3"
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3">

<name>Live Sync: Slow Sync Dummy 2</name>
<name>Live Sync Interrupted: Slow Model</name>

<extension>
<ext:objectclass>ri:AccountObjectClass</ext:objectclass>
Expand Down

0 comments on commit b8290ff

Please sign in to comment.