private void addToStream(final Operation operation, final Timestamp<?> currentTimestamp, final DBObject data, final String collection) throws InterruptedException { if (logger.isTraceEnabled()) { String dataString = data.toString(); if (dataString.length() > 400) { logger.trace("addToStream - operation [{}], currentTimestamp [{}], data (_id:[{}], serialized length:{}), collection [{}]", operation, currentTimestamp, data.get("_id"), dataString.length(), collection); } else { logger.trace("addToStream - operation [{}], currentTimestamp [{}], data [{}], collection [{}]", operation, currentTimestamp, dataString, collection); } } if (operation == Operation.DROP_DATABASE) { logger.info("addToStream - Operation.DROP_DATABASE, currentTimestamp [{}], data [{}], collection [{}]", currentTimestamp, data, collection); if (definition.isImportAllCollections()) { for (String name : slurpedDb.getCollectionNames()) { logger.info("addToStream - isImportAllCollections - Operation.DROP_DATABASE, currentTimestamp [{}], data [{}], collection [{}]", currentTimestamp, data, name); context.getStream().put(new MongoDBRiver.QueueEntry(currentTimestamp, Operation.DROP_COLLECTION, data, name)); } } else { context.getStream().put(new MongoDBRiver.QueueEntry(currentTimestamp, Operation.DROP_COLLECTION, data, collection)); } } else { context.getStream().put(new MongoDBRiver.QueueEntry(currentTimestamp, operation, data, collection)); } }
@SuppressWarnings({ "unchecked" }) private Timestamp<?> processBlockingQueue(QueueEntry entry) { Operation operation = entry.getOperation(); if (entry.getData().get(MongoDBRiver.MONGODB_ID_FIELD) == null && (operation == Operation.INSERT || operation == Operation.UPDATE || operation == Operation.DELETE)) { logger.warn("Cannot get object id. Skip the current item: [{}]", entry.getData()); return null; Timestamp<?> lastTimestamp = entry.getOplogTimestamp(); String type; if (definition.isImportAllCollections()) { type = entry.getCollection(); } else { type = definition.getTypeName(); updateBulkRequest(entry.getData(), null, operation, definition.getIndexName(), type, null, null); } catch (IOException ioEx) { logger.error("Update bulk failed.", ioEx); if (entry.getData().get(MongoDBRiver.MONGODB_ID_FIELD) != null) { objectId = entry.getData().get(MongoDBRiver.MONGODB_ID_FIELD).toString(); if (entry.isAttachment()) { try { updateBulkRequest(entry.getData(), objectId, operation, definition.getIndexName(), type, null, null); } catch (IOException ioEx) { logger.error("Update bulk failed.", ioEx); logger.trace("About to include collection. set attribute {} / {} ", definition.getIncludeCollection(), definition.getMongoCollection());
@SuppressWarnings("unchecked") private Timestamp<?> applyAdvancedTransformation(QueueEntry entry, String type) { Timestamp<?> lastTimestamp = entry.getOplogTimestamp(); Operation operation = entry.getOperation(); String objectId = ""; if (entry.getData().get(MongoDBRiver.MONGODB_ID_FIELD) != null) { objectId = entry.getData().get(MongoDBRiver.MONGODB_ID_FIELD).toString(); logger.trace("About to include collection. set attribute {} / {} ", definition.getIncludeCollection(), definition.getMongoCollection()); entry.getData().put(definition.getIncludeCollection(), definition.getMongoCollection()); if (ctx != null && documents != null) { document.put("data", entry.getData().toMap()); if (!objectId.isEmpty()) { document.put("id", objectId);
private void addToStream(final Operation operation, final Timestamp<?> currentTimestamp, final DBObject data, final String collection) throws InterruptedException { if (logger.isTraceEnabled()) { String dataString = data.toString(); if (dataString.length() > 400) { logger.trace("addToStream - operation [{}], currentTimestamp [{}], data (_id:[{}], serialized length:{}), collection [{}]", operation, currentTimestamp, data.get("_id"), dataString.length(), collection); } else { logger.trace("addToStream - operation [{}], currentTimestamp [{}], data [{}], collection [{}]", operation, currentTimestamp, dataString, collection); } } if (operation == Operation.DROP_DATABASE) { logger.info("addToStream - Operation.DROP_DATABASE, currentTimestamp [{}], data [{}], collection [{}]", currentTimestamp, data, collection); if (definition.isImportAllCollections()) { for (String name : slurpedDb.getCollectionNames()) { logger.info("addToStream - isImportAllCollections - Operation.DROP_DATABASE, currentTimestamp [{}], data [{}], collection [{}]", currentTimestamp, data, name); context.getStream().put(new MongoDBRiver.QueueEntry(currentTimestamp, Operation.DROP_COLLECTION, data, name)); } } else { context.getStream().put(new MongoDBRiver.QueueEntry(currentTimestamp, Operation.DROP_COLLECTION, data, collection)); } } else { context.getStream().put(new MongoDBRiver.QueueEntry(currentTimestamp, operation, data, collection)); } }