groups) {
+ this.groups = groups;
+ }
public long getAckVersion() {
return ackVersion;
@@ -245,51 +276,128 @@ public void setWorkerRecoveryVersion(String workerRecoveryVersion) {
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof WorkerNode)) return false;
-
- WorkerNode that = (WorkerNode) o;
-
- return new EqualsBuilder()
- .append(this.uuid, that.uuid)
- .append(this.description, that.description)
- .append(this.hostName, that.hostName)
- .append(this.installPath, that.installPath)
- .append(this.active, that.active)
- .append(this.ackTime, that.ackTime)
- .append(this.ackVersion, that.ackVersion)
- .append(this.os, that.os)
- .append(this.jvm, that.jvm)
- .append(this.dotNetVersion, that.dotNetVersion)
- .append(this.groups, that.groups)
- .append(this.bulkNumber, that.bulkNumber)
- .append(this.workerRecoveryVersion, that.workerRecoveryVersion)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(uuid,description,hostName,installPath,active,ackVersion,ackTime,os,jvm,dotNetVersion,groups,bulkNumber,workerRecoveryVersion);
- }
-
- @Override
- public String toString() {
-
- return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
- .append("UUID", uuid)
- .append("active", active)
- .append("ackTime", ackTime)
- .append("ackVersion", ackVersion)
- .append("host", hostName)
- .append("path", installPath)
- .append("OS", os)
- .append("JVM", jvm)
- .append(".NET", dotNetVersion)
- .append("groups", groups)
- .append("bulkNumber", bulkNumber)
- .append("workerRecoveryVersion", workerRecoveryVersion)
- .toString()
- ;
- }
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ @Override
+ public String getVersionId() {
+ return versionId;
+ }
+
+ public void setVersionId(String versionId) {
+ this.versionId = versionId;
+ }
+
+ public boolean isQueueSync() {
+ return queueSync;
+ }
+
+ public void setQueueSync(boolean queueSync) {
+ this.queueSync = queueSync;
+ }
+
+ @Override
+ public String getWorkerBusynessValue() {
+ return workerBusynessValue;
+ }
+
+ public void setWorkerBusynessValue(String workerBusynessValue) {
+ this.workerBusynessValue = workerBusynessValue;
+ }
+
+ @Override
+ public String getAlias() {
+ return alias;
+ }
+
+ public void setAlias(String alias) {
+ this.alias = alias;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ WorkerNode that = (WorkerNode) o;
+
+ if (active != that.active) return false;
+ if (deleted != that.deleted) return false;
+ if (ackVersion != that.ackVersion) return false;
+ if (queueSync != that.queueSync) return false;
+ if (uuid != null ? !uuid.equals(that.uuid) : that.uuid != null) return false;
+ if (status != that.status) return false;
+ if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false;
+ if (installPath != null ? !installPath.equals(that.installPath) : that.installPath != null) return false;
+ if (description != null ? !description.equals(that.description) : that.description != null) return false;
+ if (password != null ? !password.equals(that.password) : that.password != null) return false;
+ if (os != null ? !os.equals(that.os) : that.os != null) return false;
+ if (jvm != null ? !jvm.equals(that.jvm) : that.jvm != null) return false;
+ if (dotNetVersion != null ? !dotNetVersion.equals(that.dotNetVersion) : that.dotNetVersion != null)
+ return false;
+ if (ackTime != null ? !ackTime.equals(that.ackTime) : that.ackTime != null) return false;
+ if (groups != null ? !groups.equals(that.groups) : that.groups != null) return false;
+ if (bulkNumber != null ? !bulkNumber.equals(that.bulkNumber) : that.bulkNumber != null) return false;
+ if (workerRecoveryVersion != null ? !workerRecoveryVersion.equals(that.workerRecoveryVersion) : that.workerRecoveryVersion != null)
+ return false;
+ if (version != null ? !version.equals(that.version) : that.version != null) return false;
+ if (alias != null ? !alias.equals(that.alias) : that.alias != null) return false;
+ return !(versionId != null ? !versionId.equals(that.versionId) : that.versionId != null);
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = uuid != null ? uuid.hashCode() : 0;
+ result = 31 * result + (status != null ? status.hashCode() : 0);
+ result = 31 * result + (active ? 1 : 0);
+ result = 31 * result + (hostName != null ? hostName.hashCode() : 0);
+ result = 31 * result + (installPath != null ? installPath.hashCode() : 0);
+ result = 31 * result + (description != null ? description.hashCode() : 0);
+ result = 31 * result + (password != null ? password.hashCode() : 0);
+ result = 31 * result + (os != null ? os.hashCode() : 0);
+ result = 31 * result + (jvm != null ? jvm.hashCode() : 0);
+ result = 31 * result + (dotNetVersion != null ? dotNetVersion.hashCode() : 0);
+ result = 31 * result + (ackTime != null ? ackTime.hashCode() : 0);
+ result = 31 * result + (deleted ? 1 : 0);
+ result = 31 * result + (queueSync ? 1 : 0);
+ result = 31 * result + (int) (ackVersion ^ (ackVersion >>> 32));
+ result = 31 * result + (groups != null ? groups.hashCode() : 0);
+ result = 31 * result + (bulkNumber != null ? bulkNumber.hashCode() : 0);
+ result = 31 * result + (workerRecoveryVersion != null ? workerRecoveryVersion.hashCode() : 0);
+ result = 31 * result + (version != null ? version.hashCode() : 0);
+ result = 31 * result + (versionId != null ? versionId.hashCode() : 0);
+ result = 31 * result + (alias != null ? alias.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "WorkerNode{" +
+ "uuid='" + uuid + '\'' +
+ ", status=" + status +
+ ", active=" + active +
+ ", hostName='" + hostName + '\'' +
+ ", installPath='" + installPath + '\'' +
+ ", description='" + description + '\'' +
+ ", os='" + os + '\'' +
+ ", jvm='" + jvm + '\'' +
+ ", dotNetVersion='" + dotNetVersion + '\'' +
+ ", ackTime=" + ackTime +
+ ", deleted=" + deleted +
+ ", ackVersion=" + ackVersion +
+ ", groups=" + groups +
+ ", bulkNumber='" + bulkNumber + '\'' +
+ ", workerRecoveryVersion='" + workerRecoveryVersion + '\'' +
+ ", version='" + version + '\'' +
+ ", versionId='" + versionId + '\'' +
+ ", queueSync='" + queueSync + '\'' +
+ ", alias='" + alias + '\'' +
+ '}';
+ }
}
diff --git a/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/LoginListener.java b/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/LoginListener.java
index 6f08bbed37..7c01dff6ee 100644
--- a/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/LoginListener.java
+++ b/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/LoginListener.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.services;
diff --git a/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/QueueConfigurationDataService.java b/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/QueueConfigurationDataService.java
new file mode 100644
index 0000000000..e824cb0b5b
--- /dev/null
+++ b/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/QueueConfigurationDataService.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.engine.node.services;
+
+import io.cloudslang.engine.node.entities.QueueDetails;
+
+public interface QueueConfigurationDataService {
+ QueueDetails getQueueConfigurations();
+}
diff --git a/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/WorkerLockService.java b/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/WorkerLockService.java
index 9df1131f19..778f2859d2 100644
--- a/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/WorkerLockService.java
+++ b/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/WorkerLockService.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.services;
diff --git a/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/WorkerNodeService.java b/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/WorkerNodeService.java
index d7db71ef67..3e593bd33d 100644
--- a/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/WorkerNodeService.java
+++ b/engine/node/score-node-api/src/main/java/io/cloudslang/engine/node/services/WorkerNodeService.java
@@ -1,49 +1,73 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.services;
import com.google.common.collect.Multimap;
-import io.cloudslang.score.api.nodes.WorkerStatus;
+import io.cloudslang.engine.node.entities.WorkerKeepAliveInfo;
import io.cloudslang.engine.node.entities.WorkerNode;
+import io.cloudslang.score.api.nodes.WorkerStatus;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
- * Created by IntelliJ IDEA.
- * User:
- * Date: 08/11/12
- *
+ * Created by IntelliJ IDEA. User: Date: 08/11/12
+ *
* A service responsible for handling a worker node record
- *
*/
public interface WorkerNodeService {
/**
* Update the Worker Node entity with the current ack version for the keep alive mechanism
- * @param uuid worker's unique identifier
+ *
+ * @param uuid worker's unique identifier Maintained for backward compatibility only
* @return the worker's recovery version (WRV)
*/
- String keepAlive(String uuid);
+ String keepAlive(String uuid);
+
+ /**
+ * Update the Worker Node entity with the current ack version for the keep alive mechanism
+ *
+ * @param uuid worker's unique identifier
+ * @return the WorkerKeepAliveInfo that contains the worker's recovery version (WRV) and the enable state
+ */
+ WorkerKeepAliveInfo newKeepAlive(String uuid);
+
+ /**
+ * Update the Worker Node entity with the current ack version for the keep alive mechanism
+ *
+ * @param uuid worker's unique identifier
+ * @param versionMismatch the boolean value between the engine versionId and worker versionId
+ * @return the WorkerKeepAliveInfo that contains the worker's recovery version (WRV) and the enable state
+ */
+ WorkerKeepAliveInfo newKeepAlive(String uuid, boolean versionMismatch);
/**
* Create a new worker
- * @param uuid worker's unique identifier
+ *
+ * @param uuid worker's unique identifier
* @param password worker's password
- * @param hostName worker's host
+ * @param hostName worker's host
* @param installDir worker's installation directory
*/
- void create(String uuid, String password, String hostName, String installDir);
+ void create(String uuid, String password, String hostName, String installDir);
/**
- *
* update a worker record to IS_DELETED state
*
* @param uuid the uuid of the worker to mark deleted
@@ -51,34 +75,63 @@ public interface WorkerNodeService {
void updateWorkerToDeleted(String uuid);
/**
+ * update a worker record to its not deleted state
*
+ * @param uuid the uuid of the worker to mark as not deleted
+ */
+ void updateWorkerToNotDeleted(String uuid);
+
+ /**
* Reads all of the workers that are not marked with the IS_DELETED flag
*
- * @return a List of {@link io.cloudslang.engine.node.entities.WorkerNode} that are ont marked with
- * the IS_DELETED flag
+ * @return a List of {@link io.cloudslang.engine.node.entities.WorkerNode} that are ont marked with the IS_DELETED
+ * flag
*/
List readAllNotDeletedWorkers();
/**
+ * Notifies the orchestrator that a worker went up
*
+ * @param uuid the the uuid of the worker that went up
+ * @param version the version of the worker that went up
+ * @param versionId the versionId of the worker that went up
+ * @param versionMismatch the boolean value between the engine versionId and worker versionId
+ * @return a String of the current recovery version of the worker
+ */
+ String up(String uuid, String version, String versionId, boolean versionMismatch);
+
+ /**
* Notifies the orchestrator that a worker went up
*
* @param uuid the the uuid of the worker that went up
+ * @param version the version of the worker that went up
+ * @param versionId the versionId of the worker that went up
* @return a String of the current recovery version of the worker
*/
- String up(String uuid);
+ String up(String uuid, String version, String versionId);
/**
+ * Notifies the orchestrator that a worker went up
*
+ * @param uuid the the uuid of the worker that went up
+ * @return a String of the current recovery version of the worker
+ */
+ String up(String uuid);
+
+ /**
* find not deleted worker by uuid
*
* @param uuid the uuid of the worker to find
* @return a {@link io.cloudslang.engine.node.entities.WorkerNode} of the requested worker
*/
- WorkerNode readByUUID(String uuid);
+ WorkerNode readByUUID(String uuid);
+
+ /**
+ * Returns active status of the worker according to the worker UUID
+ */
+ boolean isActive(String workerUuid);
/**
- *
* find worker without relating to the IS_DELETED property
*
* @param uuid the uuid of the worker to find
@@ -87,49 +140,43 @@ public interface WorkerNodeService {
WorkerNode findByUuid(String uuid);
/**
- *
* Reads all of the workers records
*
* @return a List of all existing {@link io.cloudslang.engine.node.entities.WorkerNode}
*/
- List readAllWorkers();
+ List readAllWorkers();
/**
- *
* Read all of the worker that didn't send keep alive for a certain amount of time
*
* @return a List of String of the non-responding worker ids
*/
- List readNonRespondingWorkers();
+ List readNonRespondingWorkers();
/**
- *
* read all worker that there activation status is as a given status
*
* @param isActive the requested activation status.
- * @return a List of all {@link io.cloudslang.engine.node.entities.WorkerNode} the their
- * activation status is as the given status
+ * @return a List of all {@link io.cloudslang.engine.node.entities.WorkerNode} the their activation status is as the
+ * given status
*/
- List readWorkersByActivation(boolean isActive);
+ List readWorkersByActivation(boolean isActive);
/**
- *
* activates a worker
*
* @param uuid the uuid of the worker to activate
*/
- void activate(String uuid);
+ void activate(String uuid);
/**
- *
* deactivate a worker
*
* @param uuid the uuid of the worker to deactivate
*/
- void deactivate(String uuid);
+ void deactivate(String uuid);
/**
- *
* updates the environment params of a given worker
*
* @param uuid the uuid of the worker to update
@@ -137,19 +184,17 @@ public interface WorkerNodeService {
* @param jvm the jvm version the worker is running on
* @param dotNetVersion the dot-net version the worker is using
*/
- void updateEnvironmentParams(String uuid, String os, String jvm, String dotNetVersion);
+ void updateEnvironmentParams(String uuid, String os, String jvm, String dotNetVersion);
/**
- *
* updates the status of a given worker
*
* @param uuid the uuid of the worker to update
* @param status the status to update the given worker to
*/
- void updateStatus(String uuid, WorkerStatus status);
+ void updateStatus(String uuid, WorkerStatus status);
/**
- *
* updates the status of a given worker in a separate transaction
*
* @param uuid the uuid of the worker to update
@@ -158,7 +203,14 @@ public interface WorkerNodeService {
void updateStatusInSeparateTransaction(String uuid, WorkerStatus status);
/**
+ * updates the migration password field of a worker node
*
+ * @param uuid the uuid of the worker to update
+ * @param password the migrated password to be used
+ */
+ void migratePassword(String uuid, String password);
+
+ /**
* Reads all of the worker groups
*
* @return a List of String of all existing worker groups
@@ -166,7 +218,6 @@ public interface WorkerNodeService {
List readAllWorkerGroups();
/**
- *
* Read all of the groups associated with a worker
*
* @param uuid the the uuid of the worker to find groups for
@@ -175,52 +226,47 @@ public interface WorkerNodeService {
List readWorkerGroups(String uuid);
/**
- *
* updates the groups associated with a worker
*
* @param uuid the uuid of the worker to update groups for
* @param groupNames the groups to associate with the worker
*/
- void updateWorkerGroups(String uuid, String... groupNames);
+ void updateWorkerGroups(String uuid, String... groupNames);
/**
- *
* Reads all of the worker that are active and running and their groups
*
- * @return A {@link com.google.common.collect.Multimap} of the
- * active and running workers and their groups
+ * @param versionId - the version of workers
+ * @return A {@link com.google.common.collect.Multimap} of the active and running workers in specific version and
+ * their groups
*/
- Multimap readGroupWorkersMapActiveAndRunning();
+ Multimap readGroupWorkersMapActiveAndRunningAndVersion(String versionId);
/**
- *
* adds group to be associated with a worker
*
* @param workerUuid the uuid of the worker to associate the group to
* @param group the group to associate with the worker
*/
- void addGroupToWorker(String workerUuid, String group);
+ void addGroupToWorker(String workerUuid, String group);
/**
- *
* removes a group association with a worker
*
* @param workerUuid the uuid of the worker to remove the group association from
* @param group the group to remove its association from the worker
*/
- void removeGroupFromWorker(String workerUuid, String group);
+ void removeGroupFromWorker(String workerUuid, String group);
/**
- *
* Reads all of the groups that matches the given group names
*
* @param groups the group names to match
* @return t List of String of the matched groups
*/
- List readWorkerGroups(List groups);
+ List readWorkerGroups(List groups);
/**
- *
* updates the worker recovery bulk number
*
* @param workerUuid the uuid of the worker to update
@@ -229,7 +275,6 @@ public interface WorkerNodeService {
void updateBulkNumber(String workerUuid, String bulkNumber);
/**
- *
* updates the worker recovery version of a given worker
*
* @param workerUuid the uuid of the worker to update
@@ -238,10 +283,45 @@ public interface WorkerNodeService {
void updateWRV(String workerUuid, String wrv);
/**
- *
+ * Retrieves the worker and worker groups as a map
+ */
+ Map> readWorkerGroupsMap();
+
+ /**
* Read all workers uuids
*
* @return a List of String of the worker uuids
*/
List readAllWorkersUuids();
-}
\ No newline at end of file
+
+ /**
+ * updates the worker version of a given worker
+ *
+ * @param workerUuid the uuid of the worker to update
+ * @param version the worker's version
+ * @param versionId comparable worker's version
+ */
+ void updateVersion(String workerUuid, String version, String versionId);
+
+ /**
+ * updates worker's password encoding
+ *
+ * @param workerUuid the uuid of the worker to be updated
+ * @param encodedPassword the newly encoded password of the worker
+ */
+ void updateMigratedPassword(String workerUuid, String encodedPassword);
+
+ void updateQueueSyncByUuid(String workerUuid, boolean isQueueSync);
+
+ void updateQueueSync(boolean isQueueSync);
+
+ /**
+ * updates worker's busyness value
+ *
+ * @param uuid the uuid of the worker to be updated
+ * @param workerBusynessValue the newly added busyness value
+ */
+ void updateWorkerBusynessValue(String uuid, String workerBusynessValue);
+
+ void updateWorkerAliasByUuid(String workerUuid, String alias);
+}
diff --git a/engine/node/score-node-impl/pom.xml b/engine/node/score-node-impl/pom.xml
index 3cea70082b..272971fe6f 100644
--- a/engine/node/score-node-impl/pom.xml
+++ b/engine/node/score-node-impl/pom.xml
@@ -1,25 +1,43 @@
-
-
+
+ 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.
+
+-->
+
+
+ 4.0.0
+
io.cloudslang
node
- 0.1.282-SNAPSHOT
+ 0.4.56-SNAPSHOT
- 4.0.0
score-node-impl
+
- org.hibernate
+ org.glassfish
+ jakarta.el
+ test
+
+
+
+ org.hibernate.orm
hibernate-core
@@ -66,7 +84,7 @@
org.mockito
- mockito-all
+ mockito-core
@@ -85,12 +103,6 @@
test
-
- org.hibernate
- hibernate-entitymanager
- test
-
-
org.liquibase
liquibase-core
@@ -103,7 +115,7 @@
- org.hibernate
+ org.hibernate.validator
hibernate-validator
@@ -113,8 +125,8 @@
- log4j
- log4j
+ org.apache.logging.log4j
+ log4j-api
@@ -124,16 +136,24 @@
- mysql
- mysql-connector-java
- test
-
-
-
- postgresql
+ org.postgresql
postgresql
test
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+
\ No newline at end of file
diff --git a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/repositories/WorkerLockRepository.java b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/repositories/WorkerLockRepository.java
index 9d1c2043e3..7d90b37e87 100644
--- a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/repositories/WorkerLockRepository.java
+++ b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/repositories/WorkerLockRepository.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.repositories;
diff --git a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/repositories/WorkerNodeRepository.java b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/repositories/WorkerNodeRepository.java
index fd37fe322e..8420afb0d2 100644
--- a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/repositories/WorkerNodeRepository.java
+++ b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/repositories/WorkerNodeRepository.java
@@ -1,20 +1,28 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.repositories;
-import io.cloudslang.score.api.nodes.WorkerStatus;
import io.cloudslang.engine.node.entities.WorkerNode;
+import io.cloudslang.score.api.nodes.WorkerStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
import java.util.List;
@@ -34,6 +42,9 @@ public interface WorkerNodeRepository extends JpaRepository {
List findByActiveAndStatusAndDeleted(boolean isActive, WorkerStatus status, boolean deleted);
+ @Query("select w from WorkerNode w where (w.active = ?1) and (w.status = ?2) and (w.deleted = ?3) and ((w.versionId = ?4) or (w.versionId is null))")
+ List findByActiveAndStatusAndDeletedAndVersionId(boolean isActive, WorkerStatus status, boolean deleted, String versionId);
+
List findByGroupsAndDeleted(String group, boolean deleted);
@Query("select w.uuid from WorkerNode w where (w.ackVersion < ?1) and w.status <> ?2")
@@ -42,14 +53,13 @@ public interface WorkerNodeRepository extends JpaRepository {
@Query("select distinct g from WorkerNode w join w.groups g where w.deleted = false")
List findGroups();
- @Query(value = "update WorkerNode w set w.ackTime = current_time where w.uuid = ?1")
- @Modifying
- void updateAckTime(String uuid);
-
-
@Query("select distinct g from WorkerNode w join w.groups g where g in ?1")
List findGroups(List groupName);
@Modifying @Query("update WorkerNode w set w.uuid = w.uuid where w.uuid = ?1")
void lockByUuid(String uuid);
+
+ @Query(value = "SELECT w FROM WorkerNode w",
+ countQuery = "SELECT count(w) FROM WorkerNode w")
+ Page findAllWithPagination(Pageable pageable);
}
\ No newline at end of file
diff --git a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/StubQueueConfigurationDataServiceImpl.java b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/StubQueueConfigurationDataServiceImpl.java
new file mode 100644
index 0000000000..6406d6422d
--- /dev/null
+++ b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/StubQueueConfigurationDataServiceImpl.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.engine.node.services;
+
+import io.cloudslang.engine.node.entities.QueueDetails;
+
+public class StubQueueConfigurationDataServiceImpl implements QueueConfigurationDataService {
+
+ @Override
+ public QueueDetails getQueueConfigurations() {
+ return null;
+ }
+}
diff --git a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerLockServiceImpl.java b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerLockServiceImpl.java
index 279961bf03..e3386714be 100644
--- a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerLockServiceImpl.java
+++ b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerLockServiceImpl.java
@@ -1,18 +1,25 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.services;
import io.cloudslang.engine.node.entities.WorkerLock;
import io.cloudslang.engine.node.repositories.WorkerLockRepository;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
@@ -24,7 +31,7 @@
//@Service
public final class WorkerLockServiceImpl implements WorkerLockService {
- private final Logger logger = Logger.getLogger(getClass());
+ private final Logger logger = LogManager.getLogger(getClass());
@Autowired
private WorkerLockRepository workerLockRepository;
diff --git a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerNodeServiceImpl.java b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerNodeServiceImpl.java
index 616694cd9b..f54930d30b 100644
--- a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerNodeServiceImpl.java
+++ b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkerNodeServiceImpl.java
@@ -1,286 +1,538 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.services;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
-import io.cloudslang.score.api.nodes.WorkerStatus;
+import io.cloudslang.engine.node.entities.QueueDetails;
+import io.cloudslang.engine.node.entities.WorkerKeepAliveInfo;
import io.cloudslang.engine.node.entities.WorkerNode;
import io.cloudslang.engine.node.repositories.WorkerNodeRepository;
import io.cloudslang.engine.versioning.services.VersionService;
-import org.apache.log4j.Logger;
+import io.cloudslang.score.api.nodes.WorkerStatus;
+import jakarta.annotation.PostConstruct;
+import org.apache.commons.lang.StringUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.support.TransactionTemplate;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
-
-/**
- * @author
- * @author Avi Moradi
- * @since 11/11/2012
- * @version $Id$
- */
-public final class WorkerNodeServiceImpl implements WorkerNodeService {
-
- private static final long maxVersionGapAllowed = Long.getLong("max.allowed.version.gap.worker.recovery", 2);
- private static final String MSG_RECOVERY_VERSION_NAME = "MSG_RECOVERY_VERSION";
- private static final Logger logger = Logger.getLogger(WorkerNodeServiceImpl.class);
-
- @Autowired
- private WorkerNodeRepository workerNodeRepository;
- @Autowired
- private WorkerLockService workerLockService;
- @Autowired
- private VersionService versionService;
- @Autowired(required = false)
- private List loginListeners;
-
- @Override
- @Transactional
- public String keepAlive(String uuid) {
- WorkerNode worker = readByUUID(uuid);
- worker.setAckTime(new Date());
- String wrv = worker.getWorkerRecoveryVersion();
- long version = versionService.getCurrentVersion(MSG_RECOVERY_VERSION_NAME);
- worker.setAckVersion(version);
- if(!worker.getStatus().equals(WorkerStatus.IN_RECOVERY)) {
- worker.setStatus(WorkerStatus.RUNNING);
- }
- logger.debug("Got keepAlive for Worker with uuid=" + uuid + " and update its ackVersion to " + version);
- return wrv;
- }
-
- @Override
- @Transactional
- public void create(String uuid, String password, String hostName, String installDir) {
- WorkerNode worker = new WorkerNode();
- worker.setUuid(uuid);
- worker.setDescription(uuid);
- worker.setHostName(hostName);
- worker.setActive(false);
- worker.setInstallPath(installDir);
- worker.setStatus(WorkerStatus.FAILED);
- worker.setPassword(password);
- worker.setGroups(Arrays.asList(WorkerNode.DEFAULT_WORKER_GROUPS));
- workerNodeRepository.save(worker);
- workerLockService.create(uuid);
- }
-
- @Override
- @Transactional
- public void updateWorkerToDeleted(String uuid) {
- WorkerNode worker = readByUUID(uuid);
- if(worker != null) {
- worker.setActive(false);
- worker.setDeleted(true);
- worker.setStatus(WorkerStatus.IN_RECOVERY);
- }
- }
-
- @Override
- @Transactional
- public List readAllNotDeletedWorkers() {
- return workerNodeRepository.findByDeletedOrderByIdAsc(false);
- }
-
- @Override
- @Transactional
- public String up(String uuid) {
- if(loginListeners != null) {
- for(LoginListener listener : loginListeners) {
- listener.preLogin(uuid);
- }
- }
- String wrv = keepAlive(uuid);
- if(loginListeners != null) {
- for(LoginListener listener : loginListeners) {
- listener.postLogin(uuid);
- }
- }
- return wrv;
- }
-
- @Override
- @Transactional(readOnly = true)
- public WorkerNode readByUUID(String uuid) {
- WorkerNode worker = workerNodeRepository.findByUuidAndDeleted(uuid, false);
- if(worker == null) {
- throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
- }
- return worker;
- }
-
- @Override
- @Transactional(readOnly = true)
- public WorkerNode findByUuid(String uuid) {
- WorkerNode worker = workerNodeRepository.findByUuid(uuid);
- if(worker == null) {
- throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
- }
- return worker;
- }
-
- @Override
- @Transactional(readOnly = true)
- public List readAllWorkers() {
- return workerNodeRepository.findAll();
- }
-
- @Override
- @Transactional(readOnly = true)
- public List readAllWorkersUuids() {
- List workers = workerNodeRepository.findAll();
- List result = new ArrayList<>();
- for(WorkerNode w : workers) {
- result.add(w.getUuid());
- }
- return result;
- }
-
- @Override
- @Transactional(readOnly = true)
- public List readNonRespondingWorkers() {
- long systemVersion = versionService.getCurrentVersion(MSG_RECOVERY_VERSION_NAME);
- long minVersionAllowed = Math.max(systemVersion - maxVersionGapAllowed, 0);
- return workerNodeRepository.findNonRespondingWorkers(minVersionAllowed, WorkerStatus.RECOVERED);
- }
-
- @Override
- @Transactional(readOnly = true)
- public List readWorkersByActivation(boolean isActive) {
- return workerNodeRepository.findByActiveAndDeleted(isActive, false);
- }
-
- @Override
- @Transactional
- public void activate(String uuid) {
- WorkerNode worker = readByUUID(uuid);
- worker.setActive(true);
- }
-
- @Override
- @Transactional
- public void deactivate(String uuid) {
- WorkerNode worker = readByUUID(uuid);
- worker.setActive(false);
- }
-
- @Override
- @Transactional
- public void updateEnvironmentParams(String uuid, String os, String jvm, String dotNetVersion) {
- WorkerNode worker = readByUUID(uuid);
- worker.setOs(os);
- worker.setJvm(jvm);
- worker.setDotNetVersion(dotNetVersion);
- }
-
- @Override
- @Transactional
- public void updateStatus(String uuid, WorkerStatus status) {
- WorkerNode worker = workerNodeRepository.findByUuid(uuid);
- if(worker == null) {
- throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
- }
- worker.setStatus(status);
- }
-
- @Override
- @Transactional(propagation = Propagation.REQUIRES_NEW)
- public void updateStatusInSeparateTransaction(String uuid, WorkerStatus status) {
- WorkerNode worker = workerNodeRepository.findByUuid(uuid);
- if(worker == null) {
- throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
- }
- worker.setStatus(status);
- }
-
- @Override
- @Transactional(readOnly = true)
- public List readAllWorkerGroups() {
- return workerNodeRepository.findGroups();
- }
-
- @Override
- @Transactional(readOnly = true)
- public List readWorkerGroups(String uuid) {
- WorkerNode node = readByUUID(uuid);
- ArrayList res = new ArrayList<>();
- res.addAll(node.getGroups());
- return res;
- }
-
- @Override
- @Transactional
- public void updateWorkerGroups(String uuid, String... groupNames) {
- WorkerNode worker = readByUUID(uuid);
- List groups = groupNames != null ? Arrays.asList(groupNames) : Collections. emptyList();
- worker.setGroups(groups);
- }
-
- @Override
- @Transactional(readOnly = true)
- public Multimap readGroupWorkersMapActiveAndRunning() {
- Multimap result = ArrayListMultimap.create();
- List workers;
- workers = workerNodeRepository.findByActiveAndStatusAndDeleted(true, WorkerStatus.RUNNING, false);
- for(WorkerNode worker : workers) {
- for(String groupName : worker.getGroups()) {
- result.put(groupName, worker.getUuid());
- }
- }
- return result;
- }
-
- @Override
- @Transactional
- public void addGroupToWorker(String workerUuid, String group) {
- WorkerNode worker = readByUUID(workerUuid);
- List groups = new ArrayList<>(worker.getGroups());
- groups.add(group);
- worker.setGroups(groups);
- }
-
- @Override
- @Transactional
- public void removeGroupFromWorker(String workerUuid, String group) {
- WorkerNode worker = readByUUID(workerUuid);
- List groups = new ArrayList<>(worker.getGroups());
- groups.remove(group);
- if(groups.size() == 0) throw new IllegalStateException("Can't leave worker without any group !");
- worker.setGroups(groups);
- }
-
- @Override
- @Transactional(readOnly = true)
- public List readWorkerGroups(List groups) {
- return workerNodeRepository.findGroups(groups);
- }
-
- @Override
- @Transactional
- public void updateBulkNumber(String workerUuid, String bulkNumber) {
- WorkerNode worker = readByUUID(workerUuid);
- worker.setBulkNumber(bulkNumber);
- }
-
- @Override
- @Transactional
- public void updateWRV(String workerUuid, String wrv) {
- WorkerNode worker = workerNodeRepository.findByUuid(workerUuid);
- worker.setWorkerRecoveryVersion(wrv);
- }
-
+import java.util.Map;
+import java.util.Set;
+
+import static com.google.common.collect.Maps.newHashMapWithExpectedSize;
+
+
+public class WorkerNodeServiceImpl implements WorkerNodeService {
+
+ private static final Logger logger = LogManager.getLogger(WorkerNodeServiceImpl.class);
+
+ private static final long MAX_VERSION_GAP_ALLOWED = Long.getLong("max.allowed.version.gap.worker.recovery", 2);
+ private static boolean disableMonitoring = Boolean.getBoolean("global.worker.monitoring.disable");
+ private static final String MSG_RECOVERY_VERSION_NAME = "MSG_RECOVERY_VERSION";
+ private static final int WORKER_GROUPS_PAGE_SIZE = Integer.getInteger("worker.groups.page.size", 50);
+
+ @Autowired
+ private WorkerNodeRepository workerNodeRepository;
+
+ @Autowired
+ private WorkerLockService workerLockService;
+
+ @Autowired
+ private VersionService versionService;
+
+ @Autowired(required = false)
+ private List loginListeners;
+
+ @Autowired
+ private QueueConfigurationDataService queueConfigurationDataService;
+
+ @Autowired
+ private PlatformTransactionManager transactionManager;
+
+ @PostConstruct
+ void setWorkerMonitoring() {
+ TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager);
+
+ if (disableMonitoring) {
+ logger.info("Monitoring is disabled,setting busyness status as not available for all workers");
+ transactionTemplate.executeWithoutResult(transactionStatus -> {
+ readAllWorkersUuids().stream().forEach(uuid -> updateWorkerBusynessValue(uuid, "NA"));
+ });
+ }
+ }
+//readAllWorkersUuids().stream().forEach(uuid -> updateWorkerBusynessValue(uuid,"NA") );
+
+ @Override
+ @Transactional
+ public String keepAlive(String uuid) {
+ WorkerNode worker = readByUUID(uuid);
+ worker.setAckTime(new Date());
+ String wrv = worker.getWorkerRecoveryVersion();
+ long version = versionService.getCurrentVersion(MSG_RECOVERY_VERSION_NAME);
+ worker.setAckVersion(version);
+ if (!worker.getStatus().equals(WorkerStatus.IN_RECOVERY)) {
+ worker.setStatus(WorkerStatus.RUNNING);
+ }
+ logger.debug("Got keepAlive for Worker with uuid=" + uuid + " and update its ackVersion to " + version);
+ return wrv;
+ }
+
+ @Override
+ @Transactional
+ @Deprecated
+ public WorkerKeepAliveInfo newKeepAlive(String uuid) {
+ // Any worker using this method will be considered an older version from engine
+ return newKeepAlive(uuid, true);
+ }
+
+ @Override
+ @Transactional
+ public WorkerKeepAliveInfo newKeepAlive(String uuid, boolean versionMismatch) {
+ WorkerNode worker = readByUUID(uuid);
+ worker.setAckTime(new Date());
+ long version = versionService.getCurrentVersion(MSG_RECOVERY_VERSION_NAME);
+ worker.setAckVersion(version);
+ if (!versionMismatch && !worker.getStatus().equals(WorkerStatus.IN_RECOVERY)) {
+ worker.setStatus(WorkerStatus.RUNNING);
+ }
+ boolean active = worker.isActive();
+ logger.debug(
+ "Got keepAlive for Worker with uuid=" + uuid + " and update its ackVersion to " + version + " isActive"
+ + active);
+ QueueDetails queueDetails = queueConfigurationDataService.getQueueConfigurations();
+ return new WorkerKeepAliveInfo(worker.getWorkerRecoveryVersion(), active, queueDetails, disableMonitoring);
+ }
+
+ @Override
+ @Transactional
+ public void create(String uuid, String password, String hostName, String installDir) {
+ WorkerNode worker = new WorkerNode();
+ worker.setUuid(uuid);
+ worker.setDescription(uuid);
+ worker.setHostName(hostName);
+ worker.setActive(false);
+ worker.setInstallPath(installDir);
+ worker.setStatus(WorkerStatus.FAILED);
+ worker.setPassword(password);
+ worker.setGroups(Arrays.asList(WorkerNode.DEFAULT_WORKER_GROUPS));
+ worker.setWorkerBusynessValue("NA");
+ workerNodeRepository.save(worker);
+ workerLockService.create(uuid);
+ }
+
+ @Override
+ @Transactional
+ public void updateWorkerToDeleted(String uuid) {
+ WorkerNode worker = readByUUID(uuid);
+ if (worker != null) {
+ worker.setActive(false);
+ worker.setDeleted(true);
+ worker.setStatus(WorkerStatus.IN_RECOVERY);
+ worker.setAlias(null);
+ }
+ }
+
+ @Override
+ @Transactional
+ public void updateWorkerToNotDeleted(String uuid) {
+ WorkerNode worker = workerNodeRepository.findByUuidAndDeleted(uuid, true);
+ if (worker != null) {
+ worker.setActive(false);
+ worker.setDeleted(false);
+ worker.setStatus(WorkerStatus.IN_RECOVERY);
+ }
+ }
+
+ @Override
+ @Transactional
+ public List readAllNotDeletedWorkers() {
+ return workerNodeRepository.findByDeletedOrderByIdAsc(false);
+ }
+
+ @Override
+ @Transactional
+ public String up(String uuid, String version, String versionId, boolean versionMismatch) {
+
+ if (loginListeners != null) {
+ for (LoginListener listener : loginListeners) {
+ listener.preLogin(uuid);
+ }
+ }
+ WorkerKeepAliveInfo workerKeepAliveInfo = newKeepAlive(uuid, versionMismatch);
+ if (loginListeners != null) {
+ for (LoginListener listener : loginListeners) {
+ listener.postLogin(uuid);
+ }
+ }
+
+ updateVersion(uuid, version, versionId);
+
+ return workerKeepAliveInfo.getWorkerRecoveryVersion();
+ }
+
+ @Override
+ @Transactional
+ @Deprecated
+ public String up(String uuid, String version, String versionId) {
+
+ if (loginListeners != null) {
+ for (LoginListener listener : loginListeners) {
+ listener.preLogin(uuid);
+ }
+ }
+ WorkerKeepAliveInfo workerKeepAliveInfo = newKeepAlive(uuid);
+ if (loginListeners != null) {
+ for (LoginListener listener : loginListeners) {
+ listener.postLogin(uuid);
+ }
+ }
+
+ updateVersion(uuid, version, versionId);
+
+ return workerKeepAliveInfo.getWorkerRecoveryVersion();
+ }
+
+ @Override
+ @Transactional
+ @Deprecated //is left here for backward compatibility
+ public String up(String uuid) {
+
+ if (loginListeners != null) {
+ for (LoginListener listener : loginListeners) {
+ listener.preLogin(uuid);
+ }
+ }
+ WorkerKeepAliveInfo workerKeepAliveInfo = newKeepAlive(uuid);
+ if (loginListeners != null) {
+ for (LoginListener listener : loginListeners) {
+ listener.postLogin(uuid);
+ }
+ }
+ return workerKeepAliveInfo.getWorkerRecoveryVersion();
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public WorkerNode readByUUID(String uuid) {
+ WorkerNode worker = workerNodeRepository.findByUuidAndDeleted(uuid, false);
+ if (worker == null) {
+ throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
+ }
+ return worker;
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public boolean isActive(String uuid) {
+ WorkerNode worker = workerNodeRepository.findByUuidAndDeleted(uuid, false);
+ if (worker == null) {
+ throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
+ }
+ return worker.isActive();
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public WorkerNode findByUuid(String uuid) {
+ WorkerNode worker = workerNodeRepository.findByUuid(uuid);
+ if (worker == null) {
+ throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
+ }
+ return worker;
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public List readAllWorkers() {
+ return workerNodeRepository.findAll();
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public Map> readWorkerGroupsMap() {
+ /**
+ * Reduces memory usage by loading data in chunks of WORKER_GROUPS_PAGE_SIZE
+ * Prevent ORA-04031.
+ */
+ int currentPage = 0;
+ List all = new ArrayList<>();
+
+ Page page;
+ do {
+ page = workerNodeRepository.findAllWithPagination(
+ PageRequest.of(currentPage, WORKER_GROUPS_PAGE_SIZE)
+ );
+ if (page != null && page.hasContent()) {
+ all.addAll(page.getContent());
+ }
+ currentPage++;
+ } while (page.hasNext());
+
+ Map> workerGroupsMap = newHashMapWithExpectedSize(all.size());
+ for (WorkerNode workerNode : all) {
+ workerGroupsMap.put(workerNode.getUuid(), new HashSet<>(workerNode.getGroups()));
+ }
+ return workerGroupsMap;
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public List readAllWorkersUuids() {
+ List workers = workerNodeRepository.findAll();
+ List result = new ArrayList<>();
+ for (WorkerNode w : workers) {
+ result.add(w.getUuid());
+ }
+ return result;
+ }
+
+ @Override
+ @Transactional
+ public void updateVersion(String workerUuid, String version, String versionId) {
+ WorkerNode worker = workerNodeRepository.findByUuid(workerUuid);
+ if (worker == null) {
+ throw new IllegalStateException("No worker was found by the specified UUID:" + workerUuid);
+ }
+ worker.setVersion(version);
+ worker.setVersionId(versionId);
+ }
+
+ @Override
+ @Transactional
+ public void updateMigratedPassword(String workerUuid, String encodedPassword) {
+ WorkerNode worker = workerNodeRepository.findByUuid(workerUuid);
+ if (worker == null) {
+ throw new IllegalStateException("No worker was found by the specified UUID:" + workerUuid);
+ }
+ if (StringUtils.isEmpty(encodedPassword)) {
+ throw new IllegalStateException("Invalid encoded password provided for UUID:" + workerUuid);
+ }
+ if (!StringUtils.equals(worker.getMigratedPassword(), encodedPassword)) {
+ worker.setMigratedPassword(encodedPassword);
+ }
+ }
+
+ @Override
+ @Transactional
+ public void updateQueueSyncByUuid(String workerUuid, boolean isQueueSync) {
+ WorkerNode worker = workerNodeRepository.findByUuid(workerUuid);
+ if (worker == null) {
+ throw new IllegalStateException("No worker was found by the specified UUID:" + workerUuid);
+ }
+ worker.setQueueSync(isQueueSync);
+ }
+
+ @Override
+ @Transactional
+ public void updateQueueSync(boolean isQueueSync) {
+ List workers = workerNodeRepository.findAll();
+ for (WorkerNode w : workers) {
+ w.setQueueSync(isQueueSync);
+ }
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public List readNonRespondingWorkers() {
+ long systemVersion = versionService.getCurrentVersion(MSG_RECOVERY_VERSION_NAME);
+ long minVersionAllowed = Math.max(systemVersion - MAX_VERSION_GAP_ALLOWED, 0);
+ return workerNodeRepository.findNonRespondingWorkers(minVersionAllowed, WorkerStatus.RECOVERED);
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public List readWorkersByActivation(boolean isActive) {
+ return workerNodeRepository.findByActiveAndDeleted(isActive, false);
+ }
+
+ @Override
+ @Transactional
+ public void activate(String uuid) {
+ WorkerNode worker = readByUUID(uuid);
+ worker.setActive(true);
+ }
+
+ @Override
+ @Transactional
+ public void deactivate(String uuid) {
+ WorkerNode worker = readByUUID(uuid);
+ worker.setActive(false);
+ }
+
+ @Override
+ @Transactional
+ public void updateEnvironmentParams(String uuid, String os, String jvm, String dotNetVersion) {
+ WorkerNode worker = readByUUID(uuid);
+ worker.setOs(os);
+ worker.setJvm(jvm);
+ worker.setDotNetVersion(dotNetVersion);
+ }
+
+ @Override
+ @Transactional
+ public void updateStatus(String uuid, WorkerStatus status) {
+ WorkerNode worker = workerNodeRepository.findByUuid(uuid);
+ if (worker == null) {
+ throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
+ }
+ worker.setStatus(status);
+ }
+
+ @Override
+ @Transactional
+ public void updateWorkerBusynessValue(String uuid, String workerBusynessValue) {
+ WorkerNode worker = workerNodeRepository.findByUuid(uuid);
+ if (worker == null) {
+ throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
+ }
+ worker.setWorkerBusynessValue(workerBusynessValue);
+ }
+
+ @Override
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
+ public void updateStatusInSeparateTransaction(String uuid, WorkerStatus status) {
+ WorkerNode worker = workerNodeRepository.findByUuid(uuid);
+ if (worker == null) {
+ throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
+ }
+ worker.setStatus(status);
+ }
+
+ @Override
+ @Transactional
+ public void migratePassword(String uuid, String password) {
+ WorkerNode workerNode = workerNodeRepository.findByUuid(uuid);
+ if (workerNode == null) {
+ throw new IllegalStateException("no worker was found by the specified UUID:" + uuid);
+ }
+ if (StringUtils.isNotEmpty(workerNode.getMigratedPassword())) {
+ throw new IllegalStateException(
+ "the migration password has already been changed for the specified UUID:" + uuid);
+ }
+ workerNode.setMigratedPassword(password);
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public List readAllWorkerGroups() {
+ return workerNodeRepository.findGroups();
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public List readWorkerGroups(String uuid) {
+ WorkerNode node = readByUUID(uuid);
+ ArrayList res = new ArrayList<>();
+ res.addAll(node.getGroups());
+ return res;
+ }
+
+ @Override
+ @Transactional
+ public void updateWorkerGroups(String uuid, String... groupNames) {
+ WorkerNode worker = readByUUID(uuid);
+
+ Set groupSet = groupNames != null ? new HashSet<>(Arrays.asList(groupNames)) : new HashSet();
+ List groups = new ArrayList<>();
+ groupSet.remove(null);
+ groups.addAll(groupSet);
+
+ worker.setGroups(groups);
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public Multimap readGroupWorkersMapActiveAndRunningAndVersion(String versionId) {
+ Multimap result = ArrayListMultimap.create();
+ List workers;
+ workers = workerNodeRepository
+ .findByActiveAndStatusAndDeletedAndVersionId(true, WorkerStatus.RUNNING, false, versionId);
+ for (WorkerNode worker : workers) {
+ for (String groupName : worker.getGroups()) {
+ result.put(groupName, worker.getUuid());
+ }
+ }
+ return result;
+ }
+
+ @Override
+ @Transactional
+ public void addGroupToWorker(String workerUuid, String group) {
+
+ if (group == null) {
+ return;
+ }
+
+ WorkerNode worker = readByUUID(workerUuid);
+
+ if (!worker.getGroups().contains(group)) {
+ List groups = new ArrayList<>(worker.getGroups());
+ groups.add(group);
+ worker.setGroups(groups);
+ }
+ }
+
+ @Override
+ @Transactional
+ public void removeGroupFromWorker(String workerUuid, String group) {
+ WorkerNode worker = readByUUID(workerUuid);
+ List groups = new ArrayList<>(worker.getGroups());
+ groups.remove(group);
+ if (groups.size() == 0) {
+ throw new IllegalStateException("Can't leave worker without any group !");
+ }
+ worker.setGroups(groups);
+ }
+
+ @Override
+ @Transactional(readOnly = true)
+ public List readWorkerGroups(List groups) {
+ return workerNodeRepository.findGroups(groups);
+ }
+
+ @Override
+ @Transactional
+ public void updateBulkNumber(String workerUuid, String bulkNumber) {
+ WorkerNode worker = readByUUID(workerUuid);
+ worker.setBulkNumber(bulkNumber);
+ }
+
+ @Override
+ @Transactional
+ public void updateWRV(String workerUuid, String wrv) {
+ WorkerNode worker = workerNodeRepository.findByUuid(workerUuid);
+ worker.setWorkerRecoveryVersion(wrv);
+ }
+
+ @Override
+ @Transactional
+ public void updateWorkerAliasByUuid(String workerUuid, String alias) {
+ WorkerNode worker = workerNodeRepository.findByUuid(workerUuid);
+ worker.setAlias(alias);
+ }
}
diff --git a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkersMBean.java b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkersMBean.java
index 6fc638b3c1..2d1e2a681b 100644
--- a/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkersMBean.java
+++ b/engine/node/score-node-impl/src/main/java/io/cloudslang/engine/node/services/WorkersMBean.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.services;
diff --git a/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/repositories/WorkerLockRepositoryTest.java b/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/repositories/WorkerLockRepositoryTest.java
index f112e5b993..9d1a5234bf 100644
--- a/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/repositories/WorkerLockRepositoryTest.java
+++ b/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/repositories/WorkerLockRepositoryTest.java
@@ -1,18 +1,24 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.repositories;
-import io.cloudslang.score.api.nodes.WorkerStatus;
import io.cloudslang.engine.node.entities.WorkerLock;
import io.cloudslang.engine.node.entities.WorkerNode;
+import io.cloudslang.score.api.nodes.WorkerStatus;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -21,17 +27,17 @@
import org.springframework.context.annotation.ImportResource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
+import javax.sql.DataSource;
+import java.util.List;
+
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-import java.util.List;
-import javax.sql.DataSource;
-
/**
* User: varelasa
* Date: 21/07/14
@@ -40,7 +46,7 @@
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = WorkerLockRepositoryTest.Conf.class)
@Transactional
-@TransactionConfiguration(defaultRollback = true)
+@Rollback
public class WorkerLockRepositoryTest {
@Autowired
diff --git a/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/repositories/WorkerNodeRepositoryTest.java b/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/repositories/WorkerNodeRepositoryTest.java
index 3dd4d98574..42f47006d6 100644
--- a/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/repositories/WorkerNodeRepositoryTest.java
+++ b/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/repositories/WorkerNodeRepositoryTest.java
@@ -1,17 +1,24 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
package io.cloudslang.engine.node.repositories;
-import io.cloudslang.score.api.nodes.WorkerStatus;
import io.cloudslang.engine.node.entities.WorkerNode;
+import io.cloudslang.score.api.nodes.WorkerStatus;
import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -21,9 +28,9 @@
import org.springframework.context.annotation.ImportResource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import javax.sql.DataSource;
@@ -34,7 +41,7 @@
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = WorkerNodeRepositoryTest.Conf.class)
@Transactional
-@TransactionConfiguration(defaultRollback = true)
+@Rollback
public class WorkerNodeRepositoryTest {
@Autowired
diff --git a/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/services/WorkerLockServiceTest.java b/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/services/WorkerLockServiceTest.java
index b3c753c137..45c2149141 100644
--- a/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/services/WorkerLockServiceTest.java
+++ b/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/services/WorkerLockServiceTest.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.engine.node.services;
diff --git a/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/services/WorkerNodeServiceTest.java b/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/services/WorkerNodeServiceTest.java
index 52512cdc63..6e48bcb632 100644
--- a/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/services/WorkerNodeServiceTest.java
+++ b/engine/node/score-node-impl/src/test/java/io/cloudslang/engine/node/services/WorkerNodeServiceTest.java
@@ -1,30 +1,37 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
package io.cloudslang.engine.node.services;
-import io.cloudslang.score.api.nodes.WorkerStatus;
import io.cloudslang.engine.data.SimpleHiloIdentifierGenerator;
import io.cloudslang.engine.node.entities.WorkerNode;
import io.cloudslang.engine.node.repositories.WorkerNodeRepository;
import io.cloudslang.engine.versioning.services.VersionService;
-import junit.framework.Assert;
+import io.cloudslang.score.api.nodes.WorkerStatus;
+import jakarta.persistence.EntityManagerFactory;
import liquibase.integration.spring.SpringLiquibase;
import org.apache.commons.dbcp.BasicDataSource;
-import org.hibernate.ejb.HibernatePersistence;
+import org.hibernate.jpa.HibernatePersistenceProvider;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -35,21 +42,21 @@
import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
+import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
-import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.Arrays;
import java.util.Date;
+import java.util.HashSet;
import java.util.List;
import java.util.Properties;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -62,78 +69,80 @@
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = WorkerNodeServiceTest.Configurator.class)
@Transactional
-@TransactionConfiguration(defaultRollback=true)
-//TODO Eliya- this test depend on repo - should mock it!
+@Rollback
+// this test depend on repo - should mock it!
public class WorkerNodeServiceTest {
- private static final boolean SHOW_SQL = false;
+ private static final boolean SHOW_SQL = false;
+ private static final String versionId = "123";
- @Autowired
- private WorkerNodeService workerNodeService;
+ @Autowired
+ private WorkerNodeService workerNodeService;
@Autowired
private WorkerLockService workerLockService;
- @Autowired
- private WorkerNodeRepository workerNodeRepository;
+ @Autowired
+ private WorkerNodeRepository workerNodeRepository;
@Autowired
private VersionService versionService;
- @Before
- public void initNodes() {
- workerNodeService.create("H1", "H1", "amit.levin", "c:/dir");
+ @Before
+ public void initNodes() {
+ workerNodeService.create("H1", "H1", "amit.levin", "c:/dir");
- workerNodeService.create("H2", "H2", "dima.rassin", "c:/dir");
- }
+ workerNodeService.create("H2", "H2", "dima.rassin", "c:/dir");
+ }
@After
- public void reset(){
- Mockito.reset(versionService,workerLockService);
+ public void reset() {
+ Mockito.reset(versionService, workerLockService);
}
- @Test
- public void keepAlive() throws Exception {
+
+ @Test
+ public void keepAlive() throws Exception {
when(versionService.getCurrentVersion(anyString())).thenReturn(5L);
- WorkerNode worker = workerNodeService.readByUUID("H1");
- Date origDate = worker.getAckTime();
- Assert.assertNull(origDate);
- workerNodeService.keepAlive("H1");
- workerNodeRepository.flush();
- worker = workerNodeService.readByUUID("H1");
- Assert.assertNotNull(worker.getAckTime());
+ WorkerNode worker = workerNodeService.readByUUID("H1");
+ Date origDate = worker.getAckTime();
+ Assert.assertNull(origDate);
+ workerNodeService.keepAlive("H1");
+ workerNodeRepository.flush();
+ worker = workerNodeService.readByUUID("H1");
+ Assert.assertNotNull(worker.getAckTime());
Assert.assertEquals(5, worker.getAckVersion());
- }
+ }
- @Test
- public void createNode() throws Exception {
- workerNodeService.create("H3", "H3", "amit.levin", "c:/dir");
+ @Test
+ public void createNode() throws Exception {
+ workerNodeService.create("H3", "H3", "amit.levin", "c:/dir");
verify(workerLockService).create("H3");
- WorkerNode worker = workerNodeService.readByUUID("H3");
- Assert.assertNotNull(worker);
- }
-
- @Test
- public void login() throws Exception {
- workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
- WorkerNode worker = workerNodeService.readByUUID("H3");
- Assert.assertEquals(WorkerStatus.FAILED, worker.getStatus());
- workerNodeService.up("H3");
- worker = workerNodeService.readByUUID("H3");
- Assert.assertEquals(WorkerStatus.RUNNING, worker.getStatus());
- }
-
- @Test
- public void readByUUID() throws Exception {
- WorkerNode worker = workerNodeService.readByUUID("H1");
- Assert.assertNotNull(worker);
- }
-
- @Test
- public void readAllWorkers() throws Exception {
- List workers = workerNodeService.readAllWorkers();
- Assert.assertEquals(2, workers.size());
- }
+ WorkerNode worker = workerNodeService.readByUUID("H3");
+ Assert.assertNotNull(worker);
+ }
+
+ @Test
+ public void login() throws Exception {
+ workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
+ WorkerNode worker = workerNodeService.readByUUID("H3");
+ Assert.assertEquals(WorkerStatus.FAILED, worker.getStatus());
+ workerNodeService.up("H3", "version", versionId, false);
+ worker = workerNodeService.readByUUID("H3");
+ Assert.assertEquals(WorkerStatus.RUNNING, worker.getStatus());
+ }
+
+ @Test
+ public void readByUUID() throws Exception {
+ WorkerNode worker = workerNodeService.readByUUID("H1");
+ Assert.assertNotNull(worker);
+ }
+
+ @Test
+ public void readAllWorkers() throws Exception {
+ List workers = workerNodeService.readAllWorkers();
+ Assert.assertEquals(2, workers.size());
+ }
@Test
public void readAllNotDeletedWorkers() {
@@ -150,33 +159,50 @@ public void deleteRunningWorkerTest() {
workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
WorkerNode worker = workerNodeService.readByUUID("H3");
Assert.assertEquals(WorkerStatus.FAILED, worker.getStatus());
- workerNodeService.up("H3");
+ workerNodeService.up("H3", "version", versionId, false);
Assert.assertEquals(WorkerStatus.RUNNING, worker.getStatus());
+ workerNodeService.updateWorkerAliasByUuid("H3", "alias");
+ Assert.assertEquals("alias", worker.getAlias());
workerNodeService.updateWorkerToDeleted("H3");
Assert.assertEquals(WorkerStatus.IN_RECOVERY, worker.getStatus());
Assert.assertEquals(false, worker.isActive());
Assert.assertEquals(true, worker.isDeleted());
+ Assert.assertEquals(null, worker.getAlias());
}
+ @Test
+ public void restoreDeletedWorker() {
+ workerNodeService.create("H3", "H3", "tirla.alin", "m:/y/imaginary/path");
+ WorkerNode worker = workerNodeService.readByUUID("H3");
+ worker.setActive(false);
+ worker.setDeleted(true);
+ worker.setStatus(WorkerStatus.IN_RECOVERY);
- @Test
- public void readNonRespondingWorkers() throws Exception {
- List workers = workerNodeService.readNonRespondingWorkers();
- Assert.assertEquals(0, workers.size());
+ workerNodeService.updateWorkerToNotDeleted("H3");
- workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
- workers = workerNodeService.readNonRespondingWorkers();
- Assert.assertEquals(0, workers.size());
+ Assert.assertEquals(WorkerStatus.IN_RECOVERY, worker.getStatus());
+ Assert.assertEquals(false, worker.isActive());
+ Assert.assertEquals(false, worker.isDeleted());
+ }
- // only activate workers can be non responding
- workerNodeService.activate("H3");
- workers = workerNodeService.readNonRespondingWorkers();
- Assert.assertEquals(0, workers.size());//still it not "non responding" because it yet to login(first login)
+ @Test
+ public void readNonRespondingWorkers() throws Exception {
+ List workers = workerNodeService.readNonRespondingWorkers();
+ Assert.assertEquals(0, workers.size());
- // after login version is current system version.
- workerNodeService.up("H3");
- workers = workerNodeService.readNonRespondingWorkers();
- Assert.assertEquals(0, workers.size());
+ workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
+ workers = workerNodeService.readNonRespondingWorkers();
+ Assert.assertEquals(0, workers.size());
+
+ // only activate workers can be non responding
+ workerNodeService.activate("H3");
+ workers = workerNodeService.readNonRespondingWorkers();
+ Assert.assertEquals(0, workers.size());//still it not "non responding" because it yet to login(first login)
+
+ // after login version is current system version.
+ workerNodeService.up("H3", "version", versionId, false);
+ workers = workerNodeService.readNonRespondingWorkers();
+ Assert.assertEquals(0, workers.size());
//when the worker version is too far from the system version its NonResponding
when(versionService.getCurrentVersion(anyString())).thenReturn(100L);
@@ -184,184 +210,264 @@ public void readNonRespondingWorkers() throws Exception {
Assert.assertEquals(3, workers.size());
//after up the worker version will be aligned with current system version.
- workerNodeService.up("H3");
+ workerNodeService.up("H3", "version", versionId, false);
workers = workerNodeService.readNonRespondingWorkers();
Assert.assertEquals(2, workers.size());
Assert.assertFalse(workers.contains("H3"));
- }
-
- @Test
- public void readWorkersByActivation() throws Exception {
-
- workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
- List workers = workerNodeService.readWorkersByActivation(true);
- Assert.assertEquals(0, workers.size());
- workers = workerNodeService.readWorkersByActivation(false);
- Assert.assertEquals(3, workers.size());
-
- // activate worker
- workerNodeService.activate("H3");
- workers = workerNodeService.readWorkersByActivation(true);
- Assert.assertEquals(1, workers.size());
- workers = workerNodeService.readWorkersByActivation(false);
- Assert.assertEquals(2, workers.size());
-
- // deactivate worker
- workerNodeService.deactivate("H3");
- workers = workerNodeService.readWorkersByActivation(true);
- Assert.assertEquals(0, workers.size());
- workers = workerNodeService.readWorkersByActivation(false);
- Assert.assertEquals(3, workers.size());
-
- }
-
- @Test
- public void updateEnvironmentParams() throws Exception {
- workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
- workerNodeService.updateEnvironmentParams("H3", "Window", "7.0", "4");
- WorkerNode worker = workerNodeService.readByUUID("H3");
- Assert.assertEquals("Window", worker.getOs());
- Assert.assertEquals("7.0", worker.getJvm());
- Assert.assertEquals("4", worker.getDotNetVersion());
-
- }
-
- @Test
- public void updateStatus() {
- workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
- WorkerNode worker = workerNodeService.readByUUID("H3");
- Assert.assertEquals(WorkerStatus.FAILED, worker.getStatus());
-
- workerNodeService.updateStatus("H3",WorkerStatus.RUNNING);
- worker = workerNodeService.readByUUID("H3");
- Assert.assertEquals(WorkerStatus.RUNNING, worker.getStatus());
- }
+ }
+
+ @Test
+ public void readWorkersByActivation() throws Exception {
+
+ workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
+ List workers = workerNodeService.readWorkersByActivation(true);
+ Assert.assertEquals(0, workers.size());
+ workers = workerNodeService.readWorkersByActivation(false);
+ Assert.assertEquals(3, workers.size());
+
+ // activate worker
+ workerNodeService.activate("H3");
+ workers = workerNodeService.readWorkersByActivation(true);
+ Assert.assertEquals(1, workers.size());
+ workers = workerNodeService.readWorkersByActivation(false);
+ Assert.assertEquals(2, workers.size());
+
+ // deactivate worker
+ workerNodeService.deactivate("H3");
+ workers = workerNodeService.readWorkersByActivation(true);
+ Assert.assertEquals(0, workers.size());
+ workers = workerNodeService.readWorkersByActivation(false);
+ Assert.assertEquals(3, workers.size());
+
+ }
+
+ @Test
+ public void updateEnvironmentParams() throws Exception {
+ workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
+ workerNodeService.updateEnvironmentParams("H3", "Window", "7.0", "4");
+ WorkerNode worker = workerNodeService.readByUUID("H3");
+ Assert.assertEquals("Window", worker.getOs());
+ Assert.assertEquals("7.0", worker.getJvm());
+ Assert.assertEquals("4", worker.getDotNetVersion());
+
+ }
+
+ @Test
+ public void updateStatus() {
+ workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
+ WorkerNode worker = workerNodeService.readByUUID("H3");
+ Assert.assertEquals(WorkerStatus.FAILED, worker.getStatus());
+
+ workerNodeService.updateStatus("H3", WorkerStatus.RUNNING);
+ worker = workerNodeService.readByUUID("H3");
+ Assert.assertEquals(WorkerStatus.RUNNING, worker.getStatus());
+ }
@Test
public void updateBulkNumber() {
workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
- workerNodeService.updateBulkNumber("H3", "123");
+ workerNodeService.updateBulkNumber("H3", versionId);
WorkerNode worker = workerNodeService.readByUUID("H3");
- Assert.assertEquals("123", worker.getBulkNumber());
+ Assert.assertEquals(versionId, worker.getBulkNumber());
}
- @Test
- public void readAllWorkerGroups() {
- List groups = workerNodeService.readAllWorkerGroups();
- Assert.assertEquals(WorkerNode.DEFAULT_WORKER_GROUPS.length, groups.size());
-
- workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
- workerNodeService.updateWorkerGroups("H3", "group 1", "group 2");
- workerNodeService.updateWorkerGroups("H1", "group 1");
- groups = workerNodeService.readAllWorkerGroups();
- Assert.assertEquals(WorkerNode.DEFAULT_WORKER_GROUPS.length+2, groups.size());
-
- workerNodeService.updateWorkerGroups("H3");
- WorkerNode workerNode = workerNodeService.readByUUID("H3");
- Assert.assertTrue(workerNode.getGroups().isEmpty());
- }
-
- @Test
- public void checkIfGroupsExist() {
- workerNodeService.updateWorkerGroups("H1", "group 1", "group 2");
- workerNodeService.updateWorkerGroups("H2", "group 1");
-
- List result = workerNodeService.readWorkerGroups(Arrays.asList("group 1"));
- Assert.assertEquals(Arrays.asList("group 1"), result);
- }
-
- @Test
- public void addWorkerGroup() {
- WorkerNode workerNode = workerNodeService.readByUUID("H1");
- int groupSize = workerNode.getGroups().size();
-
- workerNodeService.addGroupToWorker("H1", "aaa");
- workerNode = workerNodeService.readByUUID("H1");
-
- Assert.assertEquals(groupSize+1, workerNode.getGroups().size());
- }
-
- @Configuration
- @EnableJpaRepositories("io.cloudslang.engine.node.repositories")
- @EnableTransactionManagement
- static class Configurator {
- @Bean
- DataSource dataSource() {
- BasicDataSource ds = new BasicDataSource();
- ds.setDriverClassName("org.h2.Driver");
- ds.setUrl("jdbc:h2:mem:test");
- ds.setUsername("sa");
- ds.setPassword("sa");
- ds.setDefaultAutoCommit(false);
- return new TransactionAwareDataSourceProxy(ds);
- }
-
- @Bean
- SpringLiquibase liquibase(DataSource dataSource) {
- SpringLiquibase liquibase = new SpringLiquibase();
- liquibase.setDataSource(dataSource);
- liquibase.setChangeLog("classpath:/META-INF/database/test.changes.xml");
- SimpleHiloIdentifierGenerator.setDataSource(dataSource);
- return liquibase;
- }
-
-
- @Bean
- Properties hibernateProperties() {
- return new Properties(){{
- setProperty("hibernate.format_sql", "true");
- setProperty("hibernate.hbm2ddl.auto", "create-drop");
- setProperty("hibernate.cache.use_query_cache", "false");
- setProperty("hibernate.generate_statistics", "false");
- setProperty("hibernate.cache.use_second_level_cache", "false");
- setProperty("hibernate.order_updates", "true");
- setProperty("hibernate.order_inserts", "true");
- }};
- }
-
- @Bean
- JpaVendorAdapter jpaVendorAdapter() {
- HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
- adapter.setShowSql(SHOW_SQL);
- adapter.setGenerateDdl(true);
- return adapter;
- }
-
- @Bean(name="entityManagerFactory")
- @DependsOn("liquibase")
- FactoryBean emf(JpaVendorAdapter jpaVendorAdapter) {
- LocalContainerEntityManagerFactoryBean fb = new LocalContainerEntityManagerFactoryBean();
- fb.setJpaProperties(hibernateProperties());
- fb.setDataSource(dataSource());
- fb.setPersistenceProviderClass(HibernatePersistence.class);
- fb.setPackagesToScan("io.cloudslang.engine.node");
- fb.setJpaVendorAdapter(jpaVendorAdapter);
- return fb;
- }
-
- @Bean
- PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
- return new JpaTransactionManager(emf);
- }
-
- @Bean
- VersionService versionService() {
- VersionService versionService = mock(VersionService.class);
- when(versionService.getCurrentVersion(anyString())).thenReturn(1L);
- return versionService;
- }
-
- @Bean
- WorkerNodeService workerNodeService(){
- return new WorkerNodeServiceImpl();
- }
+ @Test
+ public void readAllWorkerGroups() {
+ List groups = workerNodeService.readAllWorkerGroups();
+ Assert.assertEquals(WorkerNode.DEFAULT_WORKER_GROUPS.length, groups.size());
+
+ workerNodeService.create("H3", "H3", "dima.rassin", "c:/dir");
+ workerNodeService.updateWorkerGroups("H3", "group 1", "group 2");
+ workerNodeService.updateWorkerGroups("H1", "group 1");
+ groups = workerNodeService.readAllWorkerGroups();
+ Assert.assertEquals(WorkerNode.DEFAULT_WORKER_GROUPS.length + 2, groups.size());
+
+ workerNodeService.updateWorkerGroups("H3");
+ WorkerNode workerNode = workerNodeService.readByUUID("H3");
+ Assert.assertTrue(workerNode.getGroups().isEmpty());
+ }
+
+ @Test
+ public void checkIfGroupsExist() {
+ workerNodeService.updateWorkerGroups("H1", "group 1", "group 2");
+ workerNodeService.updateWorkerGroups("H2", "group 1");
+
+ List result = workerNodeService.readWorkerGroups(Arrays.asList("group 1"));
+ Assert.assertEquals(Arrays.asList("group 1"), result);
+ }
+
+ @Test
+ public void addWorkerGroup() {
+ WorkerNode workerNode = workerNodeService.readByUUID("H1");
+ int groupSize = workerNode.getGroups().size();
+
+ workerNodeService.addGroupToWorker("H1", "aaa");
+ workerNode = workerNodeService.readByUUID("H1");
+
+ Assert.assertEquals(groupSize + 1, workerNode.getGroups().size());
+ }
+
+ @Test
+ public void addWorkerInDuplicateGroups() {
+ List groups = workerNodeService.readAllWorkerGroups();
+ Assert.assertEquals(WorkerNode.DEFAULT_WORKER_GROUPS.length, groups.size());
+
+ List list;
+ HashSet expected;
+
+ workerNodeService.create("PLM", "PLM", "dan.filip", "c:/plm");
+
+ workerNodeService.updateWorkerGroups("PLM", "c1", "c2", "c2", "c3");
+ list = workerNodeService.readWorkerGroups("PLM");
+
+ expected = new HashSet<>(Arrays.asList("c2", "c1", "c3"));
+ org.junit.Assert.assertTrue("worker groups contain duplicates?", new HashSet<>(list).equals(expected));
+
+ // test null is not allowed + duplicates
+ workerNodeService.updateWorkerGroups("PLM", null, "1", null, "1", "1");
+ list = workerNodeService.readWorkerGroups("PLM");
+
+ expected = new HashSet<>(Arrays.asList("1"));
+ org.junit.Assert.assertTrue("worker groups contain duplicates?", new HashSet<>(list).equals(expected));
+
+ // test add worker in the same group twice
+ workerNodeService.addGroupToWorker("PLM", "g1");
+ workerNodeService.addGroupToWorker("PLM", "g1");
+
+ list = workerNodeService.readWorkerGroups("PLM");
+ expected = new HashSet<>(Arrays.asList("1", "g1"));
+ org.junit.Assert.assertTrue("worker groups contain duplicates?", new HashSet<>(list).equals(expected));
+ }
+
+ @Test
+ public void updateVersionTest() {
+ workerNodeService.create("worker_1", "password", "stamHost", "c:/dir");
+ WorkerNode workerNode = workerNodeService.readByUUID("H1");
+ Assert.assertEquals("", workerNode.getVersion());
+
+ workerNodeService.updateVersion("H1", "VERSION", versionId);
+
+ workerNode = workerNodeService.readByUUID("H1");
+
+ Assert.assertEquals("Version not updated!", "VERSION", workerNode.getVersion());
+ }
+
+ @Test
+ public void updateMigratedPasswordTest() {
+ workerNodeService.create("worker_1", "password", "stamHost", "c:/dir");
+ WorkerNode workerNode = workerNodeService.readByUUID("H1");
+ Assert.assertNull(workerNode.getMigratedPassword());
+
+ workerNodeService.updateMigratedPassword("H1", "newPassword");
+
+ workerNode = workerNodeService.readByUUID("H1");
+
+ Assert.assertEquals("Version not updated!", "newPassword", workerNode.getMigratedPassword());
+ }
+
+
+ @Test
+ public void updateAliasTest() {
+ workerNodeService.create("worker_1", "password", "stamHost", "c:/dir");
+ WorkerNode workerNode = workerNodeService.readByUUID("H1");
+ Assert.assertNull(workerNode.getAlias());
+
+ workerNodeService.updateWorkerAliasByUuid("H1", "alias");
+
+ workerNode = workerNodeService.readByUUID("H1");
+
+ Assert.assertEquals("Alias not updated!", "alias", workerNode.getAlias());
+ }
+
+ @Configuration
+ @EnableJpaRepositories("io.cloudslang.engine.node.repositories")
+ @EnableTransactionManagement
+ static class Configurator {
+ @Bean
+ DataSource dataSource() {
+ BasicDataSource ds = new BasicDataSource();
+ ds.setDriverClassName("org.h2.Driver");
+ ds.setUrl("jdbc:h2:mem:test");
+ ds.setUsername("sa");
+ ds.setPassword("sa");
+ ds.setDefaultAutoCommit(false);
+ return new TransactionAwareDataSourceProxy(ds);
+ }
+
+ @Bean
+ SpringLiquibase liquibase(DataSource dataSource) {
+ SpringLiquibase liquibase = new SpringLiquibase();
+ liquibase.setDataSource(dataSource);
+ //liquibase.setChangeLog("classpath:/META-INF/database/test.changes.xml");
+ liquibase.setChangeLog("classpath:/META-INF/database/score.changes.xml");
+ SimpleHiloIdentifierGenerator.setDataSource(dataSource);
+ return liquibase;
+ }
+
+
+ @Bean
+ Properties hibernateProperties() {
+ return new Properties() {{
+ setProperty("hibernate.format_sql", "true");
+ setProperty("hibernate.hbm2ddl.auto", "validate");
+ setProperty("hibernate.cache.use_query_cache", "false");
+ setProperty("hibernate.generate_statistics", "false");
+ setProperty("hibernate.cache.use_second_level_cache", "false");
+ setProperty("hibernate.order_updates", "true");
+ setProperty("hibernate.order_inserts", "true");
+ setProperty("hibernate.dialect_resolvers", "io.cloudslang.engine.dialects.ScoreDialectResolver");
+ }};
+ }
+
+ @Bean
+ JpaVendorAdapter jpaVendorAdapter() {
+ HibernateJpaVendorAdapter adapter = new HibernateJpaVendorAdapter();
+ adapter.setShowSql(SHOW_SQL);
+ adapter.setGenerateDdl(true);
+ return adapter;
+ }
+
+ @Bean(name = "entityManagerFactory")
+ @DependsOn("liquibase")
+ LocalContainerEntityManagerFactoryBean emf(JpaVendorAdapter jpaVendorAdapter) {
+ LocalContainerEntityManagerFactoryBean fb = new LocalContainerEntityManagerFactoryBean();
+ fb.setJpaProperties(hibernateProperties());
+ fb.setDataSource(dataSource());
+ fb.setPersistenceProviderClass(HibernatePersistenceProvider.class);
+ fb.setPackagesToScan("io.cloudslang.engine.node");
+ fb.setJpaVendorAdapter(jpaVendorAdapter);
+ return fb;
+ }
+
+ @Bean
+ PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
+ return new JpaTransactionManager(emf);
+ }
+
+ @Bean
+ VersionService versionService() {
+ VersionService versionService = mock(VersionService.class);
+ when(versionService.getCurrentVersion(anyString())).thenReturn(1L);
+ return versionService;
+ }
+
+ @Bean
+ WorkerNodeService workerNodeService() {
+ return new WorkerNodeServiceImpl();
+ }
@Bean
WorkerLockService workerLockService() {
return mock(WorkerLockService.class);
}
- }
+
+ @Bean
+ QueueConfigurationDataService queueConfigurationDataService() {
+ return mock(QueueConfigurationDataService.class);
+ }
+
+ }
}
diff --git a/engine/node/score-node-impl/src/test/resources/META-INF/spring/testContext.xml b/engine/node/score-node-impl/src/test/resources/META-INF/spring/testContext.xml
index 3054451306..1d0664e319 100644
--- a/engine/node/score-node-impl/src/test/resources/META-INF/spring/testContext.xml
+++ b/engine/node/score-node-impl/src/test/resources/META-INF/spring/testContext.xml
@@ -14,7 +14,7 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/t
@@ -49,7 +49,7 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/t
-
+
@@ -58,7 +58,7 @@ http://www.springframework.org/schema/tx http://www.springframework.org/schema/t
-
+
diff --git a/engine/orchestrator/pom.xml b/engine/orchestrator/pom.xml
index 85da77aed9..6e7cf82793 100644
--- a/engine/orchestrator/pom.xml
+++ b/engine/orchestrator/pom.xml
@@ -1,25 +1,36 @@
-
-
-
- io.cloudslang
- engine
- 0.1.282-SNAPSHOT
-
- 4.0.0
-
- orchestrator
- pom
-
-
- score-orchestrator-api
- score-orchestrator-impl
-
+
+ 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.
+
+-->
+
+
+ 4.0.0
+
+
+ io.cloudslang
+ engine
+ 0.4.56-SNAPSHOT
+
+
+ orchestrator
+ pom
+
+
+ score-orchestrator-api
+ score-orchestrator-impl
+
\ No newline at end of file
diff --git a/engine/orchestrator/score-orchestrator-api/pom.xml b/engine/orchestrator/score-orchestrator-api/pom.xml
index 8f42bd2846..2453d9f6b6 100644
--- a/engine/orchestrator/score-orchestrator-api/pom.xml
+++ b/engine/orchestrator/score-orchestrator-api/pom.xml
@@ -1,43 +1,75 @@
-
-
- 4.0.0
-
-
- io.cloudslang
- orchestrator
- 0.1.282-SNAPSHOT
-
-
- score-orchestrator-api
-
-
-
- ${project.groupId}
- score-facade
-
-
-
- ${project.groupId}
- score-data-api
-
-
-
- org.hibernate
- hibernate-core
-
-
- com.mysema.querydsl
- querydsl-apt
- provided
-
-
+ 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.
+
+-->
+
+
+ 4.0.0
+
+
+ io.cloudslang
+ orchestrator
+ 0.4.56-SNAPSHOT
+
+
+ score-orchestrator-api
+
+
+
+ ${project.groupId}
+ score-facade
+
+
+ ${project.groupId}
+ score-data-api
+
+
+ org.hibernate.orm
+ hibernate-core
+
+
+ com.querydsl
+ querydsl-apt
+ jakarta
+
+
+
+ com.querydsl
+ querydsl-jpa
+ jakarta
+
+
+
+ org.springframework.data
+ spring-data-jpa
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+
\ No newline at end of file
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/BranchContextByteaTypeDescriptor.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/BranchContextByteaTypeDescriptor.java
new file mode 100644
index 0000000000..57be4bd69f
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/BranchContextByteaTypeDescriptor.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.orchestrator.entities;
+
+import org.hibernate.type.descriptor.java.SerializableJavaType;
+import org.hibernate.usertype.UserTypeSupport;
+
+import java.sql.Types;
+
+public class BranchContextByteaTypeDescriptor extends UserTypeSupport {
+
+ public BranchContextByteaTypeDescriptor() {
+ super(new SerializableJavaType<>(BranchContexts.class).getJavaTypeClass(), Types.LONGVARBINARY);
+ }
+}
\ No newline at end of file
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/BranchContexts.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/BranchContexts.java
index 61f71f562b..eb27540c5a 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/BranchContexts.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/BranchContexts.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.entities;
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionByteaTypeDescriptor.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionByteaTypeDescriptor.java
new file mode 100644
index 0000000000..bbb2f1905a
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionByteaTypeDescriptor.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.orchestrator.entities;
+
+import io.cloudslang.score.facade.entities.Execution;
+import org.hibernate.type.descriptor.java.SerializableJavaType;
+import org.hibernate.usertype.UserTypeSupport;
+
+import java.sql.Types;
+
+public class ExecutionByteaTypeDescriptor extends UserTypeSupport {
+
+ public ExecutionByteaTypeDescriptor() {
+ super(new SerializableJavaType<>(Execution.class).getJavaTypeClass(), Types.LONGVARBINARY);
+ }
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionObjEntity.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionObjEntity.java
index b8520427ae..78ab50ca65 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionObjEntity.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionObjEntity.java
@@ -1,20 +1,27 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.entities;
import io.cloudslang.score.facade.entities.Execution;
-import javax.persistence.Column;
-import javax.persistence.Embeddable;
-import javax.persistence.Lob;
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import jakarta.persistence.Lob;
+import org.hibernate.annotations.Type;
/**
* Created by IntelliJ IDEA.
@@ -24,12 +31,11 @@
@Embeddable
public class ExecutionObjEntity {
-
@Lob
@Column(name = "EXECUTION_OBJECT")
+ @Type(value = io.cloudslang.orchestrator.entities.ExecutionByteaTypeDescriptor.class)
private Execution executionObj;
-
public Execution getExecutionObj() {
return executionObj;
}
@@ -38,14 +44,12 @@ public void setExecutionObj(Execution executionObj) {
this.executionObj = executionObj;
}
- public ExecutionObjEntity(){
+ public ExecutionObjEntity() {
}
- public ExecutionObjEntity(Execution executionObj){
- this.executionObj = executionObj;
+ public ExecutionObjEntity(Execution executionObj) {
+ this.executionObj = executionObj;
}
-
-
}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionState.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionState.java
index 53bf74f0f5..7ed08d1963 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionState.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/ExecutionState.java
@@ -1,29 +1,39 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.entities;
+import io.cloudslang.engine.data.AbstractIdentifiable;
import io.cloudslang.score.facade.execution.ExecutionStatus;
import io.cloudslang.score.facade.execution.ExecutionSummary;
-import io.cloudslang.engine.data.AbstractIdentifiable;
import org.apache.commons.lang.builder.EqualsBuilder;
+import org.hibernate.annotations.Parameter;
+import org.hibernate.annotations.Type;
+
+import jakarta.persistence.Basic;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.Lob;
+import jakarta.persistence.Table;
+import jakarta.persistence.UniqueConstraint;
+import org.hibernate.usertype.UserTypeLegacyBridge;
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.FetchType;
-import javax.persistence.Lob;
-import javax.persistence.Table;
-import javax.persistence.UniqueConstraint;
import java.util.Arrays;
/**
@@ -32,7 +42,7 @@
*/
@Entity
@Table(name = "OO_EXECUTION_STATE",
- uniqueConstraints = {@UniqueConstraint(name = "OO_EXECUTION_STATE_UC", columnNames = {"EXECUTION_ID", "BRANCH_ID"})})
+ uniqueConstraints = {@UniqueConstraint(name = "OO_EXECUTION_STATE_UC", columnNames = {"EXECUTION_ID", "BRANCH_ID"})})
public class ExecutionState extends AbstractIdentifiable {
public static final String EMPTY_BRANCH = "EMPTY";
@@ -49,9 +59,14 @@ public class ExecutionState extends AbstractIdentifiable {
@Column(name = "EXECUTION_OBJECT")
@Lob
+ @Type(value = UserTypeLegacyBridge.class,
+ parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "image"))
@Basic(fetch = FetchType.LAZY)
private byte[] executionObject;
+ @Column(name = "UPDATE_TIME")
+ private Long updateTime;
+
public Long getExecutionId() {
return executionId;
}
@@ -84,6 +99,14 @@ public void setExecutionObject(byte[] executionObj) {
this.executionObject = executionObj;
}
+ public Long getUpdateTime() {
+ return updateTime;
+ }
+
+ public void setUpdateTime(Long updateTime) {
+ this.updateTime = updateTime;
+ }
+
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/FinishedBranch.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/FinishedBranch.java
index 2c052b14d8..be60eae8d7 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/FinishedBranch.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/FinishedBranch.java
@@ -1,28 +1,36 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.entities;
import io.cloudslang.engine.data.AbstractIdentifiable;
+import jakarta.persistence.Basic;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.Lob;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.Table;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.Immutable;
-
-import javax.persistence.Basic;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.Lob;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
+import org.hibernate.annotations.Parameter;
+import org.hibernate.annotations.Type;
+import org.hibernate.usertype.UserTypeLegacyBridge;
/**
* Created with IntelliJ IDEA.
@@ -46,18 +54,22 @@ public class FinishedBranch extends AbstractIdentifiable {
@Lob
@Basic(fetch = FetchType.LAZY)
+ @Type(value = UserTypeLegacyBridge.class,
+ parameters = @Parameter(name = UserTypeLegacyBridge.TYPE_NAME_PARAM_KEY, value = "text"))
@Column(name = "BRANCH_EXCEPTION", updatable = false)
private String branchException;
@Column(name = "BRANCH_CONTEXT", nullable = false, updatable = false)
@Lob
+ @Type(value = io.cloudslang.orchestrator.entities.BranchContextByteaTypeDescriptor.class)
private BranchContexts branchContexts;
@ManyToOne
- @JoinColumn(name="SUSPENDED_EXECUTION_ID", nullable = false, updatable = false)
+ @JoinColumn(name = "SUSPENDED_EXECUTION_ID", nullable = false, updatable = false)
private SuspendedExecution suspendedExecution;
- public FinishedBranch() {}
+ public FinishedBranch() {
+ }
public FinishedBranch(String executionId, String branchId, String splitId, String branchException, BranchContexts branchContexts) {
this.executionId = executionId;
@@ -67,9 +79,9 @@ public FinishedBranch(String executionId, String branchId, String splitId, Strin
this.branchContexts = branchContexts;
}
- public void connectToSuspendedExecution(SuspendedExecution suspendedExecution) {
+ public boolean connectToSuspendedExecution(SuspendedExecution suspendedExecution) {
this.suspendedExecution = suspendedExecution;
- suspendedExecution.getFinishedBranches().add(this); //bi directional connection
+ return suspendedExecution.getFinishedBranches().add(this); //bi directional connection
}
public SuspendedExecution getSuspendedExecution() {
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/MergedConfigurationDataContainer.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/MergedConfigurationDataContainer.java
new file mode 100644
index 0000000000..409acf3ea5
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/MergedConfigurationDataContainer.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.orchestrator.entities;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import static java.util.Collections.emptySet;
+
+
+public class MergedConfigurationDataContainer implements Serializable {
+
+ private static final long serialVersionUID = 6409757702040555672L;
+
+ private Set cancelledExecutions;
+ private Set pausedExecutions;
+ private Set workerGroups;
+
+ public MergedConfigurationDataContainer() {
+ this.cancelledExecutions = emptySet();
+ this.pausedExecutions = emptySet();
+ this.workerGroups = emptySet();
+ }
+
+ public MergedConfigurationDataContainer(Set cancelledExecutions, Set pausedExecutions,
+ Set workerGroups) {
+ this.cancelledExecutions = cancelledExecutions;
+ this.pausedExecutions = pausedExecutions;
+ this.workerGroups = workerGroups;
+ }
+
+ public Set getCancelledExecutions() {
+ return cancelledExecutions;
+ }
+
+ public void setCancelledExecutions(Set cancelledExecutions) {
+ this.cancelledExecutions = cancelledExecutions;
+ }
+
+ public Set getPausedExecutions() {
+ return pausedExecutions;
+ }
+
+ public void setPausedExecutions(Set pausedExecutions) {
+ this.pausedExecutions = pausedExecutions;
+ }
+
+ public Set getWorkerGroups() {
+ return workerGroups;
+ }
+
+ public void setWorkerGroups(Set workerGroups) {
+ this.workerGroups = workerGroups;
+ }
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/Message.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/Message.java
index 36c4f1f8f9..00ab0b1f13 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/Message.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/Message.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.entities;
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/SplitMessage.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/SplitMessage.java
index 5b2965fd14..272367394c 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/SplitMessage.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/SplitMessage.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.entities;
@@ -32,8 +38,14 @@ public class SplitMessage implements Message {
private final String splitId;
private final Execution parent;
private final List children;
-
- public SplitMessage(String splitId, Execution parent, List children) {
+ private final int totalNumberOfBranches;
+ private final boolean executable;
+
+ public SplitMessage(String splitId,
+ Execution parent,
+ List children,
+ int totalNumberOfBranches,
+ boolean executable) {
Validate.notNull(splitId, "splitId cannot be null");
Validate.notNull(parent, "parent cannot be null");
Validate.notNull(children, "children cannot be null");
@@ -42,6 +54,8 @@ public SplitMessage(String splitId, Execution parent, List children)
this.splitId = splitId;
this.parent = parent;
this.children = new ArrayList<>(children);
+ this.totalNumberOfBranches = totalNumberOfBranches;
+ this.executable = executable;
}
public Execution getParent() {
@@ -56,6 +70,10 @@ public String getSplitId() {
return splitId;
}
+ public boolean isExecutable() {
+ return executable;
+ }
+
@Override
public int getWeight() {
return children.size() * basicSplitWeight;
@@ -71,7 +89,11 @@ public List shrink(List messages) {
return messages; // do nothing
}
- @Override
+ public int getTotalNumberOfBranches() {
+ return totalNumberOfBranches;
+ }
+
+ @Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SplitMessage)) return false;
@@ -82,6 +104,9 @@ public boolean equals(Object o) {
.append(this.splitId, that.splitId)
.append(this.parent, that.parent)
.append(this.children, that.children)
+ .append(this.totalNumberOfBranches, that.totalNumberOfBranches)
+ .append(this.executable, that.executable)
+ .append(this.totalNumberOfBranches, that.totalNumberOfBranches)
.isEquals();
}
@@ -90,6 +115,9 @@ public int hashCode() {
return Objects.hash(
this.splitId,
this.parent,
- this.children);
+ this.children,
+ this.totalNumberOfBranches,
+ this.totalNumberOfBranches,
+ this.executable);
}
}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/SuspendedExecution.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/SuspendedExecution.java
index f1f83da1d3..2e56865ce2 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/SuspendedExecution.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/entities/SuspendedExecution.java
@@ -1,21 +1,38 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.entities;
+import io.cloudslang.orchestrator.enums.SuspendedExecutionReason;
import io.cloudslang.score.facade.entities.Execution;
import io.cloudslang.engine.data.AbstractIdentifiable;
-import javax.persistence.*;
-import java.util.ArrayList;
-import java.util.List;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Table;
+import jakarta.persistence.Column;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.Basic;
+import jakarta.persistence.Embedded;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.CascadeType;
+import jakarta.persistence.FetchType;
+import java.util.HashSet;
+import java.util.Set;
+
+import static jakarta.persistence.EnumType.STRING;
/**
* Created with IntelliJ IDEA.
@@ -38,21 +55,39 @@ public class SuspendedExecution extends AbstractIdentifiable {
@Column(name= "NUMBER_OF_BRANCHES", nullable = false)
private Integer numberOfBranches;
+ @Enumerated(STRING)
+ @Column(name = "SUSPENSION_REASON", nullable = false)
+ private SuspendedExecutionReason suspensionReason;
+
+ @Column(name = "MERGED_BRANCHES", nullable = false)
+ private long mergedBranches;
+
+ @Column(name = "LOCKED", nullable = false)
+ private boolean locked;
+
@Basic(fetch = FetchType.LAZY)
@Embedded
private ExecutionObjEntity executionObj;
@OneToMany(cascade = {CascadeType.ALL}, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy="suspendedExecution")
- private List finishedBranches = new ArrayList<>();
+ private Set finishedBranches = new HashSet<>();
private SuspendedExecution() {
}
- public SuspendedExecution(String executionId, String splitId, Integer numberOfBranches, Execution executionObj) {
+ public SuspendedExecution(String executionId,
+ String splitId,
+ Integer numberOfBranches,
+ Execution executionObj,
+ SuspendedExecutionReason suspensionReason,
+ boolean locked) {
this.executionId = executionId;
this.splitId = splitId;
this.numberOfBranches = numberOfBranches;
this.executionObj = new ExecutionObjEntity(executionObj);
+ this.suspensionReason = suspensionReason;
+ this.locked = locked;
+ mergedBranches = 0;
}
public String getExecutionId() {
@@ -90,14 +125,38 @@ public void setExecutionObj(Execution executionObj) {
this.executionObj = new ExecutionObjEntity(executionObj);
}
- public List getFinishedBranches() {
+ public Set getFinishedBranches() {
return finishedBranches;
}
- public void setFinishedBranches(List finishedBranches) {
+ public void setFinishedBranches(Set finishedBranches) {
this.finishedBranches = finishedBranches;
}
+ public SuspendedExecutionReason getSuspensionReason() {
+ return suspensionReason;
+ }
+
+ public void setSuspensionReason(SuspendedExecutionReason suspensionReason) {
+ this.suspensionReason = suspensionReason;
+ }
+
+ public long getMergedBranches() {
+ return mergedBranches;
+ }
+
+ public void setMergedBranches(long mergedBranches) {
+ this.mergedBranches = mergedBranches;
+ }
+
+ public boolean isLocked() {
+ return locked;
+ }
+
+ public void setLocked(boolean locked) {
+ this.locked = locked;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -108,6 +167,9 @@ public boolean equals(Object o) {
if (!executionId.equals(that.executionId)) return false;
if (!numberOfBranches.equals(that.numberOfBranches)) return false;
if (!splitId.equals(that.splitId)) return false;
+ if (!suspensionReason.equals(that.suspensionReason)) return false;
+ if (mergedBranches != that.mergedBranches) return false;
+ if (locked != that.locked) return false;
return true;
}
@@ -117,6 +179,7 @@ public int hashCode() {
int result = executionId.hashCode();
result = 31 * result + splitId.hashCode();
result = 31 * result + numberOfBranches.hashCode();
+ result = 31 * result + suspensionReason.hashCode();
return result;
}
}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/enums/SuspendedExecutionReason.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/enums/SuspendedExecutionReason.java
new file mode 100644
index 0000000000..c5cbf92987
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/enums/SuspendedExecutionReason.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.orchestrator.enums;
+
+public enum SuspendedExecutionReason {
+ PARALLEL,
+ MULTI_INSTANCE,
+ NON_BLOCKING,
+ PARALLEL_LOOP
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/AplsLicensingService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/AplsLicensingService.java
new file mode 100644
index 0000000000..471a8e32f6
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/AplsLicensingService.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.orchestrator.services;
+
+public interface AplsLicensingService {
+
+ String BRANCH_ID_TO_CHECK_OUT_LICENSE = "BRANCH_ID_CHECKOUT";
+ String BRANCH_ID_TO_CHECK_IN_LICENSE = "BRANCH_ID_CHECKIN";
+
+ void checkoutBeginLane(String executionId, String branchId, long executionStartTimeMillis, int executionTimeoutMinutes);
+
+ void checkinEndLane(String executionId, String branchId);
+
+ boolean incrementUiStep(String executionId, String branchId);
+
+ void decrementUiStep(String executionId, String branchId);
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/CancelExecutionService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/CancelExecutionService.java
index a0942ef5ae..808430aabe 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/CancelExecutionService.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/CancelExecutionService.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/EngineVersionService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/EngineVersionService.java
new file mode 100644
index 0000000000..486d979419
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/EngineVersionService.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.orchestrator.services;
+
+/**
+ * Created by kravtsov on 03/01/2016
+ */
+
+public interface EngineVersionService {
+
+ String getEngineVersionId();
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionCleanerService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionCleanerService.java
new file mode 100644
index 0000000000..00804a1251
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionCleanerService.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.orchestrator.services;
+
+public interface ExecutionCleanerService {
+ void cleanExecutions();
+}
\ No newline at end of file
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionStateService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionStateService.java
index d5b51f4fc4..919e12c987 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionStateService.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionStateService.java
@@ -1,19 +1,27 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
import io.cloudslang.score.facade.entities.Execution;
import io.cloudslang.score.facade.execution.ExecutionStatus;
import io.cloudslang.orchestrator.entities.ExecutionState;
+import org.springframework.data.domain.PageRequest;
+import java.util.Date;
import java.util.List;
/**
@@ -26,7 +34,7 @@ public interface ExecutionStateService {
* Reads the run with the specified execution id and branch id
*
* @param executionId id of the execution
- * @param branchId id of the branch
+ * @param branchId id of the branch
* @return the execution state
*/
public ExecutionState readByExecutionIdAndBranchId(Long executionId, String branchId);
@@ -67,7 +75,7 @@ public interface ExecutionStateService {
* Creates a new execution state object
*
* @param executionId id of the execution
- * @param branchId id of the branch
+ * @param branchId id of the branch
* @return the execution state
*/
public ExecutionState createExecutionState(Long executionId, String branchId);
@@ -76,7 +84,7 @@ public interface ExecutionStateService {
* Returns the execution object for the specified execution id and branch id
*
* @param executionId id of the execution
- * @param branchId id of the branch
+ * @param branchId id of the branch
* @return the execution object
*/
public Execution readExecutionObject(Long executionId, String branchId);
@@ -85,10 +93,10 @@ public interface ExecutionStateService {
* Updates the execution object for the specified execution id and branch id
*
* @param executionId id of the execution
- * @param branchId id of the branch
- * @param execution the execution object
+ * @param branchId id of the branch
+ * @param execution the execution object
*/
- public void updateExecutionObject(Long executionId, String branchId, Execution execution);
+ public void updateExecutionObject(Long executionId, String branchId, Execution execution, Date updateDate);
/***
* Updates the status for the given execution id and branch id
@@ -96,14 +104,23 @@ public interface ExecutionStateService {
* @param executionId id of the execution
* @param branchId id of the branch
* @param status status of the execution
+ * @param updateDate update time of the execution
*/
- public void updateExecutionStateStatus(Long executionId, String branchId, ExecutionStatus status);
+ public void updateExecutionStateStatus(Long executionId, String branchId, ExecutionStatus status, Date updateDate);
/**
* Deletes the specified execution, both the parent execution and any child executions
*
* @param executionId id of the execution
- * @param branchId id of the branch
+ * @param branchId id of the branch
*/
public void deleteExecutionState(Long executionId, String branchId);
+
+ public void deleteCanceledExecutionStates();
+
+ public Execution getExecutionObjectForNullBranch(Long executionId);
+
+ public List findExecutionStateByStatusInAndUpdateTimeLessThanEqual(List statuses, long cutOffTime, PageRequest pageRequest);
+
+ public void deleteExecutionStateByIds(List toDeleteIds);
}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionSummaryDelegatorService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionSummaryDelegatorService.java
new file mode 100644
index 0000000000..8055aea242
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ExecutionSummaryDelegatorService.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.orchestrator.services;
+
+import io.cloudslang.score.facade.execution.ExecutionStatus;
+import io.cloudslang.score.facade.execution.ExecutionSummary;
+
+import java.util.List;
+
+public interface ExecutionSummaryDelegatorService {
+
+ // executionSummary entity is only populated with executionId and endTime
+ List getEndTimeByExecutionIdInAndStatusIn(List executionIds, List statuses);
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/MergedConfigurationService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/MergedConfigurationService.java
new file mode 100644
index 0000000000..733cc0d189
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/MergedConfigurationService.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.orchestrator.services;
+
+import io.cloudslang.orchestrator.entities.MergedConfigurationDataContainer;
+
+
+public interface MergedConfigurationService {
+
+ MergedConfigurationDataContainer fetchMergedConfiguration(String workerUuid);
+
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/OrchestratorDispatcherService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/OrchestratorDispatcherService.java
index f489190e7f..2d4c167b19 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/OrchestratorDispatcherService.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/OrchestratorDispatcherService.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/PauseResumeService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/PauseResumeService.java
index 3d3655ab9d..f5a1b96918 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/PauseResumeService.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/PauseResumeService.java
@@ -1,30 +1,30 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
+import io.cloudslang.score.facade.entities.Execution;
import io.cloudslang.score.facade.execution.ExecutionSummary;
import io.cloudslang.score.facade.execution.PauseReason;
-import io.cloudslang.score.facade.entities.Execution;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;
-/**
- * Created with IntelliJ IDEA.
- * User: kravtsov
- * Date: 17/12/12
- * Time: 15:34
- */
public interface PauseResumeService {
/**
@@ -37,6 +37,22 @@ public interface PauseResumeService {
*/
Long pauseExecution(Long executionId, String branchId, PauseReason reason);
+ /**
+ * Add interrupts to the system context under USER_INTERRUPT
+ *
+ * @param executionId id of the execution
+ * @return add interrupts to the current execution
+ */
+ void injectInterrupts(Long executionId, Map> interrupts);
+
+ /**
+ * removes interrupts
+ *
+ * @param executionId id of the execution
+ * @return add interrupts to the current execution
+ */
+ void deleteInterrupts(Long executionId, Map> interrupts);
+
/**
* Resumes execution and puts it back to execution queue
*
@@ -50,34 +66,45 @@ public interface PauseResumeService {
* Persists Execution object to the DB
*
* @param executionId - execution id
- * @param branchId - branch id if it is parallel lane
- * @param execution - object to persist
+ * @param branchId - branch id if it is parallel lane
+ * @param execution - object to persist
* @return the pause reason of the paused execution
*/
- PauseReason writeExecutionObject(Long executionId, String branchId, Execution execution);
+ PauseReason writeExecutionObject(Long executionId, String branchId, Execution execution, boolean updateParentExecObject);
/**
- * Returns list of strings: each one of form: executionId:branchId
+ * Uses caching Returns list of strings: each one of form: executionId:branchId
*
* @return list of execution & branch ids of all the paused branches
*/
Set readAllPausedExecutionBranchIds();
+ /**
+ * Does not use caching Returns list of strings: each one of form: executionId:branchId
+ *
+ * @return list of execution & branch ids of all the paused branches
+ */
+ Set readAllPausedExecutionBranchIdsNoCache();
+
/**
* Returns the execution if its status is Paused*. Otherwise returns null.
*
* @param executionId id of the execution
* @param branchId id of the branch
- * @return the execution if its status is Paused*. Otherwise returns null.
+ * @return the execution if its status is Paused*. Otherwise returns null.
*/
ExecutionSummary readPausedExecution(Long executionId, String branchId);
/**
- * Get a list of all pause id's that are relevant to an execution,
- * there could be many because of different lanes that can be paused
+ * Get a list of all pause id's that are relevant to an execution, there could be many because of different lanes
+ * that can be paused
*
* @param executionId th execution id in question
* @return a list of all current pauses id relevant
*/
List readPauseIds(Long executionId);
+
+ void createNoRobotGroup(Execution execution, Long pauseId, String branchId);
+
+ void deletePauseData(String executionId, String branchId);
}
\ No newline at end of file
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ScorePauseResume.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ScorePauseResume.java
index 4f7902510a..5eefd6c3a0 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ScorePauseResume.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ScorePauseResume.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ScoreTriggering.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ScoreTriggering.java
index 62e2f1a5e2..e3e1960e7d 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ScoreTriggering.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/ScoreTriggering.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SplitJoinService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SplitJoinService.java
index 71b8116c03..c61914a945 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SplitJoinService.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SplitJoinService.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
@@ -56,4 +62,8 @@ public interface SplitJoinService {
*
*/
void joinFinishedSplits();
+
+ int joinFinishedMiBranches(int bulkSize);
+
+ void deleteFinishedSuspendedExecutions(int bulkSize);
}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SuspendedExecutionCleanerService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SuspendedExecutionCleanerService.java
new file mode 100644
index 0000000000..bd4b548d29
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SuspendedExecutionCleanerService.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.orchestrator.services;
+
+
+public interface SuspendedExecutionCleanerService {
+ void cleanupSuspendedExecutions();
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SuspendedExecutionService.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SuspendedExecutionService.java
new file mode 100644
index 0000000000..669fee8bf0
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/orchestrator/services/SuspendedExecutionService.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.orchestrator.services;
+
+import io.cloudslang.score.facade.entities.Execution;
+
+public interface SuspendedExecutionService {
+
+ void updateSuspendedExecutionMiThrottlingContext(Execution execution);
+
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/CancelReason.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/CancelReason.java
new file mode 100644
index 0000000000..268d39e819
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/CancelReason.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.score.facade.execution;
+
+/**
+ * Created by eskin on 20/10/2015.
+ */
+public enum CancelReason {
+ TIMEOUT_EXPIRED,
+ MANUAL
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionActionException.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionActionException.java
index c78907ba33..7f6f5fa166 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionActionException.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionActionException.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
package io.cloudslang.score.facade.execution;
/**
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionActionResult.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionActionResult.java
index ae163555ac..6225478ea0 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionActionResult.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionActionResult.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
package io.cloudslang.score.facade.execution;
import java.util.HashMap;
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionSummary.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionSummary.java
index 891b4ef32e..20abc0c701 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionSummary.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/ExecutionSummary.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.score.facade.execution;
@@ -17,6 +23,8 @@
public class ExecutionSummary implements Serializable {
+ private static final long serialVersionUID = 3895708684033992809L;
+
public static final String EMPTY_BRANCH = "EMPTY";
private String executionId;
@@ -27,6 +35,7 @@ public class ExecutionSummary implements Serializable {
private String resultStatusType;
private String resultStatusName;
private PauseReason pauseReason;
+ private CancelReason cancelReason;
private String owner;
private String triggeredBy;
private String flowUuid;
@@ -36,6 +45,10 @@ public class ExecutionSummary implements Serializable {
@SuppressWarnings("UnusedDeclaration")
@Deprecated private long branchesCount; //not active since 10.02!! we don't set the value, but must leave it for backward compatible of the POJO in Careml.
private Double roi;
+ private boolean reserveRobot;
+ private boolean autoResume;
+ private LicenseType licenseType;
+ private Long licenseConsumption;
public String getExecutionId() {
return executionId;
@@ -176,6 +189,46 @@ public void setRoi(Double roi) {
this.roi = roi;
}
+ public CancelReason getCancelReason() {
+ return cancelReason;
+ }
+
+ public void setCancelReason(CancelReason cancelReason) {
+ this.cancelReason = cancelReason;
+ }
+
+ public boolean isReserveRobot() {
+ return reserveRobot;
+ }
+
+ public void setReserveRobot(boolean reserveRobot) {
+ this.reserveRobot = reserveRobot;
+ }
+
+ public boolean isAutoResume() {
+ return autoResume;
+ }
+
+ public void setAutoResume(boolean autoResume) {
+ this.autoResume = autoResume;
+ }
+
+ public LicenseType getLicenseType() {
+ return licenseType;
+ }
+
+ public void setLicenseType(LicenseType licenseType) {
+ this.licenseType = licenseType;
+ }
+
+ public Long getLicenseConsumption() {
+ return licenseConsumption;
+ }
+
+ public void setLicenseConsumption(Long licenseConsumption) {
+ this.licenseConsumption = licenseConsumption;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -201,6 +254,7 @@ public boolean equals(Object o) {
if (roi != that.roi) return false;
if (triggeredBy != null ? !triggeredBy.equals(that.triggeredBy) : that.triggeredBy != null) return false;
if (triggeringSource != null ? !triggeringSource.equals(that.triggeringSource) : that.triggeringSource != null) return false;
+ if (licenseConsumption != null ? !licenseConsumption.equals(that.licenseConsumption) : that.licenseConsumption != null) return false;
return true;
}
@@ -222,6 +276,7 @@ public int hashCode() {
result = 31 * result + (flowUuid != null ? flowUuid.hashCode() : 0);
result = 31 * result + (flowPath != null ? flowPath.hashCode() : 0);
result = 31 * result + (executionName != null ? executionName.hashCode() : 0);
+ result = 31 * result + (licenseConsumption != null ? licenseConsumption.hashCode() : 0);
return result;
}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/LicenseType.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/LicenseType.java
new file mode 100644
index 0000000000..8c76ee7237
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/LicenseType.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.score.facade.execution;
+
+public enum LicenseType {
+ UNDEFINED(-1),
+ CONCURRENT_BOT(0),
+ HOURLY(1),
+ INSTANT_ON(2),
+ CONCURRENT_HOURLY(3),
+ SUITE_LICENSE(4),
+ NODE_LICENSE(5);
+
+ private final int code;
+
+ LicenseType(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+}
diff --git a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/PauseReason.java b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/PauseReason.java
index 1f49dc0ba3..cdedd96c48 100644
--- a/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/PauseReason.java
+++ b/engine/orchestrator/score-orchestrator-api/src/main/java/io/cloudslang/score/facade/execution/PauseReason.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.score.facade.execution;
@@ -26,5 +32,9 @@ public enum PauseReason {
HAND_OFF,
INTERRUPT,
NO_WORKERS_IN_GROUP,
- BRANCH_PAUSED
+ BRANCH_PAUSED,
+ SEQUENTIAL_EXECUTION,
+ NO_ROBOTS_IN_GROUP,
+ PENDING_ROBOT,
+ PRECONDITION_NOT_FULFILLED
}
diff --git a/engine/orchestrator/score-orchestrator-impl/pom.xml b/engine/orchestrator/score-orchestrator-impl/pom.xml
index f33f5ae347..a87c1ba0b4 100644
--- a/engine/orchestrator/score-orchestrator-impl/pom.xml
+++ b/engine/orchestrator/score-orchestrator-impl/pom.xml
@@ -1,28 +1,51 @@
-
-
+
+ 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.
+
+-->
+
+
+
+ 4.0.0
+
io.cloudslang
orchestrator
- 0.1.282-SNAPSHOT
+ 0.4.56-SNAPSHOT
- 4.0.0
score-orchestrator-impl
+
+
+ org.glassfish
+ jakarta.el
+
+
org.springframework
spring-beans
+
+ org.springframework.data
+ spring-data-jpa
+
+
org.springframework
spring-context
@@ -39,7 +62,7 @@
- org.hibernate
+ org.hibernate.orm
hibernate-core
@@ -54,8 +77,9 @@
- com.mysema.querydsl
+ com.querydsl
querydsl-jpa
+ jakarta
@@ -63,12 +87,14 @@
score-api
${project.version}
+
${project.groupId}
score-facade
+
${project.groupId}
score-queue-api
@@ -78,8 +104,13 @@
${project.groupId}
score-orchestrator-api
-
+
+ com.google.guava
+ guava
+
+
+
junit
@@ -98,20 +129,14 @@
- org.hibernate
- hibernate-entitymanager
- test
-
-
-
- org.hibernate
+ org.hibernate.validator
hibernate-validator
test
org.mockito
- mockito-all
+ mockito-core
@@ -129,5 +154,30 @@
org.easytesting
fest-assert
+
+
+ org.awaitility
+ awaitility
+
+
+
+ org.apache.logging.log4j
+ log4j-core
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+
\ No newline at end of file
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/model/MergedConfigurationHolder.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/model/MergedConfigurationHolder.java
new file mode 100644
index 0000000000..f677937edb
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/model/MergedConfigurationHolder.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.orchestrator.model;
+
+
+import java.util.Map;
+import java.util.Set;
+
+import static java.util.Collections.emptyMap;
+import static java.util.Collections.emptySet;
+
+public class MergedConfigurationHolder {
+
+ private final Set cancelledExecutions;
+ private final Set pausedExecutionBranchIdPairs;
+ private final Map> workerGroupsMap;
+
+ public MergedConfigurationHolder() {
+ this.cancelledExecutions = emptySet();
+ this.pausedExecutionBranchIdPairs = emptySet();
+ this.workerGroupsMap = emptyMap();
+ }
+
+ public MergedConfigurationHolder(Set cancelledExecutions, Set pausedExecutions,
+ Map> workerGroupsMap) {
+ this.cancelledExecutions = cancelledExecutions;
+ this.pausedExecutionBranchIdPairs = pausedExecutions;
+ this.workerGroupsMap = workerGroupsMap;
+ }
+
+ public Set getCancelledExecutions() {
+ return cancelledExecutions;
+ }
+
+ public Set getPausedExecutionBranchIdPairs() {
+ return pausedExecutionBranchIdPairs;
+ }
+
+ public Set getWorkerGroupsForWorker(String workerId) {
+ Set groups = workerGroupsMap.get(workerId);
+ return (groups != null) ? groups : emptySet();
+ }
+
+}
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/ExecutionStateRepository.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/ExecutionStateRepository.java
index 2df7429259..aa95cbe2b2 100644
--- a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/ExecutionStateRepository.java
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/ExecutionStateRepository.java
@@ -1,18 +1,29 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.repositories;
import io.cloudslang.score.facade.execution.ExecutionStatus;
import io.cloudslang.orchestrator.entities.ExecutionState;
+import java.util.Collection;
+import java.util.Set;
+
+import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
@@ -32,4 +43,18 @@ public interface ExecutionStateRepository extends JpaRepository findExecutionIdByStatuses(@Param("statuses") List statuses);
+
+ @Query("select executionState.executionId from ExecutionState executionState where executionState.status = :status and branchId = :branchId")
+ public List findByBranchIdAndStatusIn(@Param("branchId") String branchId, @Param("status") ExecutionStatus status);
+
+ @Query("delete from ExecutionState se where se.executionId in :ids")
+ @Modifying
+ int deleteByIds(@Param("ids") Collection ids);
+
+ @Query("select executionState.executionId from ExecutionState executionState where executionState.status in :statuses and executionState.updateTime <= :time")
+ List findByStatusInAndUpdateTimeLessThanEqual(@Param("statuses")List statuses, @Param("time")long time, Pageable pageable);
+
+
+ @Query("delete from ExecutionState executionState where executionState.status in :statuses")
+ void deleteByStatusIn(@Param("statuses") List statuses);
}
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/FinishedBranchRepository.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/FinishedBranchRepository.java
index 87d528b688..c9b43e9a82 100644
--- a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/FinishedBranchRepository.java
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/FinishedBranchRepository.java
@@ -1,17 +1,29 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.repositories;
import io.cloudslang.orchestrator.entities.FinishedBranch;
+
+import java.util.Collection;
+
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
/**
* Created with IntelliJ IDEA.
@@ -20,4 +32,8 @@
* Time: 14:16
*/
public interface FinishedBranchRepository extends JpaRepository {
+
+ @Query("delete from FinishedBranch fe where fe.id in :ids")
+ @Modifying
+ void deleteByIds(@Param("ids") Collection ids);
}
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/RunningExecutionPlanRepository.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/RunningExecutionPlanRepository.java
index 03ed0cb141..01d33e2809 100644
--- a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/RunningExecutionPlanRepository.java
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/RunningExecutionPlanRepository.java
@@ -1,25 +1,36 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.repositories;
import io.cloudslang.score.facade.entities.RunningExecutionPlan;
+
+import java.util.Collection;
+import java.util.List;
+
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.data.repository.query.Param;
-import javax.persistence.QueryHint;
+import jakarta.persistence.QueryHint;
import java.lang.Long;
import java.lang.String;
-import java.util.List;
+
/**
* Created by IntelliJ IDEA.
@@ -27,18 +38,23 @@
* Date: 11/24/11
* Time: 9:41 AM
*/
-public interface RunningExecutionPlanRepository extends JpaRepository {
+public interface RunningExecutionPlanRepository extends JpaRepository {
//We are not using the default name findByUuid() because then we won't be able to use the query cache
//enhancement request should be opened to spring JPA
@Query("from RunningExecutionPlan r where r.flowUUID = :flowUUID")
- @QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value ="true") })
+ @QueryHints({@QueryHint(name = "org.hibernate.cacheable", value = "true")})
public List findByUuidCached(@Param("flowUUID") String flowUUID);
- @Query("select distinct r from RunningExecutionPlan r where r.id = :exeId and r.flowUUID = :flowId")
- RunningExecutionPlan getExecution(@Param("flowId") String flowId, @Param("exeId") Long exeId);
+ @Query("select distinct r from RunningExecutionPlan r where r.id = :exeId and r.flowUUID = :flowId")
+ RunningExecutionPlan getExecution(@Param("flowId") String flowId, @Param("exeId") Long exeId);
+
+
+ @Query("select executionPlanZipped from RunningExecutionPlan r where r.id = :exeId")
+ byte[] getZippedExecutionPlan(@Param("exeId") Long exeId);
+ @Modifying
+ @Query("delete from RunningExecutionPlan r where r.executionId in :ids")
+ int deleteByExecutionIds(@Param("ids") Collection ids);
- @Query("select executionPlanZipped from RunningExecutionPlan r where r.id = :exeId")
- byte[] getZippedExecutionPlan(@Param("exeId") Long exeId);
}
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionRepositoryCustom.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionRepositoryCustom.java
new file mode 100644
index 0000000000..a07359abea
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionRepositoryCustom.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.orchestrator.repositories;
+
+import io.cloudslang.orchestrator.entities.SuspendedExecution;
+
+import java.util.Collection;
+import java.util.List;
+
+public interface SuspendedExecutionRepositoryCustom {
+
+ List findBySplitIdIn(List splitIds);
+
+ int deleteByIds(Collection ids);
+}
\ No newline at end of file
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionRepositoryCustomImpl.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionRepositoryCustomImpl.java
new file mode 100644
index 0000000000..f6377aee6e
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionRepositoryCustomImpl.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.orchestrator.repositories;
+
+import io.cloudslang.orchestrator.entities.SuspendedExecution;
+
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.PersistenceContext;
+import jakarta.persistence.Query;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@SuppressWarnings("UnusedDeclaration")
+public class SuspendedExecutionRepositoryCustomImpl implements SuspendedExecutionRepositoryCustom {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Override
+ public List findBySplitIdIn(List splitIds) {
+ Query query = entityManager.createQuery("select se from SuspendedExecution se where " +
+ "se.splitId in (" + getIdsAsString(splitIds) + ")");
+ return query.getResultList();
+ }
+
+ @Override
+ public int deleteByIds(Collection ids) {
+ Query query = entityManager.createQuery("delete from SuspendedExecution se where " +
+ "se.executionId in (" + getIdsAsString(new ArrayList<>(ids)) + ")");
+ return query.executeUpdate();
+ }
+
+ private String getIdsAsString(List ids) {
+ return ids.stream().map((executionStatus) -> "cast('" + executionStatus + "' as string)").collect(Collectors.joining(","));
+ }
+}
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionsRepository.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionsRepository.java
index d6a58d6f34..92e018437c 100644
--- a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionsRepository.java
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/repositories/SuspendedExecutionsRepository.java
@@ -1,20 +1,31 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.repositories;
+import io.cloudslang.orchestrator.entities.ExecutionObjEntity;
import io.cloudslang.orchestrator.entities.SuspendedExecution;
+import io.cloudslang.orchestrator.enums.SuspendedExecutionReason;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
+import java.util.EnumSet;
import java.util.List;
/**
@@ -23,9 +34,23 @@
* Date: 10/09/13
* Time: 10:01
*/
-public interface SuspendedExecutionsRepository extends JpaRepository {
- public List findBySplitIdIn(List splitIds);
+public interface SuspendedExecutionsRepository extends JpaRepository, SuspendedExecutionRepositoryCustom {
+
+ @Query("from SuspendedExecution se where se.numberOfBranches=size(se.finishedBranches) and se.suspensionReason in :suspensionReasons")
+ List findFinishedSuspendedExecutions(
+ @Param("suspensionReasons") EnumSet suspensionReasons,
+ Pageable pageRequest);
+
+ @Query("from SuspendedExecution se where size(se.finishedBranches) > 0 and se.suspensionReason in :suspensionReasons and se.locked = false")
+ List findUnmergedSuspendedExecutions(
+ @Param("suspensionReasons") EnumSet suspensionReasons,
+ Pageable pageRequest);
+
+ @Query("from SuspendedExecution se where se.splitId = cast(:splitId as string)")
+ SuspendedExecution findBySplitId(@Param("splitId") String splitId);
- @Query("from SuspendedExecution se where se.numberOfBranches=size(se.finishedBranches)")
- public List findFinishedSuspendedExecutions(Pageable pageRequest);
+ @Modifying
+ @Query("update SuspendedExecution se set se.executionObj = :newExecution, se.locked = false where se.id = :suspendedExecutionId")
+ void updateSuspendedExecutionContexts(@Param("suspendedExecutionId") long suspendedExecutionId,
+ @Param("newExecution") ExecutionObjEntity newExecution);
}
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/CancelExecutionServiceImpl.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/CancelExecutionServiceImpl.java
index 4e794ec470..fb2f535bf1 100644
--- a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/CancelExecutionServiceImpl.java
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/CancelExecutionServiceImpl.java
@@ -1,16 +1,23 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
-import org.apache.log4j.Logger;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import io.cloudslang.engine.queue.entities.ExecStatus;
import io.cloudslang.engine.queue.entities.ExecutionMessageConverter;
import io.cloudslang.engine.queue.services.QueueDispatcherService;
@@ -21,6 +28,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -34,7 +42,7 @@
*/
public final class CancelExecutionServiceImpl implements CancelExecutionService {
- private final Logger logger = Logger.getLogger(getClass());
+ private final Logger logger = LogManager.getLogger(getClass());
@Autowired
private ExecutionSerializationUtil executionSerializationUtil;
@@ -75,7 +83,7 @@ public ExecutionActionResult requestCancelExecution(Long executionId) {
// it's possible to cancel only running or paused executions.
// If it's running - set to pending-cancel, and the ExecutionServiceImpl will handle it and extract it from the queue.
// If it's paused - sometimes needs to handle its branches (if such exists).
- if (status.equals(ExecutionStatus.RUNNING)) {
+ if (status.equals(ExecutionStatus.RUNNING) || status.equals(ExecutionStatus.PENDING_PAUSE)) {
executionStateToCancel.setStatus(ExecutionStatus.PENDING_CANCEL);
} else if (status.equals(ExecutionStatus.PAUSED)) {
cancelPausedRun(executionStateToCancel);
@@ -97,12 +105,19 @@ private void cancelPausedRun(ExecutionState executionStateToCancel) {
// If the parent is paused because one of the branches is paused, OR, it was paused by the user / no-workers-in-group, but has branches that were not finished (and thus, were paused) -
// The parent itself will return to the queue after all the branches are ended (due to this cancellation), and then it'll be canceled as well.
if (branches.size() > 1) { // more than 1 means that it has paused branches (branches is at least 1 - the parent)
+ executionStateToCancel.setStatus(ExecutionStatus.PENDING_CANCEL);
for (ExecutionState branch : branches) {
- if (!EMPTY_BRANCH.equals(branch.getBranchId())) { // exclude the base execution
+ if (branch.getExecutionObject() != null) { // exclude the branches with no execution object
returnCanceledRunToQueue(branch);
+ if (!EMPTY_BRANCH.equals(branch.getBranchId())) {
+ executionStateService.deleteExecutionState(branch.getExecutionId(), branch.getBranchId());
+ } else {
+ executionStateToCancel.setStatus(ExecutionStatus.CANCELED);
+ }
+ } else {
+ executionStateToCancel.setStatus(ExecutionStatus.CANCELED);
}
}
- executionStateToCancel.setStatus(ExecutionStatus.PENDING_CANCEL); // when the parent will return to queue - should have the correct status
} else {
returnCanceledRunToQueue(executionStateToCancel);
}
@@ -142,10 +157,7 @@ public boolean isCanceledExecution(Long executionId) {
@Transactional(readOnly = true)
public List readCanceledExecutionsIds() {
List result = executionStateService.readExecutionIdByStatuses(getCancelStatuses());
- if (result == null) {
- result = Arrays.asList();
- }
- return result;
+ return (result != null) ? result : new ArrayList<>(0);
}
private List getCancelStatuses() {
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/EngineVersionServiceImpl.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/EngineVersionServiceImpl.java
new file mode 100644
index 0000000000..46c5a4e6aa
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/EngineVersionServiceImpl.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+
+package io.cloudslang.orchestrator.services;
+
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Created by kravtsov on 03/01/2016
+ */
+
+public class EngineVersionServiceImpl implements EngineVersionService {
+ @Override
+ @Transactional
+ public String getEngineVersionId() {
+ return "";
+ }
+}
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionCleanerServiceImpl.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionCleanerServiceImpl.java
new file mode 100644
index 0000000000..086b446e1a
--- /dev/null
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionCleanerServiceImpl.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
+package io.cloudslang.orchestrator.services;
+
+import com.google.common.collect.Lists;
+import io.cloudslang.engine.queue.entities.ExecutionStatesData;
+import io.cloudslang.engine.queue.services.cleaner.QueueCleanerService;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import static io.cloudslang.score.facade.execution.ExecutionStatus.*;
+
+public class ExecutionCleanerServiceImpl implements ExecutionCleanerService {
+
+ private static final Logger logger = LogManager.getLogger(ExecutionCleanerServiceImpl.class);
+
+ private static final int MAX_BULK_SIZE = Integer.getInteger("execution.state.clean.job.bulk.size", 200);
+ private static final int SPLIT_SIZE = 50;
+
+ private static final long EXECUTION_STATE_INACTIVE_TIME_FINISHED = Duration.ofHours(3).toMillis();
+ private static final long EXECUTION_STATE_INACTIVE_TIME_CANCELED = Duration.ofHours(24).toMillis();
+ private static final long ORPHAN_EXECUTION_QUEUES_INACTIVE_TIME = Duration.ofHours(72).toMillis();
+
+
+ @Autowired
+ private ExecutionStateService executionStateService;
+
+ @Autowired
+ private QueueCleanerService queueCleanerService;
+
+ @Override
+ public void cleanExecutions() {
+ try {
+ performExecutionCleanup();
+ } catch (Exception exception) {
+ logger.error("Execution cleanup job failed: ", exception);
+ }
+ }
+
+ private void performExecutionCleanup() {
+ // Safely delete execution queues and state mappings for non-latest or unused states
+ // from oo_execution_states and oo_execution_queues
+ deleteUnusedExecutionStatesAndQueues();
+
+ // Remove all finished executions and related data (CANCELED, COMPLETED, SYSTEM_FAILURE)
+ // from oo_execution_queues, oo_execs_states_execs_mappings, oo_execution_states and oo_execution_state
+ deleteFinishedExecutionData();
+
+ // Clean up orphaned queue entries left from parallel or multi-instance execution from oo_execution_queues
+ deleteOrphanExecutionQueues();
+ }
+
+ private void deleteUnusedExecutionStatesAndQueues() {
+ try {
+ Set ids = queueCleanerService.getNonLatestFinishedExecStateIds();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Detected {} unused entries to clean from oo_execution_states and oo_execution_queues",
+ ids.size());
+ }
+
+ List latestExecutionStateData = queueCleanerService.getLatestExecutionStates();
+ if (logger.isDebugEnabled()) {
+ String execStates = latestExecutionStateData.stream()
+ .map(ExecutionStatesData::toString)
+ .collect(Collectors.joining(", "));
+ logger.debug("Latest execution states before unused execution cleaning job: {}", execStates);
+ }
+
+ List idList = new ArrayList<>(ids);
+ List> partitions = Lists.partition(idList, SPLIT_SIZE);
+
+ for (List partition : partitions) {
+ queueCleanerService.cleanUnusedSteps(new HashSet<>(partition));
+ }
+ } catch (Exception exception) {
+ logger.error("Unused executions cleanup job failed: ", exception);
+ }
+ }
+
+ private void deleteFinishedExecutionData() {
+ try {
+ long timeLimitMillisFinished = System.currentTimeMillis() - EXECUTION_STATE_INACTIVE_TIME_FINISHED;
+ long timeLimitMillisCanceled = System.currentTimeMillis() - EXECUTION_STATE_INACTIVE_TIME_CANCELED;
+
+ for (int i = 0; i <= MAX_BULK_SIZE / SPLIT_SIZE; i++) {
+ PageRequest pageRequest = PageRequest.of(0, SPLIT_SIZE);
+
+ List finishedStateIds = executionStateService
+ .findExecutionStateByStatusInAndUpdateTimeLessThanEqual(
+ Arrays.asList(COMPLETED, SYSTEM_FAILURE),
+ timeLimitMillisFinished,
+ pageRequest
+ );
+
+ List canceledStateIds = executionStateService
+ .findExecutionStateByStatusInAndUpdateTimeLessThanEqual(
+ Collections.singletonList(CANCELED),
+ timeLimitMillisCanceled,
+ pageRequest
+ );
+
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Detected {} completed entries and {} canceled entries to clean " +
+ "from oo_execution_queues, oo_execs_states_execs_mappings, oo_execution_states and oo_execution_state ",
+ finishedStateIds.size(), canceledStateIds.size());
+ }
+
+ if (finishedStateIds.size() + canceledStateIds.size() != 0) {
+ List allFinishedAndCanceledIds = new ArrayList<>(finishedStateIds.size() + canceledStateIds.size());
+ allFinishedAndCanceledIds.addAll(finishedStateIds);
+ allFinishedAndCanceledIds.addAll(canceledStateIds);
+ Set finishedAndCanceledStatesQueuesIds = queueCleanerService
+ .getExecutionStatesByFinishedMessageId(new HashSet<>(allFinishedAndCanceledIds));
+
+ queueCleanerService.cleanFinishedSteps(finishedAndCanceledStatesQueuesIds);
+ executionStateService.deleteExecutionStateByIds(allFinishedAndCanceledIds);
+ }
+ }
+ } catch (Exception exception) {
+ logger.error("Finished execution cleanup job failed: ", exception);
+ }
+ }
+
+ private void deleteOrphanExecutionQueues() {
+ try {
+ long timeLimitMillisOrphanExecutionQueues = System.currentTimeMillis() - ORPHAN_EXECUTION_QUEUES_INACTIVE_TIME;
+ Set orphanExecutionQueuesIds = queueCleanerService
+ .getOrphanQueues(timeLimitMillisOrphanExecutionQueues);
+ if (logger.isDebugEnabled()) {
+ String orphanIds = orphanExecutionQueuesIds.stream()
+ .map(String::valueOf)
+ .collect(Collectors.joining(", "));
+ logger.debug("Detected {} orphan execution queue entries to clean: {}",
+ orphanExecutionQueuesIds.size(), orphanIds);
+
+ }
+
+ queueCleanerService.cleanOrphanQueues(orphanExecutionQueuesIds);
+ } catch (Exception exception) {
+ logger.error("Orphan execution queues cleanup job failed: ", exception);
+ }
+ }
+}
\ No newline at end of file
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionSerializationUtil.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionSerializationUtil.java
index 7669152411..d9b4b9a223 100644
--- a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionSerializationUtil.java
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionSerializationUtil.java
@@ -1,12 +1,18 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
diff --git a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionStateServiceImpl.java b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionStateServiceImpl.java
index ba717cbb87..8bec1e6d58 100644
--- a/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionStateServiceImpl.java
+++ b/engine/orchestrator/score-orchestrator-impl/src/main/java/io/cloudslang/orchestrator/services/ExecutionStateServiceImpl.java
@@ -1,28 +1,42 @@
-/*******************************************************************************
-* (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Apache License v2.0 which accompany this distribution.
-*
-* The Apache License is available at
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-*******************************************************************************/
+/*
+ * Copyright © 2014-2017 EntIT Software LLC, a Micro Focus company (L.P.)
+ *
+ * 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.
+ */
package io.cloudslang.orchestrator.services;
+import io.cloudslang.orchestrator.entities.ExecutionState;
+import io.cloudslang.orchestrator.repositories.ExecutionStateRepository;
+import io.cloudslang.score.facade.entities.Execution;
import io.cloudslang.score.facade.execution.ExecutionActionException;
import io.cloudslang.score.facade.execution.ExecutionActionResult;
import io.cloudslang.score.facade.execution.ExecutionStatus;
-import io.cloudslang.score.facade.entities.Execution;
-import io.cloudslang.orchestrator.entities.ExecutionState;
-import io.cloudslang.orchestrator.repositories.ExecutionStateRepository;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
+import java.util.Date;
import java.util.List;
+import java.util.Optional;
+
+import static io.cloudslang.orchestrator.entities.ExecutionState.EMPTY_BRANCH;
+import static io.cloudslang.score.facade.execution.ExecutionStatus.CANCELED;
+import static io.cloudslang.score.facade.execution.ExecutionStatus.PENDING_CANCEL;
+import static org.springframework.util.CollectionUtils.isEmpty;
/**
* User:
@@ -61,7 +75,7 @@ public List readExecutionIdByStatuses(List statuses) {
@Transactional(readOnly = true)
public ExecutionState readCancelledExecution(Long executionId) {
validateExecutionId(executionId);
- return executionStateRepository.findByExecutionIdAndBranchIdAndStatusIn(executionId, ExecutionState.EMPTY_BRANCH, getCancelStatuses());
+ return executionStateRepository.findByExecutionIdAndBranchIdAndStatusIn(executionId, EMPTY_BRANCH, getCancelStatuses());
}
@Override
@@ -70,8 +84,9 @@ public ExecutionState createParentExecution(Long executionId) {
validateExecutionId(executionId);
ExecutionState executionState = new ExecutionState();
executionState.setExecutionId(executionId);
- executionState.setBranchId(ExecutionState.EMPTY_BRANCH);
+ executionState.setBranchId(EMPTY_BRANCH);
executionState.setStatus(ExecutionStatus.RUNNING);
+ executionState.setUpdateTime(new Date().getTime());
return executionStateRepository.save(executionState);
}
@@ -84,9 +99,25 @@ public ExecutionState createExecutionState(Long executionId, String branchId) {
executionState.setExecutionId(executionId);
executionState.setBranchId(branchId);
executionState.setStatus(ExecutionStatus.PENDING_PAUSE);
+ executionState.setUpdateTime(new Date().getTime());
return executionStateRepository.save(executionState);
}
+ @Override
+ @Transactional
+ public void updateExecutionStateStatus(Long executionId, String branchId, ExecutionStatus status,
+ Date updateDate) {
+ validateExecutionId(executionId);
+ Validate.notNull(status, "status cannot be null");
+ validateBranchId(branchId);
+ Optional executionState = findByExecutionIdAndBranchIdNoException(executionId, branchId);
+ if (executionState.isPresent()) {
+ ExecutionState executionState1 = executionState.get();
+ executionState1.setStatus(status);
+ executionState1.setUpdateTime(updateDate.getTime());
+ }
+ }
+
@Override
@Transactional(readOnly = true)
public Execution readExecutionObject(Long executionId, String branchId) {
@@ -102,21 +133,12 @@ public Execution readExecutionObject(Long executionId, String branchId) {
@Override
@Transactional
- public void updateExecutionObject(Long executionId, String branchId, Execution execution) {
+ public void updateExecutionObject(Long executionId, String branchId, Execution execution, Date updateDate) {
validateExecutionId(executionId);
validateBranchId(branchId);
ExecutionState executionState = findByExecutionIdAndBranchId(executionId, branchId);
executionState.setExecutionObject(executionSerializationUtil.objToBytes(execution));
- }
-
- @Override
- @Transactional
- public void updateExecutionStateStatus(Long executionId, String branchId, ExecutionStatus status) {
- validateExecutionId(executionId);
- validateBranchId(branchId);
- Validate.notNull(status, "status cannot be null");
- ExecutionState executionState = findByExecutionIdAndBranchId(executionId, branchId);
- executionState.setStatus(status);
+ executionState.setUpdateTime(updateDate.getTime());
}
private ExecutionState findByExecutionIdAndBranchId(Long executionId, String branchId) {
@@ -127,8 +149,16 @@ private ExecutionState findByExecutionIdAndBranchId(Long executionId, String bra
return executionState;
}
+ private Optional findByExecutionIdAndBranchIdNoException(Long executionId, String branchId) {
+ ExecutionState executionState = executionStateRepository.findByExecutionIdAndBranchId(executionId, branchId);
+ if (executionState == null) {
+ return Optional.empty();
+ }
+ return Optional.of(executionState);
+ }
+
private List