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