aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/main/java/com/yahoo/documentapi/AsyncSession.java
blob: 2e78a02391045802f4ebe8b7ec1ebe93b3d5952d (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
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
133
134
135
136
137
138
139
140
141
142
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi;

import com.yahoo.document.Document;
import com.yahoo.document.DocumentId;
import com.yahoo.document.DocumentUpdate;
import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol;

/**
 * <p>A session for asynchronous access to a document repository.
 * This class provides document repository writes and random access with high
 * throughput.</p>
 *
 * <p>All operations which are <i>accepted</i> by an async session will cause one or more
 * {@link Response responses} to be returned within the timeout limit. When an operation fails,
 * the response will contain the argument which was submitted to the operation.</p>
 *
 * @author bratseth
 */
public interface AsyncSession extends Session {

    /**
     * <p>Puts a document. This method returns immediately.</p>
     *
     * <p>If this result is a success, this
     * call will cause one or more {@link DocumentResponse} objects to appear within the timeout time of this session.
     * The response returned later will either be a success, or contain the document submitted here.
     * If it was not a success, this method has no further effects.</p>
     *
     * @param document the Document to put
     * @return the synchronous result of this operation
     */
    Result put(Document document);

    /**
     * <p>Puts a document. This method returns immediately.</p>
     *
     * <p>If this result is a success, this
     * call will cause one or more {@link DocumentResponse} objects to appear within the timeout time of this session.
     * The response returned later will either be a success, or contain the document submitted here.
     * If it was not a success, this method has no further effects.</p>
     *
     * @param document the Document to put
     * @return the synchronous result of this operation
     */
    Result put(Document document, DocumentProtocol.Priority priority);

    /**
     * <p>Gets a document. This method returns immediately.</p>
     *
     * <p>If this result is a success, this
     * call will cause one or more {@link DocumentResponse} objects to appear within the timeout time of this session.
     * The response returned later will contain the requested document if it is a success.
     * If it was not a success, this method has no further effects.</p>
     *
     * @param id the id of the document to get
     * @return the synchronous result of this operation
     * @throws UnsupportedOperationException if this access implementation does not support retrieving
     */
    Result get(DocumentId id);

    /**
     * <p>Gets a document. This method returns immediately.</p>
     *
     * <p>If this result is a success, this
     * call will cause one or more {@link DocumentResponse} objects to appear within the timeout time of this session.
     * The response returned later will contain the requested document if it is a success.
     * If it was not a success, this method has no further effects.</p>
     *
     * @param id the id of the document to get
     * @param priority The priority with which to perform this operation.
     * @return the synchronous result of this operation
     * @throws UnsupportedOperationException if this access implementation does not support retrieving
     */
    Result get(DocumentId id, boolean headersOnly, DocumentProtocol.Priority priority);

    /**
     * <p>Removes a document if it is present. This method returns immediately.</p>
     *
     * <p>If this result is a success, this
     * call will cause one or more {@link RemoveResponse} objects to appear within the timeout time of this session.
     * The response returned later will either be a success, or contain the document id submitted here.
     * If it was not a success, this method has no further effects.</p>
     *
     * @param id the id of the document to remove
     * @return the synchronous result of this operation
     * @throws UnsupportedOperationException if this access implementation does not support removal
     */
    Result remove(DocumentId id);

    /**
     * <p>Removes a document if it is present. This method returns immediately.</p>
     *
     * <p>If this result is a success, this
     * call will cause one or more {@link DocumentIdResponse} objects to apprear within the timeout time of this session.
     * The response returned later will either be a success, or contain the document id submitted here.
     * If it was not a success, this method has no further effects.</p>
     *
     * @param id the id of the document to remove
     * @param priority The priority with which to perform this operation.
     * @return the synchronous result of this operation
     * @throws UnsupportedOperationException if this access implementation does not support removal
     */
    Result remove(DocumentId id, DocumentProtocol.Priority priority);

    /**
     * <p>Updates a document. This method returns immediately.</p>
     *
     * <p>If this result is a success, this
     * call will cause one or more {@link DocumentUpdateResponse} within the timeout time of this session.
     * The returned response returned later will either be a success or contain the update submitted here.
     * If it was not a success, this method has no further effects.</p>
     *
     * @param update the updates to perform
     * @return the synchronous result of this operation
     * @throws UnsupportedOperationException if this access implementation does not support update
     */
    Result update(DocumentUpdate update);

    /**
     * <p>Updates a document. This method returns immediately.</p>
     *
     * <p>If this result is a success, this
     * call will cause one or more {@link DocumentUpdateResponse} within the timeout time of this session.
     * The returned response returned later will either be a success or contain the update submitted here.
     * If it was not a success, this method has no further effects.</p>
     *
     * @param update the updates to perform
     * @param priority The priority with which to perform this operation.
     * @return the synchronous result of this operation
     * @throws UnsupportedOperationException if this access implementation does not support update
     */
    Result update(DocumentUpdate update, DocumentProtocol.Priority priority);

    /**
     * Returns the current send window size of the session.
     *
     * @return Returns the window size.
     */
    double getCurrentWindowSize();

}