This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Command line bootstrap method. | |
*/ | |
public static void main(String[] argv) throws Exception { | |
final CommandlineArgs args = new CommandlineArgs(); | |
final JCommander jc = new JCommander(args); | |
try { | |
jc.parse(argv); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Build an Adapter. | |
* <P> | |
* | |
* @param session Configured Diffusion session. | |
* @param collection Source of documents for reflection. | |
* @param oplog Collection holding the MongoDB replication operation log. | |
* @param topicRoot Topic under which other topics are to be created. | |
* @return a ready-to-use Adapter | |
* @throws InterruptedException if the current thread was interrupted while waiting for update rights |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Enumerate all documents in the collection, then relay changes. | |
*/ | |
private void run() { | |
final long timeNow = System.currentTimeMillis(); | |
long topicCount = 0; | |
LOG.info("Transcribing topics from {} to {}", collection.getNamespace(), | |
topicRoot); | |
try ( | |
final MongoCursor<Document> cursor = collection.find().iterator()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Subscribe to {@code local.oplog.rs}, listening for relevant changes. | |
*/ | |
private void relayChanges(long timeNow) { | |
LOG.info("Relaying changes {} to {}", oplog.getNamespace(), topicRoot); | |
final BsonTimestamp now = new BsonTimestamp((int) (timeNow / 1000), 1); | |
final Bson filter = and( | |
gt("ts", now), | |
or( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% mongo localhost:20001 | |
MongoDB shell version: 3.2.6 | |
connecting to: localhost:20000/test | |
testReplSet:PRIMARY> use someDB | |
switched to db someDB | |
testReplSet:PRIMARY> for (i=0; i<100; i++) { db.someCollection.insert({count: i}) } | |
WriteResult({ "nInserted" : 1 }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% mongo --nodb | |
MongoDB shell version: 3.2.6 | |
> replicaSet = new ReplSetTest({"nodes" : 1, "nodeOptions": {"dbpath": "/tmp/mongodb"} }); | |
> replicaSet.startSet() | |
> replicaSet.initiate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var request = require('request'); | |
var MongoClient = require('mongodb').MongoClient; | |
var assert = require('assert'); | |
const truefxURL = "http://webrates.truefx.com/rates/connect.html"; | |
const pollFreq = 500; | |
const mongoURL = (process.argv.length == 3) ? process.argv[2] : 'mongodb://localhost/truefx'; | |
const mongoCollectionName = "currencies"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); | |
Diskspace mbean = new Diskspace(root); | |
try { | |
ObjectName objectName = new ObjectName( "com.acme.diskspace:name=foo" ); | |
mbs.registerMBean( mbean, objectName ); | |
} catch ( Exception ex ) { | |
throw new Error( String.format( "Cannot registry MBean at "%s"", mbean.getObjectName() ), ex ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.acme; | |
import java.lang.management.ManagementFactory; | |
import javax.management.MBeanServer; | |
import com.pushtechnology.diffusion.api.APIException; | |
import com.pushtechnology.diffusion.api.Logs; | |
import com.pushtechnology.diffusion.api.publisher.ServerShutdownHook; | |
import com.pushtechnology.diffusion.api.publisher.ServerStartupHook; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.acme; | |
/** | |
* JMX interface to a Network Interface Card | |
* | |
* @author martincowie - created Mar 12, 2012 | |
*/ | |
public interface NICMBean { | |
public abstract String getDisplayName(); | |
public abstract String getHardwareAddress(); |
OlderNewer