Examples of MongoException


Examples of com.mongodb.MongoException

    }
    WriteResult result = collection.update(
      criteria, toModifierObject(),
      upsert, multi, concern, dbEncoder);
    if (result.getError()!=null) {
      throw new MongoException(result.getError());
    }
    return result;
  }
View Full Code Here

Examples of com.mongodb.MongoException

  @Test
  public void mongoIsDown() throws Exception {
    MongoTemplate mongoTemplate = mock(MongoTemplate.class);
    given(mongoTemplate.executeCommand("{ buildInfo: 1 }")).willThrow(
        new MongoException("Connection failed"));
    MongoHealthIndicator healthIndicator = new MongoHealthIndicator(mongoTemplate);

    Health health = healthIndicator.health();
    assertEquals(Status.DOWN, health.getStatus());
    assertTrue(((String) health.getDetails().get("error"))
View Full Code Here

Examples of com.mongodb.MongoException

            throw new RuntimeException( "no gridfs!" );
       
        DBObject chunk = _fs._chunkCollection.findOne( BasicDBObjectBuilder.start( "files_id" , _id )
                                                       .add( "n" , i ).get() );
        if ( chunk == null )
            throw new MongoException( "can't find a chunk!  file id: " + _id + " chunk: " + i );

        return (byte[])chunk.get( "data" );
    }
View Full Code Here

Examples of com.mongodb.MongoException

     * @param chunkSize Size of chunks for file in bytes.
     * @throws MongoException if there's a problem saving the file.
     */
    public void save( long chunkSize ) {
        if (_outputStream != null)
            throw new MongoException( "cannot mix OutputStream and regular save()" );

        // note that chunkSize only changes _chunkSize in case we actually save chunks
        // otherwise there is a risk file and chunks are not compatible
        if ( ! _savedChunks ) {
            try {
                saveChunks( chunkSize );
            } catch ( IOException ioe ) {
                throw new MongoException( "couldn't save chunks" , ioe );
            }
        }

        super.save();
    }
View Full Code Here

Examples of com.mongodb.MongoException

     * @throws IOException    on problems reading the new entry's {@link java.io.InputStream}.
     * @throws MongoException
     */
    public int saveChunks( long chunkSize ) throws IOException {
        if (_outputStream != null)
            throw new MongoException( "cannot mix OutputStream and regular save()" );
        if ( _savedChunks )
            throw new MongoException( "chunks already saved!" );

        if ( chunkSize <= 0) {
            throw new MongoException("chunkSize must be greater than zero");
        }

        if ( _chunkSize != chunkSize ) {
            _chunkSize = chunkSize;
            _buffer = new byte[(int) _chunkSize];
View Full Code Here

Examples of com.mongodb.MongoException

     *
     * @throws MongoException
     */
    public void save(){
        if ( _fs == null )
            throw new MongoException( "need _fs" );
        _fs._filesCollection.save( this );
    }
View Full Code Here

Examples of jp.ameba.mongo.MongoException

    this.done = done;
  }

  @Override
  public boolean cancel(boolean mayInterruptIfRunning) {
    throw new MongoException("Cancel is not available.");
  }
View Full Code Here

Examples of mungbean.MongoException

    private void validateResponse(T response) {
        int responseId = response.responseTo();
        if (responseId != -1) {
            if (responseId != requestId) {
                throw new MongoException("Received response to unexpected request " + requestId + "!=" + responseId);
            }
        }
    }
View Full Code Here

Examples of mungbean.MongoException

            transaction = new DBTransaction<T>(message, incrementAndGetCounter());
            return transaction.call(outputStream, inputStream);
        } catch (Exception e) {
            // Close this connection as it's probably invalid
            close();
            throw new MongoException("Error communicating with server", e, transaction);
        }
    }
View Full Code Here

Examples of mungbean.MongoException

            SingleNodeDbOperationExecutor server = allServers.get(roundRobinCount.incrementAndGet() % numberOfServersAvailable);
            if (server.isAlive()) {
                return server;
            }
        }
        throw new MongoException("No servers available for read!");
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.