View Javadoc
1   /*
2    * #%L
3    * BatchedWriteMode.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  
21  package com.allanbank.mongodb.builder;
22  
23  import com.allanbank.mongodb.builder.write.WriteOperationType;
24  
25  /**
26   * BatchedWriteMode provides enumeration of the available modes for submitting
27   * the batched writes.
28   * 
29   * @api.yes This enumeration is part of the driver's API. Public and protected
30   *          members will be deprecated for at least 1 non-bugfix release
31   *          (version numbers are <major>.<minor>.<bugfix>)
32   *          before being removed or modified.
33   * @copyright 2014, Allanbank Consulting, Inc., All Rights Reserved
34   */
35  public enum BatchedWriteMode {
36      /**
37       * Indicates that the writes can be reordered to optimize the write
38       * performance. This included re-ordering writes within a
39       * {@link WriteOperationType} (e.g., move one insert before another to
40       * better pack messages to the server) and across types (e.g., move an
41       * insert before an update to group all like operations).
42       * <p>
43       * This mode should provide close to optimal performance.
44       * </p>
45       */
46      REORDERED,
47  
48      /**
49       * Indicates that the writes should be submitted to the server in the order
50       * they were added to the {@link BatchedWrite} but that all writes should be
51       * tried on the server even after a failure.
52       * <p>
53       * This mode will perform better than the {@link #SERIALIZE_AND_STOP} mode
54       * since the driver can submit multiple writes to the server at once.
55       * </p>
56       */
57      SERIALIZE_AND_CONTINUE,
58  
59      /**
60       * Indicates that the writes should be submitted to the server in the order
61       * they were added to the {@link BatchedWrite} and that the writes should
62       * stop on the first write failure.
63       * <p>
64       * This mode will perform slower than all of the other modes since the
65       * driver must wait for the results of one write before submitting the next.
66       * </p>
67       */
68      SERIALIZE_AND_STOP;
69  }