aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/GetBucketStateMessage.java
blob: fa4e80ddc050a09d7989d2aff7f9c733b666f634 (plain) (blame)
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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.messagebus.protocol;

import com.yahoo.document.BucketId;

/**
 * This message is a request to return the state of a given bucket. The corresponding reply is {@link
 * GetBucketStateReply}.
 *
 * @author Simon Thoresen Hult
 */
public class GetBucketStateMessage extends DocumentMessage {

    private BucketId bucket = null;

    /**
     * Constructs a new message for deserialization.
     */
    GetBucketStateMessage() {
        // empty
    }

    /**
     * Constructs a new reply with initial content.
     *
     * @param bucket The bucket whose state to reply with.
     */
    public GetBucketStateMessage(BucketId bucket) {
        this.bucket = bucket;
    }

    /**
     * Returns the bucket whose state this contains.
     *
     * @return The bucket id.
     */
    public BucketId getBucketId() {
        return bucket;
    }

    /**
     * Sets the bucket whose state this contains.
     *
     * @param bucket The bucket id to set.
     */
    public void setBucketId(BucketId bucket) {
        this.bucket = bucket;
    }

    @Override
    public DocumentReply createReply() {
        return new GetBucketStateReply();
    }

    @Override
    public long getSequenceId() {
        return bucket.getRawId();
    }

    @Override
    public int getApproxSize() {
        return super.getApproxSize() + 8;
    }

    @Override
    public int getType() {
        return DocumentProtocol.MESSAGE_GETBUCKETSTATE;
    }
}