summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntje Fuhrmann2012-10-02 08:19:16 (EDT)
committer Robert Sauer2012-10-02 08:19:16 (EDT)
commitc70b49103543172cf0b130e4fd10d480b8268011 (patch)
tree85c6453c99608b1ca72e8582089937511a49e852
parenta4c2329943fc903612929e9c492ba073bb9504f2 (diff)
downloadorg.eclipse.stardust.engine-c70b49103543172cf0b130e4fd10d480b8268011.zip
org.eclipse.stardust.engine-c70b49103543172cf0b130e4fd10d480b8268011.tar.gz
org.eclipse.stardust.engine-c70b49103543172cf0b130e4fd10d480b8268011.tar.bz2
Jira-ID: CRNT-26286
A new sysconsole command 'auditTrail -checkConsistency' should be introduced. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/engine@59710 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java38
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/Archiver.java2
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/AuditTrailConsistencyCheck.java15
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/AuditTrailConsistencyChecker.java71
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/SharedDocumentDataConsistencyCheck.java114
-rw-r--r--stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java2
6 files changed, 239 insertions, 3 deletions
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java
index 0ee2d26..2239245 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/AlterAuditTrailCommand.java
@@ -30,6 +30,9 @@ import org.eclipse.stardust.engine.core.persistence.QueryExtension;
import org.eclipse.stardust.engine.core.persistence.jdbc.Session;
import org.eclipse.stardust.engine.core.persistence.jdbc.SessionFactory;
import org.eclipse.stardust.engine.core.runtime.beans.*;
+import org.eclipse.stardust.engine.core.runtime.beans.removethis.KernelTweakingProperties;
+import org.eclipse.stardust.engine.cli.sysconsole.consistency.AuditTrailConsistencyChecker;
+import org.eclipse.stardust.engine.cli.sysconsole.consistency.SharedDocumentDataConsistencyCheck;
import org.eclipse.stardust.engine.cli.sysconsole.utils.Utils;
@@ -58,6 +61,7 @@ public class AlterAuditTrailCommand extends AuditTrailCommand
private static final String AUDITTRAIL_SKIPDML = "skipDML";
private static final String AUDITTRAIL_SQL = "sql";
private static final String STATEMENT_DELIMITER = "statementDelimiter";
+ private static final String AUDITTRAIL_CHECK_CONSISTENCY = "checkConsistency";
private static final Options argTypes = new Options();
@@ -96,11 +100,13 @@ public class AlterAuditTrailCommand extends AuditTrailCommand
"Spools SQL statements to file instead of executing them on audit trail.", true);
argTypes.register("-" + STATEMENT_DELIMITER, "-sd", STATEMENT_DELIMITER,
"Specifies the delimiter applied after each SQL statement.", true);
+ argTypes.register("-" + AUDITTRAIL_CHECK_CONSISTENCY, "-cco", AUDITTRAIL_CHECK_CONSISTENCY,
+ "Checks wether any problem instances exists in audit trail.", false);
argTypes.addExclusionRule(//
new String[] { LOCKTABLE_ENABLE, LOCKTABLE_VERIFY, LOCKTABLE_DROP,//
DATACLUSTER_ENABLE, DATACLUSTER_VERIFY, DATACLUSTER_DROP,//
- PARTITION_CREATE, PARTITION_DROP, PARTITIONS_LIST }, true);
+ PARTITION_CREATE, PARTITION_DROP, PARTITIONS_LIST, AUDITTRAIL_CHECK_CONSISTENCY }, true);
argTypes.addExclusionRule(//
new String[] { LOCKTABLE_ENABLE, LOCKTABLE_VERIFY, LOCKTABLE_DROP,//
DATACLUSTER_VERIFY, DATACLUSTER_DROP,//
@@ -374,6 +380,34 @@ public class AlterAuditTrailCommand extends AuditTrailCommand
return optionHandled;
}
+
+ private boolean doRunCheckConsistencyOptions(Map options)
+ {
+ boolean optionHandled = false;
+ if (options.containsKey(AUDITTRAIL_CHECK_CONSISTENCY))
+ {
+ optionHandled = true;
+ print("Checks wether any problem instances exists in audit trail.");
+ AuditTrailConsistencyChecker consistencyChecker = new AuditTrailConsistencyChecker(
+ options);
+ consistencyChecker.addConsistencyCheck(new SharedDocumentDataConsistencyCheck());
+ consistencyChecker.run();
+ if (Boolean
+ .parseBoolean(SchemaHelper
+ .getAuditTrailProperty(KernelTweakingProperties.INFINITY_DMS_SHARED_DATA_EXIST)))
+ {
+ print("The audit trail contains data of type \"Document\" and \"Document Set\" that are shared "
+ + "between super- and subprocess although they should not. This will may result in "
+ + "undesired effects at runtime and will slow down archiving operations.");
+ }
+ else
+ {
+ print("The audit trail does not contain any problem instances.");
+ }
+ print("Consistency check done.");
+ }
+ return optionHandled;
+ }
public int doRun(Map options)
{
@@ -404,7 +438,7 @@ public class AlterAuditTrailCommand extends AuditTrailCommand
}
if ( !doRunLockingTableOptions(options) && !doRunDataClusterOptions(options)
- && !doRunPartitionOptions(options))
+ && !doRunPartitionOptions(options) && !doRunCheckConsistencyOptions(options))
{
print("Unknown option for command auditTrail.");
}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/Archiver.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/Archiver.java
index 6aead96..c3831ff 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/Archiver.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/Archiver.java
@@ -2396,7 +2396,7 @@ public class Archiver
});
}
- private static Set<Long> findAllDocumentDataOids()
+ public static Set<Long> findAllDocumentDataOids()
{
return findAllDataOids(new Functor()
{
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/AuditTrailConsistencyCheck.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/AuditTrailConsistencyCheck.java
new file mode 100644
index 0000000..a2f2916
--- /dev/null
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/AuditTrailConsistencyCheck.java
@@ -0,0 +1,15 @@
+package org.eclipse.stardust.engine.cli.sysconsole.consistency;
+
+
+/**
+ * The AuditTrailConsistencyCheck verifies if any problem instances exist in audittrail.
+ *
+ */
+public interface AuditTrailConsistencyCheck
+{
+
+ /**
+ * Runs the consistency check.
+ */
+ void execute();
+}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/AuditTrailConsistencyChecker.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/AuditTrailConsistencyChecker.java
new file mode 100644
index 0000000..ae46e29
--- /dev/null
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/AuditTrailConsistencyChecker.java
@@ -0,0 +1,71 @@
+package org.eclipse.stardust.engine.cli.sysconsole.consistency;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.stardust.common.CollectionUtils;
+import org.eclipse.stardust.common.StringUtils;
+import org.eclipse.stardust.common.config.ParametersFacade;
+import org.eclipse.stardust.common.error.PublicException;
+import org.eclipse.stardust.engine.api.model.PredefinedConstants;
+import org.eclipse.stardust.engine.cli.sysconsole.utils.Utils;
+import org.eclipse.stardust.engine.core.runtime.beans.removethis.SecurityProperties;
+
+/**
+ * AuditTrailConsistencyChecker runs all added consistency checks.
+ *
+ */
+public class AuditTrailConsistencyChecker
+{
+ private static final String PARTITION = "partition";
+
+ private List<AuditTrailConsistencyCheck> consistencyChecks = CollectionUtils.newList();
+
+ private List<String> partitionIds;
+
+ public AuditTrailConsistencyChecker(Map options)
+ {
+ // evaluate partition, fall back to default partition, if configured
+ String partitionSpec = (String) options.get(PARTITION);
+ if (StringUtils.isEmpty(partitionSpec))
+ {
+ partitionSpec = ParametersFacade.instance().getString(
+ SecurityProperties.DEFAULT_PARTITION,
+ PredefinedConstants.DEFAULT_PARTITION_ID);
+ }
+ partitionIds = CollectionUtils.newList();
+ for (Iterator i = StringUtils.split(partitionSpec, ","); i.hasNext();)
+ {
+ String id = (String) i.next();
+ if ((2 < id.length())
+ && ((id.startsWith("\"") && id.endsWith("\"") || (id.startsWith("'") && id
+ .endsWith("'")))))
+ {
+ id = id.substring(1, id.length() - 2);
+ }
+ partitionIds.add(id);
+ }
+ if (partitionIds.isEmpty())
+ {
+ throw new PublicException("No audittrail partition specified.");
+ }
+ }
+
+ public void addConsistencyCheck(AuditTrailConsistencyCheck consistencyCheck)
+ {
+ consistencyChecks.add(consistencyCheck);
+ }
+
+ public void run()
+ {
+ for (String partitionId : partitionIds)
+ {
+ Utils.initCarnotEngine(partitionId);
+ for (AuditTrailConsistencyCheck consistencyCheck : consistencyChecks)
+ {
+ consistencyCheck.execute();
+ }
+ }
+ }
+}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/SharedDocumentDataConsistencyCheck.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/SharedDocumentDataConsistencyCheck.java
new file mode 100644
index 0000000..627165a
--- /dev/null
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/cli/sysconsole/consistency/SharedDocumentDataConsistencyCheck.java
@@ -0,0 +1,114 @@
+package org.eclipse.stardust.engine.cli.sysconsole.consistency;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.stardust.common.error.PublicException;
+import org.eclipse.stardust.engine.cli.sysconsole.Archiver;
+import org.eclipse.stardust.engine.core.persistence.Column;
+import org.eclipse.stardust.engine.core.persistence.Join;
+import org.eclipse.stardust.engine.core.persistence.Predicates;
+import org.eclipse.stardust.engine.core.persistence.QueryDescriptor;
+import org.eclipse.stardust.engine.core.persistence.jdbc.QueryUtils;
+import org.eclipse.stardust.engine.core.persistence.jdbc.Session;
+import org.eclipse.stardust.engine.core.persistence.jdbc.SessionFactory;
+import org.eclipse.stardust.engine.core.runtime.beans.DataValueBean;
+import org.eclipse.stardust.engine.core.runtime.beans.ProcessInstanceBean;
+import org.eclipse.stardust.engine.core.runtime.beans.SchemaHelper;
+import org.eclipse.stardust.engine.core.runtime.beans.removethis.KernelTweakingProperties;
+
+/**
+ * SharedDocumentDataConsistencyCheck checks wether there are legacy document data types
+ * that are shared between super- and subprocess
+ *
+ */
+public class SharedDocumentDataConsistencyCheck implements AuditTrailConsistencyCheck
+{
+ @Override
+ public void execute()
+ {
+ Set docDataOids = Archiver.findAllDocumentDataOids();
+ if ((!docDataOids.isEmpty()) && checkSharedDataExists(docDataOids))
+ {
+ SchemaHelper.setAuditTrailProperty(
+ KernelTweakingProperties.INFINITY_DMS_SHARED_DATA_EXIST, "true");
+ }
+ else
+ {
+ SchemaHelper.setAuditTrailProperty(
+ KernelTweakingProperties.INFINITY_DMS_SHARED_DATA_EXIST, "false");
+ }
+ }
+
+ private boolean checkSharedDataExists(Set docDataOids)
+ {
+ Session session = (Session) SessionFactory.getSession(SessionFactory.AUDIT_TRAIL);
+ QueryDescriptor q = buildQuery(docDataOids);
+
+ List stillRunningRootPiOids = new ArrayList();
+ ResultSet rs = null;
+ try
+ {
+ rs = session.executeQuery(q);
+ while (rs.next())
+ {
+ stillRunningRootPiOids.add(new Long(rs.getLong(1)));
+ }
+ }
+ catch (SQLException e)
+ {
+ throw new PublicException(e);
+ }
+ finally
+ {
+ QueryUtils.closeResultSet(rs);
+ }
+ return !stillRunningRootPiOids.isEmpty();
+
+ }
+
+ private QueryDescriptor buildQuery(Set docDataOids)
+ {
+ /*
+ * SELECT DISTINCT spi.ROOTPROCESSINSTANCE from data_value dv
+ * INNER JOIN process_instance spi ON (dv.processInstance = spi.oid)
+ * left outer join data_value dv2 on (dv.NUMBER_VALUE = dv2.NUMBER_VALUE and dv.DATA = dv2.DATA and dv.MODEL = dv2.MODEL)
+ * left outer join PROCESS_INSTANCE spi2 on (dv2.PROCESSINSTANCE = spi2.OID)
+ * where dv.DATA in (12) and dv.TYPE_KEY != -1 and dv.oid != dv2.oid and spi2.TERMINATIONTIME = 0
+ */
+
+ QueryDescriptor q = QueryDescriptor.from(DataValueBean.class, "dv");
+ Join spiJoin = new Join(ProcessInstanceBean.class, "spi").on(
+ DataValueBean.FR__PROCESS_INSTANCE, ProcessInstanceBean.FIELD__OID);
+
+ Join dv2Join = new Join(DataValueBean.class, "dv2")
+ .on(DataValueBean.FR__NUMBER_VALUE, DataValueBean.FIELD__NUMBER_VALUE)
+ .andOn(DataValueBean.FR__DATA, DataValueBean.FIELD__DATA)
+ .andOn(DataValueBean.FR__MODEL, DataValueBean.FIELD__MODEL);
+ dv2Join.setRequired(false);
+
+ Join spi2Join = new Join(ProcessInstanceBean.class, "spi2").on(
+ dv2Join.fieldRef(DataValueBean.FIELD__PROCESS_INSTANCE),
+ ProcessInstanceBean.FIELD__OID);
+ spi2Join.setRequired(false);
+ spi2Join.setDependency(dv2Join);
+
+ q.getQueryExtension().addJoin(spiJoin).addJoin(dv2Join).addJoin(spi2Join);
+
+ q.getQueryExtension().setDistinct(true);
+ q.getQueryExtension().setSelection(
+ new Column[] {spiJoin
+ .fieldRef(ProcessInstanceBean.FIELD__ROOT_PROCESS_INSTANCE)});
+
+ q.where(Predicates.andTerm(Archiver.splitUpOidsSubList(new ArrayList(docDataOids),
+ DataValueBean.FR__DATA), Predicates.notEqual(DataValueBean.FR__TYPE_KEY, -1),
+ Predicates.notEqual(DataValueBean.FR__OID,
+ dv2Join.fieldRef(DataValueBean.FIELD__OID)), Predicates.isEqual(
+ spi2Join.fieldRef(ProcessInstanceBean.FIELD__TERMINATION_TIME), 0)));
+ return q;
+ }
+
+}
diff --git a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java
index d929c95..672bfe3 100644
--- a/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java
+++ b/stardust-engine-core/src/main/java/org/eclipse/stardust/engine/core/runtime/beans/removethis/KernelTweakingProperties.java
@@ -201,4 +201,6 @@ public final class KernelTweakingProperties
public static final String HZ_JCA_CONNECTION_FACTORY_PROVIDER = "Carnot.Engine.Hazelcast.JcaConnectionFactoryProvider";
public static final String ASSIGN_TO_INVALID_USER = "Infinity.Engine.Activity.AssignToInvalidUser";
+
+ public static final String INFINITY_DMS_SHARED_DATA_EXIST = "Infinity.Dms.SharedDataExist";
} \ No newline at end of file