blob: 319cc64a99247b78a51e6fdc20ee35f472280b19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*-
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* 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.
* ============LICENSE_END=========================================================
*/
package org.onap.policy.controlloop.eventmanager;
import java.io.Serializable;
import java.util.concurrent.CompletableFuture;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
/**
* Context used by steps to perform their work.
*/
public interface StepContext {
/**
* Determines if the context contains a property.
*
* @param name name of the property of interest
* @return {@code true} if the context contains the property, {@code false} otherwise
*/
public boolean contains(String name);
/**
* Gets a property, casting it to the desired type.
*
* @param <T> desired type
* @param name name of the property whose value is to be retrieved
* @return the property's value, or {@code null} if it does not yet have a value
*/
public <T> T getProperty(String name);
/**
* Sets a property's value.
*
* @param name property name
* @param value new property value
*/
public void setProperty(String name, Serializable value);
/**
* Removes a property.
*
* @param name property name
*/
public void removeProperty(String name);
/**
* Requests a lock. This requests the lock for the time that remains before the
* timeout expires. This avoids having to extend the lock.
*
* @param targetEntity entity to be locked
* @return a future that can be used to await the lock
*/
public CompletableFuture<OperationOutcome> requestLock(String targetEntity);
/**
* Releases a lock.
* <p/>
* Note: once this has been invoked, whether or not the "release" operation succeeds,
* subsequent calls to {@link #requestLock(String)} for the same target entity may
* always fail, and subsequent calls to {@link #releaseLock(String)} may always
* succeed, depending on the implementation.
*
* @param targetEntity entity to be locked
* @return a future that can be used to await the release operation
*/
public CompletableFuture<OperationOutcome> releaseLock(String targetEntity);
}
|