@Override public String toString() { return proxied.toString(); }
private String toKey(final MongoClientURI uri) { return uri.toString(); } }
@Override public String toString() { return proxied.toString(); }
@Override public String toString() { return "MongoInputSplit{URI=" + this.inputURI.toString() + ", authURI=" + this.authURI + ", min=" + this.min + ", max=" + this.max + ", query=" + this.query + ", sort=" + this.sort + ", fields=" + this.fields + ", notimeout=" + this.notimeout + '}'; }
private String toKey(final MongoClientURI uri) { return uri.toString(); } }
@Override public String toString() { return String.format("DocumentNodeStore[%s]", uri.toString()); } }
@Override public String toString() { return String.format("DocumentNodeStore[%s]", uri.toString()); } }
public static void setMongoURI(final Configuration conf, final String key, final MongoClientURI value) { conf.set(key, value.toString()); // todo - verify you can toString a // URI object }
public static void setMongoURI(final Configuration conf, final String key, final MongoClientURI value) { conf.set(key, value.toString()); // todo - verify you can toString a // URI object }
@Override public void serialize(MongoClientURI value, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException { jsonGenerator.writeString(value.toString()); }
/** * Helper for providing a {@code MongoClientURI} as the value for a setting. * @param conf the Configuration * @param key the key for the setting * @param value the value for the setting */ public static void setMongoURI(final Configuration conf, final String key, final MongoClientURI value) { conf.set(key, value.toString()); // todo - verify you can toString a // URI object }
@Override public void write(final DataOutput out) throws IOException { out.writeUTF(inputURI.toString()); out.write(fileId.toByteArray()); out.writeInt(chunkId); out.writeLong(fileLength); out.writeInt(chunkSize); }
/** * Takes an existing {@link MongoClientURI} and returns a new modified URI which replaces the original's server host + port with a * supplied new server host + port, but maintaining all the same original options. This is useful for generating distinct URIs for each * mongos instance so that large batch reads can all target them separately, distributing the load more evenly. It can also be used to * force a block of data to be read directly from the shard's servers directly, bypassing mongos entirely. * * @param originalUri the URI to rewrite * @param newServerUri the new host(s) to target, e.g. server1:port1[,server2:port2,...] */ protected static MongoClientURI rewriteURI(final MongoClientURI originalUri, final String newServerUri) { String originalUriString = originalUri.toString(); originalUriString = originalUriString.substring(MongoURI.MONGODB_PREFIX.length()); // uris look like: mongodb://fred:foobar@server1[,server2]/path?options // //Locate the last character of the original hostname int serverEnd; int idx = originalUriString.lastIndexOf("/"); serverEnd = idx < 0 ? originalUriString.length() : idx; //Locate the first character of the original hostname idx = originalUriString.indexOf("@"); int serverStart = idx > 0 ? idx + 1 : 0; StringBuilder sb = new StringBuilder(originalUriString); sb.replace(serverStart, serverEnd, newServerUri); String ans = MongoURI.MONGODB_PREFIX + sb.toString(); return new MongoClientURI(ans); }
public Map<String, String> toConfigMap() { HashMap<String, String> outMap = new HashMap<String, String>(); if (inputURI != null) { outMap.put(MongoConfigUtil.INPUT_URI, inputURI.toString()); } if (authURI != null) { outMap.put(MongoConfigUtil.AUTH_URI, authURI.toString()); } outMap.put(MongoConfigUtil.INPUT_NOTIMEOUT, noTimeout + ""); if (fields != null) { outMap.put(MongoConfigUtil.INPUT_FIELDS, JSON.serialize(fields)); } if (sort != null) { outMap.put(MongoConfigUtil.INPUT_SORT, JSON.serialize(sort)); } if (query != null) { outMap.put(MongoConfigUtil.INPUT_QUERY, JSON.serialize(query)); } outMap.put(MongoConfigUtil.SPLITS_USE_RANGEQUERY, useRangeQuery ? "true" : "false"); if (splitClass != null) { outMap.put(MongoConfigUtil.MONGO_SPLITTER_CLASS, splitClass.getCanonicalName()); } return outMap; } }
String originalUriString = originalUri.toString(); originalUriString = originalUriString.substring(MongoURI.MONGODB_PREFIX.length());
public Map<String, String> toConfigMap() { HashMap<String, String> outMap = new HashMap<String, String>(); if (inputURI != null) { outMap.put(MongoConfigUtil.INPUT_URI, inputURI.toString()); } if (authURI != null) { outMap.put(MongoConfigUtil.AUTH_URI, authURI.toString()); } outMap.put(MongoConfigUtil.INPUT_NOTIMEOUT, noTimeout + ""); if (fields != null) { outMap.put(MongoConfigUtil.INPUT_FIELDS, JSON.serialize(fields)); } if (sort != null) { outMap.put(MongoConfigUtil.INPUT_SORT, JSON.serialize(sort)); } if (query != null) { outMap.put(MongoConfigUtil.INPUT_QUERY, JSON.serialize(query)); } outMap.put(MongoConfigUtil.SPLITS_USE_RANGEQUERY, useRangeQuery ? "true" : "false"); if (splitClass != null) { outMap.put(MongoConfigUtil.MONGO_SPLITTER_CLASS, splitClass.getCanonicalName()); } return outMap; } }
@Test @DisplayName("test build client uri for default settings") public void testBuildClientUriWithDefaultSettings() { MongoDbSinkConnectorConfig cfg = new MongoDbSinkConnectorConfig(new HashMap<>()); MongoClientURI uri = cfg.buildClientURI(); assertEquals(CLIENT_URI_DEFAULT_SETTINGS, uri.toString(), "wrong connection uri"); }
@Test @DisplayName("test build client uri for configured auth settings") public void testBuildClientUriWithAuthSettings() { Map<String, String> map = new HashMap<String, String>(); map.put(MONGODB_CONNECTION_URI_CONF, "mongodb://hanspeter:secret@localhost:27017/kafkaconnect?w=1&journal=true&authSource=admin&authMechanism=SCRAM-SHA-1"); MongoDbSinkConnectorConfig cfg = new MongoDbSinkConnectorConfig(map); MongoClientURI uri = cfg.buildClientURI(); assertEquals(CLIENT_URI_AUTH_SETTINGS, uri.toString(), "wrong connection uri"); }
@Override public void write(final DataOutput out) throws IOException { BSONObject spec = BasicDBObjectBuilder.start() .add("inputURI", getInputURI().toString()) .add("authURI", getAuthURI() != null ? getAuthURI().toString() : null) .add("keyField", getKeyField()) .add("fields", getFields()) .add("query", getQuery()) .add("sort", getSort()) .add("min", getMin()) .add("max", getMax()) .add("notimeout", getNoTimeout()) .get(); byte[] buf = _bsonEncoder.encode(spec); out.write(buf); }
@Override public void write(final DataOutput out) throws IOException { BSONObject spec = BasicDBObjectBuilder.start() .add("inputURI", getInputURI().toString()) .add("authURI", getAuthURI() != null ? getAuthURI().toString() : null) .add("keyField", getKeyField()) .add("fields", getFields()) .add("query", getQuery()) .add("sort", getSort()) .add("min", getMin()) .add("max", getMax()) .add("notimeout", getNoTimeout()) .add("limit", limit) .add("skip", skip) .get(); byte[] buf = _bsonEncoder.encode(spec); out.write(buf); }