summaryrefslogtreecommitdiffstats
path: root/feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/BucketWrapper.java
blob: 2628513cfe0064ddcf43bd8452b2aae704f7ac5d (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
 * ============LICENSE_START=======================================================
 * feature-server-pool
 * ================================================================================
 * Copyright (C) 2020 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.drools.serverpooltest;

import java.io.PrintStream;

/**
 * This class provides base classes for accessing the various 'Bucket'
 * classes. There is a separate copy of the 'Bucket' class for each
 * adapter, and this wrapper was created to give them a common interface.
 */
public interface BucketWrapper {
    /**
     * This calls the 'Bucket.getBucketNumber()' method
     *
     * @return the bucket number
     */
    public int getBucketNumber();

    /**
     * This calls the 'Bucket.getOwner()' method
     *
     * @return a 'ServerWrapper' instance that corresponds to the owner
     *     of the bucket ('null' if unassigned)
     */
    public ServerWrapper getOwner();

    /**
     * This calls the 'Bucket.getPrimaryBackup()' method
     *
     * @return a 'ServerWrapper' instance that corresponds to the primary backup
     *     host for the bucket ('null' if unassigned)
     */
    public ServerWrapper getPrimaryBackup();

    /**
     * This calls the 'Bucket.getPrimaryBackup()' method
     *
     * @return a 'ServerWrapper' instance that corresponds to the secondary
     *     backup host for the bucket ('null' if unassigned)
     */
    public ServerWrapper getSecondaryBackup();

    /* ============================================================ */

    /**
     * This class provides access to the static 'Bucket' methods. There are
     * multiple 'Bucket' classes (one for each 'Adapter'), and each has
     * a corresponding 'BucketWrapper.Static' instance. In other words, there
     * is one 'Bucket.Static' instance for each simulated host.
     */
    public interface Static {
        /**
         * This returns the value of 'Bucket.BUCKETCOUNT'
         *
         * @return the number of Bucket instances in the bucket table
         */
        public int getBucketCount();

        /**
         * This calls the static 'Bucket.bucketNumber(String)' method
         *
         * @param value the keyword to be converted
         * @return the bucket number
         */
        public int bucketNumber(String value);

        /**
         * This calls the static 'Bucket.bucketToServer(int)' method
         *
         * @param bucketNumber a bucket number in the range 0-1023
         * @return a 'ServerWrapper' for the server that currently handles the
         *     bucket, or 'null' if none is currently assigned
         */
        public ServerWrapper bucketToServer(int bucketNumber);

        /**
         * This calls the static 'Bucket.getBucket(int)' method
         *
         * @param bucketNumber a bucket number in the range 0-1023
         * @return A 'BucketWrapper' for the Bucket associated with
         *     this bucket number
         */
        public BucketWrapper getBucket(int bucketNumber);

        /**
         * This calls the static 'Bucket.isKeyOnThisServer(String)' method
         *
         * @param key the keyword to be hashed
         * @return 'true' if the associated bucket is assigned to this server,
         *     'false' if not
         */
        public boolean isKeyOnThisServer(String key);

        /**
         * This calls the static 'Bucket.moveBucket(PrintStream, int, String)'
         * method (the one associated with the '/cmd/moveBucket' REST call).
         *
         * @param out the 'PrintStream' to use for displaying information
         * @param bucketNumber the bucket number to be moved
         * @param newHostUuid the UUID of the destination host (if 'null', a
         *     destination host will be chosen at random)
         */
        public void moveBucket(PrintStream out, int bucketNumber, String newHostUuid);

        /**
         * This calls the static 'Bucket.dumpAdjuncts(PrintStream)' method
         * (the one associated with the '/cmd/dumpBucketAdjuncts' REST call).
         *
         * @param out the 'PrintStream' to use for displaying information
         */
        public void dumpAdjuncts(PrintStream out);
    }
}