@Override public ServerSession getServerSession() { isTrue("open", !closed); return serverSession; }
@Override public TransactionOptions getTransactionOptions() { isTrue("in transaction", transactionState == TransactionState.IN || transactionState == TransactionState.COMMITTED); return transactionOptions; }
/** * Sets the limit to apply. * * @param limit the limit * @return this * @mongodb.driver.manual reference/method/cursor.limit/#cursor.limit Limit */ public DBCollectionCountOptions limit(final long limit) { isTrue("limit is too large", limit <= Integer.MAX_VALUE); this.limit = (int) limit; return this; }
/** * Gets the w value as an integer. * * @return w as an int * @throws IllegalStateException if w is null or not an integer */ public int getW() { isTrue("w is an Integer", w != null && w instanceof Integer); return (Integer) w; }
/** * Gets the w parameter as a String. * * @return w as a String * @throws IllegalStateException if w is null or not a String */ public String getWString() { isTrue("w is a String", w != null && w instanceof String); return (String) w; }
@Override public void setBatchSize(final int batchSize) { isTrue("open", !isClosed.get()); this.batchSize = batchSize; }
@Override public int getBatchSize() { isTrue("open", !isClosed.get()); return batchSize; }
/** * Constructs a new instance with the given version list of integers. * * @param versionList a non-null, three-item list of integers */ public ServerVersion(final List<Integer> versionList) { notNull("versionList", versionList); isTrue("version array has three elements", versionList.size() == 3); this.versionList = Collections.unmodifiableList(new ArrayList<Integer>(versionList)); }
@Override public void advanceClusterTime(final BsonDocument newClusterTime) { isTrue("open", !closed); this.clusterTime = greaterOf(newClusterTime); }
@Override public <T> T sendAndReceive(final CommandMessage message, final Decoder<T> decoder, final SessionContext sessionContext) { isTrue("open", !isClosed.get()); try { return wrapped.sendAndReceive(message, decoder, sessionContext); } catch (MongoException e) { incrementGenerationOnSocketException(this, e); throw e; } }
/** * Construct an instance with the given list of cluster listeners * * @param clusterListeners the non-null list of cluster listeners, none of which may be null */ public ClusterEventMulticaster(final List<ClusterListener> clusterListeners) { notNull("clusterListeners", clusterListeners); isTrue("All ClusterListener instances are non-null", !clusterListeners.contains(null)); this.clusterListeners = new ArrayList<ClusterListener>(clusterListeners); }
@Override public ServerDescription getDescription() { isTrue("open", !isClosed()); return description; }
/** * Construct an instance with the given list of server listeners * * @param serverListeners the non-null list of server listeners, none of which may be null */ public ServerEventMulticaster(final List<ServerListener> serverListeners) { notNull("serverListeners", serverListeners); isTrue("All ServerListener instances are non-null", !serverListeners.contains(null)); this.serverListeners = new ArrayList<ServerListener>(serverListeners); }
@Override public ResponseBuffers receiveMessage(final int responseTo) { isTrue("open", !isClosed.get()); try { return wrapped.receiveMessage(responseTo); } catch (MongoException e) { incrementGenerationOnSocketException(this, e); throw e; } }
@Override protected ClusterableServer getServer(final ServerAddress serverAddress) { isTrue("is open", !isClosed()); ServerTuple serverTuple = addressToServerTupleMap.get(serverAddress); if (serverTuple == null) { return null; } return serverTuple.server; }
/** * @return a new SplittablePayload containing only the values after the current position. */ public SplittablePayload getNextSplit() { isTrue("hasAnotherSplit", hasAnotherSplit()); List<BsonDocument> nextPayLoad = payload.subList(position, payload.size()); return new SplittablePayload(payloadType, nextPayLoad); }
/** * Start building a write request to add to the bulk write operation. The returned builder can be used to create an update, replace, * or remove request with the given query. * * @param query the query for an update, replace or remove request * @return a builder for a single write request */ public BulkWriteRequestBuilder find(final DBObject query) { isTrue("already executed", !closed); return new BulkWriteRequestBuilder(this, query, collection.getDefaultDBObjectCodec(), collection.getObjectCodec()); }
public ServerSession get() { isTrue("server session pool is open", !closed); ServerSessionImpl serverSession = serverSessionPool.get(); while (shouldPrune(serverSession)) { serverSessionPool.release(serverSession, true); serverSession = serverSessionPool.get(); } return serverSession; }
AbstractMultiServerCluster(final ClusterId clusterId, final ClusterSettings settings, final ClusterableServerFactory serverFactory) { super(clusterId, settings, serverFactory); isTrue("connection mode is multiple", settings.getMode() == ClusterConnectionMode.MULTIPLE); clusterType = settings.getRequiredClusterType(); replicaSetName = settings.getRequiredReplicaSetName(); if (LOGGER.isInfoEnabled()) { LOGGER.info(format("Cluster created with settings %s", settings.getShortDescription())); } }
@Override public Void execute(final WriteBinding binding) { isTrue("in transaction", binding.getSessionContext().hasActiveTransaction()); return executeRetryableCommand(binding, "admin", null, new NoOpFieldNameValidator(), new BsonDocumentCodec(), getCommandCreator(), writeConcernErrorTransformer()); }