1 /*
2 * #%L
3 * ConnectionModel.java - mongodb-async-driver - Allanbank Consulting, Inc.
4 * %%
5 * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc.
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 * #L%
19 */
20 package com.allanbank.mongodb;
21
22 /**
23 * ConnectionModel provides an enumeration of the connection models that the
24 * driver supports. Currently this is related to the number of threads used by
25 * the socket connections to the server.
26 *
27 * @api.yes This interface is part of the driver's API. Public and protected
28 * members will be deprecated for at least 1 non-bugfix release
29 * (version numbers are <major>.<minor>.<bugfix>)
30 * before being removed or modified.
31 * @copyright 2012-2013, Allanbank Consulting, Inc., All Rights Reserved
32 */
33 public enum ConnectionModel {
34
35 /**
36 * Each sender thread writes the message to the socket connection directly.
37 * A single receive thread is used per connection to receive the replies.
38 * While a sender writes each message to the socket the driver still has the
39 * ability to batch multiple send requests in a packet but batching is
40 * limited to concurrent senders. A single threaded application will not
41 * batch requests.
42 * <p>
43 * This is the default {@code ConnectionModel}.
44 * </p>
45 * <p>
46 * In a multi-threaded application this {@code ConnectionModel} should
47 * perform as well as if not better than the {@link #SENDER_RECEIVER_THREAD}
48 * model. This is achieved by completely avoiding cross thread passing of
49 * the message on a send.
50 * </p>
51 */
52 RECEIVER_THREAD,
53
54 /**
55 * Each socket uses a pair of threads: sender and receiver.
56 * <p>
57 * This was the default {@code ConnectionModel} versions prior to 1.3.0.
58 * </p>
59 * <p>
60 * This {@code ConnectionModel} is most useful for connections where a
61 * single {@code write()} to the socket implementation is slow and the
62 * application only uses a single write thread.
63 * </p>
64 *
65 * @since 1.0.0
66 */
67 SENDER_RECEIVER_THREAD;
68 }