Drools support for kafka topics
[policy/drools-pdp.git] / feature-pooling-messages / src / main / java / org / onap / policy / drools / pooling / PoolingManager.java
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2024 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.drools.pooling;
23
24 import org.onap.policy.drools.pooling.message.BucketAssignments;
25 import org.onap.policy.drools.pooling.message.Message;
26 import org.onap.policy.drools.pooling.state.State;
27 import org.onap.policy.drools.pooling.state.StateTimerTask;
28
29 /**
30  * Pooling manager for a single PolicyController.
31  */
32 public interface PoolingManager {
33
34     /**
35      * Gets the properties used to configure the manager.
36      *
37      * @return pooling properties
38      */
39     PoolingProperties getProperties();
40
41     /**
42      * Gets the host id.
43      *
44      * @return the host id
45      */
46     String getHost();
47
48     /**
49      * Gets the name of the internal DMaaP topic used by this manager to communicate with
50      * its other hosts.
51      *
52      * @return the name of the internal DMaaP topic
53      */
54     String getTopic();
55
56     /**
57      * Starts distributing requests according to the given bucket assignments.
58      *
59      * @param assignments must <i>not</i> be {@code null}
60      */
61     void startDistributing(BucketAssignments assignments);
62
63     /**
64      * Gets the current bucket assignments.
65      *
66      * @return the current bucket assignments, or {@code null} if no assignments have been
67      *         made
68      */
69     BucketAssignments getAssignments();
70
71     /**
72      * Publishes a message to the internal topic on the administrative channel.
73      *
74      * @param msg message to be published
75      */
76     void publishAdmin(Message msg);
77
78     /**
79      * Publishes a message to the internal topic on a particular channel.
80      *
81      * @param channel channel on which the message should be published
82      * @param msg message to be published
83      */
84     void publish(String channel, Message msg);
85
86     /**
87      * Schedules a timer to fire after a delay.
88      *
89      * @param delayMs delay, in milliseconds
90      * @param task task
91      * @return a new scheduled task
92      */
93     CancellableScheduledTask schedule(long delayMs, StateTimerTask task);
94
95     /**
96      * Schedules a timer to fire repeatedly.
97      *
98      * @param initialDelayMs initial delay, in milliseconds
99      * @param delayMs delay, in milliseconds
100      * @param task task
101      * @return a new scheduled task
102      */
103     CancellableScheduledTask scheduleWithFixedDelay(long initialDelayMs, long delayMs, StateTimerTask task);
104
105     /**
106      * Transitions to the "start" state.
107      *
108      * @return the new state
109      */
110     State goStart();
111
112     /**
113      * Transitions to the "query" state.
114      *
115      * @return the new state
116      */
117     State goQuery();
118
119     /**
120      * Transitions to the "active" state.
121      *
122      * @return the new state
123      */
124     State goActive();
125
126     /**
127      * Transitions to the "inactive" state.
128      *
129      * @return the new state
130      */
131     State goInactive();
132
133 }