Java Code Examples for com.mongodb.WriteConcern#W3
The following examples show how to use
com.mongodb.WriteConcern#W3 .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultDataSourceCreater.java From tangyuan2 with GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") private WriteConcern getWriteConcern(String writeConcern) { if ("ACKNOWLEDGED".equalsIgnoreCase(writeConcern)) { return WriteConcern.ACKNOWLEDGED; } if ("W1".equalsIgnoreCase(writeConcern)) { return WriteConcern.W1; } if ("W2".equalsIgnoreCase(writeConcern)) { return WriteConcern.W2; } if ("W3".equalsIgnoreCase(writeConcern)) { return WriteConcern.W3; } if ("UNACKNOWLEDGED".equalsIgnoreCase(writeConcern)) { return WriteConcern.UNACKNOWLEDGED; } if ("FSYNCED".equalsIgnoreCase(writeConcern)) { return WriteConcern.FSYNCED; } if ("REPLICA_ACKNOWLEDGED".equalsIgnoreCase(writeConcern)) { return WriteConcern.REPLICA_ACKNOWLEDGED; } if ("NORMAL".equalsIgnoreCase(writeConcern)) { return WriteConcern.NORMAL; } if ("SAFE".equalsIgnoreCase(writeConcern)) { return WriteConcern.SAFE; } if ("MAJORITY".equalsIgnoreCase(writeConcern)) { return WriteConcern.MAJORITY; } if ("FSYNC_SAFE".equalsIgnoreCase(writeConcern)) { return WriteConcern.FSYNC_SAFE; } if ("JOURNAL_SAFE".equalsIgnoreCase(writeConcern)) { return WriteConcern.JOURNAL_SAFE; } if ("REPLICAS_SAFE".equalsIgnoreCase(writeConcern)) { return WriteConcern.REPLICAS_SAFE; } return WriteConcern.ACKNOWLEDGED; }
Example 2
Source File: MongoDBEntityStoreMixin.java From attic-polygene-java with Apache License 2.0 | 4 votes |
private void loadConfiguration() throws UnknownHostException { configuration.refresh(); MongoDBEntityStoreConfiguration config = configuration.get(); // Combine hostname, port and nodes configuration properties // If no configuration, use 127.0.0.1:27017 serverAddresses = new ArrayList<>(); int port = config.port().get() == null ? 27017 : config.port().get(); List<String> nodes = config.nodes().get(); if( nodes.isEmpty() ) { String hostname = config.hostname().get() == null ? "127.0.0.1" : config.hostname().get(); serverAddresses.add( new ServerAddress( hostname, port ) ); } else { if( config.hostname().get() != null && !config.hostname().get().isEmpty() ) { serverAddresses.add( new ServerAddress( config.hostname().get(), port ) ); } serverAddresses.addAll( nodes.stream() .map( this::parseNode ) .collect( toList() ) ); } // If database name not configured, set it to polygene:entitystore databaseName = config.database().get(); if( databaseName == null ) { databaseName = DEFAULT_DATABASE_NAME; } // If collection name not configured, set it to polygene:entitystore:entities collectionName = config.collection().get(); if( collectionName == null ) { collectionName = DEFAULT_COLLECTION_NAME; } // If write concern not configured, set it to normal switch( config.writeConcern().get() ) { case W1: writeConcern = WriteConcern.W1; break; case W2: writeConcern = WriteConcern.W2; break; case W3: writeConcern = WriteConcern.W3; break; case UNACKNOWLEDGED: writeConcern = WriteConcern.UNACKNOWLEDGED; break; case JOURNALED: writeConcern = WriteConcern.JOURNALED; break; case MAJORITY: writeConcern = WriteConcern.MAJORITY; break; case ACKNOWLEDGED: default: writeConcern = WriteConcern.ACKNOWLEDGED; } // Username and password are defaulted to empty strings username = config.username().get(); password = config.password().get().toCharArray(); }