@Override public String toString() { //TODO: This must be changed to preserve privacy on logs return "UpdateMessage{" + super.toString() + ", database='" + database + '\'' + ", collection='" + collection + '\'' + ", selector=" + (getDataContext().isValid() ? selector : "<not available>") + ", update=" + (getDataContext().isValid() ? update : "<not avaiable>") + '}'; } }
@Override public void update(UpdateMessage updateMessage, MessageReplier messageReplier) { C connection = getConnection(messageReplier); try { Request req = new Request( updateMessage.getDatabase(), new ExternalClientInfo(updateMessage.getClientAddress(), updateMessage.getRequestId()), false, null //Set the requested timeout ); safeRequestProcessor.update(connection, req, updateMessage); } catch (MongoException ex) { errorHandler.handleMongodbException(connection, messageReplier.getRequestId(), false, ex); } }
@Override public UpdateMessage decode(ByteBuf buffer, RequestBaseMessage requestBaseMessage) throws InvalidNamespaceException, InvalidBsonException { try { buffer.skipBytes(4); String fullCollectionName = stringReader.readCString(buffer, true); int flags = buffer.readInt(); BsonDocument selector = docReader.readDocument(HEAP, buffer); BsonDocument update = docReader.readDocument(HEAP, buffer); //TODO: improve the way database and cache are pooled return new UpdateMessage( requestBaseMessage, EmptyBsonContext.getInstance(), getDatabase(fullCollectionName).intern(), getCollection(fullCollectionName).intern(), selector, update, EnumInt32FlagsUtil.isActive(Flag.UPSERT, flags), EnumInt32FlagsUtil.isActive(Flag.MULTI_UPDATE, flags) ); } catch (NettyBsonReaderException ex) { throw new InvalidBsonException(ex); } }